Description
In pytorch-quantization package, the _normalize_distr(distr) function in entropy calibrator is not right.
def _normalize_distr(distr):
summ = np.sum(distr)
if summ != 0:
distr = distr / summ
This won't actually normalize the input distr as expected. The distr = is a new array. To achieve in-place, it should be distr /= summ.
The reason this calibrator still works is that in scipy's entropy function, scipy also performs normalization. But we better fix it here in case scipy changes its implementation.
Description
In pytorch-quantization package, the _normalize_distr(distr) function in entropy calibrator is not right.
This won't actually normalize the input distr as expected. The
distr =is a new array. To achieve in-place, it should bedistr /= summ.The reason this calibrator still works is that in scipy's entropy function, scipy also performs normalization. But we better fix it here in case scipy changes its implementation.