From d79f0a260a3d43d68012b216ea7a68c59883be9f Mon Sep 17 00:00:00 2001 From: y00500818 Date: Thu, 4 Feb 2021 14:47:10 +0800 Subject: [PATCH] optimize InitModelProfile cost time --- ge/graph/load/model_manager/davinci_model.cc | 21 ++++++++++--------- ge/graph/load/model_manager/davinci_model.h | 1 + .../ge/graph/load/davinci_model_unittest.cc | 2 ++ 3 files changed, 14 insertions(+), 10 deletions(-) diff --git a/ge/graph/load/model_manager/davinci_model.cc b/ge/graph/load/model_manager/davinci_model.cc index 8d6dca2a..3401ee47 100755 --- a/ge/graph/load/model_manager/davinci_model.cc +++ b/ge/graph/load/model_manager/davinci_model.cc @@ -147,7 +147,6 @@ DavinciModel::DavinciModel(int32_t priority, const std::shared_ptrStop(); + if (data_inputer_ != nullptr) { + data_inputer_->Stop(); + } if (thread_id_.joinable()) { thread_id_.join(); } + if (shrink_id_.joinable()) { + shrink_id_.join(); + } + return SUCCESS; } @@ -2820,8 +2823,6 @@ Status DavinciModel::ModelRunStop() { LockRunFlg(); GE_MAKE_GUARD(tmp_lock, [&] { UnlockRunFlg(); }); - GE_IF_BOOL_EXEC(!run_flg_, return SUCCESS); - GE_CHK_STATUS_RET(DestroyThread(), "DestoyThead failed."); return SUCCESS; diff --git a/ge/graph/load/model_manager/davinci_model.h b/ge/graph/load/model_manager/davinci_model.h index 8ed82912..31cc9939 100755 --- a/ge/graph/load/model_manager/davinci_model.h +++ b/ge/graph/load/model_manager/davinci_model.h @@ -907,6 +907,7 @@ class DavinciModel { vector output_memory_size_list_; thread thread_id_; + thread shrink_id_; shared_ptr listener_; diff --git a/tests/ut/ge/graph/load/davinci_model_unittest.cc b/tests/ut/ge/graph/load/davinci_model_unittest.cc index a66aed7e..39e8ef2e 100644 --- a/tests/ut/ge/graph/load/davinci_model_unittest.cc +++ b/tests/ut/ge/graph/load/davinci_model_unittest.cc @@ -280,7 +280,9 @@ TEST_F(UtestDavinciModel, init_unknown) { memcpy_async->set_op_index(2); EXPECT_EQ(model.Assign(ge_model), SUCCESS); + ProfilingManager::Instance().is_load_profiling_ = true; EXPECT_EQ(model.Init(), SUCCESS); + ProfilingManager::Instance().is_load_profiling_ = false; EXPECT_EQ(model.input_addrs_list_.size(), 1); EXPECT_EQ(model.output_addrs_list_.size(), 1);