From 0d1fbcef54b886fcb72a81e51ccd77b8abc85485 Mon Sep 17 00:00:00 2001 From: "wangwenhua1@huawei.com" Date: Tue, 5 Jan 2021 17:28:28 +0800 Subject: [PATCH] display model info --- ge/generator/ge_generator.cc | 9 +-------- ge/offline/main.cc | 5 +++++ ge/session/omg.cc | 16 ++++++++++++++-- inc/framework/common/ge_types.h | 8 ++++++++ 4 files changed, 28 insertions(+), 10 deletions(-) diff --git a/ge/generator/ge_generator.cc b/ge/generator/ge_generator.cc index f8d4900a..f3c81ebf 100644 --- a/ge/generator/ge_generator.cc +++ b/ge/generator/ge_generator.cc @@ -556,17 +556,10 @@ bool GeGenerator::Impl::SetOmSystemInfo(AttrHolder &obj) { return false; } - // 0(Caffe) 1(MindSpore) 3(TensorFlow) 5(Onnx) - std::map framework_type_to_string = { - {"0", "Caffe"}, - {"1", "MindSpore"}, - {"3", "TensorFlow"}, - {"5", "Onnx"} - }; std::string framework_type; (void)ge::GetContext().GetOption(ge::FRAMEWORK_TYPE, framework_type); GELOGI("SetOmSystemInfo framework_type: %s", framework_type.c_str()); - if (!ge::AttrUtils::SetStr(obj, "framework_type", framework_type_to_string[framework_type.c_str()])) { + if (!ge::AttrUtils::SetStr(obj, "framework_type", ge::kFwkTypeToStr[framework_type])) { GELOGW("SetStr of framework_type failed."); return false; } diff --git a/ge/offline/main.cc b/ge/offline/main.cc index 81e1638b..40a20e16 100755 --- a/ge/offline/main.cc +++ b/ge/offline/main.cc @@ -458,6 +458,11 @@ class GFlagUtils { ge::CheckEnableSingleStreamParamValid(std::string(FLAGS_enable_single_stream)) == ge::SUCCESS, ret = ge::FAILED, "check enable single stream failed!"); + GE_CHK_BOOL_TRUE_EXEC_WITH_LOG((FLAGS_display_model_info != "0") && (FLAGS_display_model_info != "1"), + ErrorManager::GetInstance().ATCReportErrMessage( + "E10006", {"parameter"}, {"display_model_info", FLAGS_display_model_info}), + ret = ge::FAILED, "Input parameter[--display_model_info]'s value must be 1 or 0."); + return ret; } diff --git a/ge/session/omg.cc b/ge/session/omg.cc index 11384cfb..37f31071 100755 --- a/ge/session/omg.cc +++ b/ge/session/omg.cc @@ -963,6 +963,7 @@ FMK_FUNC_HOST_VISIBILITY Status ConvertOm(const char *model_file, const char *js OmFileLoadHelper omFileLoadHelper; ge::graphStatus status = omFileLoadHelper.Init(model_data, model_len); if (status != ge::GRAPH_SUCCESS) { + ErrorManager::GetInstance().ATCReportErrMessage("E19021", "Om file init failed"); GELOGE(ge::FAILED, "Om file init failed."); if (model.model_data != nullptr) { delete[] reinterpret_cast(model.model_data); @@ -974,6 +975,7 @@ FMK_FUNC_HOST_VISIBILITY Status ConvertOm(const char *model_file, const char *js ModelPartition ir_part; status = omFileLoadHelper.GetModelPartition(MODEL_DEF, ir_part); if (status != ge::GRAPH_SUCCESS) { + ErrorManager::GetInstance().ATCReportErrMessage("E19021", "Get model part failed"); GELOGE(ge::FAILED, "Get model part failed."); if (model.model_data != nullptr) { delete[] reinterpret_cast(model.model_data); @@ -999,9 +1001,12 @@ FMK_FUNC_HOST_VISIBILITY Status ConvertOm(const char *model_file, const char *js } } else { ret = INTERNAL_ERROR; + ErrorManager::GetInstance().ATCReportErrMessage("E19021", "ReadProtoFromArray failed"); GELOGE(ret, "ReadProtoFromArray failed."); } } else { + ErrorManager::GetInstance().ATCReportErrMessage("E10003", + {"parameter", "value", "reason"}, {"om", model_file, "invalid om file"}); GELOGE(PARAM_INVALID, "ParseModelContent failed because of invalid om file. Please check --om param."); } @@ -1011,6 +1016,8 @@ FMK_FUNC_HOST_VISIBILITY Status ConvertOm(const char *model_file, const char *js } return ret; } catch (const std::exception &e) { + ErrorManager::GetInstance().ATCReportErrMessage("E19021", "Convert om model to json failed, exception message[" + + e.what() + "]"); GELOGE(FAILED, "Convert om model to json failed, exception message : %s.", e.what()); return FAILED; } @@ -1041,7 +1048,8 @@ FMK_FUNC_HOST_VISIBILITY Status ConvertPbtxtToJson(const char *model_file, const if (!flag) { free_model_data(&model.model_data); - GELOGE(FAILED, "ParseFromString fail."); + ErrorManager::GetInstance().ATCReportErrMessage("E19021", "ParseFromString failed"); + GELOGE(FAILED, "ParseFromString failed."); return FAILED; } GetGroupName(model_def); @@ -1057,9 +1065,13 @@ FMK_FUNC_HOST_VISIBILITY Status ConvertPbtxtToJson(const char *model_file, const return SUCCESS; } catch (google::protobuf::FatalException &e) { free_model_data(&model.model_data); - GELOGE(FAILED, "ParseFromString fail. exception message : %s", e.what()); + ErrorManager::GetInstance().ATCReportErrMessage("E19021", "ParseFromString failed, exception message[" + + e.what() + "]"); + GELOGE(FAILED, "ParseFromString failed. exception message : %s", e.what()); return FAILED; } catch (const std::exception &e) { + ErrorManager::GetInstance().ATCReportErrMessage("E19021", "Convert pbtxt to json failed, exception message[" + + e.what() + "]"); GELOGE(FAILED, "Convert pbtxt to json failed, exception message : %s.", e.what()); return FAILED; } diff --git a/inc/framework/common/ge_types.h b/inc/framework/common/ge_types.h index 4267aec4..edd9d7ed 100644 --- a/inc/framework/common/ge_types.h +++ b/inc/framework/common/ge_types.h @@ -43,6 +43,14 @@ enum FrameworkType { FRAMEWORK_RESERVED, }; +const std::map kFwkTypeToStr = { + {"0", "Caffe"}, + {"1", "MindSpore"}, + {"3", "TensorFlow"}, + {"4", "Android_NN"}, + {"5", "Onnx"} +}; + enum OpEngineType { ENGINE_SYS = 0, // default engine ENGINE_AICORE = 1,