Skip to content

Commit

Permalink
Merge pull request opencv#22802 from zihaomu:fix_infinit_loop_in_tf_34
Browse files Browse the repository at this point in the history
Fix infinit loop in tf 3.4 branch
  • Loading branch information
asmorkalov authored Nov 15, 2022
2 parents b418eb1 + 5bf64e7 commit b5a68f2
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions modules/dnn/src/tensorflow/tf_graph_simplifier.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -829,12 +829,19 @@ void RemoveIdentityOps(tensorflow::GraphDef& net)
IdentityOpsMap::iterator it = identity_ops.find(input_op_name);

if (it != identity_ops.end()) {
std::set<String> loopCheckSet;
// In case of Identity after Identity
while (true)
{
IdentityOpsMap::iterator nextIt = identity_ops.find(it->second);
if (nextIt != identity_ops.end())
{
// Loop check
if (loopCheckSet.find(it->second) != loopCheckSet.end())
CV_Error(Error::StsError, "Found a loop in your input Tensorflow model, which is illegal!");
loopCheckSet.insert(it->second);
it = nextIt;
}
else
break;
}
Expand Down

0 comments on commit b5a68f2

Please sign in to comment.