Merge pull request #22802 from zihaomu:fix_infinit_loop_in_tf_34

Fix infinit loop in tf 3.4 branch
pull/22818/head^2
Alexander Smorkalov 2 years ago committed by GitHub
commit b5a68f235a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 7
      modules/dnn/src/tensorflow/tf_graph_simplifier.cpp

@ -829,12 +829,19 @@ void RemoveIdentityOps(tensorflow::GraphDef& net)
IdentityOpsMap::iterator it = identity_ops.find(input_op_name); IdentityOpsMap::iterator it = identity_ops.find(input_op_name);
if (it != identity_ops.end()) { if (it != identity_ops.end()) {
std::set<String> loopCheckSet;
// In case of Identity after Identity // In case of Identity after Identity
while (true) while (true)
{ {
IdentityOpsMap::iterator nextIt = identity_ops.find(it->second); IdentityOpsMap::iterator nextIt = identity_ops.find(it->second);
if (nextIt != identity_ops.end()) 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; it = nextIt;
}
else else
break; break;
} }

Loading…
Cancel
Save