Skip to content

Commit 2406555

Browse files
Eliminate CHECK-fails from IsSimplifiableReshape via MakeShape(<invalid shape>)
PiperOrigin-RevId: 409166738 Change-Id: I7f0a3590b8acae3f3e3e2fe636e1f5ef285693cf
1 parent 1fb2773 commit 2406555

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

tensorflow/core/grappler/optimizers/constant_folding.cc

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1741,14 +1741,16 @@ Status ConstantFolding::IsSimplifiableReshape(
17411741
int32_t dim = outputs[0]->flat<int32>()(i);
17421742
shp.push_back(dim);
17431743
}
1744-
TF_CHECK_OK(TensorShapeUtils::MakeShape(shp, &new_dims));
1744+
s = TensorShapeUtils::MakeShape(shp, &new_dims);
1745+
if (!s.ok()) return s;
17451746
} else {
17461747
std::vector<int64_t> shp;
17471748
for (int i = 0; i < outputs[0]->NumElements(); ++i) {
17481749
int64_t dim = outputs[0]->flat<int64_t>()(i);
17491750
shp.push_back(dim);
17501751
}
1751-
TF_CHECK_OK(TensorShapeUtils::MakeShape(shp, &new_dims));
1752+
s = TensorShapeUtils::MakeShape(shp, &new_dims);
1753+
if (!s.ok()) return s;
17521754
}
17531755

17541756
if (!shape.IsCompatibleWith(new_dims)) {

0 commit comments

Comments
 (0)