Skip to content
Permalink
Browse files Browse the repository at this point in the history
Handle invalid inputs instead of crashing.
PiperOrigin-RevId: 409549744
Change-Id: I7f5935b34b53f7e426a5462fcc027bdbf5dcda24
  • Loading branch information
Dan Moldovan authored and tensorflower-gardener committed Nov 13, 2021
1 parent c5ae019 commit c99d98c
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions tensorflow/core/graph/graph.cc
Expand Up @@ -222,10 +222,16 @@ void Node::RunForwardTypeInference() {
const auto& node_t = node->def().experimental_type();
if (node_t.type_id() != TFT_UNSET) {
int ix = input_idx[i];
DCHECK(ix < node_t.args_size())
<< "input " << i << " should have an output " << ix
<< " but instead only has " << node_t.args_size()
<< " outputs: " << node_t.DebugString();
if (ix >= node_t.args_size()) {
LOG(WARNING) << name() << " has bad type information: input " << i
<< " should have an output " << ix
<< " but instead only has " << node_t.args_size()
<< " outputs: " << node_t.DebugString()
<< "\nThis indicates either "
"a bug in op registration or a corrupted graph.";
ClearTypeInfo();
return;
}
input_types.emplace_back(node_t.args(ix));
} else {
input_types.emplace_back(*no_type);
Expand Down

0 comments on commit c99d98c

Please sign in to comment.