Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Masked_conv2d NPU #2394

Merged
merged 2 commits into from
Nov 7, 2022
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 consistent with the shape of output_conv.')
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should be 'is not' rather than 'is'.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok

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