Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

_normalize_distr function bug in entropy calibrator #4384

Open
PT0X0E opened this issue Mar 14, 2025 · 2 comments
Open

_normalize_distr function bug in entropy calibrator #4384

PT0X0E opened this issue Mar 14, 2025 · 2 comments

Comments

@PT0X0E
Copy link

PT0X0E commented Mar 14, 2025

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.

@lix19937
Copy link

see #3752

@lix19937
Copy link

BTW, Pytorch Quantization no longer receive further development.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants