diff --git a/onnxruntime/core/providers/mkldnn/mkldnn_execution_provider.cc b/onnxruntime/core/providers/mkldnn/mkldnn_execution_provider.cc index c568e22f9a308..a2908888c5b49 100644 --- a/onnxruntime/core/providers/mkldnn/mkldnn_execution_provider.cc +++ b/onnxruntime/core/providers/mkldnn/mkldnn_execution_provider.cc @@ -357,8 +357,8 @@ void MKLDNNExecutionProvider::CreateMetaDef(const onnxruntime::GraphViewer& grap std::vector>& result) const { std::string graph_fused_nodes; std::string node_list; - std::string subgraph_id = std::to_string(sub_var.subgraph_index); - sub_var.subgraph_index++; + std::string subgraph_id = std::to_string(subgraph_index_); + subgraph_index_++; // This is a list of initializers that subgraph considers as constants. // Example weights, reshape shape etc. @@ -378,7 +378,7 @@ void MKLDNNExecutionProvider::CreateMetaDef(const onnxruntime::GraphViewer& grap auto meta_def = std::make_unique<::onnxruntime::IndexedSubGraph::MetaDef>(); meta_def->attributes["initializers"] = initializers; - meta_def->name = "MkldnnCustomOp" + std::to_string(sub_var.subgraph_index); + meta_def->name = "MkldnnCustomOp" + std::to_string(subgraph_index_); meta_def->domain = kMSDomain; meta_def->since_version = 1; meta_def->status = ONNX_NAMESPACE::EXPERIMENTAL; diff --git a/onnxruntime/core/providers/mkldnn/mkldnn_execution_provider.h b/onnxruntime/core/providers/mkldnn/mkldnn_execution_provider.h index 2869698568bde..a57f290689382 100644 --- a/onnxruntime/core/providers/mkldnn/mkldnn_execution_provider.h +++ b/onnxruntime/core/providers/mkldnn/mkldnn_execution_provider.h @@ -147,6 +147,8 @@ class MKLDNNExecutionProvider : public IExecutionProvider { } private: + mutable int subgraph_index_ = 0; + // supported MklDnn Operators std::set mkldnn_ops_ = {"Conv", "BatchNormalization", "Relu", "Sum", "AveragePool", "GlobalMaxPool", "GlobalAveragePool", "MaxPool", "LRN"}; diff --git a/onnxruntime/core/providers/mkldnn/subgraph/subgraph.h b/onnxruntime/core/providers/mkldnn/subgraph/subgraph.h index 6e3f967dab65d..b63692bce04ec 100644 --- a/onnxruntime/core/providers/mkldnn/subgraph/subgraph.h +++ b/onnxruntime/core/providers/mkldnn/subgraph/subgraph.h @@ -48,12 +48,8 @@ struct Subgraph { std::vector outputs; std::vector outputs_as_input_other_node; std::vector subgraph_node_indexes; - int subgraph_index = 0; - SubgraphVariables() { - subgraph_index = 0; - } - void Reset() { + void Reset() { subgraph_node_indexes.clear(); inputs.clear(); outputs.clear();