Hi all,

I would like to let you know that in https://github.com/numpy/numpy/pull/32231, 
we are implementing a fused np.minmax implementation that uses the mechanism to 
register reduction loops to ufuncs added in 
https://github.com/numpy/numpy/pull/31816. The implementation includes 
optimizations such as loop unrolling and SIMD (similar to the ones np.min/max 
were already using). This obviously does not remove any actual computation as 
both min and max need to be computed but it does them in a single pass over the 
input array. We saw a 1.25x to a 2x improvement over consecutive min/max calls 
depending on the axis being reduced and the dtype (the 2x comes in the cases 
where the computation is mostly limited by reading from memory).

This is a long requested feature for NumPy (see 
https://github.com/numpy/numpy/issues/9836 and 
https://stackoverflow.com/questions/12200580/numpy-function-for-simultaneous-max-and-min
 for example)

There are ~15 sites in NumPy and ~70 sites in SciPy where both min and max are 
computed consecutively and np.minmax can replace those.

I'm just sending this email out to inform the community and to also welcome 
feedback if people think this is a bad idea or have thoughts to share.

Cheers,
Iason.
_______________________________________________
NumPy-Discussion mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3//lists/numpy-discussion.python.org
Member address: [email protected]

Reply via email to