From f07ed6bcc0fcfb82c12933748ec94f94b90c7cd6 Mon Sep 17 00:00:00 2001 From: Yinlei Sun Date: Thu, 15 Jun 2023 16:46:07 +0800 Subject: [PATCH] [Fix] Fix deform_conv ops on Ascend NPU (#2805) --- mmcv/ops/deform_conv.py | 3 ++- mmcv/ops/modulated_deform_conv.py | 7 +++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/mmcv/ops/deform_conv.py b/mmcv/ops/deform_conv.py index cf37a376a..73472dc9b 100644 --- a/mmcv/ops/deform_conv.py +++ b/mmcv/ops/deform_conv.py @@ -56,7 +56,8 @@ class DeformConv2dFunction(Function): input_tensor, grad_output, offset_out, weight, offset_all, kernel_size=[weight.shape[3], weight.shape[2]], stride=[1, 1, ctx.stride[0], ctx.stride[1]], - padding=[1, 1, ctx.padding[0], ctx.padding[1]], + padding=[ctx.padding[0], ctx.padding[0], ctx.padding[1], + ctx.padding[1]], dilation=[1, 1, ctx.dilation[0], ctx.dilation[1]], groups=ctx.groups, deformable_groups=ctx.deform_groups, modulated=True) diff --git a/mmcv/ops/modulated_deform_conv.py b/mmcv/ops/modulated_deform_conv.py index a313745a4..4c735e2a0 100644 --- a/mmcv/ops/modulated_deform_conv.py +++ b/mmcv/ops/modulated_deform_conv.py @@ -63,7 +63,9 @@ class ModulatedDeformConv2dFunction(Function): conv2d_bias, kernel_size=[kernel_w, kernel_h], stride=[1, 1, ctx.stride[0], ctx.stride[1]], - padding=[1, 1, ctx.padding[0], ctx.padding[1]], + padding=[ + ctx.padding[0], ctx.padding[0], ctx.padding[1], ctx.padding[1] + ], dilation=[1, 1, ctx.dilation[0], ctx.dilation[1]], groups=ctx.groups, deformable_groups=ctx.deform_groups, @@ -83,7 +85,8 @@ class ModulatedDeformConv2dFunction(Function): input_tensor, grad_output, offset_out, weight, offset_all, kernel_size=[weight.shape[3], weight.shape[2]], stride=[1, 1, ctx.stride[0], ctx.stride[1]], - padding=[1, 1, ctx.padding[0], ctx.padding[1]], + padding=[ctx.padding[0], ctx.padding[0], ctx.padding[1], + ctx.padding[1]], dilation=[1, 1, ctx.dilation[0], ctx.dilation[1]], groups=ctx.groups, deformable_groups=ctx.deform_groups, modulated=True)