Browse Source

display model info

tags/v1.2.0
wangwenhua1@huawei.com 4 years ago
parent
commit
0d1fbcef54
4 changed files with 28 additions and 10 deletions
  1. +1
    -8
      ge/generator/ge_generator.cc
  2. +5
    -0
      ge/offline/main.cc
  3. +14
    -2
      ge/session/omg.cc
  4. +8
    -0
      inc/framework/common/ge_types.h

+ 1
- 8
ge/generator/ge_generator.cc View File

@@ -556,17 +556,10 @@ bool GeGenerator::Impl::SetOmSystemInfo(AttrHolder &obj) {
return false;
}

// 0(Caffe) 1(MindSpore) 3(TensorFlow) 5(Onnx)
std::map<string, string> 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;
}


+ 5
- 0
ge/offline/main.cc View File

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



+ 14
- 2
ge/session/omg.cc View File

@@ -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<char *>(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<char *>(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;
}


+ 8
- 0
inc/framework/common/ge_types.h View File

@@ -43,6 +43,14 @@ enum FrameworkType {
FRAMEWORK_RESERVED,
};

const std::map<std::string, std::string> kFwkTypeToStr = {
{"0", "Caffe"},
{"1", "MindSpore"},
{"3", "TensorFlow"},
{"4", "Android_NN"},
{"5", "Onnx"}
};

enum OpEngineType {
ENGINE_SYS = 0, // default engine
ENGINE_AICORE = 1,


Loading…
Cancel
Save