Skip to content

Commit

Permalink
Update on "[reland][quant][fix] Add bias once in conv_fused (#48593)"
Browse files Browse the repository at this point in the history
Summary:
Previously _conv_forward will add self.bias to the result, so bias is added twice in qat ConvBn module
this PR added a bias argument to _conv_forward and _conv_forward is called with zero bias
in ConvBn module

fixes: #48514

Test Plan: Imported from OSS

Reviewed By: raghuramank100

Differential Revision: [D25249175](https://our.internmc.facebook.com/intern/diff/D25249175)

[ghstack-poisoned]
  • Loading branch information
jerryzh168 committed Dec 2, 2020
1 parent 118c96f commit a97f4ca
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion torch/nn/intrinsic/qat/modules/conv_fused.py
Expand Up @@ -93,7 +93,8 @@ def _forward(self, input):
bias_shape = [1] * len(self.weight.shape)
bias_shape[1] = -1
scaled_weight = self.weight_fake_quant(self.weight * scale_factor.reshape(weight_shape))
# this does not include the conv bias
# using zero bias here since the bias for original conv
# will be added later
if self.bias:
zero_bias = torch.zeros_like(self.bias)
else:
Expand Down

0 comments on commit a97f4ca

Please sign in to comment.