From d383e91c52ed9a681777d965cde4ba27e6f40b64 Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 25 Jan 2021 22:00:59 +0800 Subject: [PATCH] For aicpu all_shape compile. --- ge/generator/ge_generator.cc | 5 +++-- .../task_info/kernel_ex_task_info.cc | 4 ++-- .../task_info/kernel_task_info.cc | 18 ++++++++++-------- .../node_executor/aicpu/aicpu_node_executor.cc | 3 +-- ge/single_op/task/op_task.cc | 4 ++-- 5 files changed, 18 insertions(+), 16 deletions(-) diff --git a/ge/generator/ge_generator.cc b/ge/generator/ge_generator.cc index b050ab93..52dfa65d 100644 --- a/ge/generator/ge_generator.cc +++ b/ge/generator/ge_generator.cc @@ -47,6 +47,7 @@ const char *const kEngineNameDefault = "default"; const char *const kVectorEngine = "VectorEngine"; const char *const kAIcoreEngine = "AIcoreEngine"; const char *const kFileNameSuffix = "online"; +const char *const kAicpuAllshape = "_AllShape"; const size_t kDynamicDimSize = 1; const int64_t kDynamicDimValue = -2; @@ -722,10 +723,10 @@ Status GeGenerator::BuildSingleOp(OpDescPtr &op_desc, const vector &in GELOGD("The opType in op_desc_tmp is [%s]", op_desc_tmp->GetType().c_str()); bool all_shape = false; - (void)AttrUtils::GetBool(op_desc, "_AllShape", all_shape); bool dynamic_flag = false; + (void)AttrUtils::GetBool(op_desc, kAicpuAllshape, all_shape); CheckShapeReset(op_desc, dynamic_flag); - if (all_shape && dynamic_flag) { + if (dynamic_flag && all_shape) { GELOGD("Get aicpu all_shape kernel!"); vector inputs_dynamic; vector outputs_dynamic; diff --git a/ge/graph/load/model_manager/task_info/kernel_ex_task_info.cc b/ge/graph/load/model_manager/task_info/kernel_ex_task_info.cc index be91dd15..b9644946 100644 --- a/ge/graph/load/model_manager/task_info/kernel_ex_task_info.cc +++ b/ge/graph/load/model_manager/task_info/kernel_ex_task_info.cc @@ -45,7 +45,7 @@ Status KernelExTaskInfo::InitTaskExtInfo(const std::string &ext_info, const OpDe num_outputs, unknown_type)); GE_CHK_BOOL_RET_STATUS(ext_handle != nullptr, FAILED, "Malloc aicpu_ext_handle mem failed!"); - GE_CHK_STATUS_RET(ext_handle->Parse(ext_info) + GE_CHK_STATUS_RET(ext_handle->Parse(ext_info), "Parse kernel ext info failed, kernel_ext_info_size=%zu.", ext_info.size()); GE_CHK_STATUS_RET(ext_handle->UpdateExecuteMode(true), "UpdateExecuteMode failed."); GELOGD("Update aicpu_task ext_info bit_map execute mode to 1."); @@ -54,7 +54,7 @@ Status KernelExTaskInfo::InitTaskExtInfo(const std::string &ext_info, const OpDe GE_IF_BOOL_EXEC(rt_ret != RT_ERROR_NONE, GELOGE(RT_FAILED, "rtMalloc ext_info error: 0x%X, size=%zu", rt_ret, ext_info.size()); return RT_ERROR_TO_GE_STATUS(rt_ret);) - rt_ret = rtMemcpy(ext_info_addr_, ext_handle_->GetExtInfoLen(), ext_handle_->GetExtInfo(), + rt_ret = rtMemcpy(ext_info_addr_, ext_handle->GetExtInfoLen(), ext_handle->GetExtInfo(), ext_handle->GetExtInfoLen(), RT_MEMCPY_HOST_TO_DEVICE); GE_IF_BOOL_EXEC(rt_ret != RT_ERROR_NONE, GELOGE(RT_FAILED, "rtMemcpy ext_info error: 0x%X, size=%zu", rt_ret, ext_info.size()); diff --git a/ge/graph/load/model_manager/task_info/kernel_task_info.cc b/ge/graph/load/model_manager/task_info/kernel_task_info.cc index 9582b9ab..2a3ddaf8 100755 --- a/ge/graph/load/model_manager/task_info/kernel_task_info.cc +++ b/ge/graph/load/model_manager/task_info/kernel_task_info.cc @@ -32,6 +32,8 @@ #include "super_kernel/super_kernel.h" #include "super_kernel/super_kernel_factory.h" #include "cce/aicpu_engine_struct.h" +#include "hybrid/node_executor/aicpu/aicpu_ext_info.h" +#include "framework/common/debug/log.h" namespace { const uint8_t kL2LoadToDdr = 1; @@ -965,20 +967,20 @@ Status KernelTaskInfo::InitAicpuTaskExtInfo(const std::string &ext_info) { } int32_t unknown_shape_type_val = 0; - (void) AttrUtils::GetInt(op_desc, ::ge::ATTR_NAME_UNKNOWN_SHAPE_TYPE, unknown_shape_type_val); + (void) AttrUtils::GetInt(op_desc_, ::ge::ATTR_NAME_UNKNOWN_SHAPE_TYPE, unknown_shape_type_val); UnknowShapeOpType unknown_type = static_cast(unknown_shape_type_val); - uint32_t num_inputs = op_desc->GetInputsSize(); - uint32_t num_outputs = op_desc->GetOutputsSize(); + uint32_t num_inputs = op_desc_->GetInputsSize(); + uint32_t num_outputs = op_desc_->GetOutputsSize(); std::unique_ptr ext_handle( - new(std::nothrow) ::ge::hybrid::AicpuExtInfoHandler(op_desc->GetName(), + new(std::nothrow) ::ge::hybrid::AicpuExtInfoHandler(op_desc_->GetName(), num_inputs, num_outputs, unknown_type)); GE_CHK_BOOL_RET_STATUS(ext_handle != nullptr, FAILED, "Malloc aicpu_ext_handle mem failed!"); - GE_CHK_STATUS_RET(ext_handle->Parse(ext_info) + GE_CHK_STATUS_RET(ext_handle->Parse(ext_info), "Parse kernel ext info failed, kernel_ext_info_size=%zu.", ext_info.size()); - GE_CHK_STATUS_RET(aicpu_ext_handle_->UpdateSessionInfo(davinci_model_->GetSessionId()), - "Update session info session id sfailed."); + GE_CHK_STATUS_RET(ext_handle_->UpdateSessionInfo(davinci_model_->GetSessionId()), + "Update session info session id failed."); GELOGD("Update aicpu_task ext_info session_info session_id is %lu", davinci_model_->GetSessionId()); GE_CHK_STATUS_RET(ext_handle->UpdateExecuteMode(true), "UpdateExecuteMode failed."); GELOGD("Update aicpu_task ext_info bit_map execute mode to 1."); @@ -988,7 +990,7 @@ Status KernelTaskInfo::InitAicpuTaskExtInfo(const std::string &ext_info) { GELOGE(RT_FAILED, "rtMalloc ext_info error: 0x%X, size=%zu", rt_ret, ext_info.size()); return RT_ERROR_TO_GE_STATUS(rt_ret); } - rt_ret = rtMemcpy(aicpu_ext_info_addr_, ext_handle->GetExtInfoLen(), ext_handle_->GetExtInfo(), + rt_ret = rtMemcpy(aicpu_ext_info_addr_, ext_handle->GetExtInfoLen(), ext_handle->GetExtInfo(), ext_handle->GetExtInfoLen(), RT_MEMCPY_HOST_TO_DEVICE); if (rt_ret != RT_ERROR_NONE) { GELOGE(RT_FAILED, "rtMemcpy ext_info error: 0x%X, size=%zu", rt_ret, ext_info.size()); diff --git a/ge/hybrid/node_executor/aicpu/aicpu_node_executor.cc b/ge/hybrid/node_executor/aicpu/aicpu_node_executor.cc index e9e99629..ca9e908b 100755 --- a/ge/hybrid/node_executor/aicpu/aicpu_node_executor.cc +++ b/ge/hybrid/node_executor/aicpu/aicpu_node_executor.cc @@ -60,7 +60,6 @@ Status AicpuNodeTaskBase::InitExtInfo(const std::string &kernel_ext_info, int64_ GELOGD("To update aicpu_task ext_info session_info session_id to %lu", session_id); GE_CHK_STATUS_RET(aicpu_ext_handle_.UpdateSessionInfoSessionId(session_id), "UpdateSessionInfoSessionId failed."); - GE_CHK_STATUS_RET(aicpu_ext_handle_.UpdateExecuteMode(true), "UpdateExecuteMode failed."); // copy task args buf GE_CHK_STATUS_RET(AllocTensorBuffer(aicpu_ext_handle_.GetExtInfoLen(), ext_info_addr_dev_), @@ -137,7 +136,7 @@ Status AicpuNodeTaskBase::UpdateExtInfo() { return SUCCESS; } - GE_CHK_STATUS_RET(ext_handle->UpdateExecuteMode(false), "UpdateExecuteMode failed."); + GE_CHK_STATUS_RET(aicpu_ext_handle_.UpdateExecuteMode(false), "UpdateExecuteMode failed."); for (auto i = 0; i < node_item_->num_inputs; ++i) { auto input_desc = node_item_->MutableInputDesc(i); GE_CHECK_NOTNULL(input_desc); diff --git a/ge/single_op/task/op_task.cc b/ge/single_op/task/op_task.cc index 8bef8c50..28ddcbe2 100755 --- a/ge/single_op/task/op_task.cc +++ b/ge/single_op/task/op_task.cc @@ -373,7 +373,7 @@ Status AiCpuBaseTask::SetExtInfoAndType(const std::string &kernel_ext_info, uint GE_CHK_STATUS_RET(aicpu_ext_handle_->UpdateSessionInfo(ULLONG_MAX, kernel_id, false), "UpdateSessionInfo failed."); - GE_CHK_STATUS_RET(ext_handle->UpdateExecuteMode(true, "UpdateExecuteMode failed."); + GE_CHK_STATUS_RET(aicpu_ext_handle_->UpdateExecuteMode(true, "UpdateExecuteMode failed."); GE_CHK_RT_RET(rtMalloc(&ext_info_addr_dev_, aicpu_ext_handle_->GetExtInfoLen(), RT_MEMORY_HBM)); GE_CHK_RT_RET(rtMemcpy(ext_info_addr_dev_, aicpu_ext_handle_->GetExtInfoLen(), @@ -406,7 +406,7 @@ Status AiCpuBaseTask::UpdateExtInfo(const std::vector &input_desc, rtStream_t stream) { GELOGI("Update ext info begin, unknown_type=%d.", unknown_type_); GE_CHECK_NOTNULL(aicpu_ext_handle_); - GE_CHK_STATUS_RET(ext_handle->UpdateExecuteMode(false), "UpdateExecuteMode failed."); + GE_CHK_STATUS_RET(aicpu_ext_handle_->UpdateExecuteMode(false), "UpdateExecuteMode failed."); if (num_inputs_ == 0 && num_outputs_ == 0) { GELOGI("No input and output, no need update ext info.");