Skip to content

Commit

Permalink
Fix another regression, which should also minimize QD-ID divergence
Browse files Browse the repository at this point in the history
  • Loading branch information
FrancescoConti committed May 8, 2020
1 parent ea7b429 commit 1174ba7
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions nemo/quant/pact.py
Original file line number Diff line number Diff line change
Expand Up @@ -424,7 +424,7 @@ def forward(self, x):

if self.deployment:
x_rq = pact_quantized_requantize(x, self.eps_in, self.eps_static, self.D, exclude_requant_rounding=self.precise) * self.eps_static
return x_rq.clamp(0, self.alpha_static.data[0] - self.eps_static.data[0])
return x_rq.clamp(0, self.alpha_static.data[0])
elif self.statistics_only:
if self.leaky is None:
x = torch.nn.functional.relu(x)
Expand All @@ -438,7 +438,7 @@ def forward(self, x):
return x
else:
eps = self.alpha/(2.0**(self.precision.get_bits())-1)
return pact_quantize(x, eps, self.alpha)
return pact_quantize(x, eps, self.alpha + eps)

class PACT_IntegerAdd(torch.nn.Module):
r"""PACT (PArametrized Clipping acTivation) activation for integer images.
Expand Down

0 comments on commit 1174ba7

Please sign in to comment.