-
-
Notifications
You must be signed in to change notification settings - Fork 12.2k
BUG: invalid value encountered in rint/floor/ceil/trunc on X86(SSE2) and ARMHF(NEON) #22797
Copy link
Copy link
Closed
Labels
00 - Bugcomponent: SIMDIssues in SIMD (fast instruction sets) code or machineryIssues in SIMD (fast instruction sets) code or machinery
Description
Describe the issue:
Passing any nonfinite float32 value to (rint, floor, ceil, trunc) will raise an invalid FP exception if SSE41 isn't enabled or not supported by the CPU (old x86). The same issue also exists on armhf.
Another case that appeared after #22750, passing float64 qNaN to (rint, floor, ceil, trunc) will also raise an invalid FP exception.
Reproduce the code example:
export NPY_DISABLE_CPU_FEATURES="SSE41"
Python 3.10.8 (main, Nov 1 2022, 14:18:21) [GCC 12.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import numpy as np
>>> np.seterr(all='raise')
{'divide': 'warn', 'over': 'warn', 'under': 'ignore', 'invalid': 'warn'}
>>> np.trunc(np.float32(-np.inf))
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
FloatingPointError: invalid value encountered in trunc
>>> np.trunc(np.float32(np.nan))
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
FloatingPointError: invalid value encountered in trunc
>>> np.trunc(np.float32(np.inf))
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
FloatingPointError: invalid value encountered in trunc
>>> np.rint(np.float32(np.inf))
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
FloatingPointError: invalid value encountered in rint
>>> np.ceil(np.float32(np.inf))
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
FloatingPointError: invalid value encountered in ceil
>>> np.floor(np.float32(np.inf))
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
FloatingPointError: invalid value encountered in floor
>>>Error message:
No response
NumPy/Python version information:
1.23.5 3.10.8 (main, Nov 1 2022, 14:18:21) [GCC 12.2.0]
Context for the issue:
No response
edit:armhf
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
00 - Bugcomponent: SIMDIssues in SIMD (fast instruction sets) code or machineryIssues in SIMD (fast instruction sets) code or machinery