Browse Source

bugfix for onnx data index order

pull/216/head
y00500818 5 years ago
parent
commit
9ee21cc37b
2 changed files with 11 additions and 16 deletions
  1. +6
    -14
      parser/onnx/onnx_parser.cc
  2. +5
    -2
      parser/tensorflow/tensorflow_parser.cc

+ 6
- 14
parser/onnx/onnx_parser.cc View File

@@ -157,7 +157,6 @@ Status OnnxModelParser::ParseInput(ge::onnx::GraphProto &onnx_graph,
}

// get input value info map
std::map<std::string, ge::onnx::TensorProto> 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;
}


+ 5
- 2
parser/tensorflow/tensorflow_parser.cc View File

@@ -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;
}



Loading…
Cancel
Save