diff --git a/include/aidge/backend/TensorImpl.hpp b/include/aidge/backend/TensorImpl.hpp index 08e9764218b260c5e5dd7b4ce8b6b6b9a579a647..c363546f1108c0a536637b8c7c71308d16a9e8ca 100644 --- a/include/aidge/backend/TensorImpl.hpp +++ b/include/aidge/backend/TensorImpl.hpp @@ -191,7 +191,7 @@ public: * @brief Set every element of the implementation to zero. */ virtual void zeros() { - printf("Not implemented yet"); + AIDGE_THROW_OR_ABORT(std::runtime_error, "Function not implented"); } constexpr const char *backend() const { return mBackend; } diff --git a/include/aidge/utils/ArrayHelpers.hpp b/include/aidge/utils/ArrayHelpers.hpp index 3f241fa6a163522c81238757da1efb6a8df24001..b0db3ca11c10c10a3ce63c3c4809cf7ae09173da 100644 --- a/include/aidge/utils/ArrayHelpers.hpp +++ b/include/aidge/utils/ArrayHelpers.hpp @@ -103,32 +103,11 @@ constexpr std::array<T, N + 1> append(T t, std::array<T, N> a) { // Generic helper for initializing a Tensor template <typename T, std::size_t SIZE_0> struct Array1D { - // Array1D(std::initializer_list<T> list) { - // auto it = list.begin(); - // for (std::size_t i = 0; i < SIZE_0; ++i, ++it) { - // data[i] = *it; - // } - // } - // Array1D(const T (&dataArray)[SIZE_0]) { - // std::copy_n(&dataArray[0], SIZE_0, &data[0]); - // } T data[SIZE_0]; }; template <typename T, std::size_t SIZE_0, std::size_t SIZE_1> struct Array2D { - // Array2D(std::initializer_list<std::initializer_list<T>> list) { - // auto it1 = list.begin(); - // for (std::size_t i = 0; i < SIZE_0; ++i, ++it1) { - // auto it2 = it1->begin(); - // for (std::size_t j = 0; j < SIZE_1; ++j, ++it2) { - // data[i][j] = *it2; - // } - // } - // } - // Array2D(const T (&dataArray)[SIZE_0][SIZE_1]) { - // std::copy_n(&dataArray[0][0], SIZE_0 * SIZE_1, &data[0][0]); - // } T data[SIZE_0][SIZE_1]; }; diff --git a/unit_tests/data/Test_Tensor.cpp b/unit_tests/data/Test_Tensor.cpp index f26901dc357080eebbaa2c6bea1b727134bd143d..12cd9840ef259f2af836496e4163f4440bd2910b 100644 --- a/unit_tests/data/Test_Tensor.cpp +++ b/unit_tests/data/Test_Tensor.cpp @@ -142,7 +142,7 @@ TEST_CASE("[core/data] Tensor(Construction)", "[Tensor][Constructor]") { Tensor T(Tdims); // file the tensor - float* array0 = new float[T.size()]; + std::unique_ptr<float[]> array0(new float[T.size()]); for (std::size_t i = 0; i < T.size(); ++i) { array0[i] = valueDist(gen); } @@ -216,7 +216,7 @@ TEST_CASE("[core/data] Tensor(getter/setter)", "[Tensor][Getter][Setter]") { REQUIRE(T.strides() == Tstrides); // file the tensor - float* array0 = new float[T.size()]; + std::unique_ptr<float[]> array0(new float[T.size()]); for (std::size_t i = 0; i < T.size(); ++i) { array0[i] = valueDist(gen); } @@ -241,7 +241,6 @@ TEST_CASE("[core/data] Tensor(getter/setter)", "[Tensor][Getter][Setter]") { REQUIRE(T.get<float>(true_flatid) == 40.0f); REQUIRE(T.getImplOffset() == 0); - delete[] array0; ////////////// // backend @@ -279,12 +278,12 @@ TEST_CASE("[core/data] Tensor(other)", "[Tensor][extract][zeros][print]") { T.resize(Tdims); // file the tensor - float* array0 = new float[T.size()]; + std::unique_ptr<float[]> array0(new float[T.size()]); for (std::size_t i = 0; i < T.size(); ++i) { array0[i] = valueDist(gen); } T.setBackend("cpu"); - T.getImpl() -> setRawPtr(array0, T.size()); + T.getImpl() -> setRawPtr(array0.get(), T.size()); float* res = static_cast<float*>(T.getImpl()->hostPtr()); for (std::size_t i = 0; i < T.size(); ++i) { REQUIRE(res[i] == array0[i]); @@ -295,7 +294,6 @@ TEST_CASE("[core/data] Tensor(other)", "[Tensor][extract][zeros][print]") { for (std::size_t i = 0; i < T.size(); ++i) { REQUIRE(res[i] == 0.0f); } - delete[] array0; } }