diff --git a/tensorflow/core/grappler/costs/graph_properties.cc b/tensorflow/core/grappler/costs/graph_properties.cc index 925ea44d454df2..439d09923ff5da 100644 --- a/tensorflow/core/grappler/costs/graph_properties.cc +++ b/tensorflow/core/grappler/costs/graph_properties.cc @@ -1911,7 +1911,7 @@ Status GraphProperties::UpdateMerge(SymbolicShapeRefiner* shape_refiner, // Infer the shape of the second output once and for all since it never // changes. ShapeHandle out1 = ic->Scalar(); - ic->set_output(1, out1); + if (ic->num_outputs() >= 2) ic->set_output(1, out1); } ShapeHandle out;