From 69cd525ee3ab72fea19d30d57846a161d0cbed91 Mon Sep 17 00:00:00 2001 From: Semyon1104 Date: Mon, 5 Aug 2024 13:18:05 +0300 Subject: [PATCH] clang' --- include/layers/Tensor.hpp | 1 + src/Weights_Reader/reader_weights.cpp | 9 --------- test/model_read/model_read.cpp | 4 ---- 3 files changed, 1 insertion(+), 13 deletions(-) diff --git a/include/layers/Tensor.hpp b/include/layers/Tensor.hpp index 1df30616..f6c2c71f 100644 --- a/include/layers/Tensor.hpp +++ b/include/layers/Tensor.hpp @@ -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"); diff --git a/src/Weights_Reader/reader_weights.cpp b/src/Weights_Reader/reader_weights.cpp index a87288a5..562b7bc8 100644 --- a/src/Weights_Reader/reader_weights.cpp +++ b/src/Weights_Reader/reader_weights.cpp @@ -80,7 +80,6 @@ void extract_values_without_bias(const json& j, std::vector& values) { std::cout << "Values size after extraction: " << values.size() << std::endl; } - // Функция для определения формы из JSON void parse_json_shape(const json& j, std::vector& shape, size_t dim) { // Если dim == 0, просто проверяем первый уровень @@ -117,7 +116,6 @@ void parse_json_shape(const json& j, std::vector& shape, size_t dim) { } } - void extract_bias_from_json(const json& j, std::vector& bias) { if (j.is_array()) { if (!j.empty() && j.back().is_array()) { @@ -160,10 +158,7 @@ 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 { extract_bias_from_json(j, bias); std::cout << "Extracted bias size: " << bias.size() << std::endl; @@ -171,12 +166,8 @@ Tensor create_tensor_from_json(const json& j, Type type) { std::cout << "No bias found or error extracting bias: " << e.what() << std::endl; } - - Shape sh(shape); - return make_tensor(vals, sh, bias); - } throw std::invalid_argument("Unsupported type or invalid JSON format"); } diff --git a/test/model_read/model_read.cpp b/test/model_read/model_read.cpp index 6c78ccaa..b5730397 100644 --- a/test/model_read/model_read.cpp +++ b/test/model_read/model_read.cpp @@ -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 values; @@ -81,6 +80,3 @@ TEST(ParseJsonShapeTests, HandlesEmptyArray) { std::vector expected = {0}; EXPECT_EQ(shape, expected); } - - -