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

[Fix] Fix saconv #1147

Merged
merged 5 commits into from
Jul 2, 2021
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
6 changes: 4 additions & 2 deletions mmcv/ops/saconv.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,8 @@ def forward(self, x):
switch = self.switch(avg_x)
# sac
weight = self._get_weight(self.weight)
zero_bias = torch.zeros(self.out_channels, device=weight.device)
kennymckormick marked this conversation as resolved.
Show resolved Hide resolved

if self.use_deform:
offset = self.offset_s(avg_x)
out_s = deform_conv2d(x, offset, weight, self.stride, self.padding,
Expand All @@ -106,7 +108,7 @@ def forward(self, x):
if TORCH_VERSION < '1.5.0' or TORCH_VERSION == 'parrots':
out_s = super().conv2d_forward(x, weight)
else:
out_s = super()._conv_forward(x, weight)
out_s = super()._conv_forward(x, weight, zero_bias)
ZwwWayne marked this conversation as resolved.
Show resolved Hide resolved
ori_p = self.padding
ori_d = self.dilation
self.padding = tuple(3 * p for p in self.padding)
Expand All @@ -120,7 +122,7 @@ def forward(self, x):
if TORCH_VERSION < '1.5.0' or TORCH_VERSION == 'parrots':
out_l = super().conv2d_forward(x, weight)
else:
out_l = super()._conv_forward(x, weight)
out_l = super()._conv_forward(x, weight, zero_bias)
out = switch * out_s + (1 - switch) * out_l
self.padding = ori_p
self.dilation = ori_d
Expand Down