diff --git a/mmcv/ops/csrc/pytorch/npu/focal_loss_npu.cpp b/mmcv/ops/csrc/pytorch/npu/focal_loss_npu.cpp index 3f3bc5a047..ef7df560c9 100644 --- a/mmcv/ops/csrc/pytorch/npu/focal_loss_npu.cpp +++ b/mmcv/ops/csrc/pytorch/npu/focal_loss_npu.cpp @@ -194,6 +194,7 @@ void softmax_focal_loss_backward_npu(Tensor input, Tensor target, Tensor weight, weight_y = at::sum(weight_y, 1, true); weight_y = at::broadcast_to(weight_y, input.sizes()); } + grad_input_y = grad_input_y.fill_(0); OpCommand cmd; string reduction = "none"; cmd.Name("SoftmaxFocalLossGrad")