Browse Source

optimize time cost for Shrink thread

pull/1167/head
y00500818 4 years ago
parent
commit
74819122e8
4 changed files with 13 additions and 3 deletions
  1. +5
    -1
      ge/graph/load/model_manager/davinci_model.cc
  2. +1
    -0
      ge/graph/load/model_manager/davinci_model.h
  3. +2
    -2
      ge/graph/load/model_manager/model_manager.cc
  4. +5
    -0
      inc/framework/common/helper/model_helper.h

+ 5
- 1
ge/graph/load/model_manager/davinci_model.cc View File

@@ -173,6 +173,7 @@ DavinciModel::DavinciModel(int32_t priority, const std::shared_ptr<ModelListener
runtime_model_id_(0),
version_(0),
ge_model_(nullptr),
is_shrink_created_(false),
listener_(listener),
run_flg_(false),
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;
}

@@ -3708,6 +3708,10 @@ Status DavinciModel::NnExecute(rtStream_t stream, bool async_mode, const InputDa
GELOGD("current_data.index=%u", input_data.index);
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()) {
GELOGD("rtModelExecute do");
GE_IF_BOOL_EXEC(ProfilingManager::Instance().ProfilingModelExecuteOn(), SetProfileTime(MODEL_INFER_START));


+ 1
- 0
ge/graph/load/model_manager/davinci_model.h View File

@@ -905,6 +905,7 @@ class DavinciModel {

thread thread_id_;
thread shrink_id_;
bool is_shrink_created_;

shared_ptr<ModelListener> listener_;



+ 2
- 2
ge/graph/load/model_manager/model_manager.cc View File

@@ -1058,7 +1058,6 @@ Status ModelManager::LoadModelOffline(uint32_t &model_id, const ModelData &model
}

do {
GeModelPtr ge_model = model_helper.GetGeModel();
shared_ptr<DavinciModel> davinci_model = MakeShared<DavinciModel>(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;


+ 5
- 0
inc/framework/common/helper/model_helper.h View File

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


Loading…
Cancel
Save