Skip to content

Commit

Permalink
Fix (test): custom a2q quantizer for ort tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Giuseppe5 committed Oct 31, 2023
1 parent 0929560 commit 04af0d2
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion tests/brevitas_ort/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,22 @@
FLOAT_TOLERANCE = 1e-6
KERNEL_SIZE = 1 # keep float error during fake-quantization under control
BIT_WIDTHS = range(2, 9)
ACCUMULATOR_BIT_WIDTH_FOR_TESTS = 16


# For testing purpose, we create a custom quantizer with a reduced bitwidth for the accumulator
class A2QWeightQuantizerForTests(Int8AccumulatorAwareWeightQuant):
accumulator_bit_width = ACCUMULATOR_BIT_WIDTH_FOR_TESTS


WBIOL_QUANTIZERS = {
'asymmetric_per_tensor_float':
(ShiftedUint8WeightPerTensorFloat, ShiftedUint8ActPerTensorFloat),
'symmetric_per_tensor_float': (Int8WeightPerTensorFloat, Int8ActPerTensorFloat),
'asymmetric_per_channel_float':
(ShiftedUint8WeightPerChannelFloat, ShiftedUint8ActPerTensorFloat),
'symmetric_per_channel_float': (Int8WeightPerChannelFloat, Int8ActPerTensorFloat),
'a2q': (Int8AccumulatorAwareWeightQuant, Int8ActPerTensorFloat),
'a2q': (A2QWeightQuantizerForTests, Int8ActPerTensorFloat),
'symmetric_per_tensor_fixed_point': (Int8WeightPerTensorFixedPoint, Int8ActPerTensorFixedPoint),
'symmetric_per_channel_fixed_point':
(Int8WeightPerChannelFixedPoint, Int8ActPerTensorFixedPoint)}
Expand Down

0 comments on commit 04af0d2

Please sign in to comment.