| @@ -268,7 +268,6 @@ ge::Status ProfSetStepInfo(uint64_t index_id, uint16_t tag_id, rtStream_t stream | |||||
| return ge::FAILED; | return ge::FAILED; | ||||
| } | } | ||||
| auto &profiling_manager = ge::ProfilingManager::Instance(); | auto &profiling_manager = ge::ProfilingManager::Instance(); | ||||
| profiling_manager.SetStepInfoIndex(index_id); | |||||
| if (is_first_run && tag_id == kStepStart) { | if (is_first_run && tag_id == kStepStart) { | ||||
| GE_CHK_STATUS_RET_NOLOG(profiling_manager.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; | is_first_run = false; | ||||
| @@ -71,7 +71,7 @@ ProfilingManager::ProfilingManager() | |||||
| is_training_trace_(false), | is_training_trace_(false), | ||||
| subscribe_count_(0), | subscribe_count_(0), | ||||
| prof_cb_({nullptr, nullptr}), | prof_cb_({nullptr, nullptr}), | ||||
| index_id_(UINT64_MAX), | |||||
| cur_iter_num_(UINT64_MAX), | |||||
| subscribe_info_({false, 0, 0}) { | subscribe_info_({false, 0, 0}) { | ||||
| } | } | ||||
| @@ -326,6 +326,7 @@ void ProfilingManager::ProfilingTaskDescInfo(uint32_t model_id, const std::vecto | |||||
| Status ProfilingManager::ProfileStepInfo(uint64_t index_id, uint64_t model_id, uint16_t tag_id, rtStream_t stream, | Status ProfilingManager::ProfileStepInfo(uint64_t index_id, uint64_t model_id, uint16_t tag_id, rtStream_t stream, | ||||
| int32_t device_id) { | int32_t device_id) { | ||||
| #ifdef DAVINCI_SUPPORT_PROFILING | #ifdef DAVINCI_SUPPORT_PROFILING | ||||
| cur_iter_num_ = index_id; | |||||
| if (!is_load_profiling_ && subscribe_count_ == 0) { | if (!is_load_profiling_ && subscribe_count_ == 0) { | ||||
| GELOGD("Profiling is not turned on, no need to profile step info."); | GELOGD("Profiling is not turned on, no need to profile step info."); | ||||
| return SUCCESS; | return SUCCESS; | ||||
| @@ -603,7 +604,7 @@ Status ProfilingManager::ProfFinalize() { | |||||
| is_load_profiling_ = false; | is_load_profiling_ = false; | ||||
| is_training_trace_ = false; | is_training_trace_ = false; | ||||
| is_execute_profiling_ = false; | is_execute_profiling_ = false; | ||||
| index_id_ = UINT64_MAX; | |||||
| cur_iter_num_ = UINT64_MAX; | |||||
| // profiling plugin uninit | // profiling plugin uninit | ||||
| PluginUnInit(); | PluginUnInit(); | ||||
| @@ -107,8 +107,7 @@ class ProfilingManager { | |||||
| void GetOpInputOutputInfo(const OpDescPtr &op, TaskDescInfo &task_desc_info) const; | 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); | 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); | Status ProfileStepInfo(uint64_t index_id, uint64_t model_id, uint16_t tag_id, rtStream_t stream, int32_t device_id); | ||||
| void SetStepInfoIndex(uint64_t index_id) { index_id_ = index_id; } | |||||
| uint64_t GetStepInfoIndex() const { return index_id_; } | |||||
| uint64_t GetCurIterNum() const { return cur_iter_num_; } | |||||
| void SetGraphIdToDeviceMap(uint32_t graph_id, uint32_t device_id) { device_id_map_[graph_id] = device_id; } | void SetGraphIdToDeviceMap(uint32_t graph_id, uint32_t device_id) { device_id_map_[graph_id] = device_id; } | ||||
| Status GetDeviceIdFromGraph(uint32_t graph_id, uint32_t &device_id); | Status GetDeviceIdFromGraph(uint32_t graph_id, uint32_t &device_id); | ||||
| void SetSubscribeInfo(uint64_t prof_switch, uint32_t model_id, bool is_subscribe); | void SetSubscribeInfo(uint64_t prof_switch, uint32_t model_id, bool is_subscribe); | ||||
| @@ -143,7 +142,7 @@ class ProfilingManager { | |||||
| std::string fp_point_; | std::string fp_point_; | ||||
| std::string bp_point_; | std::string bp_point_; | ||||
| uint32_t reporter_max_len_ = 0; | uint32_t reporter_max_len_ = 0; | ||||
| uint64_t index_id_; | |||||
| uint64_t cur_iter_num_; | |||||
| std::map<uint32_t, uint32_t> device_id_map_; // key: graph_id, value: device_id | std::map<uint32_t, uint32_t> device_id_map_; // key: graph_id, value: device_id | ||||
| std::map<uint32_t, uint32_t> model_id_map_; // key: graph_id, value: model_id | std::map<uint32_t, uint32_t> model_id_map_; // key: graph_id, value: model_id | ||||
| ProfSubscribeInfo subscribe_info_; | ProfSubscribeInfo subscribe_info_; | ||||
| @@ -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.op_name.c_str(), tmp_task_desc_info.model_name.c_str()); | ||||
| tmp_task_desc_info.shape_type = shape_type; | tmp_task_desc_info.shape_type = shape_type; | ||||
| tmp_task_desc_info.cur_iter_num = ProfilingManager::Instance().GetStepInfoIndex(); | |||||
| tmp_task_desc_info.cur_iter_num = ProfilingManager::Instance().GetCurIterNum(); | |||||
| tmp_task_desc_info.task_type = op_task->GetTaskType(); | tmp_task_desc_info.task_type = op_task->GetTaskType(); | ||||
| std::vector<TaskDescInfo> task_desc_info; | std::vector<TaskDescInfo> task_desc_info; | ||||
| @@ -156,23 +156,6 @@ TEST_F(UtestGeProfilinganager, set_step_info_failed) { | |||||
| EXPECT_EQ(ret, ge::FAILED); | EXPECT_EQ(ret, ge::FAILED); | ||||
| } | } | ||||
| TEST_F(UtestGeProfilinganager, get_device_from_graph) { | |||||
| GraphId graph_id = 1; | |||||
| uint32_t device_id = 0; | |||||
| GraphManager graph_manager; | |||||
| GraphNodePtr graph_node = MakeShared<ge::GraphNode>(graph_id); | |||||
| graph_manager.AddGraphNode(graph_id, graph_node); | |||||
| graph_manager.SetAddGraphCondition(graph_id, 2); | |||||
| Graph graph("test_graph"); | |||||
| CreateGraph(graph); | |||||
| std::map<std::string, std::string> options; | |||||
| OmgContext context; | |||||
| Status ret = graph_manager.AddGraph(graph_id, graph, options, context); | |||||
| EXPECT_EQ(ret, ge::SUCCESS); | |||||
| ret = ProfGetDeviceFormGraphId(graph_id, device_id); | |||||
| EXPECT_EQ(ret, ge::SUCCESS); | |||||
| } | |||||
| TEST_F(UtestGeProfilinganager, handle_subscribe_info) { | TEST_F(UtestGeProfilinganager, handle_subscribe_info) { | ||||
| ProfCommandHandleType prof_type = kProfCommandhandleModelSubscribe; | ProfCommandHandleType prof_type = kProfCommandhandleModelSubscribe; | ||||
| ProfCommandHandleData prof_data; | ProfCommandHandleData prof_data; | ||||
| @@ -16,6 +16,8 @@ | |||||
| #include <gtest/gtest.h> | #include <gtest/gtest.h> | ||||
| #include "framework/common/profiling/ge_profiling.h" | |||||
| #define private public | #define private public | ||||
| #define protected public | #define protected public | ||||
| #include "session/inner_session.h" | #include "session/inner_session.h" | ||||
| @@ -58,4 +60,16 @@ TEST_F(UtestInnerSession, check_op_precision_mode) { | |||||
| auto ret = inner_session.Initialize(); | auto ret = inner_session.Initialize(); | ||||
| EXPECT_NE(ret, ge::SUCCESS); | EXPECT_NE(ret, ge::SUCCESS); | ||||
| } | } | ||||
| TEST_F(Utest_Inner_session, get_device_from_graph) { | |||||
| std::map<std::string, std::string> options = {}; | |||||
| uint64_t session_id = 1; | |||||
| InnerSession inner_session(session_id, options); | |||||
| GraphId graph_id = 1; | |||||
| uint32_t device_id = 0; | |||||
| Graph graph("test_graph"); | |||||
| Status ret = inner_session.AddGraph(graph_id, graph); | |||||
| ret = ProfGetDeviceFormGraphId(graph_id, device_id); | |||||
| EXPECT_EQ(ret, ge::SUCCESS); | |||||
| } | |||||
| } // namespace ge | } // namespace ge | ||||