Skip to content

Commit

Permalink
[fix] fix LSQObserver bug (#180)
Browse files Browse the repository at this point in the history
  • Loading branch information
jixiege authored and Tracin committed Sep 14, 2022
1 parent 80345e5 commit 8cc2477
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions mqbench/observer.py
Expand Up @@ -410,7 +410,7 @@ def forward(self, x_orig):
y = x.permute(new_axis_list)
y = torch.flatten(y, start_dim=1)
self.tensor_norm = y.abs().mean(1)
self.min_val, self.max_val = torch._aminmax(y)
self.min_val, self.max_val = torch._aminmax(y, 1)

return x

Expand All @@ -422,8 +422,7 @@ def calculate_qparams(self):
if self.pot_scale:
scale = pot_quantization(scale)
if not is_symmetric_quant(self.qscheme):
if self.min_val >= 0.:
zero_point = self.quant_min - torch.round(self.min_val / scale)
zero_point = self.quant_min - torch.round(self.min_val / scale)
return scale, zero_point


Expand Down

0 comments on commit 8cc2477

Please sign in to comment.