From d4cb564ce25eb7c251e98178f39af0110f4d128b Mon Sep 17 00:00:00 2001 From: Alexander Lyulkov Date: Fri, 15 Sep 2023 14:22:21 +0700 Subject: [PATCH] Fixed removePhaseSwitches in tf_graph_simplifier --- modules/dnn/src/tensorflow/tf_graph_simplifier.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/modules/dnn/src/tensorflow/tf_graph_simplifier.cpp b/modules/dnn/src/tensorflow/tf_graph_simplifier.cpp index 2e8cde2799..5531b28111 100644 --- a/modules/dnn/src/tensorflow/tf_graph_simplifier.cpp +++ b/modules/dnn/src/tensorflow/tf_graph_simplifier.cpp @@ -1120,15 +1120,16 @@ void removePhaseSwitches(tensorflow::GraphDef& net) inpName = inpName.substr(1 + (int)inpName.find('^'), inpName.rfind(':')); nodesMapIt = nodesMap.find(inpName); CV_Assert(nodesMapIt != nodesMap.end()); - int inpNodeId = nodesMapIt->second; + + CV_CheckGT(numConsumers[inpNodeId], 0, + "Input node of the current node should have at least one output node"); if (numConsumers[inpNodeId] == 1) { mergeOpSubgraphNodes.push(inpNodeId); nodesToRemove.push_back(inpNodeId); } - else if (numConsumers[inpNodeId] > 0) - numConsumers[inpNodeId] -= 1; + numConsumers[inpNodeId] -= 1; } } std::sort(nodesToRemove.begin(), nodesToRemove.end());