diff --git a/mindspore/ccsrc/plugin/device/cpu/kernel/space_to_batch_nd_cpu_kernel.cc b/mindspore/ccsrc/plugin/device/cpu/kernel/space_to_batch_nd_cpu_kernel.cc index 9d1e2161750..8e879619325 100644 --- a/mindspore/ccsrc/plugin/device/cpu/kernel/space_to_batch_nd_cpu_kernel.cc +++ b/mindspore/ccsrc/plugin/device/cpu/kernel/space_to_batch_nd_cpu_kernel.cc @@ -79,7 +79,7 @@ bool SpaceToBatchNDCpuKernelMod::LaunchKernel(const std::vector(inputs[0]->addr); auto *output = reinterpret_cast(outputs[0]->addr); - int ret = memset_s(output, outputs[0]->size, 0, sizeof(T) * output_size_); + int ret = memset_s(output, outputs[0]->size, 0, sizeof(T) * static_cast(output_size_)); if (ret != 0) { MS_LOG(EXCEPTION) << "For '" << kernel_name_ << "', memset_s error. Error no: " << ret; } @@ -88,8 +88,8 @@ bool SpaceToBatchNDCpuKernelMod::LaunchKernel(const std::vector input_index(input_shape_.size(), 0); int64_t cur_pos = pos; for (int rev_i = input_shape_.size() - 1; rev_i >= 0; rev_i -= 1) { - input_index[rev_i] = cur_pos % input_shape_[rev_i]; - cur_pos = cur_pos / input_shape_[rev_i]; + input_index[rev_i] = cur_pos % input_shape_[IntToSize(rev_i)]; + cur_pos = cur_pos / input_shape_[IntToSize(rev_i)]; } std::vector output_index(input_index); @@ -142,9 +142,9 @@ bool SpaceToBatchNDCpuKernelMod::Init(const BaseOperatorPtr &base_operator, cons int SpaceToBatchNDCpuKernelMod::Resize(const BaseOperatorPtr &base_operator, const std::vector &inputs, const std::vector &outputs, const std::map &inputsOnHost) { - if (KernelMod::Resize(base_operator, inputs, outputs, inputsOnHost) == KRET_RESIZE_FAILED) { + if (KernelMod::Resize(base_operator, inputs, outputs, inputsOnHost) == static_cast(KRET_RESIZE_FAILED)) { MS_LOG(WARNING) << kernel_name_ << " reinit failed."; - return KRET_RESIZE_FAILED; + return static_cast(KRET_RESIZE_FAILED); } // get input_shape input_shape_ = inputs.at(kIndex0)->GetShapeVector(); @@ -153,15 +153,15 @@ int SpaceToBatchNDCpuKernelMod::Resize(const BaseOperatorPtr &base_operator, con input_size_ = 1; output_size_ = 1; for (size_t i = 0; i < input_shape_.size(); ++i) { - input_size_ = input_shape_[i] * input_size_; + input_size_ *= input_shape_[i]; } for (size_t i = 0; i < output_shape_.size(); ++i) { - output_size_ = output_shape_[i] * output_size_; + output_size_ *= output_shape_[i]; } off_set_ = input_shape_.size() - block_size_.size(); - return KRET_OK; + return static_cast(KRET_OK); } const std::vector> &SpaceToBatchNDCpuKernelMod::GetFuncList() const { diff --git a/mindspore/core/ops/space_to_batch_nd.cc b/mindspore/core/ops/space_to_batch_nd.cc index c365f9a410a..a2a48234e7d 100644 --- a/mindspore/core/ops/space_to_batch_nd.cc +++ b/mindspore/core/ops/space_to_batch_nd.cc @@ -91,7 +91,7 @@ abstract::ShapePtr SpaceToBatchNDInferShape(const PrimitivePtr &primitive, for (const auto &item : input_args) { MS_EXCEPTION_IF_NULL(item); } - auto input_shape_ptr = CheckAndConvertUtils::GetTensorInputShape(prim_name, input_args, kInputIndex0); + auto input_shape_ptr = CheckAndConvertUtils::GetTensorInputShape(prim_name, input_args, 0); auto paddings_value_ptr = primitive->GetAttr(kPaddings); MS_EXCEPTION_IF_NULL(paddings_value_ptr); @@ -115,7 +115,7 @@ TypePtr SpaceToBatchNDInferType(const PrimitivePtr &prim, const std::vector valid_types = {kInt8, kInt16, kInt32, kInt64, kUInt8, kUInt16, kUInt32, kUInt64, kFloat16, kFloat32, kFloat64}; - auto var_type = input_args[kInputIndex0]->BuildType(); + auto var_type = input_args[0]->BuildType(); return CheckAndConvertUtils::CheckTensorTypeValid("input type", var_type, valid_types, prim->name()); }