From 74819122e889d4cccaa68782be58fca86d47dc76 Mon Sep 17 00:00:00 2001 From: y00500818 Date: Sat, 27 Feb 2021 16:38:19 +0800 Subject: [PATCH] optimize time cost for Shrink thread --- ge/graph/load/model_manager/davinci_model.cc | 6 +++++- ge/graph/load/model_manager/davinci_model.h | 1 + ge/graph/load/model_manager/model_manager.cc | 4 ++-- inc/framework/common/helper/model_helper.h | 5 +++++ 4 files changed, 13 insertions(+), 3 deletions(-) diff --git a/ge/graph/load/model_manager/davinci_model.cc b/ge/graph/load/model_manager/davinci_model.cc index a593ea67..db149e67 100755 --- a/ge/graph/load/model_manager/davinci_model.cc +++ b/ge/graph/load/model_manager/davinci_model.cc @@ -173,6 +173,7 @@ DavinciModel::DavinciModel(int32_t priority, const std::shared_ptr listener_; diff --git a/ge/graph/load/model_manager/model_manager.cc b/ge/graph/load/model_manager/model_manager.cc index 512c6e72..9b79b5b3 100755 --- a/ge/graph/load/model_manager/model_manager.cc +++ b/ge/graph/load/model_manager/model_manager.cc @@ -1058,7 +1058,6 @@ Status ModelManager::LoadModelOffline(uint32_t &model_id, const ModelData &model } do { - GeModelPtr ge_model = model_helper.GetGeModel(); shared_ptr davinci_model = MakeShared(model.priority, listener); if (davinci_model == nullptr) { GELOGE(ACL_ERROR_GE_MEMORY_ALLOCATION, "Make shared failed"); @@ -1066,11 +1065,12 @@ Status ModelManager::LoadModelOffline(uint32_t &model_id, const ModelData &model } davinci_model->SetProfileTime(MODEL_LOAD_START, (timespec.tv_sec * kTimeSpecNano + timespec.tv_nsec)); // 1000 ^ 3 converts second to nanosecond - ret = davinci_model->Assign(ge_model); + ret = davinci_model->Assign(model_helper.GetGeModel()); if (ret != SUCCESS) { GELOGW("assign model failed."); break; } + model_helper.ResetGeModel(); davinci_model->SetId(model_id); int32_t device_id = 0; diff --git a/inc/framework/common/helper/model_helper.h b/inc/framework/common/helper/model_helper.h index e25d5d6f..263ae2b5 100644 --- a/inc/framework/common/helper/model_helper.h +++ b/inc/framework/common/helper/model_helper.h @@ -53,6 +53,11 @@ class GE_FUNC_VISIBILITY ModelHelper { Status GetBaseNameFromFileName(const std::string &file_name, std::string &base_name); Status GetModelNameFromMergedGraphName(const std::string &graph_name, std::string &model_name); + void ResetGeModel() { + root_model_.reset(); + model_.reset(); + } + private: bool is_assign_model_ = false; bool is_offline_ = true;