| 879 | } |
| 880 | |
| 881 | Status TensorShapeUtils::NumElements(gtl::ArraySlice<int64> shape, |
| 882 | int64* num_elements) { |
| 883 | int64 n = 1; |
| 884 | for (auto dim : shape) { |
| 885 | n = MultiplyWithoutOverflow(n, dim); |
| 886 | if (n < 0) { |
| 887 | return errors::InvalidArgument("Can't compute total size of shape [", |
| 888 | absl::StrJoin(shape, ","), |
| 889 | "]; product would overflow int64"); |
| 890 | } |
| 891 | } |
| 892 | *num_elements = n; |
| 893 | return Status::OK(); |
| 894 | } |
| 895 | |
| 896 | template class TensorShapeBase<TensorShape>; |
| 897 | template class TensorShapeBase<PartialTensorShape>; |
nothing calls this directly
no test coverage detected