diff --git a/mindspore/ccsrc/backend/kernel_compiler/cpu/masked_select_grad_cpu_kernel.cc b/mindspore/ccsrc/backend/kernel_compiler/cpu/masked_select_grad_cpu_kernel.cc index b8fe8335017..c0b2d74c05c 100644 --- a/mindspore/ccsrc/backend/kernel_compiler/cpu/masked_select_grad_cpu_kernel.cc +++ b/mindspore/ccsrc/backend/kernel_compiler/cpu/masked_select_grad_cpu_kernel.cc @@ -46,6 +46,12 @@ bool MaskedSelectGradCPUKernel::Launch(const std::vector auto mask = reinterpret_cast(inputs[1]->addr); auto grad = reinterpret_cast(inputs[2]->addr); auto dx = reinterpret_cast(outputs[0]->addr); + + auto ret = memset_s(dx, outputs[0]->size, 0, outputs[0]->size); + if (ret != EOK) { + MS_LOG(EXCEPTION) << "Memset output[0] of kernel MaskedSelectGrad failed, ret: " << ret; + } + uint64_t output_size = outputs[0]->size / sizeof(T); uint64_t j = 0; if (input_shape_a_ == input_shape_b_) {