From 07ede11816c46c3b2cca9a1a6d99241c2d84683a Mon Sep 17 00:00:00 2001 From: Aganlengzi Date: Wed, 8 Jun 2022 18:29:16 +0800 Subject: [PATCH] [NPU] fix reduce_max (#43230) --- paddle/fluid/operators/reduce_ops/reduce_max_op_npu.cc | 3 +++ 1 file changed, 3 insertions(+) diff --git a/paddle/fluid/operators/reduce_ops/reduce_max_op_npu.cc b/paddle/fluid/operators/reduce_ops/reduce_max_op_npu.cc index e3d8d15a30..8b9925a4c2 100644 --- a/paddle/fluid/operators/reduce_ops/reduce_max_op_npu.cc +++ b/paddle/fluid/operators/reduce_ops/reduce_max_op_npu.cc @@ -141,6 +141,9 @@ class ReduceMaxGradNPUKernel : public framework::OpKernel { Tensor tmp_out, tmp_out_grad; auto tmp_out_dims_vec = x_dims_vec; for (auto d : reduce_dims) { + if (d < 0) { + d += x_dims_vec.size(); + } tmp_out_dims_vec[d] = 1; } -- GitLab