From 975dddc0d58156149a9f528542437f2b1ae75e1b Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 25 Jan 2021 21:45:12 +0800 Subject: [PATCH 1/8] For aicpu all_shape compile. --- .../task_info/kernel_ex_task_info.cc | 46 +++++++++++++---- .../task_info/kernel_ex_task_info.h | 1 + .../task_info/kernel_task_info.cc | 51 ++++++++----------- .../node_executor/aicpu/aicpu_ext_info.cc | 26 ++++++++++ .../node_executor/aicpu/aicpu_ext_info.h | 4 ++ .../aicpu/aicpu_node_executor.cc | 2 + ge/single_op/task/op_task.cc | 6 ++- .../load/kernel_ex_task_info_unittest.cc | 8 +++ .../graph/load/kernel_task_info_unittest.cc | 6 +++ 9 files changed, 109 insertions(+), 41 deletions(-) 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 6da1bf63..be91dd15 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 @@ -26,8 +26,42 @@ #include "graph/attr_value.h" #include "graph/load/model_manager/davinci_model.h" #include "graph/load/model_manager/model_manager.h" +#include "hybrid/node_executor/aicpu/aicpu_ext_info.h" +#include "framework/common/debug/log.h" namespace ge { +Status KernelExTaskInfo::InitTaskExtInfo(const std::string &ext_info, const OpDescPtr &op_desc) { + if (ext_info.empty()) { + return SUCCESS; + } + int32_t unknown_shape_type_val = 0; + (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(); + std::unique_ptr ext_handle( + 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) + "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."); + + auto rt_ret = rtMalloc(&ext_info_addr_, ext_handle->GetExtInfoLen(), RT_MEMORY_HBM); + 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(), + 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()); + return RT_ERROR_TO_GE_STATUS(rt_ret);) + return SUCCESS; +} + Status KernelExTaskInfo::Init(const domi::TaskDef &task_def, DavinciModel *davinci_model) { GELOGI("KernelExTaskInfo Init Start."); GE_CHECK_NOTNULL(davinci_model); @@ -63,16 +97,8 @@ Status KernelExTaskInfo::Init(const domi::TaskDef &task_def, DavinciModel *davin } const auto &ext_info = kernel_ex_def.kernel_ext_info(); - if (!ext_info.empty()) { - auto rt_ret = rtMalloc(&ext_info_addr_, ext_info.size(), RT_MEMORY_HBM); - 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_info.size(), ext_info.c_str(), ext_info.size(), 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()); - return RT_ERROR_TO_GE_STATUS(rt_ret);) - } + GE_CHK_STATUS_RET(InitTaskExtInfo(ext_info, op_desc), + "Init aicpu tf_task ext info failed, ext_info size=%zu", ext_info.size()); GELOGI("Node[%s] type[%s] kernel_ext_info size=%zu, ext_info_addr_=%p", op_desc->GetName().c_str(), op_desc->GetType().c_str(), ext_info.size(), ext_info_addr_); diff --git a/ge/graph/load/model_manager/task_info/kernel_ex_task_info.h b/ge/graph/load/model_manager/task_info/kernel_ex_task_info.h index 265316ce..71153c31 100644 --- a/ge/graph/load/model_manager/task_info/kernel_ex_task_info.h +++ b/ge/graph/load/model_manager/task_info/kernel_ex_task_info.h @@ -62,6 +62,7 @@ class KernelExTaskInfo : public TaskInfo { void SetIoAddrs(const OpDescPtr &op_desc); void InitDumpTask(void *addr, const OpDescPtr &op_desc); + Status InitTaskExtInfo(const std::string &ext_info, const OpDescPtr &op_desc); uint32_t task_id_; uint32_t stream_id_; 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 27fe8eb0..9582b9ab 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 @@ -964,39 +964,32 @@ Status KernelTaskInfo::InitAicpuTaskExtInfo(const std::string &ext_info) { return SUCCESS; } - std::unique_ptr copy_ext_info; - copy_ext_info.reset(new(std::nothrow)uint8_t[ext_info.size()]); - GE_CHECK_NOTNULL(copy_ext_info); - auto sec_ret = memcpy_s(copy_ext_info.get(), ext_info.size(), ext_info.c_str(), ext_info.size()); - if (sec_ret != EOK) { - GELOGE(FAILED, "memcpy failed, ret: %d", sec_ret); - return FAILED; - } - - auto ext_info_data = copy_ext_info.get(); - size_t offset = 0; - while (offset + sizeof(aicpu::FWKAdapter::ExtInfo) <= ext_info.size()) { - auto aicpu_ext_info = reinterpret_cast(ext_info_data + offset); - GELOGD("Ext infoType=%d, infoLen=%u.", aicpu_ext_info->infoType, aicpu_ext_info->infoLen); - if (aicpu_ext_info->infoType == aicpu::FWKAdapter::FWK_ADPT_EXT_SESSION_INFO) { - GE_CHK_BOOL_RET_STATUS(aicpu_ext_info->infoLen == sizeof(SessionInfo), PARAM_INVALID, - "Parse ext session info failed as infoLen must be %zu but %u.", - sizeof(SessionInfo), aicpu_ext_info->infoLen); - SessionInfo *session_info = reinterpret_cast(aicpu_ext_info->infoMsg); - session_info->sessionId = davinci_model_->GetSessionId(); - session_info->sessFlag = true; - GELOGD("Update aicpu_task ext_info session_info session_id is %lu", session_info->sessionId); - } - offset += sizeof(aicpu::FWKAdapter::ExtInfo); - offset += aicpu_ext_info->infoLen; - } - - auto rt_ret = rtMalloc(&aicpu_ext_info_addr_, ext_info.size(), RT_MEMORY_HBM); + int32_t unknown_shape_type_val = 0; + (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(); + std::unique_ptr ext_handle( + 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) + "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."); + 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."); + + auto rt_ret = rtMalloc(&aicpu_ext_info_addr_, ext_handle->GetExtInfoLen(), RT_MEMORY_HBM); if (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(aicpu_ext_info_addr_, ext_info.size(), ext_info_data, ext_info.size(), RT_MEMCPY_HOST_TO_DEVICE); + 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()); return RT_ERROR_TO_GE_STATUS(rt_ret); diff --git a/ge/hybrid/node_executor/aicpu/aicpu_ext_info.cc b/ge/hybrid/node_executor/aicpu/aicpu_ext_info.cc index e9c7c604..b178b906 100644 --- a/ge/hybrid/node_executor/aicpu/aicpu_ext_info.cc +++ b/ge/hybrid/node_executor/aicpu/aicpu_ext_info.cc @@ -64,6 +64,9 @@ Status AicpuExtInfoHandler::Parse(const std::string &ext_info) { case aicpu::FWKAdapter::FWK_ADPT_EXT_SESSION_INFO: GE_CHK_STATUS_RET(ParseExtSessionInfo(aicpu_ext_info), "Parse ext session info failed."); break; + case aicpu::FWKAdapter::FWK_ADPT_EXT_BITMAP: + GE_CHK_STATUS_RET(ParseExtBitMap(aicpu_ext_info), "Parse ext bit map failed."); + break; default: GELOGD("Node[%s] ignore infoType=%d, infoLen=%u.", node_name_.c_str(), aicpu_ext_info->infoType, aicpu_ext_info->infoLen); @@ -140,6 +143,29 @@ Status AicpuExtInfoHandler::ParseExtSessionInfo(AicpuExtInfo *aicpu_ext_info) { return SUCCESS; } +Status AicpuExtInfoHandler::ParseExtBitMap(AicpuExtInfo *aicpu_ext_info) { + GE_CHK_BOOL_RET_STATUS(aicpu_ext_info->infoLen == sizeof(uint64_t), PARAM_INVALID, + "Node[%s] parse bit_map info failed as infoLen must be %zu but %u.", + node_name_.c_str(), sizeof(uint64_t), aicpu_ext_info->infoLen); + + bit_map_ = reinterpret_cast(aicpu_ext_info->infoMsg); + GELOGI("Node[%s] bit_map info success infoLen=%u.", node_name_.c_str(), aicpu_ext_info->infoLen); + return SUCCESS; +} + +Status AicpuExtInfoHandler::UpdateExecuteMode(bool flag) { + if (bit_map_ == nullptr) { + GELOGD("There is no bit_map in ext_info, no need update."); + return SUCCESS; + } + if (flag) { + *(bit_map_) |= 1; + } else { + *(bit_map_) &= ~1; + } + return SUCCESS; +} + Status AicpuExtInfoHandler::UpdateSessionInfo(uint64_t session_id, uint64_t kernel_id, bool sess_flag) { if (session_info_ == nullptr) { GELOGD("There is no session info in ext_info, no need update."); diff --git a/ge/hybrid/node_executor/aicpu/aicpu_ext_info.h b/ge/hybrid/node_executor/aicpu/aicpu_ext_info.h index 2defba8f..e5b94452 100644 --- a/ge/hybrid/node_executor/aicpu/aicpu_ext_info.h +++ b/ge/hybrid/node_executor/aicpu/aicpu_ext_info.h @@ -57,6 +57,8 @@ class AicpuExtInfoHandler { Status UpdateSessionInfoSessionId(uint64_t session_id); + Status UpdateExecuteMode(bool flag); + Status GetOutputShapeAndType(uint32_t output_index, GeShape &shape, DataType &data_type); private: @@ -65,6 +67,7 @@ class AicpuExtInfoHandler { Status ParseExtInputShape(AicpuExtInfo *aicpu_ext_info); Status ParseExtOutputShape(AicpuExtInfo *aicpu_ext_info); Status ParseExtSessionInfo(AicpuExtInfo *aicpu_ext_info); + Status ParseExtBitMap(AicpuExtInfo *aicpu_ext_info); static Status UpdateShapeAndType(const GeShape &shape, DataType data_type, @@ -80,6 +83,7 @@ class AicpuExtInfoHandler { const uint32_t output_num_; UnknowShapeOpType unknown_type_; AicpuSessionInfo *session_info_ = nullptr; + uint64_t *bit_map_ = nullptr; std::unique_ptr ext_info_; size_t ext_info_len_ = 0; diff --git a/ge/hybrid/node_executor/aicpu/aicpu_node_executor.cc b/ge/hybrid/node_executor/aicpu/aicpu_node_executor.cc index 1c160eea..e9e99629 100755 --- a/ge/hybrid/node_executor/aicpu/aicpu_node_executor.cc +++ b/ge/hybrid/node_executor/aicpu/aicpu_node_executor.cc @@ -60,6 +60,7 @@ 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_), @@ -136,6 +137,7 @@ Status AicpuNodeTaskBase::UpdateExtInfo() { return SUCCESS; } + GE_CHK_STATUS_RET(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 3d001d8b..8bef8c50 100755 --- a/ge/single_op/task/op_task.cc +++ b/ge/single_op/task/op_task.cc @@ -373,6 +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_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(), @@ -404,13 +405,14 @@ Status AiCpuBaseTask::UpdateExtInfo(const std::vector &input_desc, std::vector &output_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."); + if (num_inputs_ == 0 && num_outputs_ == 0) { GELOGI("No input and output, no need update ext info."); return SUCCESS; } - GE_CHECK_NOTNULL(aicpu_ext_handle_); - size_t non_const_index = 0; for (size_t input_index = 0; input_index < num_inputs_; input_index++) { if (input_index < input_is_const_.size() && input_is_const_[input_index]) { diff --git a/tests/ut/ge/graph/load/kernel_ex_task_info_unittest.cc b/tests/ut/ge/graph/load/kernel_ex_task_info_unittest.cc index 53436820..7bc3faca 100644 --- a/tests/ut/ge/graph/load/kernel_ex_task_info_unittest.cc +++ b/tests/ut/ge/graph/load/kernel_ex_task_info_unittest.cc @@ -137,4 +137,12 @@ TEST_F(UtestKernelExTaskInfo, kernel_ex_task_info_calculate_args) { EXPECT_EQ(kernel_ex_task_info.CalculateArgs(task_def, &model), FAILED); } +TEST_F(UtestKernelExTaskInfo, kernel_ex_task_ext_info) { + const char ext_info[4] = {0, 0, 0, 4}; + const OpDescPtr op_desc = CreateOpDesc("FrameworkOp", "FrameworkOp"); + + KernelExTaskInfo kernel_ex_task_info; + EXPECT_EQ(kernel_ex_task_info.InitTaskExtInfo(ext_info, op_desc), SUCCESS); +} + } // namespace ge diff --git a/tests/ut/ge/graph/load/kernel_task_info_unittest.cc b/tests/ut/ge/graph/load/kernel_task_info_unittest.cc index a3a27a7b..c253666f 100644 --- a/tests/ut/ge/graph/load/kernel_task_info_unittest.cc +++ b/tests/ut/ge/graph/load/kernel_task_info_unittest.cc @@ -1195,4 +1195,10 @@ TEST_F(UtestKernelTaskInfo, kernel_task_info_super_kernel_info) { EXPECT_EQ(kernel_task_info.SKTFinalize(), SUCCESS); } +TEST_F(UtestKernelTaskInfo, kernel_ask_ext_info) { + const char ext_info[4] = {0, 0, 0, 4}; + KernelTaskInfo kernel_task_info; + EXPECT_EQ(kernel_task_info.InitAicpuTaskExtInfo(ext_info), SUCCESS); +} + } // namespace ge From f640f729c978141e27195e93f0ba0d069d1881cc Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 25 Jan 2021 21:46:35 +0800 Subject: [PATCH 2/8] For aicpu all_shape compile. --- ge/generator/ge_generator.cc | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/ge/generator/ge_generator.cc b/ge/generator/ge_generator.cc index fe7ea3bf..b050ab93 100644 --- a/ge/generator/ge_generator.cc +++ b/ge/generator/ge_generator.cc @@ -721,8 +721,12 @@ Status GeGenerator::BuildSingleOp(OpDescPtr &op_desc, const vector &in GeModelPtr &ge_model = name_to_ge_model.begin()->second; 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; - if (CheckShapeReset(op_desc, dynamic_flag) == SUCCESS && dynamic_flag) { + CheckShapeReset(op_desc, dynamic_flag); + if (all_shape && dynamic_flag) { + GELOGD("Get aicpu all_shape kernel!"); vector inputs_dynamic; vector outputs_dynamic; GE_CHK_STATUS_RET_NOLOG(ResetTensorVecShape(inputs, inputs_dynamic)); From d383e91c52ed9a681777d965cde4ba27e6f40b64 Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 25 Jan 2021 22:00:59 +0800 Subject: [PATCH 3/8] 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."); From 3f69c0ca6515544dfa69fe6251f3c53a7ad8ce14 Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 25 Jan 2021 22:02:49 +0800 Subject: [PATCH 4/8] For aicpu all_shape compile. --- ge/generator/ge_generator.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ge/generator/ge_generator.cc b/ge/generator/ge_generator.cc index 52dfa65d..6c0fb6e5 100644 --- a/ge/generator/ge_generator.cc +++ b/ge/generator/ge_generator.cc @@ -726,7 +726,7 @@ Status GeGenerator::BuildSingleOp(OpDescPtr &op_desc, const vector &in bool dynamic_flag = false; (void)AttrUtils::GetBool(op_desc, kAicpuAllshape, all_shape); CheckShapeReset(op_desc, dynamic_flag); - if (dynamic_flag && all_shape) { + if (dynamic_flag || all_shape) { GELOGD("Get aicpu all_shape kernel!"); vector inputs_dynamic; vector outputs_dynamic; From 5b001c5684914fc1f4a1caee85cb192318c79ed0 Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 25 Jan 2021 22:06:18 +0800 Subject: [PATCH 5/8] For aicpu all_shape compile. --- ge/graph/load/model_manager/task_info/kernel_task_info.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 2a3ddaf8..861ef484 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 @@ -979,7 +979,7 @@ Status KernelTaskInfo::InitAicpuTaskExtInfo(const std::string &ext_info) { GE_CHK_BOOL_RET_STATUS(ext_handle != nullptr, FAILED, "Malloc aicpu_ext_handle mem failed!"); 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_->UpdateSessionInfo(davinci_model_->GetSessionId()), + GE_CHK_STATUS_RET(ext_handle_->UpdateSessionInfoSessionId(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."); From df604f679b325f1bb8c63ef22e9c4b99e2cf46b1 Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 25 Jan 2021 22:07:12 +0800 Subject: [PATCH 6/8] For aicpu all_shape compile. --- ge/graph/load/model_manager/task_info/kernel_task_info.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 861ef484..1d2a74cc 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 @@ -979,7 +979,7 @@ Status KernelTaskInfo::InitAicpuTaskExtInfo(const std::string &ext_info) { GE_CHK_BOOL_RET_STATUS(ext_handle != nullptr, FAILED, "Malloc aicpu_ext_handle mem failed!"); 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_->UpdateSessionInfoSessionId(davinci_model_->GetSessionId()), + GE_CHK_STATUS_RET(ext_handle->UpdateSessionInfoSessionId(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."); From 323e0fcde7ba55d1f28e6b787160d6387ac852aa Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 25 Jan 2021 22:10:14 +0800 Subject: [PATCH 7/8] For aicpu all_shape compile. --- ge/single_op/task/op_task.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ge/single_op/task/op_task.cc b/ge/single_op/task/op_task.cc index 28ddcbe2..ff200806 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(aicpu_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(), From e331dee2b9b1bf2d4fe09487719f31cac17cd8fe Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 26 Jan 2021 10:59:53 +0800 Subject: [PATCH 8/8] Fix ut. --- tests/ut/ge/graph/load/kernel_ex_task_info_unittest.cc | 2 +- tests/ut/ge/graph/load/kernel_task_info_unittest.cc | 9 +++------ 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/tests/ut/ge/graph/load/kernel_ex_task_info_unittest.cc b/tests/ut/ge/graph/load/kernel_ex_task_info_unittest.cc index 7bc3faca..850a29ad 100644 --- a/tests/ut/ge/graph/load/kernel_ex_task_info_unittest.cc +++ b/tests/ut/ge/graph/load/kernel_ex_task_info_unittest.cc @@ -138,7 +138,7 @@ TEST_F(UtestKernelExTaskInfo, kernel_ex_task_info_calculate_args) { } TEST_F(UtestKernelExTaskInfo, kernel_ex_task_ext_info) { - const char ext_info[4] = {0, 0, 0, 4}; + const string ext_info = {1, 1, 1, 1, 0, 0, 0, 0}; const OpDescPtr op_desc = CreateOpDesc("FrameworkOp", "FrameworkOp"); KernelExTaskInfo kernel_ex_task_info; diff --git a/tests/ut/ge/graph/load/kernel_task_info_unittest.cc b/tests/ut/ge/graph/load/kernel_task_info_unittest.cc index c253666f..65783ac9 100644 --- a/tests/ut/ge/graph/load/kernel_task_info_unittest.cc +++ b/tests/ut/ge/graph/load/kernel_task_info_unittest.cc @@ -413,6 +413,9 @@ TEST_F(UtestKernelTaskInfo, init_kernel_taskInfo_with_aicpu_kernel_type_fail) { // rtMemcpy -> RT_ERROR_INVALID_VALUE EXPECT_EQ(kernel_task_info.Init(task_def, &model), SUCCESS); + const string ext_info = {1, 1, 1, 1, 0, 0, 0, 0}; + EXPECT_EQ(kernel_task_info.InitAicpuTaskExtInfo(ext_info), SUCCESS); + EXPECT_EQ(kernel_task_info.Distribute(), SUCCESS); EXPECT_EQ(kernel_task_info.Release(), SUCCESS); @@ -1195,10 +1198,4 @@ TEST_F(UtestKernelTaskInfo, kernel_task_info_super_kernel_info) { EXPECT_EQ(kernel_task_info.SKTFinalize(), SUCCESS); } -TEST_F(UtestKernelTaskInfo, kernel_ask_ext_info) { - const char ext_info[4] = {0, 0, 0, 4}; - KernelTaskInfo kernel_task_info; - EXPECT_EQ(kernel_task_info.InitAicpuTaskExtInfo(ext_info), SUCCESS); -} - } // namespace ge