| @@ -173,6 +173,7 @@ DavinciModel::DavinciModel(int32_t priority, const std::shared_ptr<ModelListener | |||||
| runtime_model_id_(0), | runtime_model_id_(0), | ||||
| version_(0), | version_(0), | ||||
| ge_model_(nullptr), | ge_model_(nullptr), | ||||
| is_shrink_created_(false), | |||||
| listener_(listener), | listener_(listener), | ||||
| run_flg_(false), | run_flg_(false), | ||||
| priority_(priority), | priority_(priority), | ||||
| @@ -765,7 +766,6 @@ Status DavinciModel::Init(void *dev_ptr, size_t mem_size, void *weight_ptr, size | |||||
| } | } | ||||
| } | } | ||||
| CREATE_STD_THREAD(shrink_id_, &DavinciModel::Shrink, this); | |||||
| return SUCCESS; | return SUCCESS; | ||||
| } | } | ||||
| @@ -3708,6 +3708,10 @@ Status DavinciModel::NnExecute(rtStream_t stream, bool async_mode, const InputDa | |||||
| GELOGD("current_data.index=%u", input_data.index); | GELOGD("current_data.index=%u", input_data.index); | ||||
| GE_IF_BOOL_EXEC(ProfilingManager::Instance().ProfilingModelExecuteOn(), SetProfileTime(MODEL_PRE_PROC_END)); | GE_IF_BOOL_EXEC(ProfilingManager::Instance().ProfilingModelExecuteOn(), SetProfileTime(MODEL_PRE_PROC_END)); | ||||
| if (!is_shrink_created_) { | |||||
| CREATE_STD_THREAD(shrink_id_, &DavinciModel::Shrink, this); | |||||
| is_shrink_created_ = true; | |||||
| } | |||||
| if (!task_list_.empty()) { | if (!task_list_.empty()) { | ||||
| GELOGD("rtModelExecute do"); | GELOGD("rtModelExecute do"); | ||||
| GE_IF_BOOL_EXEC(ProfilingManager::Instance().ProfilingModelExecuteOn(), SetProfileTime(MODEL_INFER_START)); | GE_IF_BOOL_EXEC(ProfilingManager::Instance().ProfilingModelExecuteOn(), SetProfileTime(MODEL_INFER_START)); | ||||
| @@ -905,6 +905,7 @@ class DavinciModel { | |||||
| thread thread_id_; | thread thread_id_; | ||||
| thread shrink_id_; | thread shrink_id_; | ||||
| bool is_shrink_created_; | |||||
| shared_ptr<ModelListener> listener_; | shared_ptr<ModelListener> listener_; | ||||
| @@ -1058,7 +1058,6 @@ Status ModelManager::LoadModelOffline(uint32_t &model_id, const ModelData &model | |||||
| } | } | ||||
| do { | do { | ||||
| GeModelPtr ge_model = model_helper.GetGeModel(); | |||||
| shared_ptr<DavinciModel> davinci_model = MakeShared<DavinciModel>(model.priority, listener); | shared_ptr<DavinciModel> davinci_model = MakeShared<DavinciModel>(model.priority, listener); | ||||
| if (davinci_model == nullptr) { | if (davinci_model == nullptr) { | ||||
| GELOGE(ACL_ERROR_GE_MEMORY_ALLOCATION, "Make shared failed"); | 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 + | davinci_model->SetProfileTime(MODEL_LOAD_START, (timespec.tv_sec * kTimeSpecNano + | ||||
| timespec.tv_nsec)); // 1000 ^ 3 converts second to nanosecond | 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) { | if (ret != SUCCESS) { | ||||
| GELOGW("assign model failed."); | GELOGW("assign model failed."); | ||||
| break; | break; | ||||
| } | } | ||||
| model_helper.ResetGeModel(); | |||||
| davinci_model->SetId(model_id); | davinci_model->SetId(model_id); | ||||
| int32_t device_id = 0; | int32_t device_id = 0; | ||||
| @@ -53,6 +53,11 @@ class GE_FUNC_VISIBILITY ModelHelper { | |||||
| Status GetBaseNameFromFileName(const std::string &file_name, std::string &base_name); | Status GetBaseNameFromFileName(const std::string &file_name, std::string &base_name); | ||||
| Status GetModelNameFromMergedGraphName(const std::string &graph_name, std::string &model_name); | Status GetModelNameFromMergedGraphName(const std::string &graph_name, std::string &model_name); | ||||
| void ResetGeModel() { | |||||
| root_model_.reset(); | |||||
| model_.reset(); | |||||
| } | |||||
| private: | private: | ||||
| bool is_assign_model_ = false; | bool is_assign_model_ = false; | ||||
| bool is_offline_ = true; | bool is_offline_ = true; | ||||