Skip to content
Permalink
Browse files Browse the repository at this point in the history
Properly handle the case where SpecializeType() returns an error `S…
…tatus`.

If the error case in `SpecializeType()` is reached, then we would get a crash when trying to access the value of an errorenous `StatusOr` object

PiperOrigin-RevId: 408380069
Change-Id: If3c3fc876dcf9384d5ec7a4985adc68c23ea7318
  • Loading branch information
mihaimaruseac authored and tensorflower-gardener committed Nov 8, 2021
1 parent c2b31ff commit cb16478
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion tensorflow/core/framework/shape_inference.cc
Expand Up @@ -170,7 +170,10 @@ void InferenceContext::PreInputInit(
const std::vector<ShapeHandle>& input_tensors_as_shapes) {
// TODO(mdan): This is also done at graph construction. Run only here instead?
const auto ret = full_type::SpecializeType(attrs_, op_def);
DCHECK(ret.status().ok()) << "while instantiating types: " << ret.status();
if (!ret.status().ok()) {
construction_status_ = ret.status();
return;
}
ret_types_ = ret.ValueOrDie();

input_tensors_ = input_tensors;
Expand Down

0 comments on commit cb16478

Please sign in to comment.