Skip to content

Commit

Permalink
clang'
Browse files Browse the repository at this point in the history
  • Loading branch information
Semyon1104 committed Aug 5, 2024
1 parent 9cd0c87 commit 69cd525
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 13 deletions.
1 change: 1 addition & 0 deletions include/layers/Tensor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ class Tensor {
if (a.size() != values_.size()) {
throw std::invalid_argument("Incorrect vector size given to Tensor");
}
values_ = a;
if (bias.size() != shape_[shape_.dims() - 1]) {
throw std::invalid_argument(
"Bias size does not match the last dimension of the shape");
Expand Down
9 changes: 0 additions & 9 deletions src/Weights_Reader/reader_weights.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,6 @@ void extract_values_without_bias(const json& j, std::vector<float>& values) {
std::cout << "Values size after extraction: " << values.size() << std::endl;
}


// Функция для определения формы из JSON
void parse_json_shape(const json& j, std::vector<size_t>& shape, size_t dim) {
// Если dim == 0, просто проверяем первый уровень
Expand Down Expand Up @@ -117,7 +116,6 @@ void parse_json_shape(const json& j, std::vector<size_t>& shape, size_t dim) {
}
}


void extract_bias_from_json(const json& j, std::vector<float>& bias) {

Check warning on line 119 in src/Weights_Reader/reader_weights.cpp

View check run for this annotation

Codecov / codecov/patch

src/Weights_Reader/reader_weights.cpp#L119

Added line #L119 was not covered by tests
if (j.is_array()) {
if (!j.empty() && j.back().is_array()) {
Expand Down Expand Up @@ -160,23 +158,16 @@ Tensor create_tensor_from_json(const json& j, Type type) {
if (expected_size == 1 && shape.empty()) {
expected_size = 0;
}

std::cout << "Expected size: " << expected_size << std::endl;


try {

Check warning on line 162 in src/Weights_Reader/reader_weights.cpp

View check run for this annotation

Codecov / codecov/patch

src/Weights_Reader/reader_weights.cpp#L162

Added line #L162 was not covered by tests
extract_bias_from_json(j, bias);
std::cout << "Extracted bias size: " << bias.size() << std::endl;
} catch (const std::exception& e) {
std::cout << "No bias found or error extracting bias: " << e.what()
<< std::endl;

Check warning on line 167 in src/Weights_Reader/reader_weights.cpp

View check run for this annotation

Codecov / codecov/patch

src/Weights_Reader/reader_weights.cpp#L167

Added line #L167 was not covered by tests
}


Shape sh(shape);

return make_tensor<float>(vals, sh, bias);

}
throw std::invalid_argument("Unsupported type or invalid JSON format");
}
4 changes: 0 additions & 4 deletions test/model_read/model_read.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ TEST(ExtractValuesFromJsonTests, HandlesFlatArray) {
EXPECT_EQ(values, expected);
}


TEST(ExtractValuesFromJsonTests, HandlesNestedArray) {
json j = json::array({{1.0, 2.0}, {3.0, 4.0}});
std::vector<float> values;
Expand All @@ -81,6 +80,3 @@ TEST(ParseJsonShapeTests, HandlesEmptyArray) {
std::vector<size_t> expected = {0};
EXPECT_EQ(shape, expected);
}



0 comments on commit 69cd525

Please sign in to comment.