Skip to content

Commit

Permalink
Fix add QT
Browse files Browse the repository at this point in the history
  • Loading branch information
Giuseppe5 committed Mar 28, 2024
1 parent 8069731 commit 6f2c437
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/brevitas/quant_tensor/int_quant_tensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -332,16 +332,16 @@ def __add__(self, other):
bit_width=output_bit_width,
signed=output_signed,
training=output_training)
elif self.value.shape == other.shape:
else:
# When adding a QT with a normal Tensor, we use the zero_point as a way to preserve
# and return a QT.
output = QuantTensor(
value=self.value + other,
scale=self.scale,
zero_point=self.zero_point - other / self.scale,
bit_width=self.bit_width,
signed=self.signed,
training=self.training)
else:
output = self.value + other
return output

def __radd__(self, other):
Expand Down

0 comments on commit 6f2c437

Please sign in to comment.