From c7599d0705a1f60ea2709e65647b67db220691b8 Mon Sep 17 00:00:00 2001 From: Sreekanth Yalachigere <17345104+sreekanth-yalachigere@users.noreply.github.com> Date: Thu, 24 Oct 2019 22:14:30 -0700 Subject: [PATCH] subgraph parse error fix (#2254) --- .../mkldnn/mkldnn_execution_provider.cc | 39 ++++++++++--------- 1 file changed, 20 insertions(+), 19 deletions(-) diff --git a/onnxruntime/core/providers/mkldnn/mkldnn_execution_provider.cc b/onnxruntime/core/providers/mkldnn/mkldnn_execution_provider.cc index 8f814eb4b6..3672f246e0 100644 --- a/onnxruntime/core/providers/mkldnn/mkldnn_execution_provider.cc +++ b/onnxruntime/core/providers/mkldnn/mkldnn_execution_provider.cc @@ -296,28 +296,29 @@ std::vector> MKLDNNExecutionProvider::GetCapa bool create_subgraph = false; bool break_loop = false; while (!break_loop) { - if (temp_index > graph_viewer.MaxNodeIndex()) - break_loop = true; - - auto next_node = graph_viewer.GetNode(temp_index); - while (next_node == nullptr) { + if (temp_index < graph_viewer.MaxNodeIndex()) { + auto next_node = graph_viewer.GetNode(temp_index); + while (next_node == nullptr) { + temp_index++; + next_node = graph_viewer.GetNode(temp_index); + } + if (next_node->GetInputEdgesCount() == node->GetOutputEdgesCount()) { + // if all nodes in the branch loop are mkldnn nodes + // then continue with adding nodes to sub-graph + break_loop = true; + } + // inner nodes. if inner nodes are not mkldnn nodes + // create subgraph (inception v2) + auto sub_it = mkldnn_ops_.find(next_node->OpType()); + if (sub_it == mkldnn_ops_.end()) { + // break and create a sub-graph + break_loop = true; + create_subgraph = true; + } temp_index++; - next_node = graph_viewer.GetNode(temp_index); - } - if (next_node->GetInputEdgesCount() == node->GetOutputEdgesCount()) { - // if all nodes in the branch loop are mkldnn nodes - // then continue with adding nodes to sub-graph + } else { break_loop = true; } - // inner nodes. if inner nodes are not mkldnn nodes - // create subgraph (inception v2) - auto sub_it = mkldnn_ops_.find(next_node->OpType()); - if (sub_it == mkldnn_ops_.end()) { - // break and create a sub-graph - break_loop = true; - create_subgraph = true; - } - temp_index++; } if (create_subgraph) { CreateMetaDef(graph_viewer, subgraph_attributes, subgraph_ptr, sub_var, result);