From 16a21b7e521008ab75cc8bee9fd50039af762bb7 Mon Sep 17 00:00:00 2001 From: wuweikang Date: Wed, 28 Apr 2021 15:39:26 +0800 Subject: [PATCH] add atc-cmdline to om --- ge/common/auth/file_saver.cc | 1 - ge/common/helper/model_helper.cc | 15 +++++++++++++-- ge/offline/main.cc | 3 +++ ge/session/omg.cc | 7 ++++++- inc/framework/omg/omg_inner_types.h | 1 + parser | 2 +- 6 files changed, 24 insertions(+), 5 deletions(-) diff --git a/ge/common/auth/file_saver.cc b/ge/common/auth/file_saver.cc index 50dcf776..b1e94c59 100755 --- a/ge/common/auth/file_saver.cc +++ b/ge/common/auth/file_saver.cc @@ -128,7 +128,6 @@ Status FileSaver::SaveWithFileHeader(const std::string &file_path, const ModelFi Status FileSaver::SaveWithFileHeader(const std::string &file_path, const ModelFileHeader &file_header, ModelPartitionTable &model_partition_table, - const std::vector &partition_datas) { GE_CHK_BOOL_RET_STATUS(!partition_datas.empty() && model_partition_table.num != 0 && model_partition_table.num == partition_datas.size(), FAILED, diff --git a/ge/common/helper/model_helper.cc b/ge/common/helper/model_helper.cc index ac3343ed..ff32f123 100644 --- a/ge/common/helper/model_helper.cc +++ b/ge/common/helper/model_helper.cc @@ -21,6 +21,7 @@ #include "framework/omg/version.h" #include "graph/debug/ge_attr_define.h" #include "graph/utils/graph_utils.h" +#include "framework/omg/omg_inner_types.h" using std::string; using domi::ModelTaskDef; @@ -304,7 +305,6 @@ Status ModelHelper::SaveAllModelPartiton(std::shared_ptr& om_f return FAILED; } - if (SaveModelTaskDef(om_file_save_helper, ge_model, task_buffer, model_index) != SUCCESS) { GELOGE(FAILED, "[Save][TaskDef]Failed, model %s, model index %zu", ge_model->GetName().c_str(), model_index); @@ -333,6 +333,10 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY Status ModelHelper::SaveToOmMod ge::Buffer model_buffer; ge::Buffer task_buffer; + GE_CHK_BOOL_EXEC(ge::AttrUtils::SetStr(*(ge_model.get()), ATTR_MODEL_ATC_CMDLINE, + domi::GetContext().atc_cmdline), + GELOGE(FAILED, "SetStr for atc_cmdline failed."); + return FAILED); auto ret = SaveAllModelPartiton(om_file_save_helper, ge_model, model_buffer, task_buffer); if (ret != SUCCESS) { GELOGE(ret, "[Save][AllModelPartition]Failed, model %s, error_code %u", @@ -386,9 +390,12 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY Status ModelHelper::SaveToOmRoo REPORT_INNER_ERROR("E19999", "GraphBuilder SaveModel received invalid " "file name prefix"); return FAILED); - if (!is_unknown_shape) { auto &model_root = name_to_ge_model.begin()->second; + GE_CHK_BOOL_EXEC(ge::AttrUtils::SetStr(*(model_root.get()), ATTR_MODEL_ATC_CMDLINE, + domi::GetContext().atc_cmdline), + GELOGE(FAILED, "SetStr for atc_cmdline failed."); + return FAILED); return SaveToOmModel(model_root, save_param, output_file, model); } @@ -396,6 +403,10 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY Status ModelHelper::SaveToOmRoo GE_CHECK_NOTNULL(om_file_save_helper); auto &first_ge_model = name_to_ge_model.at(ge_root_model->GetRootGraph()->GetName()); + GE_CHK_BOOL_EXEC(ge::AttrUtils::SetStr(*(first_ge_model.get()), ATTR_MODEL_ATC_CMDLINE, + domi::GetContext().atc_cmdline), + GELOGE(FAILED, "SetStr for atc_cmdline failed."); + return FAILED); // ge root model must be the first to be loaded vector model_names{ge_root_model->GetRootGraph()->GetName()}; diff --git a/ge/offline/main.cc b/ge/offline/main.cc index 6603a3f5..0376becb 100755 --- a/ge/offline/main.cc +++ b/ge/offline/main.cc @@ -1343,6 +1343,9 @@ domi::Status ConvertPbtxtToJson() { int init(int argc, char* argv[]) { GFlagUtils::InitGFlag(argc, argv); + const char *gflag_argv = gflags::GetArgv(); + string cmdline = gflag_argv == nullptr ? "" : gflag_argv; + domi::GetContext().atc_cmdline = cmdline; // set log level int ret = -1; const std::set log_level = {"null", "debug", "info", "warning", "error"}; diff --git a/ge/session/omg.cc b/ge/session/omg.cc index ca5043b1..46c39b2a 100755 --- a/ge/session/omg.cc +++ b/ge/session/omg.cc @@ -867,7 +867,12 @@ FMK_FUNC_HOST_VISIBILITY void PrintModelInfo(ge::proto::ModelDef *model_def, uin auto soc_version = (iter != model_attr_map->end()) ? iter->second.s() : ""; iter = model_attr_map->find("framework_type"); auto framework_type = (iter != model_attr_map->end()) ? iter->second.s() : ""; - std::cout << "system info: " + // original atc cmdline + iter = model_attr_map->find(ATTR_MODEL_ATC_CMDLINE); + auto cmdline = (iter != model_attr_map->end()) ? iter->second.s() : ""; + std::cout << "Original Atc command line: " + << cmdline << std::endl + << "system info: " << ATTR_MODEL_ATC_VERSION << "[" << atc_version << "], " << "soc_version" diff --git a/inc/framework/omg/omg_inner_types.h b/inc/framework/omg/omg_inner_types.h index 84f6ef46..1024f7e6 100644 --- a/inc/framework/omg/omg_inner_types.h +++ b/inc/framework/omg/omg_inner_types.h @@ -124,6 +124,7 @@ struct OmgContext { std::vector data_nodes; std::vector getnext_nosink_nodes; bool fuzz_compile_flag = false; + std::string atc_cmdline; }; } // namespace ge diff --git a/parser b/parser index f12a4159..055cc4f2 160000 --- a/parser +++ b/parser @@ -1 +1 @@ -Subproject commit f12a4159641de89e38460205be89da8ef74eba8a +Subproject commit 055cc4f21aac44b96ef2f951d9e7f89f7042d77a