From c41799434cafd0311d1666e060f8cbde19ebda8b Mon Sep 17 00:00:00 2001 From: han-jian27 <15895851726@139.com> Date: Tue, 12 Apr 2022 17:59:31 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=97=A5=E5=BF=97=E5=86=85?= =?UTF-8?q?=E5=AE=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- parser/caffe/caffe_parser.cc | 4 ++-- parser/common/pre_checker.cc | 10 +++++++--- parser/tensorflow/tensorflow_parser.cc | 9 ++++++--- tests/st/testcase/test_tensorflow_parser.cc | 9 +++++++++ .../tensorflow_parser_unittest.cc | 9 +++++++++ 5 files changed, 33 insertions(+), 8 deletions(-) diff --git a/parser/caffe/caffe_parser.cc b/parser/caffe/caffe_parser.cc index 5e6b0b7..489d7a8 100644 --- a/parser/caffe/caffe_parser.cc +++ b/parser/caffe/caffe_parser.cc @@ -1473,8 +1473,8 @@ Status CaffeModelParser::Parse(const char *model_path, ge::ComputeGraphPtr &grap GE_RETURN_IF_ERROR(PreCheck(proto_message)); if (PreChecker::Instance().HasError()) { - REPORT_INNER_ERROR("E19999", "Precheck failed. Please read check report."); - GELOGE(INTERNAL_ERROR, "[Has][Error]Precheck failed. Please read check report."); + REPORT_INNER_ERROR("E19999", "Precheck failed. a report of json format will be create, Please read it."); + GELOGE(INTERNAL_ERROR, "[Has][Error]Precheck failed. a report of json format will be create, Please read it."); return FAILED; } diff --git a/parser/common/pre_checker.cc b/parser/common/pre_checker.cc index 8f8d577..00e7d12 100644 --- a/parser/common/pre_checker.cc +++ b/parser/common/pre_checker.cc @@ -101,7 +101,7 @@ Status PreChecker::CheckName(OpId id) { cause.code = ErrorCode::NAME_REPEATED; cause.message = "The name is repeated."; - GELOGI("Name %s repeated.", info.name.c_str()); + GELOGE(FAILED, "opname %s repeated, same name op in the graph", info.name.c_str()); ErrorManager::GetInstance().ATCReportErrMessage("E19009", {"opname"}, {info.name}); GE_RETURN_WITH_LOG_IF_ERROR(AddCause(id, cause), "[Add][Cause] failed."); GE_RETURN_WITH_LOG_IF_ERROR(AddCause(v.first, cause), "[Add][Cause] failed."); @@ -250,9 +250,11 @@ Status PreChecker::CheckTypeSupported(OpId id, const string &type, const string Cause cause; cause.code = ErrorCode::TYPE_UNSUPPORTED; cause.message = "The type is not supported."; - GELOGI("Check op[%s]'s type[%s] failed, it is not supported.", name.c_str(), type.c_str()); if (!is_tensorflow) { ErrorManager::GetInstance().ATCReportErrMessage("E19010", {"opname", "optype"}, {name, type}); + GELOGE(FAILED, "Check op[%s]'s type[%s] failed, it is not supported.", name.c_str(), type.c_str()); + } else { + GELOGI("Check op[%s]'s type[%s] is not supported.", name.c_str(), type.c_str()); } GE_RETURN_WITH_LOG_IF_ERROR(AddCause(id, cause), "[Add][Cause] failed."); } @@ -265,9 +267,11 @@ Status PreChecker::CheckTypeSupported(OpId id, const string &type, const string cause.code = ErrorCode::TYPE_UNSUPPORTED; cause.message = "The type is not supported."; - GELOGI("Check op[%s]'s type[%s] failed, it is not supported.", name.c_str(), type.c_str()); if (!is_tensorflow) { ErrorManager::GetInstance().ATCReportErrMessage("E19010", {"opname", "optype"}, {name, type}); + GELOGE(FAILED, "Check op[%s]'s type[%s] failed, it is not supported.", name.c_str(), type.c_str()); + } else { + GELOGI("Check op[%s]'s type[%s] is not supported.", name.c_str(), type.c_str()); } GE_RETURN_WITH_LOG_IF_ERROR(AddCause(id, cause), "[Add][Cause] failed."); } diff --git a/parser/tensorflow/tensorflow_parser.cc b/parser/tensorflow/tensorflow_parser.cc index d6470c6..f1fbba6 100644 --- a/parser/tensorflow/tensorflow_parser.cc +++ b/parser/tensorflow/tensorflow_parser.cc @@ -1361,7 +1361,7 @@ Status TensorFlowModelParser::Parse(const char *model_path, ge::ComputeGraphPtr domi::tensorflow::GraphDef ori_def; bool read = ge::parser::ReadProtoFromBinaryFile(model_path, &ori_def); if (!read) { - GELOGE(FAILED, "read_proto_from_binary failed."); + GELOGE(FAILED, "read_proto_from_binary failed. --framework=3, file format should be tensorflow."); return INTERNAL_ERROR; } @@ -3186,7 +3186,7 @@ Status TensorFlowModelParser::TrimGraphByOutput(const domi::tensorflow::GraphDef GE_CHK_BOOL_EXEC(node_lookup.count(current_input) > 0U, ErrorManager::GetInstance().ATCReportErrMessage("E10016", {"parameter", "opname"}, {"out_nodes", current_input}); - return FAILED, "Input op[%s] not found in graph.", current_input.c_str()); + return FAILED, "op[%s] not found in graph.", current_input.c_str()); const NodeDef *current_node = node_lookup[current_input]; GE_CHECK_NOTNULL(current_node); for (const string &input_name : current_node->input()) { @@ -3442,7 +3442,10 @@ Status TensorFlowModelParser::AddControlEdgeAfterRemoveInputs(domi::tensorflow:: if (input_node_def->op() == parser::SWITCH || input_node_def->op() == parser::REFSWITCH) { NodeDef *identity_node_def = graph_def->add_node(); GE_CHECK_NOTNULL(identity_node_def); - input_node_name = input_node_name + "identity"; + std::string remove_input_name = remove_input; + remove_input_name = remove_input_name.find(":") == std::string::npos ? + input_node_name : (remove_input_name.replace(remove_input_name.find(":"), 1, "_")); + input_node_name = remove_input_name + "_identity"; identity_node_def->set_name(input_node_name); identity_node_def->set_op(parser::IDENTITY); identity_node_def->add_input(remove_input); diff --git a/tests/st/testcase/test_tensorflow_parser.cc b/tests/st/testcase/test_tensorflow_parser.cc index ca226d9..582b75e 100644 --- a/tests/st/testcase/test_tensorflow_parser.cc +++ b/tests/st/testcase/test_tensorflow_parser.cc @@ -2832,6 +2832,15 @@ TEST_F(STestTensorflowParser, tensorflow_AddControlEdgeAfterRemoveInputs_test) removed_inputs_vec.emplace_back("Add0"); Status ret = tensorflow_parser.AddControlEdgeAfterRemoveInputs(&graph_def, node_def, all_node_map, removed_inputs_vec); EXPECT_EQ(ret, SUCCESS); + + tensorflow::NodeDef *node_swith = initNodeDef(); + node_swith->set_name("switch_op"); + node_swith->set_op(parser::SWITCH); + all_node_map.emplace("switch_op", node_swith); + removed_inputs_vec.clear(); + removed_inputs_vec.emplace_back("switch_op"); + ret = tensorflow_parser.AddControlEdgeAfterRemoveInputs(&graph_def, node_swith, all_node_map, removed_inputs_vec); + EXPECT_EQ(ret, SUCCESS); } TEST_F(STestTensorflowParser, tensorflow_GraphDefOptimizeIdentity_test) diff --git a/tests/ut/parser/testcase/tensorflow_parser_testcase/tensorflow_parser_unittest.cc b/tests/ut/parser/testcase/tensorflow_parser_testcase/tensorflow_parser_unittest.cc index 644732a..ae684ae 100644 --- a/tests/ut/parser/testcase/tensorflow_parser_testcase/tensorflow_parser_unittest.cc +++ b/tests/ut/parser/testcase/tensorflow_parser_testcase/tensorflow_parser_unittest.cc @@ -3008,6 +3008,15 @@ TEST_F(UtestTensorflowParser, tensorflow_AddControlEdgeAfterRemoveInputs_test) removed_inputs_vec.emplace_back("Add0"); Status ret = tensorflow_parser.AddControlEdgeAfterRemoveInputs(&graph_def, node_def, all_node_map, removed_inputs_vec); EXPECT_EQ(ret, SUCCESS); + + tensorflow::NodeDef *node_swith = initNodeDef(); + node_swith->set_name("switch_op"); + node_swith->set_op(parser::SWITCH); + all_node_map.emplace("switch_op", node_swith); + removed_inputs_vec.clear(); + removed_inputs_vec.emplace_back("switch_op"); + ret = tensorflow_parser.AddControlEdgeAfterRemoveInputs(&graph_def, node_swith, all_node_map, removed_inputs_vec); + EXPECT_EQ(ret, SUCCESS); } TEST_F(UtestTensorflowParser, tensorflow_GraphDefOptimizeIdentity_test)