| @@ -17,6 +17,7 @@ | |||||
| #include "single_op/single_op.h" | #include "single_op/single_op.h" | ||||
| #include "common/fmk_types.h" | #include "common/fmk_types.h" | ||||
| #include "common/ge_types.h" | |||||
| #include "common/math/math_util.h" | #include "common/math/math_util.h" | ||||
| #include "common/profiling/profiling_manager.h" | #include "common/profiling/profiling_manager.h" | ||||
| #include "framework/common/debug/ge_log.h" | #include "framework/common/debug/ge_log.h" | ||||
| @@ -164,16 +165,52 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY Status SingleOp::ExecuteAsync(c | |||||
| return ret; | return ret; | ||||
| } | } | ||||
| int index = 0; | |||||
| for (auto &task : tasks_) { | for (auto &task : tasks_) { | ||||
| ret = task->LaunchKernel(stream_); | ret = task->LaunchKernel(stream_); | ||||
| if (ret != SUCCESS) { | if (ret != SUCCESS) { | ||||
| return ret; | return ret; | ||||
| } | } | ||||
| if (ProfilingManager::Instance().ProfilingModelExecuteOn()) { | |||||
| GE_CHK_STATUS_RET_NOLOG(ProfilingTaskInfo(index)); | |||||
| } | |||||
| index++; | |||||
| } | } | ||||
| return ret; | return ret; | ||||
| } | } | ||||
| Status SingleOp::ProfilingTaskInfo(int index) { | |||||
| if (op_name_.size() <= index) { | |||||
| GELOGE(ACL_ERROR_GE_PARAM_INVALID, "index[%d] is out of range of op_name_ size[%d].", index, op_name_.size()); | |||||
| return ACL_ERROR_GE_PARAM_INVALID; | |||||
| } | |||||
| GELOGD("ProfilingReport of op[%s] model[%s] start.", op_name_[index].c_str(), model_name_.c_str()); | |||||
| std::vector<TaskDescInfo> task_desc_info; | |||||
| uint32_t task_id = 0; | |||||
| uint32_t stream_id = 0; | |||||
| if (rtGetTaskIdAndStreamID(&task_id, &stream_id) != RT_ERROR_NONE) { | |||||
| GELOGE(ACL_ERROR_GE_PARAM_INVALID, "Get task_id and stream_id failed."); | |||||
| return ACL_ERROR_GE_PARAM_INVALID; | |||||
| } | |||||
| TaskDescInfo tmp_task_desc_info; | |||||
| tmp_task_desc_info.model_name = model_name_; | |||||
| tmp_task_desc_info.op_name = op_name_[index]; | |||||
| tmp_task_desc_info.block_dim = 0; | |||||
| tmp_task_desc_info.task_id = task_id; | |||||
| tmp_task_desc_info.stream_id = stream_id; | |||||
| GELOGD("GetTaskDescInfo of op [%s] end, task_id[%u], stream_id[%u]", op_name_[index].c_str(), task_id, stream_id); | |||||
| task_desc_info.emplace_back(tmp_task_desc_info); | |||||
| std::vector<ComputeGraphDescInfo> compute_graph_info; | |||||
| auto &profiling_manager = ProfilingManager::Instance(); | |||||
| profiling_manager.ReportProfilingData(model_id_, task_desc_info, compute_graph_info, | |||||
| !profiling_manager.IsAclApiMode()); | |||||
| return SUCCESS; | |||||
| } | |||||
| void SingleOp::SetStream(rtStream_t stream) { | void SingleOp::SetStream(rtStream_t stream) { | ||||
| stream_ = stream; | stream_ = stream; | ||||
| } | } | ||||
| @@ -42,6 +42,7 @@ class SingleOp { | |||||
| Status ValidateArgs(const std::vector<DataBuffer> &inputs, const std::vector<DataBuffer> &outputs); | Status ValidateArgs(const std::vector<DataBuffer> &inputs, const std::vector<DataBuffer> &outputs); | ||||
| Status UpdateArgs(const std::vector<DataBuffer> &inputs, const std::vector<DataBuffer> &outputs); | Status UpdateArgs(const std::vector<DataBuffer> &inputs, const std::vector<DataBuffer> &outputs); | ||||
| Status GetArgs(const std::vector<DataBuffer> &inputs, const std::vector<DataBuffer> &outputs); | Status GetArgs(const std::vector<DataBuffer> &inputs, const std::vector<DataBuffer> &outputs); | ||||
| Status ProfilingTaskInfo(int index); | |||||
| friend class SingleOpModel; | friend class SingleOpModel; | ||||
| std::mutex *stream_mutex_; | std::mutex *stream_mutex_; | ||||
| @@ -53,7 +54,10 @@ class SingleOp { | |||||
| std::vector<uintptr_t> args_; | std::vector<uintptr_t> args_; | ||||
| std::vector<OpTask *> tasks_; | std::vector<OpTask *> tasks_; | ||||
| std::vector<std::string> op_name_; | |||||
| std::vector<std::vector<uintptr_t *>> arg_table_; | std::vector<std::vector<uintptr_t *>> arg_table_; | ||||
| std::string model_name_; | |||||
| uint32_t model_id_ = 0; | |||||
| }; | }; | ||||
| class DynamicSingleOp { | class DynamicSingleOp { | ||||
| @@ -86,6 +90,7 @@ class DynamicSingleOp { | |||||
| rtStream_t stream_ = nullptr; | rtStream_t stream_ = nullptr; | ||||
| size_t num_inputs_ = 0; | size_t num_inputs_ = 0; | ||||
| size_t num_outputs_ = 0; | size_t num_outputs_ = 0; | ||||
| std::string model_name_; | |||||
| }; | }; | ||||
| } // namespace ge | } // namespace ge | ||||
| #endif // GE_SINGLE_OP_SINGLE_OP_H_ | #endif // GE_SINGLE_OP_SINGLE_OP_H_ | ||||
| @@ -157,6 +157,7 @@ Status SingleOpModel::LoadAllNodes() { | |||||
| auto ge_model = model_helper_.GetGeModel(); | auto ge_model = model_helper_.GetGeModel(); | ||||
| GE_CHECK_NOTNULL(ge_model); | GE_CHECK_NOTNULL(ge_model); | ||||
| Graph graph = ge_model->GetGraph(); | Graph graph = ge_model->GetGraph(); | ||||
| model_id_ = ge_model->GetModelId(); | |||||
| auto compute_graph = GraphUtils::GetComputeGraph(graph); | auto compute_graph = GraphUtils::GetComputeGraph(graph); | ||||
| if (compute_graph == nullptr) { | if (compute_graph == nullptr) { | ||||
| GELOGE(ACL_ERROR_GE_INTERNAL_ERROR, "[%s] compute_graph is null", model_name_.c_str()); | GELOGE(ACL_ERROR_GE_INTERNAL_ERROR, "[%s] compute_graph is null", model_name_.c_str()); | ||||
| @@ -222,6 +223,8 @@ Status SingleOpModel::SetInputsAndOutputs(SingleOp &single_op) { | |||||
| } | } | ||||
| single_op.args_.resize(arg_index); | single_op.args_.resize(arg_index); | ||||
| single_op.model_name_ = model_name_; | |||||
| single_op.model_id_ = model_id_; | |||||
| return SUCCESS; | return SUCCESS; | ||||
| } | } | ||||
| @@ -245,10 +248,11 @@ Status SingleOpModel::BuildTaskList(SingleOp &single_op) { | |||||
| if (ret != SUCCESS) { | if (ret != SUCCESS) { | ||||
| return ret; | return ret; | ||||
| } | } | ||||
| string tbe_op_name = op_list_[context.op_index()]->GetName(); | |||||
| single_op.arg_table_.resize(single_op.input_sizes_.size() + single_op.output_sizes_.size()); | single_op.arg_table_.resize(single_op.input_sizes_.size() + single_op.output_sizes_.size()); | ||||
| ParseArgTable(tbe_task, single_op); | ParseArgTable(tbe_task, single_op); | ||||
| single_op.tasks_.emplace_back(tbe_task); | single_op.tasks_.emplace_back(tbe_task); | ||||
| single_op.op_name_.emplace_back(tbe_op_name); | |||||
| } else if (kernel_type == cce::ccKernelType::AI_CPU || kernel_type == cce::ccKernelType::CUST_AI_CPU) { | } else if (kernel_type == cce::ccKernelType::AI_CPU || kernel_type == cce::ccKernelType::CUST_AI_CPU) { | ||||
| GELOGD("Building AICPU_CC task"); | GELOGD("Building AICPU_CC task"); | ||||
| OpTask *task = nullptr; | OpTask *task = nullptr; | ||||
| @@ -258,7 +262,9 @@ Status SingleOpModel::BuildTaskList(SingleOp &single_op) { | |||||
| if (ret != SUCCESS) { | if (ret != SUCCESS) { | ||||
| return ret; | return ret; | ||||
| } | } | ||||
| string aicpu_op_name = op_list_[context.op_index()]->GetName(); | |||||
| single_op.tasks_.emplace_back(task); | single_op.tasks_.emplace_back(task); | ||||
| single_op.op_name_.emplace_back(aicpu_op_name); | |||||
| } else { | } else { | ||||
| GELOGE(ACL_ERROR_GE_OP_KERNEL_TYPE_INVALID, "Only TBE, AI_CPU, CUST_AI_CPU kernel are supported, but got %u", context.kernel_type()); | GELOGE(ACL_ERROR_GE_OP_KERNEL_TYPE_INVALID, "Only TBE, AI_CPU, CUST_AI_CPU kernel are supported, but got %u", context.kernel_type()); | ||||
| return ACL_ERROR_GE_OP_KERNEL_TYPE_INVALID; | return ACL_ERROR_GE_OP_KERNEL_TYPE_INVALID; | ||||
| @@ -273,7 +279,9 @@ Status SingleOpModel::BuildTaskList(SingleOp &single_op) { | |||||
| if (ret != SUCCESS) { | if (ret != SUCCESS) { | ||||
| return ret; | return ret; | ||||
| } | } | ||||
| string op_name = op_list_[context.op_index()]->GetName(); | |||||
| single_op.tasks_.emplace_back(aicpu_task); | single_op.tasks_.emplace_back(aicpu_task); | ||||
| single_op.op_name_.emplace_back(op_name); | |||||
| } else { | } else { | ||||
| // skip | // skip | ||||
| GELOGD("Skip task type: %d", static_cast<int>(task_type)); | GELOGD("Skip task type: %d", static_cast<int>(task_type)); | ||||
| @@ -77,6 +77,7 @@ class SingleOpModel { | |||||
| void ParseArgTable(TbeOpTask *task, SingleOp &op); | void ParseArgTable(TbeOpTask *task, SingleOp &op); | ||||
| std::string model_name_; | std::string model_name_; | ||||
| uint32_t model_id_ = 0; | |||||
| const void *ori_model_data_; | const void *ori_model_data_; | ||||
| uint32_t ori_model_size_; | uint32_t ori_model_size_; | ||||