Skip to content
Permalink
Browse files Browse the repository at this point in the history
Eliminate CHECK-fails from IsSimplifiableReshape via `MakeShape(<…
…invalid shape>)`

PiperOrigin-RevId: 409166738
Change-Id: I7f0a3590b8acae3f3e3e2fe636e1f5ef285693cf
  • Loading branch information
mihaimaruseac authored and tensorflower-gardener committed Nov 11, 2021
1 parent 1fb2773 commit 2406555
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions tensorflow/core/grappler/optimizers/constant_folding.cc
Expand Up @@ -1741,14 +1741,16 @@ Status ConstantFolding::IsSimplifiableReshape(
int32_t dim = outputs[0]->flat<int32>()(i);
shp.push_back(dim);
}
TF_CHECK_OK(TensorShapeUtils::MakeShape(shp, &new_dims));
s = TensorShapeUtils::MakeShape(shp, &new_dims);
if (!s.ok()) return s;
} else {
std::vector<int64_t> shp;
for (int i = 0; i < outputs[0]->NumElements(); ++i) {
int64_t dim = outputs[0]->flat<int64_t>()(i);
shp.push_back(dim);
}
TF_CHECK_OK(TensorShapeUtils::MakeShape(shp, &new_dims));
s = TensorShapeUtils::MakeShape(shp, &new_dims);
if (!s.ok()) return s;
}

if (!shape.IsCompatibleWith(new_dims)) {
Expand Down

0 comments on commit 2406555

Please sign in to comment.