From 256bf6ff7e9973150a8fe837e3a6b2d24d3539f1 Mon Sep 17 00:00:00 2001 From: USTCKAY <50285351+USTCKAY@users.noreply.github.com> Date: Thu, 25 Aug 2022 11:58:30 +0800 Subject: [PATCH] fix roi_align_op_npu to pass the unittest (#45310) --- paddle/fluid/operators/roi_align_op_npu.cc | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/paddle/fluid/operators/roi_align_op_npu.cc b/paddle/fluid/operators/roi_align_op_npu.cc index 0d01771d9d6..f14e29f8ddc 100644 --- a/paddle/fluid/operators/roi_align_op_npu.cc +++ b/paddle/fluid/operators/roi_align_op_npu.cc @@ -157,8 +157,10 @@ class ROIAlignNPUGradKernel : public framework::OpKernel { "ConcatD", {x_list}, {ROIs_N5}, {{"N", 2}, {"concat_dim", 1}}); runner_concat.Run(stream); - // By analysis, in order to match cpu grad version, - // rois[:,3:5] should substrate 1 before call ascend grad function + // If CANN version code is less than 504, by analysis, in order to match + // cpu grad version, rois[:,3:5] should substrate 1 before call ascend grad + // function +#if (CANN_VERSION_CODE < 504000) std::vector vec_dlt = {0, 0, 0, -1.0f, -1.0f}; Tensor tsr_dlt; tsr_dlt.mutable_data({5}, place); @@ -167,6 +169,7 @@ class ROIAlignNPUGradKernel : public framework::OpKernel { const auto& runner_add = NpuOpRunner("AddV2", {ROIs_N5, tsr_dlt}, {ROIs_N5}, {}); runner_add.Run(stream); +#endif // Call ascend RoiAlignGrad function int roi_end_mode = 0; -- GitLab