From 6be1702326358767207244c10cdcb23878eb0a7e Mon Sep 17 00:00:00 2001 From: YR0717 Date: Fri, 4 Nov 2022 11:47:37 +0800 Subject: [PATCH] SparseSlice SparseSliceGrad code-fix --- .../cpu/kernel/sparse_slice_cpu_kernel.cc | 18 +++++++++--------- .../cpu/kernel/sparse_slice_grad_cpu_kernel.cc | 16 ++++++++-------- 2 files changed, 17 insertions(+), 17 deletions(-) diff --git a/mindspore/ccsrc/plugin/device/cpu/kernel/sparse_slice_cpu_kernel.cc b/mindspore/ccsrc/plugin/device/cpu/kernel/sparse_slice_cpu_kernel.cc index f4a70994793..20d977e9bc0 100644 --- a/mindspore/ccsrc/plugin/device/cpu/kernel/sparse_slice_cpu_kernel.cc +++ b/mindspore/ccsrc/plugin/device/cpu/kernel/sparse_slice_cpu_kernel.cc @@ -13,10 +13,10 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -#include -#include #include "plugin/device/cpu/kernel/sparse_slice_cpu_kernel.h" +#include +#include #include "plugin/device/cpu/hal/device/cpu_device_address.h" #include "plugin/device/cpu/kernel/eigen/eigen_common_utils.h" @@ -27,8 +27,8 @@ using complex64 = std::complex; using complex128 = std::complex; constexpr int64_t kSparseSliceInputsNum = 5; constexpr int64_t kSparseSliceOutputsNum = 3; -constexpr int64_t dim0num = 1; -constexpr int64_t dim1num = 2; +constexpr int64_t kDim0Num = 1; +constexpr int64_t kDim1Num = 2; #define ADD_KERNEL(dtype, type) \ { \ @@ -68,23 +68,23 @@ int SparseSliceCpuKernelMod::Resize(const BaseOperatorPtr &base_operator, const const auto input_start_shape = inputs[kIndex3]->GetShapeVector(); const auto input_size_shape = inputs[kIndex4]->GetShapeVector(); - if (input_indices_shape.size() != dim1num) { + if (input_indices_shape.size() != kDim1Num) { MS_LOG(EXCEPTION) << "For '" << kernel_name_ << "', it requires 'input_indices_shape' must be 2D Tensor " << ", but got " << input_indices_shape.size() << "-D"; } - if (input_values_shape.size() != dim0num) { + if (input_values_shape.size() != kDim0Num) { MS_LOG(EXCEPTION) << "For '" << kernel_name_ << "', it requires 'input_values_shape' must be 1D Tensor " << ", but got " << input_values_shape.size() << "-D"; } - if (input_shape_shape.size() != dim0num) { + if (input_shape_shape.size() != kDim0Num) { MS_LOG(EXCEPTION) << "For '" << kernel_name_ << "', it requires 'input_shape_shape' must be 1D Tensor " << ", but got " << input_shape_shape.size() << "-D"; } - if (input_start_shape.size() != dim0num) { + if (input_start_shape.size() != kDim0Num) { MS_LOG(EXCEPTION) << "For '" << kernel_name_ << "', it requires 'input_start_shape' must be 1D Tensor " << ", but got " << input_start_shape.size() << "-D"; } - if (input_size_shape.size() != dim0num) { + if (input_size_shape.size() != kDim0Num) { MS_LOG(EXCEPTION) << "For '" << kernel_name_ << "', it requires 'input_size_shape' must be 1D Tensor " << ", but got " << input_size_shape.size() << "-D"; } diff --git a/mindspore/ccsrc/plugin/device/cpu/kernel/sparse_slice_grad_cpu_kernel.cc b/mindspore/ccsrc/plugin/device/cpu/kernel/sparse_slice_grad_cpu_kernel.cc index 03a1e0f3e56..a7732e5c7ae 100644 --- a/mindspore/ccsrc/plugin/device/cpu/kernel/sparse_slice_grad_cpu_kernel.cc +++ b/mindspore/ccsrc/plugin/device/cpu/kernel/sparse_slice_grad_cpu_kernel.cc @@ -13,10 +13,10 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -#include -#include #include "plugin/device/cpu/kernel/sparse_slice_grad_cpu_kernel.h" +#include +#include #include "plugin/device/cpu/hal/device/cpu_device_address.h" #include "plugin/device/cpu/kernel/eigen/eigen_common_utils.h" @@ -27,8 +27,8 @@ using complex64 = std::complex; using complex128 = std::complex; constexpr int64_t kSparseSliceGradInputsNum = 4; constexpr int64_t kSparseSliceGradOutputsNum = 1; -constexpr int64_t dim0num = 1; -constexpr int64_t dim1num = 2; +constexpr int64_t kDim0Num = 1; +constexpr int64_t kDim1Num = 2; #define ADD_KERNEL(dtype, type) \ { \ @@ -65,19 +65,19 @@ int SparseSliceGradCpuKernelMod::Resize(const BaseOperatorPtr &base_operator, const auto new_indices_shape = inputs[kIndex3]->GetShapeVector(); // Check shape - if (backprop_val_grad_shape.size() != dim0num) { + if (backprop_val_grad_shape.size() != kDim0Num) { MS_LOG(EXCEPTION) << "For '" << kernel_name_ << "', it requires 'brackprop_val_gard' must be 1D Tensor " << ", but got " << backprop_val_grad_shape.size() << "-D"; } - if (indices_shape.size() != dim1num) { + if (indices_shape.size() != kDim1Num) { MS_LOG(EXCEPTION) << "For '" << kernel_name_ << "', it requires 'indices_shape' must be 2D Tensor " << ", but got " << indices_shape.size() << "-D"; } - if (start_shape.size() != dim0num) { + if (start_shape.size() != kDim0Num) { MS_LOG(EXCEPTION) << "For '" << kernel_name_ << "', it requires 'start_shape' must be 1D Tensor " << ", but got " << start_shape.size() << "-D"; } - if (new_indices_shape.size() != dim1num) { + if (new_indices_shape.size() != kDim1Num) { MS_LOG(EXCEPTION) << "For '" << kernel_name_ << "', it requires 'new_indices_shape' must be 2D Tensor " << ", but got " << new_indices_shape.size() << "-D"; }