google / aqt

Apache License 2.0
248 stars 25 forks source link

Refactor `Calibration` to calculate scales and biases instead of just scale bounds. #700

Closed copybara-service[bot] closed 1 week ago

copybara-service[bot] commented 3 weeks ago

Refactor Calibration to calculate scales and biases instead of just scale bounds.

This will enable the addition of bias calculation to AQT.

Itemized changes:

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.