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

Method IsValid

tensorflow/core/framework/tensor_shape.cc:55–72  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

53
54template <class Shape>
55bool TensorShapeBase<Shape>::IsValid(const TensorShapeProto& proto) {
56 // NOTE(irving): Unfortunately, TensorShape allows parsing protos with
57 // unknown_shape() set, and it seems hard to remove this without backwards
58 // compatibility issues.
59 if (kIsPartial && proto.unknown_rank()) return proto.dim_size() == 0;
60 int64 num_elements = 1;
61 if (proto.dim().size() > MaxDimensions()) return false;
62 for (const auto& d : proto.dim()) {
63 if (d.size() < (kIsPartial ? -1 : 0)) return false;
64 if (d.size() == -1) {
65 num_elements = -1;
66 } else if (!kIsPartial || num_elements >= 0) {
67 num_elements = MultiplyWithoutOverflow(num_elements, d.size());
68 if (num_elements < 0) return false;
69 }
70 }
71 return true;
72}
73
74template <class Shape>
75Status TensorShapeBase<Shape>::IsValidShape(const TensorShapeProto& proto) {

Callers

nothing calls this directly

Calls 5

unknown_rankMethod · 0.80
MultiplyWithoutOverflowFunction · 0.50
dim_sizeMethod · 0.45
sizeMethod · 0.45
dimMethod · 0.45

Tested by

no test coverage detected