Skip to content

Commit

Permalink
Test (quantize): preliminary unit tests to the CNNs 'quantize_model' (#…
Browse files Browse the repository at this point in the history
…927)

* Added some prelininary unit tests to the CNNs 'quantize_model'. We test some aspects of 'layerwise' and 'fx' quantization, as well as some invalid inputs, e.g. invalid strings and zero and negative valued bit widths.

* We test po2 scale values, and have the negative bit widths fail.

* Updated to lastest dev

* Added tests for symm/asym quantization, per_chan quantization, and started work on minifloat quantization

* Remove unecessary inputs for minifloat

* Removed minifloat tests

* Add tests for checking calibration percentile performance, and testing MSE for qparam calibration.

* Fix default and condition

* Use Brevitas FX

---------

Co-authored-by: Giuseppe Franco <giuseppefranco4@gmail.com>
  • Loading branch information
OscarSavolainenDR and Giuseppe5 authored Jul 29, 2024
1 parent cc26a62 commit 55fd0ea
Show file tree
Hide file tree
Showing 2 changed files with 816 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ def quantize_model(
act_param_method='stats',
weight_quant_type='sym',
act_quant_granularity='per_tensor',
act_scale_computation_type='dynamic',
act_scale_computation_type='static',
uint_sym_act_for_unsigned_values=True,
dtype=torch.float32,
device='cpu'):
Expand All @@ -196,7 +196,7 @@ def quantize_model(
act_mantissa_bit_width,
act_exponent_bit_width)

if act_scale_computation_type == 'dynamic':
if act_scale_computation_type == 'dynamic' and backend != 'layerwise':
assert bias_bit_width is None, "Bias quantization is not supported with dynamic activation quantization"

weight_quant_format = quant_format
Expand Down Expand Up @@ -602,4 +602,5 @@ def check_positive_int(*args):
if arg is None:
continue
assert arg > 0.0
assert not math.isclose(arg, 0.0)
assert math.isclose(arg % 1, 0.0)
Loading

0 comments on commit 55fd0ea

Please sign in to comment.