Refactor Calibration to calculate scales and biases instead of just scale bounds.
This will enable the addition of bias calculation to AQT.
Itemized changes:
Moves po2_scale and scale_dtype from Quantizer to Calibration.
Renames scale in Calibration subclasses to clipping_factor to reflect it's function and avoid confusion with quantization scales.
Adds init_calibration calls to config_test.py to ensure that changes to Calibration configuration are caught.
Adds support for a constant bias to ConstantCalibration.
NOTE: If Calibration.dtype is None then the scale is now guaranteed to have the same dtype as the input. This was the stated behavior of Quantizer.scale_dtype, but it would default to float32 for integer inputs because of the division by abs_val_mapped_to after the bound was cast to x.dtype. Quantizing an integer input with Calibration.dtype = None will now throw an error.
Refactor
Calibration
to calculate scales and biases instead of just scale bounds.This will enable the addition of bias calculation to AQT.
Itemized changes:
po2_scale
andscale_dtype
fromQuantizer
toCalibration
.scale
inCalibration
subclasses toclipping_factor
to reflect it's function and avoid confusion with quantization scales.init_calibration
calls toconfig_test.py
to ensure that changes toCalibration
configuration are caught.ConstantCalibration
.NOTE: If
Calibration.dtype is None
then the scale is now guaranteed to have the samedtype
as the input. This was the stated behavior ofQuantizer.scale_dtype
, but it would default tofloat32
for integer inputs because of the division byabs_val_mapped_to
after the bound was cast tox.dtype
. Quantizing an integer input withCalibration.dtype = None
will now throw an error.