Skip to content

BUG: inaccurate 8-bit unsigned integer division when the divisor is a scalar #20168

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

Closed
seiko2plus opened this issue Oct 23, 2021 · 1 comment · Fixed by #20153
Closed

BUG: inaccurate 8-bit unsigned integer division when the divisor is a scalar #20168

seiko2plus opened this issue Oct 23, 2021 · 1 comment · Fixed by #20153
Labels
00 - Bug component: SIMD Issues in SIMD (fast instruction sets) code or machinery

Comments

@seiko2plus
Copy link
Member

seiko2plus commented Oct 23, 2021

Describe the issue:

The bug appears when the divisor is a scalar, ceil(log2(divisor)) == 8 and the dividend length >= 64 or 32 or 16 depend on the enabled SIMD extension e.g. on AVX2 length >= 32

Reproduce the code example:

>>> import numpy as np
>>> np.arange(0, 32, dtype=np.uint8) // 132 # ceil(log2(132)) == 8
array([0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
       1, 0, 1, 0, 1, 0, 1, 0, 1, 0], dtype=uint8)
>>> # while it should return the following instead
>>> np.arange(0, 32, dtype=np.uint16) // 132
array([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
       0, 0, 0, 0, 0, 0, 0, 0, 0, 0], dtype=uint16)

Error message:

No response

NumPy/Python version information:

1.21.3 3.9.5 (default, May 19 2021, 11:32:47)
[GCC 10.2.0]

related to #20025, #18766, #18178

@seiko2plus
Copy link
Member Author

fixed by #20153.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
00 - Bug component: SIMD Issues in SIMD (fast instruction sets) code or machinery
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant