Skip to content

Commit

Permalink
Merge pull request #2394 from zcc-zjut/mask
Browse files Browse the repository at this point in the history
Masked_conv2d NPU
  • Loading branch information
ckirchhoff2021 committed Nov 7, 2022
2 parents e3d78a8 + 97e35bc commit ab36885
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions mmcv/ops/masked_conv.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,15 @@ def forward(ctx,
weight,
bias,
stride=(stride_h, stride_w),
padding=padding,
padding=(pad_h, pad_w),
dilation=(1, 1),
groups=1)
features_h, features_w = features.size()[2:]
mask_reshape = mask.reshape(1, 1, features_h, features_w)
mask_bool = mask_reshape > 0
output = conv * mask_bool
if mask.size()[1:] != conv.size()[2:]:
raise ValueError(
'The mask is inconsistent with the shape of output_conv.')
conv_h, conv_w = conv.size()[2:]
mask_reshape = mask.reshape(1, 1, conv_h, conv_w)
output = conv * mask_reshape
return output

batch_size = features.size(0)
Expand Down

0 comments on commit ab36885

Please sign in to comment.