Skip to content

Commit 03b0a6e

Browse files
committed
REV: Manual revert of float16 svml use
This is a manual revert of numpygh-23351 since things were moved around quite a lot since then.
1 parent 3b02418 commit 03b0a6e

2 files changed

Lines changed: 1 addition & 45 deletions

File tree

numpy/_core/src/umath/loops_half.dispatch.c.src

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
#define NPY__SVML_IS_ENABLED 0
1313
#endif
1414

15-
#if NPY__SVML_IS_ENABLED && !defined(NPY_HAVE_AVX512_SPR)
15+
#if NPY__SVML_IS_ENABLED
1616

1717
typedef __m256i npyvh_f16;
1818
#define npyv_cvt_f16_f32 _mm512_cvtph_ps
@@ -80,11 +80,7 @@ NPY_NO_EXPORT void NPY_CPU_DISPATCH_CURFX(HALF_@func@)
8080
if (!is_mem_overlap(src, steps[0], dst, steps[1], len) &&
8181
(steps[0] == sizeof(npy_half)) &&
8282
(steps[1] == sizeof(npy_half))) {
83-
#ifdef NPY_HAVE_AVX512_SPR
84-
__svml_@intrin@s32(src, dst, len);
85-
#else
8683
avx512_@intrin@_f16(src, dst, len);
87-
#endif
8884
return;
8985
}
9086
#endif // NPY__SVML_IS_ENABLED

numpy/_core/tests/test_umath_accuracy.py

Lines changed: 0 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,6 @@
2121
IS_AVX = __cpu_features__.get('AVX512F', False) or \
2222
(__cpu_features__.get('FMA3', False) and __cpu_features__.get('AVX2', False))
2323

24-
IS_AVX512FP16 = __cpu_features__.get('AVX512FP16', False)
25-
2624
# only run on linux with AVX, also avoid old glibc (numpy/numpy#20448).
2725
runtest = (sys.platform.startswith('linux')
2826
and IS_AVX and not _glibc_older_than("2.17"))
@@ -84,8 +82,6 @@ def test_validate_transcendentals(self):
8482
maxulperr = data_subset['ulperr'].max()
8583
assert_array_max_ulp(npfunc(inval), outval, maxulperr)
8684

87-
@pytest.mark.skipif(IS_AVX512FP16,
88-
reason="SVML FP16 have slightly higher ULP errors")
8985
@pytest.mark.parametrize("ufunc", UNARY_OBJECT_UFUNCS)
9086
def test_validate_fp16_transcendentals(self, ufunc):
9187
with np.errstate(all='ignore'):
@@ -94,39 +90,3 @@ def test_validate_fp16_transcendentals(self, ufunc):
9490
datafp32 = datafp16.astype(np.float32)
9591
assert_array_max_ulp(ufunc(datafp16), ufunc(datafp32),
9692
maxulp=1, dtype=np.float16)
97-
98-
@pytest.mark.skipif(not IS_AVX512FP16,
99-
reason="lower ULP only apply for SVML FP16")
100-
def test_validate_svml_fp16(self):
101-
max_ulp_err = {
102-
"arccos": 2.54,
103-
"arccosh": 2.09,
104-
"arcsin": 3.06,
105-
"arcsinh": 1.51,
106-
"arctan": 2.61,
107-
"arctanh": 1.88,
108-
"cbrt": 1.57,
109-
"cos": 1.43,
110-
"cosh": 1.33,
111-
"exp2": 1.33,
112-
"exp": 1.27,
113-
"expm1": 0.53,
114-
"log": 1.80,
115-
"log10": 1.27,
116-
"log1p": 1.88,
117-
"log2": 1.80,
118-
"sin": 1.88,
119-
"sinh": 2.05,
120-
"tan": 2.26,
121-
"tanh": 3.00,
122-
}
123-
124-
with np.errstate(all='ignore'):
125-
arr = np.arange(65536, dtype=np.int16)
126-
datafp16 = np.frombuffer(arr.tobytes(), dtype=np.float16)
127-
datafp32 = datafp16.astype(np.float32)
128-
for func in max_ulp_err:
129-
ufunc = getattr(np, func)
130-
ulp = np.ceil(max_ulp_err[func])
131-
assert_array_max_ulp(ufunc(datafp16), ufunc(datafp32),
132-
maxulp=ulp, dtype=np.float16)

0 commit comments

Comments
 (0)