From 4d75d7b992620961c12d5d6b8e2275d01d514d8c Mon Sep 17 00:00:00 2001 From: liubuyu Date: Fri, 18 Dec 2020 17:10:29 +0800 Subject: [PATCH] fix shape type error --- .../ccsrc/backend/kernel_compiler/aicpu/aicpu_kernel_build.cc | 4 +++- .../runtime/device/ascend/executor/ai_cpu_dynamic_kernel.cc | 2 +- .../runtime/device/ascend/executor/aicpu_ext_info_handle.cc | 1 + mindspore/ccsrc/utils/utils.h | 4 ++++ 4 files changed, 9 insertions(+), 2 deletions(-) diff --git a/mindspore/ccsrc/backend/kernel_compiler/aicpu/aicpu_kernel_build.cc b/mindspore/ccsrc/backend/kernel_compiler/aicpu/aicpu_kernel_build.cc index 5b16e6d8a7..e956c4179a 100644 --- a/mindspore/ccsrc/backend/kernel_compiler/aicpu/aicpu_kernel_build.cc +++ b/mindspore/ccsrc/backend/kernel_compiler/aicpu/aicpu_kernel_build.cc @@ -22,6 +22,7 @@ #include #include #include +#include "utils/utils.h" #include "runtime/device/kernel_runtime.h" #include "backend/kernel_compiler/aicpu/aicpu_kernel_mod.h" #include "proto/tensor.pb.h" @@ -402,7 +403,8 @@ bool CreateExtInfo(const std::shared_ptr &anf_node, const std::shared_p char *ext_info_buf = ext_info.data(); UnknowShapeOpType shape_type = UnknowShapeOpType::DEPEND_IN_SHAPE; - if (AnfAlgo::GetCNodeName(anf_node) == "Unique") { + auto op_name = AnfAlgo::GetCNodeName(anf_node); + if (kComputeDepend.find(op_name) != kComputeDepend.end()) { shape_type = UnknowShapeOpType::DEPEND_COMPUTE; } ext_info_offset = SetExtInfoShapeType(ext_info_buf, ext_info_offset, shape_type); diff --git a/mindspore/ccsrc/runtime/device/ascend/executor/ai_cpu_dynamic_kernel.cc b/mindspore/ccsrc/runtime/device/ascend/executor/ai_cpu_dynamic_kernel.cc index 097b6d364e..1d47c72af2 100644 --- a/mindspore/ccsrc/runtime/device/ascend/executor/ai_cpu_dynamic_kernel.cc +++ b/mindspore/ccsrc/runtime/device/ascend/executor/ai_cpu_dynamic_kernel.cc @@ -21,6 +21,7 @@ #include #include "runtime/mem.h" #include "runtime/kernel.h" +#include "utils/utils.h" #include "backend/session/anf_runtime_algorithm.h" #include "backend/kernel_compiler/aicpu/aicpu_util.h" #include "runtime/device/executor/executor_callback.h" @@ -28,7 +29,6 @@ namespace mindspore { namespace device { namespace ascend { -std::set kComputeDepend = {"Unique", "ComputeAccidentalHits"}; AiCpuDynamicKernel::~AiCpuDynamicKernel() { // free dev ptr if (ext_info_addr_dev_ == nullptr) { diff --git a/mindspore/ccsrc/runtime/device/ascend/executor/aicpu_ext_info_handle.cc b/mindspore/ccsrc/runtime/device/ascend/executor/aicpu_ext_info_handle.cc index 7933d49956..181161a7e8 100644 --- a/mindspore/ccsrc/runtime/device/ascend/executor/aicpu_ext_info_handle.cc +++ b/mindspore/ccsrc/runtime/device/ascend/executor/aicpu_ext_info_handle.cc @@ -92,6 +92,7 @@ bool AicpuExtInfoHandler::ParseExtShapeType(AicpuExtInfo *aicpu_ext_info) { if (*type != unknown_type_) { MS_LOG(ERROR) << "Node:" << node_name_ << " parse ext shape type failed as need:" << unknown_type_ << " but got:" << *type; + return false; } MS_LOG(INFO) << "Node:" << node_name_ << "parse ext shape type success infoLen=" << aicpu_ext_info->infoLen; return true; diff --git a/mindspore/ccsrc/utils/utils.h b/mindspore/ccsrc/utils/utils.h index 8f39918609..10aa325587 100644 --- a/mindspore/ccsrc/utils/utils.h +++ b/mindspore/ccsrc/utils/utils.h @@ -30,6 +30,8 @@ namespace mindspore { // op name. Op which not exists in operator/ops.h, so define it's name here +constexpr auto kUniqueOpName = "Unique"; +constexpr auto kComputeAccidentalHitsOpName = "ComputeAccidentalHits"; constexpr auto kFour2FiveOpName = "Four2Five"; constexpr auto kFive2FourOpName = "Five2Four"; constexpr auto kConv2DOpName = "Conv2D"; @@ -478,6 +480,8 @@ const std::set kHWSpecialFormatSet = { const std::set kFloatDataTypeSet = {kNumberTypeFloat16, kNumberTypeFloat32}; +const std::set kComputeDepend = {kUniqueOpName, kComputeAccidentalHitsOpName}; + static inline void ChangeFileMode(const std::string &file_name, mode_t mode) { try { if (chmod(file_name.c_str(), mode) != 0) {