Skip to content

Commit

Permalink
apply branching pattern
Browse files Browse the repository at this point in the history
  • Loading branch information
eendebakpt committed May 11, 2024
1 parent 3ff27fe commit 2eff77f
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 12 deletions.
10 changes: 0 additions & 10 deletions numpy/_core/src/umath/fast_loop_macros.h
Original file line number Diff line number Diff line change
Expand Up @@ -90,16 +90,6 @@ abs_ptrdiff(char *a, char *b)
BINARY_DEFS\
BINARY_LOOP_SLIDING

/** (ip1, ip2) -> (op1), for case ip2 has zero stride*/
#define BINARY_DEFS_ZERO_STRIDE\
char *ip1 = args[0], *ip2 = args[1], *op1 = args[2];\
npy_intp is1 = steps[0], os1 = steps[2];\
npy_intp n = dimensions[0];\
npy_intp i;\

#define BINARY_LOOP_SLIDING_ZERO_STRIDE \
for (i = 0; i < n; i++, ip1 += is1, op1 += os1)

/** (ip1, ip2) -> (op1, op2) */
#define BINARY_LOOP_TWO_OUT\
char *ip1 = args[0], *ip2 = args[1], *op1 = args[2], *op2 = args[3];\
Expand Down
4 changes: 2 additions & 2 deletions numpy/_core/src/umath/loops_umath_fp.dispatch.c.src
Original file line number Diff line number Diff line change
Expand Up @@ -237,10 +237,10 @@ NPY_NO_EXPORT void NPY_CPU_DISPATCH_CURFX(@TYPE@_@func@)
{
int stride_zero = steps[1]==0;
if (stride_zero) {
BINARY_DEFS_ZERO_STRIDE
BINARY_DEFS
const @type@ in2 = *(@type@ *)ip2;
if (in2 == 2.0) {
BINARY_LOOP_SLIDING_ZERO_STRIDE {
BINARY_LOOP_SLIDING {
const @type@ in1 = *(@type@ *)ip1;
*(@type@ *)op1 = in1 * in1;
}
Expand Down

0 comments on commit 2eff77f

Please sign in to comment.