From 119212d9e63fe9d39a44d23ae45f4688f09bfa2b Mon Sep 17 00:00:00 2001 From: CaoJian Date: Wed, 13 Jan 2021 16:55:51 +0800 Subject: [PATCH] the output of resize_nearest/bilinear ops memset to zero. --- .../kernel_compiler/cpu/resize_bilinear_grad_cpu_kernel.cc | 5 +++++ .../cpu/resize_nearest_neighbor_grad_cpu_kernel.cc | 6 ++++++ 2 files changed, 11 insertions(+) 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 bf28dc231f5..fcd3cc53955 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 @@ -54,6 +54,11 @@ void ResizeBilinearGradCPUKernel::LaunchKernel(const std::vector &in auto dloss_addr = reinterpret_cast(inputs[0]->addr); auto output_addr = reinterpret_cast(outputs[0]->addr); + 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; + } + size_t batch_size = shape_[0]; size_t channel = shape_[1]; size_t in_height = shape_[2]; 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 50f12a216aa..4d20c01d3be 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 @@ -55,6 +55,12 @@ void ResizeNearestNeighborGradCPUKernel::LaunchKernel(const std::vector &outputs) { auto dloss_addr = reinterpret_cast(inputs[0]->addr); auto output_addr = reinterpret_cast(outputs[0]->addr); + + 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; + } + size_t in_hw_size = in_width_ * in_height_; size_t out_hw_size = out_width_ * out_height_;