From 465c03cdb7fe56ed0f322cfaf26fbee06b2b2048 Mon Sep 17 00:00:00 2001 From: "wangwenhua1@huawei.com" Date: Wed, 23 Dec 2020 11:37:14 +0800 Subject: [PATCH] display model info --- ge/common/helper/model_helper.cc | 3 +- ge/generator/ge_generator.cc | 38 +++++++++--------------- ge/session/omg.cc | 50 ++++++++++++++------------------ 3 files changed, 36 insertions(+), 55 deletions(-) diff --git a/ge/common/helper/model_helper.cc b/ge/common/helper/model_helper.cc index d357394f..9ad5a1bd 100644 --- a/ge/common/helper/model_helper.cc +++ b/ge/common/helper/model_helper.cc @@ -78,6 +78,7 @@ Status ModelHelper::SaveModelPartition(std::shared_ptr &om_fil Status ModelHelper::SaveSizeToModelDef(const GeModelPtr &ge_model, ge::Buffer &model_buffer) { vector om_info; + GELOGD("SaveSizeToModelDef modeldef_size is %zu", model_buffer.GetSize()); om_info.push_back(model_buffer.GetSize()); // GE_CHK_BOOL_EXEC(ge::AttrUtils::SetInt(ge_model, "modeldef_size", model_buffer.GetSize()), // GELOGE(FAILED, "SetInt of modeldef_size failed."); @@ -129,9 +130,9 @@ Status ModelHelper::SaveModelDef(std::shared_ptr &om_file_save model_tmp->SetGraph(ge_model->GetGraph()); model_tmp->SetVersion(ge_model->GetVersion()); model_tmp->SetAttr(ge_model->MutableAttrMap()); - SaveSizeToModelDef(ge_model, model_buffer); (void)model_tmp->Save(model_buffer); + SaveSizeToModelDef(ge_model, model_buffer); GELOGD("MODEL_DEF size is %zu", model_buffer.GetSize()); if (model_buffer.GetSize() > 0) { if (SaveModelPartition(om_file_save_helper, ModelPartitionType::MODEL_DEF, model_buffer.GetData(), diff --git a/ge/generator/ge_generator.cc b/ge/generator/ge_generator.cc index 9db7f795..efef82d4 100644 --- a/ge/generator/ge_generator.cc +++ b/ge/generator/ge_generator.cc @@ -557,6 +557,19 @@ void GeGenerator::Impl::DisplayModelInfo(AttrHolder &obj) { } std::cout << "------ Display Model Info start ------" << std::endl; + // system info + std::string atc_version; + (void)ge::AttrUtils::GetStr(obj, ATTR_MODEL_ATC_VERSION, atc_version); + std::string soc_version; + (void)ge::AttrUtils::GetStr(obj, "soc_version", soc_version); + std::string framework_type; + (void)ge::AttrUtils::GetStr(obj, "framework_type", framework_type); + std::cout << ATTR_MODEL_ATC_VERSION + << "[" << atc_version << "], " + << "soc_version" + << "[" << soc_version << "], " + << "framework_type" + << "[" << framework_type << "]." << std::endl; // resource info int64_t memory_size; @@ -577,31 +590,6 @@ void GeGenerator::Impl::DisplayModelInfo(AttrHolder &obj) { << "[" << event_num << "]." << std::endl; - // system info - std::string atc_version; - (void)ge::AttrUtils::GetStr(obj, ATTR_MODEL_ATC_VERSION, atc_version); - std::string soc_version; - (void)ge::AttrUtils::GetStr(obj, "soc_version", soc_version); - std::string framework_type; - (void)ge::AttrUtils::GetStr(obj, "framework_type", framework_type); - std::cout << ATTR_MODEL_ATC_VERSION - << "[" << atc_version << "], " - << "soc_version" - << "[" << soc_version << "], " - << "framework_type" - << "[" << framework_type << "]." << std::endl; - - // om info -// int64_t modeldef_size; -// (void)ge::AttrUtils::GetInt(obj, "modeldef_size", modeldef_size); -// int64_t weight_data_size; -// (void)ge::AttrUtils::GetInt(obj, "weight_data_size", weight_data_size); -// int64_t tbe_kernels_size; -// (void)ge::AttrUtils::GetInt(obj, "tbe_kernels_size", tbe_kernels_size); -// int64_t cust_aicpu_kernel_store_size; -// (void)ge::AttrUtils::GetInt(obj, "cust_aicpu_kernel_store_size", cust_aicpu_kernel_store_size); -// int64_t task_info_size; -// (void)ge::AttrUtils::GetInt(obj, "task_info_size", task_info_size); vector om_info; (void)ge::AttrUtils::GetListInt(obj, "om_info_list", om_info); if (om_info.size() == 5) { diff --git a/ge/session/omg.cc b/ge/session/omg.cc index 2c136348..59ecbbed 100755 --- a/ge/session/omg.cc +++ b/ge/session/omg.cc @@ -870,7 +870,22 @@ void GetGroupName(ge::proto::ModelDef &model_def) { } FMK_FUNC_HOST_VISIBILITY void PrintModelInfo(ge::proto::ModelDef *model_def) { - std::cout << "------ Display Model Info start ------" << std::endl; + std::cout << "------------ Display Model Info start ------------" << std::endl; + + // system info + iter = model_attr_map->find(ATTR_MODEL_ATC_VERSION); + auto atc_version = (iter != model_attr_map->end()) ? iter->second.s() : ""; + iter = model_attr_map->find("soc_version"); + 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: " + << ATTR_MODEL_ATC_VERSION + << "[" << atc_version << "], " + << "soc_version" + << "[" << soc_version << "], " + << "framework_type" + << "[" << framework_type << "]." << std::endl; // resource info auto model_attr_map = model_def->mutable_attr(); @@ -882,7 +897,8 @@ FMK_FUNC_HOST_VISIBILITY void PrintModelInfo(ge::proto::ModelDef *model_def) { auto stream_num = (iter != model_attr_map->end()) ? iter->second.i() : -1; iter = model_attr_map->find(ATTR_MODEL_EVENT_NUM); auto event_num = (iter != model_attr_map->end()) ? iter->second.i() : -1; - std::cout << ATTR_MODEL_MEMORY_SIZE + std::cout << "resource info: " + << ATTR_MODEL_MEMORY_SIZE << "[" << memory_size << "], " << ATTR_MODEL_WEIGHT_SIZE << "[" << weight_size << "], " @@ -892,36 +908,12 @@ FMK_FUNC_HOST_VISIBILITY void PrintModelInfo(ge::proto::ModelDef *model_def) { << "[" << event_num << "]." << std::endl; - // system info - iter = model_attr_map->find(ATTR_MODEL_ATC_VERSION); - auto atc_version = (iter != model_attr_map->end()) ? iter->second.s() : ""; - iter = model_attr_map->find("soc_version"); - 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 << ATTR_MODEL_ATC_VERSION - << "[" << atc_version << "], " - << "soc_version" - << "[" << soc_version << "], " - << "framework_type" - << "[" << framework_type << "]." << std::endl; - -// iter = model_attr_map->find("modeldef_size"); -// auto modeldef_size = (iter != model_attr_map->end()) ? iter->second.i() : -1; -// iter = model_attr_map->find("weight_data_size"); -// auto weight_data_size = (iter != model_attr_map->end()) ? iter->second.i() : -1; -// iter = model_attr_map->find("tbe_kernels_size"); -// auto tbe_kernels_size = (iter != model_attr_map->end()) ? iter->second.i() : -1; -// iter = model_attr_map->find("cust_aicpu_kernel_store_size"); -// auto cust_aicpu_kernel_store_size = (iter != model_attr_map->end()) ? iter->second.i() : -1; -// iter = model_attr_map->find("task_info_size"); -// auto task_info_size = (iter != model_attr_map->end()) ? iter->second.i() : -1; - // om info iter = model_attr_map->find("om_info_size"); auto bt = iter->second.list().i_size(); if (bt == 5) { - std::cout << "modeldef_size" + std::cout << "om info: " + << "modeldef_size" << "[" << iter->second.list().i(0) << "], " << "weight_data_size" << "[" << iter->second.list().i(1) << "], " @@ -935,7 +927,7 @@ FMK_FUNC_HOST_VISIBILITY void PrintModelInfo(ge::proto::ModelDef *model_def) { std::cout << "Display Model Info error, please check!" << std::endl; }; - std::cout << "------ Display Model Info end ------" << std::endl; + std::cout << "------------ Display Model Info end ------------" << std::endl; } FMK_FUNC_HOST_VISIBILITY Status ConvertOm(const char *model_file, const char *json_file, bool is_covert_to_json) {