@@ -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()); | |||
@@ -328,7 +328,8 @@ Status ModelManager::LoadModelOnline(uint32_t &model_id, const shared_ptr<ge::Ge | |||
GELOGE(FAILED, "davinci_model is nullptr"); | |||
return FAILED; | |||
} | |||
davinci_model->SetProfileTime(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_ptr<ge::Ge | |||
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); | |||
} while (0); | |||
GE_CHK_RT(rtDeviceReset(static_cast<int32_t>(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); | |||
@@ -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<std::string, std::pair<uint32_t, uint32_t>> op_info; | |||
op_info["relu"] = std::pair<uint32_t, uint32_t>(1, 1); | |||
model.profiler_report_op_info_ = op_info; | |||
model.SinkModelProfile(); | |||
} | |||
} // namespace ge |