Skip to content

Commit fe00888

Browse files
committed
strides comparison performance fix, compare discussion #29179
1 parent 2f4ace7 commit fe00888

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

numpy/_core/src/umath/matmul.c.src

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@
2727
*****************************************************************************
2828
*/
2929

30+
#define ABS(x) ((x) < 0 ? -(x) : (x))
31+
3032
#if defined(HAVE_CBLAS)
3133
/*
3234
* -1 to be conservative, in case blas internally uses a for loop with an
@@ -554,9 +556,9 @@ NPY_NO_EXPORT void
554556
} else {
555557
/* matrix @ matrix
556558
* copy if not blasable, see gh-12365 & gh-23588 */
557-
npy_bool i1_transpose = is1_m < is1_n,
558-
i2_transpose = is2_n < is2_p,
559-
o_transpose = os_m < os_p;
559+
npy_bool i1_transpose = ABS(is1_m) < ABS(is1_n),
560+
i2_transpose = ABS(is2_n) < ABS(is2_p),
561+
o_transpose = ABS(os_m) < ABS(os_p);
560562

561563
npy_intp tmp_is1_m = i1_transpose ? sz : sz*dn,
562564
tmp_is1_n = i1_transpose ? sz*dm : sz,

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy