From bf70ca6fef631c7044e9627287673528c8824742 Mon Sep 17 00:00:00 2001 From: jianghui58 Date: Thu, 28 Jul 2022 18:26:57 +0800 Subject: [PATCH] fix bias grad bug --- mindspore/lite/src/runtime/kernel/cpu/fp32_grad/bias_grad.cc | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/mindspore/lite/src/runtime/kernel/cpu/fp32_grad/bias_grad.cc b/mindspore/lite/src/runtime/kernel/cpu/fp32_grad/bias_grad.cc index 21e76495bdd..99c2b43b3ff 100644 --- a/mindspore/lite/src/runtime/kernel/cpu/fp32_grad/bias_grad.cc +++ b/mindspore/lite/src/runtime/kernel/cpu/fp32_grad/bias_grad.cc @@ -67,10 +67,11 @@ int BiasGradCPUKernel::DoExecute(int task_id) { size_t total_size = channels * nhw_size; for (size_t c = 0; c < channels; ++c) { - out[c] = 0; + float tmp = 0.0f; for (size_t offset = 0; offset < total_size; offset += channels) { - out[c] += in[offset + c]; + tmp += in[offset + c]; } + out[c] = tmp; } return RET_OK;