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

Method AddDimWithStatus

tensorflow/core/framework/tensor_shape.cc:391–421  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

389
390template <class Shape>
391Status TensorShapeBase<Shape>::AddDimWithStatus(int64 size) {
392 if (!kIsPartial) {
393 if (TF_PREDICT_FALSE(size < 0)) {
394 return errors::InvalidArgument("Expected a non-negative size, got ",
395 size);
396 }
397 }
398
399 if (unknown_rank()) {
400 return Status::OK();
401 }
402
403 if (TF_PREDICT_FALSE(ndims_byte() >= MaxDimensions())) {
404 return errors::InvalidArgument("Too many dimensions in tensor");
405 }
406
407 int64 new_num_elements;
408 if (kIsPartial && (num_elements() < 0 || size < 0)) {
409 new_num_elements = -1;
410 } else {
411 new_num_elements = MultiplyWithoutOverflow(num_elements(), size);
412 if (TF_PREDICT_FALSE(new_num_elements < 0)) {
413 return errors::InvalidArgument("Encountered overflow when multiplying ",
414 num_elements(), " with ", size,
415 ", result: ", new_num_elements);
416 }
417 }
418
419 UnsafeAddDim(size, new_num_elements);
420 return Status::OK();
421}
422
423template <class Shape>
424void TensorShapeBase<Shape>::UnsafeAddDim(int64 size, int64 new_num_elements) {

Callers 7

BuildTensorShapeBaseMethod · 0.80
ComputeMethod · 0.80
ComputeAsyncMethod · 0.80
ComputeAsyncMethod · 0.80
ComputeMethod · 0.80
ComputeMethod · 0.80

Calls 2

InvalidArgumentFunction · 0.85
MultiplyWithoutOverflowFunction · 0.50

Tested by

no test coverage detected