diff --git a/mindspore/ccsrc/plugin/device/cpu/kernel/scatter_nd_update_cpu_kernel.cc b/mindspore/ccsrc/plugin/device/cpu/kernel/scatter_nd_update_cpu_kernel.cc index c22eedfa985..08b731e0fe5 100644 --- a/mindspore/ccsrc/plugin/device/cpu/kernel/scatter_nd_update_cpu_kernel.cc +++ b/mindspore/ccsrc/plugin/device/cpu/kernel/scatter_nd_update_cpu_kernel.cc @@ -33,17 +33,17 @@ bool Compute(const ComputeParams *params, const size_t start, const size_t en T *x = params->x_; int *indices = params->indices_; T *updates = params->updates_; - std::vector *out_strides = params->out_strides_; + std::vector *out_strides = params->out_strides_; MS_EXCEPTION_IF_NULL(x); MS_EXCEPTION_IF_NULL(indices); MS_EXCEPTION_IF_NULL(updates); MS_EXCEPTION_IF_NULL(out_strides); - for (int i = SizeToInt(start); i < SizeToInt(end); ++i) { - int offset = 0; - std::vector local_indices; - for (int j = 0; j < params->indices_unit_rank_; ++j) { - auto index = indices[i * params->indices_unit_rank_ + j]; + for (size_t i = start; i < end; ++i) { + size_t offset = 0; + std::vector local_indices; + for (size_t j = 0; j < params->indices_unit_rank_; ++j) { + auto index = IntToSize(indices[i * params->indices_unit_rank_ + j]); (void)local_indices.emplace_back(index); if (index < 0) { MS_LOG(ERROR) << "For '" << kKernelName @@ -104,20 +104,20 @@ void ScatterUpdateCpuKernelMod::InitKernel(const CNodePtr &kernel_node) { << indices_shape[i]; } } - indices_unit_rank_ = SizeToInt(indices_unit_rank); + indices_unit_rank_ = indices_unit_rank; unit_size_ = 1; for (size_t i = indices_shape.size() - 1; i < updates_shape.size(); ++i) { - unit_size_ *= SizeToInt(updates_shape[i]); + unit_size_ *= updates_shape[i]; } num_units_ = 1; num_units_ *= updates_shape[indices_shape.size() - 2]; for (int i = SizeToInt(indices_shape.size()) - 3; i >= 0; i--) { num_units_ *= updates_shape[i]; } - int out_stride = 1; + size_t out_stride = 1; out_strides_.push_back(out_stride); for (int i = indices_unit_rank_ - 2; i >= 0; i--) { - out_stride *= shape[i + 1]; + out_stride *= LongToSize(shape[i + 1]); out_strides_.push_back(out_stride); } reverse(out_strides_.begin(), out_strides_.end()); diff --git a/mindspore/ccsrc/plugin/device/cpu/kernel/scatter_nd_update_cpu_kernel.h b/mindspore/ccsrc/plugin/device/cpu/kernel/scatter_nd_update_cpu_kernel.h index 7a90af5c93e..d9acae4a47b 100644 --- a/mindspore/ccsrc/plugin/device/cpu/kernel/scatter_nd_update_cpu_kernel.h +++ b/mindspore/ccsrc/plugin/device/cpu/kernel/scatter_nd_update_cpu_kernel.h @@ -30,9 +30,9 @@ struct ComputeParams { T *x_{nullptr}; int *indices_{nullptr}; T *updates_{nullptr}; - int unit_size_{0}; - int indices_unit_rank_{0}; - std::vector *out_strides_{nullptr}; + size_t unit_size_{0}; + size_t indices_unit_rank_{0}; + std::vector *out_strides_{nullptr}; size_t x_mem_size_{0}; }; @@ -55,10 +55,10 @@ class ScatterUpdateCpuKernelMod : public DeprecatedNativeCpuKernelMod { void LaunchKernel(const std::vector &inputs, const std::vector &outputs); TypeId dtype_{kTypeUnknown}; - int unit_size_{0}; + size_t unit_size_{0}; size_t num_units_{0}; - int indices_unit_rank_{0}; - std::vector out_strides_; + size_t indices_unit_rank_{0}; + std::vector out_strides_; }; class ScatterNdUpdateCpuKernelMod : public ScatterUpdateCpuKernelMod { diff --git a/mindspore/core/ops/svd.cc b/mindspore/core/ops/svd.cc index 53277ec711d..bf1c9aed06f 100644 --- a/mindspore/core/ops/svd.cc +++ b/mindspore/core/ops/svd.cc @@ -18,6 +18,7 @@ #include #include +#include #include "mindapi/ir/type.h" #include "utils/check_convert_utils.h" @@ -39,7 +40,7 @@ abstract::BaseShapePtr SvdInferShape(const PrimitivePtr &prim, const std::vector auto n = a_shape[ndim - kIndexOne]; auto p = std::min(m, n); - auto s_shape = ShapeVector(a_shape.begin(), a_shape.end() - kIndexOne); + auto s_shape = ShapeVector(a_shape.begin(), a_shape.end() - SizeToLong(kIndexOne)); s_shape[s_shape.size() - kIndexOne] = p; auto u_shape = ShapeVector(a_shape.begin(), a_shape.end()); auto v_shape = ShapeVector(a_shape.begin(), a_shape.end()); diff --git a/mindspore/core/ops/svd.h b/mindspore/core/ops/svd.h index 8c0ef4772c3..dfb1e5ce887 100644 --- a/mindspore/core/ops/svd.h +++ b/mindspore/core/ops/svd.h @@ -17,7 +17,6 @@ #ifndef MINDSPORE_CORE_OPS_SVD_H_ #define MINDSPORE_CORE_OPS_SVD_H_ #include -#include #include #include "ops/base_operator.h"