Skip to content

Commit c2426bb

Browse files
Use PartialTensorShape instead of TensorShape.
`TensorShape` constructor throws a CHECK-fail if shape is partial/overflows which the other doesn't. We are only determining the number of elements in the shape and partial shape should be used as it returns negative number when needed. PiperOrigin-RevId: 409205384 Change-Id: Ia56542ff9ec758f2c9ffc7e4dcc9fa7eecd86e7b
1 parent 31d8f80 commit c2426bb

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

tensorflow/core/framework/attr_value_util.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ constexpr int kMaxTensorNestDepth = 100;
4545
// not fully defined return -1.
4646
int64_t TensorByteSize(const TensorProto& t) {
4747
// num_elements returns -1 if shape is not fully defined.
48-
int64_t num_elems = TensorShape(t.tensor_shape()).num_elements();
48+
int64_t num_elems = PartialTensorShape(t.tensor_shape()).num_elements();
4949
return num_elems < 0 ? -1 : num_elems * DataTypeSize(t.dtype());
5050
}
5151

0 commit comments

Comments
 (0)