From 10794beb5533580c84f06fb8450452614fa9941f Mon Sep 17 00:00:00 2001 From: zhupuxu Date: Wed, 14 Jul 2021 11:32:26 +0800 Subject: [PATCH] fix bug for step info r1.5 Signed-off-by: zhupuxu --- ge/common/profiling/ge_profiling.cc | 13 +++---------- ge/common/profiling/profiling_manager.cc | 11 ++++++++--- ge/common/profiling/profiling_manager.h | 2 ++ ge/single_op/single_op.cc | 2 +- 4 files changed, 14 insertions(+), 14 deletions(-) diff --git a/ge/common/profiling/ge_profiling.cc b/ge/common/profiling/ge_profiling.cc index 48d12609..0773f396 100644 --- a/ge/common/profiling/ge_profiling.cc +++ b/ge/common/profiling/ge_profiling.cc @@ -230,21 +230,14 @@ ge::Status ProfSetStepInfo(uint64_t index_id, uint16_t tag_id, rtStream_t stream REPORT_CALL_ERROR("E19999", "Get logic device id failed, ret 0x%X", rt_ret); return ge::FAILED; } + auto &profiling_manager = ge::ProfilingManager::Instance(); if (is_first_run && tag_id == kStepStart) { - GE_CHK_STATUS_RET_NOLOG(ge::ProfilingManager::Instance().ProfileStepInfo(index_id, - kModelId, - tag_id, - stream, - device_id)); + GE_CHK_STATUS_RET_NOLOG(profiling_manager.ProfileStepInfo(index_id, kModelId, tag_id, stream, device_id)); is_first_run = false; return ge::SUCCESS; } if (!is_first_run && tag_id == kStepEnd) { - GE_CHK_STATUS_RET_NOLOG(ge::ProfilingManager::Instance().ProfileStepInfo(index_id, - kModelId, - tag_id, - stream, - device_id)); + GE_CHK_STATUS_RET_NOLOG(profiling_manager.ProfileStepInfo(index_id, kModelId, tag_id, stream, device_id)); is_first_run = true; return ge::SUCCESS; } diff --git a/ge/common/profiling/profiling_manager.cc b/ge/common/profiling/profiling_manager.cc index 61210de6..fa8a0e4c 100644 --- a/ge/common/profiling/profiling_manager.cc +++ b/ge/common/profiling/profiling_manager.cc @@ -66,9 +66,12 @@ const std::string kIdx = "idx"; namespace ge { ProfilingManager::ProfilingManager() - : is_load_profiling_(false), is_execute_profiling_(false), is_training_trace_(false), subscribe_count_(0) { - prof_cb_.msprofCtrlCallback = nullptr; - prof_cb_.msprofReporterCallback = nullptr; + : is_load_profiling_(false), + is_execute_profiling_(false), + is_training_trace_(false), + subscribe_count_(0), + prof_cb_({nullptr, nullptr}), + cur_iter_num_(UINT64_MAX) { } ProfilingManager::~ProfilingManager() {} @@ -323,6 +326,7 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY void ProfilingManager::Profilin FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY Status ProfilingManager::ProfileStepInfo( uint64_t index_id, uint64_t model_id, uint16_t tag_id, rtStream_t stream, int32_t device_id) { #ifdef DAVINCI_SUPPORT_PROFILING + cur_iter_num_ = index_id; if (!is_load_profiling_ && subscribe_count_ == 0) { GELOGD("Profiling is not turned on, no need to profile step info."); return SUCCESS; @@ -604,6 +608,7 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY Status ProfilingManager::ProfFi is_load_profiling_ = false; is_training_trace_ = false; is_execute_profiling_ = false; + cur_iter_num_ = UINT64_MAX; // profiling plugin uninit PluginUnInit(); diff --git a/ge/common/profiling/profiling_manager.h b/ge/common/profiling/profiling_manager.h index 049a4df4..6f3a8d4b 100755 --- a/ge/common/profiling/profiling_manager.h +++ b/ge/common/profiling/profiling_manager.h @@ -101,6 +101,7 @@ class FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY ProfilingManager { void GetOpInputOutputInfo(const OpDescPtr &op, TaskDescInfo &task_desc_info) const; void ReportData(const int32_t &device_id, const std::string &data, const std::string &tag_name); Status ProfileStepInfo(uint64_t index_id, uint64_t model_id, uint16_t tag_id, rtStream_t stream, int32_t device_id); + uint64_t GetCurIterNum() const { return cur_iter_num_; } private: Status InitFromOptions(const Options &options, MsprofGeOptions &prof_conf); Status ParseOptions(const std::string &options); @@ -127,6 +128,7 @@ class FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY ProfilingManager { std::string fp_point_; std::string bp_point_; uint32_t reporter_max_len_ = 0; + uint64_t cur_iter_num_; }; } // namespace ge #endif // GE_COMMON_PROFILING_PROFILING_MANAGER_H_ diff --git a/ge/single_op/single_op.cc b/ge/single_op/single_op.cc index d09e8398..f6c6731e 100755 --- a/ge/single_op/single_op.cc +++ b/ge/single_op/single_op.cc @@ -58,7 +58,7 @@ Status ProfilingTaskInfo(OpTask *op_task, const string &shape_type) { tmp_task_desc_info.op_name.c_str(), tmp_task_desc_info.model_name.c_str()); tmp_task_desc_info.shape_type = shape_type; - tmp_task_desc_info.cur_iter_num = 0; + tmp_task_desc_info.cur_iter_num = ProfilingManager::Instance().GetCurIterNum(); tmp_task_desc_info.task_type = op_task->GetTaskType(); std::vector task_desc_info;