Commit af8da631 authored by Gustavo Valiente's avatar Gustavo Valiente

Tensor::getSize() fix

parent 88bd1e4e
...@@ -65,10 +65,7 @@ public: ...@@ -65,10 +65,7 @@ public:
return _dims; return _dims;
} }
std::size_t getSize() const noexcept std::size_t getSize() const noexcept;
{
return getSizeImpl(_dims);
}
const DataVector& getData() const noexcept const DataVector& getData() const noexcept
{ {
...@@ -237,18 +234,6 @@ public: ...@@ -237,18 +234,6 @@ public:
protected: protected:
DimsVector _dims; DimsVector _dims;
DataVector _data; DataVector _data;
static std::size_t getSizeImpl(const DimsVector& dims) noexcept
{
std::size_t size = 1;
for(std::size_t dim : dims)
{
size *= dim;
}
return size;
}
}; };
} }
......
...@@ -281,6 +281,23 @@ std::unique_ptr<Tensor> Tensor::create(std::size_t dims, std::istream& stream) ...@@ -281,6 +281,23 @@ std::unique_ptr<Tensor> Tensor::create(std::size_t dims, std::istream& stream)
return tensor; return tensor;
} }
std::size_t Tensor::getSize() const noexcept
{
std::size_t size = 0;
if(! _dims.empty())
{
++size;
for(auto dim : _dims)
{
size *= dim;
}
}
return size;
}
void Tensor::copyTo(Tensor& other) const void Tensor::copyTo(Tensor& other) const
{ {
other._dims.clear(); other._dims.clear();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment