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

Method RecomputeNumElements

tensorflow/core/framework/tensor_shape.cc:353–373  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

351
352template <class Shape>
353Status TensorShapeBase<Shape>::RecomputeNumElements() {
354 if (unknown_rank()) {
355 set_num_elements(-1);
356 return Status::OK();
357 }
358 int64 n = 1;
359 for (auto dim : *this) {
360 if (kIsPartial && dim.size < 0) {
361 n = -1;
362 break;
363 }
364 n = MultiplyWithoutOverflow(n, dim.size);
365 if (TF_PREDICT_FALSE(n < 0)) {
366 return errors::InvalidArgument(
367 "Shape ", this->DebugString(),
368 " results in overflow when computing number of elements");
369 }
370 }
371 set_num_elements(n);
372 return Status::OK();
373}
374
375template <class Shape>
376void TensorShapeBase<Shape>::AddDim(int64 size) {

Callers

nothing calls this directly

Calls 3

InvalidArgumentFunction · 0.85
MultiplyWithoutOverflowFunction · 0.50
DebugStringMethod · 0.45

Tested by

no test coverage detected