diff --git a/mindspore/ccsrc/plugin/device/cpu/kernel/uniform_cpu_kernel.cc b/mindspore/ccsrc/plugin/device/cpu/kernel/uniform_cpu_kernel.cc index 592d340a2b5..d47afa14f99 100644 --- a/mindspore/ccsrc/plugin/device/cpu/kernel/uniform_cpu_kernel.cc +++ b/mindspore/ccsrc/plugin/device/cpu/kernel/uniform_cpu_kernel.cc @@ -104,8 +104,7 @@ int UniformCpuKernelMod::Resize(const BaseOperatorPtr &base_operator, const std: if ((ret = NativeCpuKernelMod::Resize(base_operator, inputs, outputs)) != 0) { return ret; } - std::vector input_shape = inputs.at(kIndex0)->GetShapeVector(); - std::transform(input_shape.begin(), input_shape.end(), std::back_inserter(input_shape_), LongToSize); + input_elements_ = SizeOf(inputs.at(kIndex0)->GetShapeVector()); return ret; } @@ -118,7 +117,6 @@ bool UniformCpuKernelMod::LaunchKernel(const std::vector &in InitMSPhiloxRandom(seed_, offset_); auto y = reinterpret_cast(outputs[0]->addr); - input_elements_ = std::accumulate(input_shape_.begin(), input_shape_.end(), int64_t(1), std::multiplies()); for (int64_t i = 0; i < input_elements_; i++) { y[i] = static_cast(RandFloat() * (to_ - from_) + from_); } diff --git a/mindspore/ccsrc/plugin/device/cpu/kernel/uniform_cpu_kernel.h b/mindspore/ccsrc/plugin/device/cpu/kernel/uniform_cpu_kernel.h index f4912dfb4ed..da2fb304a54 100644 --- a/mindspore/ccsrc/plugin/device/cpu/kernel/uniform_cpu_kernel.h +++ b/mindspore/ccsrc/plugin/device/cpu/kernel/uniform_cpu_kernel.h @@ -68,8 +68,6 @@ class UniformCpuKernelMod : public NativeCpuKernelMod { static std::vector> func_list_; UniformFunc kernel_func_; - std::vector input_shape_; - std::vector output_shape_; int64_t input_elements_; float from_{0.0}; float to_{1.0};