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

Method SetDimWithStatus

tensorflow/core/framework/tensor_shape.cc:524–561  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

522
523template <class Shape>
524Status TensorShapeBase<Shape>::SetDimWithStatus(int d, int64 size) {
525 if (TF_PREDICT_FALSE(d < 0)) {
526 return errors::InvalidArgument("Index must be non-negative, got ", d);
527 }
528 if (TF_PREDICT_FALSE(d >= dims())) {
529 return errors::InvalidArgument("Index must be less than ", dims(), ", got ",
530 d);
531 }
532 if (TF_PREDICT_FALSE(size < 0)) {
533 return errors::InvalidArgument("Expected a non-negative size, got ", size);
534 }
535
536 if (tag() == REP16 && size < kMaxRep16) {
537 as16()->dims_[d] =
538 kIsPartial && size < 0 ? kUnknownRep16 : static_cast<uint16>(size);
539 } else if (tag() == REP32 && size < kMaxRep32) {
540 as32()->dims_[d] =
541 kIsPartial && size < 0 ? kUnknownRep32 : static_cast<uint32>(size);
542 } else if (tag() == REP_OUT_OF_LINE) {
543 (*as64()->dims_)[d] = size;
544 } else {
545 // Must upgrade
546 gtl::InlinedVector<int64, 8> vals;
547 AppendTo(*this, &vals);
548 vals[d] = size;
549 ClearAllButDataType();
550
551 Status s = Status::OK();
552 for (auto dval : vals) {
553 s.Update(AddDimWithStatus(dval));
554 if (!s.ok()) {
555 return s;
556 }
557 }
558 }
559
560 return RecomputeNumElements();
561}
562
563template <class Shape>
564void TensorShapeBase<Shape>::RemoveDimRange(int begin, int end) {

Callers 6

ComputeMethod · 0.80
ComputeMethod · 0.80
ComputeMethod · 0.80
ComputeMethod · 0.80
ComputeAsyncMethod · 0.80
SliceMethod · 0.80

Calls 5

InvalidArgumentFunction · 0.85
dimsFunction · 0.85
AppendToFunction · 0.85
UpdateMethod · 0.45
okMethod · 0.45

Tested by

no test coverage detected