Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 93cbbbe

Browse files
ENH: Add SIMD versions of bool logical_and, logical_or, logical_not and absolute
NumPy has SIMD versions of BOOL `logical_and`, `logical_or`, `logical_not`, and `absolute` for SSE2. The changes here replace that implementation with one that uses their universal intrinsics. This allows other architectures to have SIMD versions of the functions too. BOOL `logical_and` and `logical_or` are particularly important for NumPy as that's how `np.any()` / `np.all()` are implemented.
1 parent 28c81bc commit 93cbbbe

8 files changed

Lines changed: 1614 additions & 307 deletions

File tree

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,7 @@ numpy/core/src/umath/loops_unary.dispatch.c
220220
numpy/core/src/umath/loops_unary_fp.dispatch.c
221221
numpy/core/src/umath/loops_arithm_fp.dispatch.c
222222
numpy/core/src/umath/loops_arithmetic.dispatch.c
223+
numpy/core/src/umath/loops_logical.dispatch.c
223224
numpy/core/src/umath/loops_minmax.dispatch.c
224225
numpy/core/src/umath/loops_trigonometric.dispatch.c
225226
numpy/core/src/umath/loops_exponent_log.dispatch.c

numpy/core/code_generators/generate_umath.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -413,6 +413,7 @@ def english_upper(s):
413413
docstrings.get('numpy.core.umath.absolute'),
414414
'PyUFunc_AbsoluteTypeResolver',
415415
TD(bints+flts+timedeltaonly, dispatch=[('loops_unary_fp', 'fd')]),
416+
TD('?', dispatch=[('loops_logical', '?')]),
416417
TD(cmplx, simd=[('avx512f', cmplxvec)], out=('f', 'd', 'g')),
417418
TD(O, f='PyNumber_Absolute'),
418419
),
@@ -496,20 +497,23 @@ def english_upper(s):
496497
Ufunc(2, 1, True_,
497498
docstrings.get('numpy.core.umath.logical_and'),
498499
'PyUFunc_SimpleBinaryComparisonTypeResolver',
500+
TD('?', dispatch=[('loops_logical', '?')]),
499501
TD(nodatetime_or_obj, out='?', simd=[('avx2', ints)]),
500502
TD(O, f='npy_ObjectLogicalAnd'),
501503
),
502504
'logical_not':
503505
Ufunc(1, 1, None,
504506
docstrings.get('numpy.core.umath.logical_not'),
505507
None,
508+
TD('?', dispatch=[('loops_logical', '?')]),
506509
TD(nodatetime_or_obj, out='?', simd=[('avx2', ints)]),
507510
TD(O, f='npy_ObjectLogicalNot'),
508511
),
509512
'logical_or':
510513
Ufunc(2, 1, False_,
511514
docstrings.get('numpy.core.umath.logical_or'),
512515
'PyUFunc_SimpleBinaryComparisonTypeResolver',
516+
TD('?', dispatch=[('loops_logical', '?')]),
513517
TD(nodatetime_or_obj, out='?', simd=[('avx2', ints)]),
514518
TD(O, f='npy_ObjectLogicalOr'),
515519
),

numpy/core/setup.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1009,6 +1009,7 @@ def generate_umath_doc_header(ext, build_dir):
10091009
join('src', 'umath', 'loops_unary_fp.dispatch.c.src'),
10101010
join('src', 'umath', 'loops_arithm_fp.dispatch.c.src'),
10111011
join('src', 'umath', 'loops_arithmetic.dispatch.c.src'),
1012+
join('src', 'umath', 'loops_logical.dispatch.c.src'),
10121013
join('src', 'umath', 'loops_minmax.dispatch.c.src'),
10131014
join('src', 'umath', 'loops_trigonometric.dispatch.c.src'),
10141015
join('src', 'umath', 'loops_umath_fp.dispatch.c.src'),

0 commit comments

Comments
 (0)