_dimensions.insert(_dimensions.cbegin(), to_rank - rank(), 1);
}
-int64_t Shape::num_elements() const
+uint64_t Shape::num_elements() const
{
- return std::accumulate(_dimensions.cbegin(), _dimensions.cend(), INT64_C(1),
- std::multiplies<int64_t>());
+ // All of the nodes must have non-negative dimension
+ assert(std::all_of(_dimensions.begin(), _dimensions.end(),
+ [](const int32_t &v) { return (v >= 0); }));
+
+ return std::accumulate(_dimensions.cbegin(), _dimensions.cend(), UINT64_C(1),
+ std::multiplies<uint64_t>());
}
} // namespace model