MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / NumElements

Method NumElements

tensorflow/core/framework/tensor_shape.cc:881–894  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

879}
880
881Status 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
896template class TensorShapeBase<TensorShape>;
897template class TensorShapeBase<PartialTensorShape>;

Callers

nothing calls this directly

Calls 2

InvalidArgumentFunction · 0.85
MultiplyWithoutOverflowFunction · 0.50

Tested by

no test coverage detected