Skip to content
Snippets Groups Projects
Commit 3ba4bdb8 authored by Olivier BICHLER's avatar Olivier BICHLER
Browse files

Improved Tensor::zeros()

parent 628ae5e4
No related branches found
No related tags found
2 merge requests!152Update Aidge export to take a graph view has an argument instead of a...,!135Improved Tensor::zeros()
Pipeline #47914 passed
...@@ -201,9 +201,7 @@ public: ...@@ -201,9 +201,7 @@ public:
/** /**
* @brief Set every element of the implementation to zero. * @brief Set every element of the implementation to zero.
*/ */
virtual void zeros() { virtual void zeros() = 0;
AIDGE_THROW_OR_ABORT(std::runtime_error, "Function not implented");
}
const std::string backend() const { return mBackend; } const std::string backend() const { return mBackend; }
......
...@@ -38,12 +38,7 @@ bool Aidge::TensorImpl_cpu<T>::operator==(const Aidge::TensorImpl &other) const ...@@ -38,12 +38,7 @@ bool Aidge::TensorImpl_cpu<T>::operator==(const Aidge::TensorImpl &other) const
template <typename T> template <typename T>
void Aidge::TensorImpl_cpu<T>::zeros() { void Aidge::TensorImpl_cpu<T>::zeros() {
if (mData.empty()) { std::memset(rawPtr(), T(0), mNbElts * sizeof(T));
lazyInit();
}
for (std::size_t i = 0; i < mData.size(); ++i) {
*(mData.data() + i) = T(0);
}
} }
template <typename T> template <typename T>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment