diff --git a/mindspore/ccsrc/backend/kernel_compiler/cpu/gathernd_cpu_kernel.cc b/mindspore/ccsrc/backend/kernel_compiler/cpu/gathernd_cpu_kernel.cc index 14ed76a5d10..213e5e197bb 100644 --- a/mindspore/ccsrc/backend/kernel_compiler/cpu/gathernd_cpu_kernel.cc +++ b/mindspore/ccsrc/backend/kernel_compiler/cpu/gathernd_cpu_kernel.cc @@ -15,10 +15,10 @@ */ #include "backend/kernel_compiler/cpu/gathernd_cpu_kernel.h" #include "runtime/device/cpu/cpu_device_address.h" +#define MAX_INT (((unsigned int)(-1)) >> 1) namespace mindspore { namespace kernel { - void GatherNdCPUKernel::InitKernel(const CNodePtr &kernel_node) { input_shapes_ = AnfAlgo::GetPrevNodeOutputInferShape(kernel_node, 0); indices_shapes_ = AnfAlgo::GetPrevNodeOutputInferShape(kernel_node, 1); @@ -83,11 +83,14 @@ bool GatherNdCPUKernel::LaunchKernel(const std::vector &inputs, cons size_t output_dim1 = dims_[1]; size_t indices_dim1 = dims_[2]; - int num = output_dim0 * output_dim1; + size_t num = output_dim0 * output_dim1; + if (num > MAX_INT) { + MS_LOG(EXCEPTION) << "Exceed MAX_INT: " << MAX_INT << ", dim0: " << output_dim0 << ", dim1: " << output_dim1; + } - for (int write_index = 0; write_index < num; write_index++) { - int i = write_index / output_dim1 % output_dim0; - int j = write_index % output_dim1; + for (size_t write_index = 0; write_index < num; write_index++) { + size_t i = write_index / output_dim1 % output_dim0; + size_t j = write_index % output_dim1; int read_index = 0; for (size_t k = 0; k < indices_dim1; k++) { diff --git a/mindspore/ccsrc/backend/kernel_compiler/cpu/range_cpu_kernel.h b/mindspore/ccsrc/backend/kernel_compiler/cpu/range_cpu_kernel.h index f4e846b5ce6..433142684a3 100644 --- a/mindspore/ccsrc/backend/kernel_compiler/cpu/range_cpu_kernel.h +++ b/mindspore/ccsrc/backend/kernel_compiler/cpu/range_cpu_kernel.h @@ -47,7 +47,6 @@ MS_REG_CPU_KERNEL(Range, KernelAttr().AddInputAttr(kNumberTypeFloat32).AddOutput RangeCPUKernel); MS_REG_CPU_KERNEL(Range, KernelAttr().AddInputAttr(kNumberTypeFloat64).AddOutputAttr(kNumberTypeFloat64), RangeCPUKernel); - } // namespace kernel } // namespace mindspore diff --git a/mindspore/ccsrc/backend/kernel_compiler/cpu/resize_bilinear_grad_cpu_kernel.cc b/mindspore/ccsrc/backend/kernel_compiler/cpu/resize_bilinear_grad_cpu_kernel.cc index fcd3cc53955..ab649c7a8f5 100644 --- a/mindspore/ccsrc/backend/kernel_compiler/cpu/resize_bilinear_grad_cpu_kernel.cc +++ b/mindspore/ccsrc/backend/kernel_compiler/cpu/resize_bilinear_grad_cpu_kernel.cc @@ -56,7 +56,7 @@ void ResizeBilinearGradCPUKernel::LaunchKernel(const std::vector &in auto ret = memset_s(output_addr, outputs[0]->size, 0, outputs[0]->size); if (ret != EOK) { - MS_LOG(ERROR) << "Output buffer memset failed, ret:" << ret; + MS_LOG(EXCEPTION) << "Output buffer memset failed, ret:" << ret; } size_t batch_size = shape_[0]; diff --git a/mindspore/ccsrc/backend/kernel_compiler/cpu/resize_nearest_neighbor_grad_cpu_kernel.cc b/mindspore/ccsrc/backend/kernel_compiler/cpu/resize_nearest_neighbor_grad_cpu_kernel.cc index bc456b3cd68..6637d4b95b0 100644 --- a/mindspore/ccsrc/backend/kernel_compiler/cpu/resize_nearest_neighbor_grad_cpu_kernel.cc +++ b/mindspore/ccsrc/backend/kernel_compiler/cpu/resize_nearest_neighbor_grad_cpu_kernel.cc @@ -62,7 +62,7 @@ void ResizeNearestNeighborGradCPUKernel::LaunchKernel(const std::vectorsize, 0, outputs[0]->size); if (ret != EOK) { - MS_LOG(ERROR) << "Output buffer memset failed, ret:" << ret; + MS_LOG(EXCEPTION) << "Output buffer memset failed, ret:" << ret; } size_t in_hw_size = in_width_ * in_height_;