diff --git a/ge/graph/load/model_manager/davinci_model.cc b/ge/graph/load/model_manager/davinci_model.cc index ed2428d9..8d6dca2a 100755 --- a/ge/graph/load/model_manager/davinci_model.cc +++ b/ge/graph/load/model_manager/davinci_model.cc @@ -728,6 +728,7 @@ Status DavinciModel::Init(void *dev_ptr, size_t mem_size, void *weight_ptr, size GE_CHK_RT_RET(rtSetCtxINFMode((fp_ceiling_mode != "0"))); } + SetProfileTime(MODEL_LOAD_END); // collect profiling for ge GE_CHK_STATUS_RET(InitModelProfile(), "Init model profile failed"); auto &profiling_manager = ProfilingManager::Instance(); @@ -2279,8 +2280,12 @@ Status DavinciModel::SinkModelProfile() { } // stream id info - uint32_t streamId = profile.fusion_info.stream_id; - reporter_data.data = (unsigned char *)&streamId; + uint32_t stream_id = 0; + auto iter = profiler_report_op_info_.find(fusion_op_name); + if (iter != profiler_report_op_info_.end()) { + stream_id = iter->second.second; + } + reporter_data.data = (unsigned char *)&stream_id; reporter_data.dataLen = sizeof(int32_t); GE_CHK_BOOL_EXEC(prof_mgr.CallMsprofReport(reporter_data) == 0, return FAILED, "Reporter data fail, model id:%u.", this->Id()); diff --git a/ge/graph/load/model_manager/model_manager.cc b/ge/graph/load/model_manager/model_manager.cc index 4eb3254b..d8ac4f8a 100755 --- a/ge/graph/load/model_manager/model_manager.cc +++ b/ge/graph/load/model_manager/model_manager.cc @@ -328,7 +328,8 @@ Status ModelManager::LoadModelOnline(uint32_t &model_id, const shared_ptrSetProfileTime(MODEL_LOAD_START, (timespec.tv_sec * kTimeSpecNano + + timespec.tv_nsec)); // 1000 ^ 3 converts second to nanosecond davinci_model->SetId(model_id); davinci_model->SetDeviceId(GetContext().DeviceId()); @@ -355,10 +356,6 @@ Status ModelManager::LoadModelOnline(uint32_t &model_id, const shared_ptrSetProfileTime(MODEL_LOAD_START, (timespec.tv_sec * kTimeSpecNano + - timespec.tv_nsec)); // 1000 ^ 3 converts second to nanosecond - davinci_model->SetProfileTime(MODEL_LOAD_END); } while (0); GE_CHK_RT(rtDeviceReset(static_cast(GetContext().DeviceId()))); @@ -1085,6 +1082,8 @@ Status ModelManager::LoadModelOffline(uint32_t &model_id, const ModelData &model GELOGE(ACL_ERROR_GE_MEMORY_ALLOCATION, "Make shared failed since other exception raise"); return ACL_ERROR_GE_MEMORY_ALLOCATION; } + 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); if (ret != SUCCESS) { GELOGW("assign model failed."); @@ -1121,11 +1120,7 @@ Status ModelManager::LoadModelOffline(uint32_t &model_id, const ModelData &model InsertModel(model_id, davinci_model); GELOGI("Parse model %u success.", model_id); - - davinci_model->SetProfileTime(MODEL_LOAD_START, (timespec.tv_sec * kTimeSpecNano + - timespec.tv_nsec)); // 1000 ^ 3 converts second to nanosecond - davinci_model->SetProfileTime(MODEL_LOAD_END); - + GE_IF_BOOL_EXEC(ret == SUCCESS, device_count++); return SUCCESS; } while (0); diff --git a/tests/ut/ge/graph/load/davinci_model_unittest.cc b/tests/ut/ge/graph/load/davinci_model_unittest.cc index 2b9bb4ed..a66aed7e 100644 --- a/tests/ut/ge/graph/load/davinci_model_unittest.cc +++ b/tests/ut/ge/graph/load/davinci_model_unittest.cc @@ -34,6 +34,10 @@ class UtestDavinciModel : public testing::Test { void TearDown() {} }; +int32_t MsprofReport(uint32_t moduleId, uint32_t type, void *data, uint32_t len) { + return 0; +} + /* TEST_F(UtestDavinciModel, init_success) { DavinciModel model(0, nullptr); @@ -853,4 +857,18 @@ TEST_F(UtestDavinciModel, LoadWithQueue_fail_with_diff_args) { EXPECT_EQ(model.LoadWithQueue(), INTERNAL_ERROR); EXPECT_EQ(model.active_stream_list_.size(), 0); } + +TEST_F(UtestDavinciModel, Sink_model_profile) { + ProfilingManager::Instance().prof_cb_.msprofReporterCallback = MsprofReport; + ProfileInfo profile; + profile.fusion_info.op_name = "relu"; + + DavinciModel model(0, nullptr); + model.profile_list_.emplace_back(profile); + std::map> op_info; + op_info["relu"] = std::pair(1, 1); + model.profiler_report_op_info_ = op_info; + model.SinkModelProfile(); +} + } // namespace ge