Skip to content

Commit

Permalink
fix deformConv and modulatedDeformConv input kernel_size
Browse files Browse the repository at this point in the history
  • Loading branch information
wuzheyi1028 committed Jun 17, 2024
1 parent 859a2cc commit 15ad155
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion mmcv/ops/deform_conv.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def _npu_backward(ctx, grad_output):
grad_input, grad_weight, grad_offset_all, grad_bias = \
torch.npu_deformable_conv2dbk(
input_tensor, grad_output, offset_out, weight, offset_all,
kernel_size=[weight.shape[3], weight.shape[2]],
kernel_size=[weight.shape[2], weight.shape[3]],
stride=[1, 1, ctx.stride[0], ctx.stride[1]],
padding=[ctx.padding[0], ctx.padding[0], ctx.padding[1],
ctx.padding[1]],
Expand Down
2 changes: 1 addition & 1 deletion mmcv/ops/masked_conv.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def forward(ctx,
stride_h, stride_w = _pair(stride)
if stride_h != 1 or stride_w != 1:
raise ValueError(
'Stride could not only be 1 in masked_conv2d currently.')
'Stride could only be 1 in masked_conv2d currently.')
out_channel, in_channel, kernel_h, kernel_w = weight.size()

if features.device.type == 'npu':
Expand Down
6 changes: 3 additions & 3 deletions mmcv/ops/modulated_deform_conv.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,15 +53,15 @@ def _npu_forward(ctx, input_tensor, offset, mask, weight, bias):
conv2d_bias = bias if len(bias) > 0 else None
sort_index_fp, sort_index_bp = \
ModulatedDeformConv2dFunction._calculate_sort_index(
kernel_w, kernel_h, ctx.deform_groups)
kernel_h, kernel_w, ctx.deform_groups)
select_offset = offset.index_select(1, sort_index_fp)
offset_all = torch.cat([select_offset, mask], dim=1)
output, offset_out = torch.npu_deformable_conv2d(
input_tensor,
weight,
offset_all,
conv2d_bias,
kernel_size=[kernel_w, kernel_h],
kernel_size=[kernel_h, kernel_w],
stride=[1, 1, ctx.stride[0], ctx.stride[1]],
padding=[
ctx.padding[0], ctx.padding[0], ctx.padding[1], ctx.padding[1]
Expand All @@ -83,7 +83,7 @@ def _npu_backward(ctx, grad_output):
grad_input, grad_weight, grad_offset_all, grad_bias = \
torch.npu_deformable_conv2dbk(
input_tensor, grad_output, offset_out, weight, offset_all,
kernel_size=[weight.shape[3], weight.shape[2]],
kernel_size=[weight.shape[2], weight.shape[3]],
stride=[1, 1, ctx.stride[0], ctx.stride[1]],
padding=[ctx.padding[0], ctx.padding[0], ctx.padding[1],
ctx.padding[1]],
Expand Down

0 comments on commit 15ad155

Please sign in to comment.