Skip to content

MAINT: simplify power fast path logic #27901

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 28 commits into from
Jan 7, 2025
Merged
Changes from 1 commit
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
6923108
MAINT: remove fast paths from array power
MaanasArora Dec 4, 2024
8196fbb
MAINT: Add fast paths to power loops
MaanasArora Dec 4, 2024
4090a1c
MAINT: Clean loops for integer power in umath
MaanasArora Dec 4, 2024
91dd9dd
MAINT: Remove blocking regression test for power fast paths
MaanasArora Dec 4, 2024
c0e88c8
MAINT: Add helper function for power fast paths
MaanasArora Dec 4, 2024
c00489d
BUG: Change misspelled bitwise and to logical and
MaanasArora Dec 4, 2024
1d9f355
BUG: Fix missing value on power helper return
MaanasArora Dec 4, 2024
4b2920c
BUG: Fix exponent bitwise logic in power fast paths
MaanasArora Dec 4, 2024
dd6e773
MAINT: Add power fast paths to floating point umath
MaanasArora Dec 4, 2024
c95bff2
MAINT: Add fast power paths to array power when exponent is python ob…
MaanasArora Dec 4, 2024
084416e
MAINT: Fix division by zero runtime warning in test regression
MaanasArora Dec 4, 2024
e23423c
MAINT: Adapt object regression test for linalg to power fast paths
MaanasArora Dec 5, 2024
7cad24e
MAINT: Remove incorrect declarations in power fast paths
MaanasArora Dec 5, 2024
c028996
MAINT: Reduce calls to power fast path helper when scalar is ineligible
MaanasArora Dec 5, 2024
3297309
MAINT: Fix missing sliding loop
MaanasArora Dec 5, 2024
455407f
BUG: Fix syntax error
MaanasArora Dec 5, 2024
df6f54a
MAINT: Fix semantic misuse of -1 for non-error returns
MaanasArora Dec 5, 2024
d10bce5
MAINT: Improve error checking in power fast paths to remove PyErr_Clear
MaanasArora Dec 5, 2024
21c12a6
MAINT: Improve type checking in power fast paths
MaanasArora Dec 5, 2024
c9929ff
MAINT: Efficient handling of ones arrays in scalar fast paths
MaanasArora Dec 5, 2024
ed449e7
MAINT: Simplify outer check for scalar power fast paths
MaanasArora Dec 6, 2024
ba24783
MAINT: Reduce code reuse in float power fast paths and add reciprocal
MaanasArora Dec 6, 2024
b5f8a2b
MAINT: Remove Python scalar checking for fast power paths
MaanasArora Dec 10, 2024
023d55a
MAINT: Add benchmarks for power operators in float binary bench
MaanasArora Dec 11, 2024
efbd6b8
MAINT: Add scalar power fast paths
MaanasArora Dec 11, 2024
31418e9
BUG: Add missing pointer cast
MaanasArora Dec 11, 2024
a5d0ef4
BUG: Allow scalar power fast paths only for non-integers
MaanasArora Dec 11, 2024
2e0f6ca
MAINT: Restore outdated changes in regression test to master
MaanasArora Dec 27, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
MAINT: Reduce code reuse in float power fast paths and add reciprocal
  • Loading branch information
MaanasArora committed Dec 6, 2024
commit ba2478384bea7c0668ff7fcdb6b2028b2e5dafcd
35 changes: 17 additions & 18 deletions numpy/_core/src/umath/loops_umath_fp.dispatch.c.src
Original file line number Diff line number Diff line change
Expand Up @@ -239,31 +239,30 @@ NPY_NO_EXPORT void NPY_CPU_DISPATCH_CURFX(@TYPE@_@func@)
if (stride_zero) {
BINARY_DEFS
const @type@ in2 = *(@type@ *)ip2;
if (in2 == 0.0) {
BINARY_LOOP_SLIDING {
int fastop_found = 1;
BINARY_LOOP_SLIDING {
const @type@ in1 = *(@type@ *)ip1;
if (in2 == -1.0) {
*(@type@ *)op1 = 1.0 / in1;
}
else if (in2 == 0.0) {
*(@type@ *)op1 = 1.0;
}
return;
}
else if (in2 == 0.5) {
BINARY_LOOP_SLIDING {
const @type@ in1 = *(@type@ *)ip1;
*(@type@ *)op1 = sqrt(in1);
else if (in2 == 0.5) {
*(@type@ *)op1 = @sqrt@(in1);
}
return;
}
else if (in2 == 1.0) {
BINARY_LOOP_SLIDING {
const @type@ in1 = *(@type@ *)ip1;
else if (in2 == 1.0) {
*(@type@ *)op1 = in1;
}
return;
}
else if (in2 == 2.0) {
BINARY_LOOP_SLIDING {
const @type@ in1 = *(@type@ *)ip1;
else if (in2 == 2.0) {
*(@type@ *)op1 = in1 * in1;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In fact, here we also should maybe just call the normal multiply loop (with duplicated op1 pointer).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will do with the SQRT!

}
else {
fastop_found = 0;
break;
}
}
if (fastop_found) {
return;
}
}
Expand Down
Loading
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