From 9ee21cc37b72aee3760ee76223eca0ccdd4fa1cb Mon Sep 17 00:00:00 2001 From: y00500818 Date: Tue, 19 Jan 2021 10:05:03 +0800 Subject: [PATCH] bugfix for onnx data index order --- parser/onnx/onnx_parser.cc | 20 ++++++-------------- parser/tensorflow/tensorflow_parser.cc | 7 +++++-- 2 files changed, 11 insertions(+), 16 deletions(-) diff --git a/parser/onnx/onnx_parser.cc b/parser/onnx/onnx_parser.cc index 1731254..b4ef845 100644 --- a/parser/onnx/onnx_parser.cc +++ b/parser/onnx/onnx_parser.cc @@ -157,7 +157,6 @@ Status OnnxModelParser::ParseInput(ge::onnx::GraphProto &onnx_graph, } // get input value info map - std::map input_name_tensor; for (int i = 0; i < onnx_graph.input_size(); i++) { ge::onnx::ValueInfoProto value_info = onnx_graph.input(i); GELOGI("The index of %d input name : %s.", i, value_info.name().c_str()); @@ -165,7 +164,6 @@ Status OnnxModelParser::ParseInput(ge::onnx::GraphProto &onnx_graph, // The input are possibly initialized by a default value found in ‘initializer.’ auto initializer_iter = initializer_name_tensor.find(value_info.name()); if (initializer_iter != initializer_name_tensor.end()) { - input_name_tensor[value_info.name()] = initializer_iter->second; initializer_name_tensor.erase(initializer_iter); continue; } @@ -188,27 +186,21 @@ Status OnnxModelParser::ParseInput(ge::onnx::GraphProto &onnx_graph, } } } - input_name_tensor[value_info.name()] = tensor_tmp; - } - - // Construct node for input - int64_t index = 0; - for (auto it : input_name_tensor) { + // Construct node for input ge::onnx::NodeProto *input_node = onnx_graph.add_node(); - input_node->set_name(it.first); + input_node->set_name(value_info.name()); input_node->set_op_type(ge::kOpTypeInput); - input_node->add_output(it.first); + input_node->add_output(value_info.name()); // add tensor ge::onnx::AttributeProto *attribute = input_node->add_attribute(); attribute->set_name(ge::kAttrNameInput); ge::onnx::TensorProto *attribute_tensor = attribute->mutable_t(); - *attribute_tensor = it.second; + *attribute_tensor = tensor_tmp; // add index ge::onnx::AttributeProto *attribute_index = input_node->add_attribute(); attribute_index->set_name(ge::kAttrNameIndex); - attribute_index->set_i(index++); - - input_node_names_.emplace_back(it.first); + attribute_index->set_i(i); + input_node_names_.emplace_back(value_info.name()); } return SUCCESS; } diff --git a/parser/tensorflow/tensorflow_parser.cc b/parser/tensorflow/tensorflow_parser.cc index 0342f2b..c532d15 100644 --- a/parser/tensorflow/tensorflow_parser.cc +++ b/parser/tensorflow/tensorflow_parser.cc @@ -294,8 +294,11 @@ Status TensorFlowModelParser::DefunToPartitionedCall(const domi::tensorflow::Nod if (!ge::TensorFlowUtil::FindAttrValue(node_def, "_disable_call_shape_inference", attr_call_inference)) { ErrorManager::GetInstance().ATCReportErrMessage( "E19014", {"opname", "value", "reason"}, - {node_def->name(), "attr [_disable_call_shape_inference]", "is not exist in nodedef"}); - GELOGE(FAILED, "In NodeDef %s attr [_disable_call_shape_inference] not exist.", op_name.c_str()); + {node_def->name(), "attr [_disable_call_shape_inference]", + "may has no ir definition, if it is not a common decorate function operator"}); + GELOGE(FAILED, + "Op %s has no ir definition, or has no attr [_disable_call_shape_inference] " + "if it is a common decorate function operator.", op_name.c_str()); return FAILED; }