-
-
Notifications
You must be signed in to change notification settings - Fork 11k
ENH: Create boolean and integer ufuncs for isnan, isinf, and isfinite. #12988
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -64,6 +64,8 @@ | |
#define IS_UNARY_CONT(tin, tout) (steps[0] == sizeof(tin) && \ | ||
steps[1] == sizeof(tout)) | ||
|
||
#define IS_OUTPUT_CONT(tout) (steps[1] == sizeof(tout)) | ||
|
||
#define IS_BINARY_REDUCE ((args[0] == args[2])\ | ||
&& (steps[0] == steps[2])\ | ||
&& (steps[0] == 0)) | ||
|
@@ -82,6 +84,29 @@ | |
steps[2] == sizeof(tout)) | ||
|
||
|
||
/* | ||
* loop with contiguous specialization | ||
* op should be the code storing the result in `tout * out` | ||
* combine with NPY_GCC_OPT_3 to allow autovectorization | ||
* should only be used where its worthwhile to avoid code bloat | ||
*/ | ||
#define BASE_OUTPUT_LOOP(tout, op) \ | ||
OUTPUT_LOOP { \ | ||
tout * out = (tout *)op1; \ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can omit the space after There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixed in #13208 |
||
op; \ | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Blank line between macros. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixed in #13208 |
||
#define OUTPUT_LOOP_FAST(tout, op) \ | ||
do { \ | ||
/* condition allows compiler to optimize the generic macro */ \ | ||
if (IS_OUTPUT_CONT(tout)) { \ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should be indented. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this matches the existing macros, sadly There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please see #13208 - I have fixed the indentation for all macros in this file |
||
BASE_OUTPUT_LOOP(tout, op) \ | ||
} \ | ||
else { \ | ||
BASE_OUTPUT_LOOP(tout, op) \ | ||
} \ | ||
} \ | ||
while (0) | ||
|
||
/* | ||
* loop with contiguous specialization | ||
* op should be the code working on `tin in` and | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -644,6 +644,19 @@ BOOL__ones_like(char **args, npy_intp *dimensions, npy_intp *steps, void *NPY_UN | |
} | ||
|
||
|
||
/**begin repeat | ||
* #kind = isnan, isinf, isfinite# | ||
* #func = npy_isnan, npy_isinf, npy_isfinite# | ||
* #val = NPY_FALSE, NPY_FALSE, NPY_TRUE# | ||
**/ | ||
NPY_NO_EXPORT void | ||
BOOL_@kind@(char **args, npy_intp *dimensions, npy_intp *steps, void *NPY_UNUSED(func)) | ||
{ | ||
OUTPUT_LOOP_FAST(npy_bool, *out = @val@); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why not just pass the value and move the assignment to the macro where There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It was entirely to preserve calling convention to be similar to the other macros - I've implemented your suggestion in #13208 |
||
} | ||
|
||
/**end repeat**/ | ||
|
||
/* | ||
***************************************************************************** | ||
** INTEGER LOOPS | ||
|
@@ -875,6 +888,18 @@ NPY_NO_EXPORT void | |
} | ||
} | ||
|
||
/**begin repeat1 | ||
* #kind = isnan, isinf, isfinite# | ||
* #func = npy_isnan, npy_isinf, npy_isfinite# | ||
* #val = NPY_FALSE, NPY_FALSE, NPY_TRUE# | ||
**/ | ||
NPY_NO_EXPORT void | ||
@TYPE@_@kind@(char **args, npy_intp *dimensions, npy_intp *steps, void *NPY_UNUSED(func)) | ||
{ | ||
OUTPUT_LOOP_FAST(npy_bool, *out = @val@); | ||
} | ||
/**end repeat1**/ | ||
|
||
/**end repeat**/ | ||
|
||
/**begin repeat | ||
|
Uh oh!
There was an error while loading. Please reload this page.