| 351 | |
| 352 | template <class Shape> |
| 353 | Status 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 | |
| 375 | template <class Shape> |
| 376 | void TensorShapeBase<Shape>::AddDim(int64 size) { |
nothing calls this directly
no test coverage detected