google / qkeras

QKeras: a quantization deep learning library for Tensorflow Keras
Apache License 2.0
533 stars 102 forks source link

removed the integer and bits scaling in quantized bits for alpha=auto and alpha=auto_po2 #128

Closed fabrizioaymone closed 3 months ago

fabrizioaymone commented 6 months ago

In the quantized_bits class, when alpha=auto or alpha=auto_po2, the unquantized value "x" is manipulated in a strange way. Even if the number of integer bits is not considered when scaling with alpha=auto and alpha=auto_po2, "x" is divided by m_i (, namely 2**integer_bits) to be later remultiplied by the same value m_i. As x is originally divided by m_i, z (which depends on x) is later multiplied by m_i and divided by m. In order to adjust for the division by m, the scale factor (which multiplies z) is multiplied by m.

I removed the m_i and m references in the code as they don't matter when considering alpha=auto or alpha=auto_po2. I also tested this new version of the quantizer with older versions and the result is the same.

google-cla[bot] commented 6 months ago

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.