Skip to content

Commit 5c8212c

Browse files
authored
move bitwise to descriptor part3 (#748)
1 parent e93e0f6 commit 5c8212c

File tree

2 files changed

+18
-15
lines changed

2 files changed

+18
-15
lines changed

dpnp/dpnp_algo/dpnp_algo_bitwise.pyx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,23 +45,23 @@ __all__ += [
4545

4646

4747
cpdef dparray dpnp_bitwise_and(object x1_obj, object x2_obj, object dtype=None, dparray out=None, object where=True):
48-
return call_fptr_2in_1out(DPNP_FN_BITWISE_AND, x1_obj, x2_obj, dtype=dtype, out=out, where=where)
48+
return call_fptr_2in_1out_new(DPNP_FN_BITWISE_AND, x1_obj, x2_obj, dtype=dtype, out=out, where=where)
4949

5050

5151
cpdef dparray dpnp_bitwise_or(object x1_obj, object x2_obj, object dtype=None, dparray out=None, object where=True):
52-
return call_fptr_2in_1out(DPNP_FN_BITWISE_OR, x1_obj, x2_obj, dtype=dtype, out=out, where=where)
52+
return call_fptr_2in_1out_new(DPNP_FN_BITWISE_OR, x1_obj, x2_obj, dtype=dtype, out=out, where=where)
5353

5454

5555
cpdef dparray dpnp_bitwise_xor(object x1_obj, object x2_obj, object dtype=None, dparray out=None, object where=True):
56-
return call_fptr_2in_1out(DPNP_FN_BITWISE_XOR, x1_obj, x2_obj, dtype=dtype, out=out, where=where)
56+
return call_fptr_2in_1out_new(DPNP_FN_BITWISE_XOR, x1_obj, x2_obj, dtype=dtype, out=out, where=where)
5757

5858

5959
cpdef dparray dpnp_invert(dparray arr):
6060
return call_fptr_1in_1out(DPNP_FN_INVERT, arr, arr.shape)
6161

6262

6363
cpdef dparray dpnp_left_shift(object x1_obj, object x2_obj, object dtype=None, dparray out=None, object where=True):
64-
return call_fptr_2in_1out(DPNP_FN_LEFT_SHIFT, x1_obj, x2_obj, dtype=dtype, out=out, where=where)
64+
return call_fptr_2in_1out_new(DPNP_FN_LEFT_SHIFT, x1_obj, x2_obj, dtype=dtype, out=out, where=where)
6565

6666
cpdef dparray dpnp_right_shift(object x1_obj, object x2_obj, object dtype=None, dparray out=None, object where=True):
67-
return call_fptr_2in_1out(DPNP_FN_RIGHT_SHIFT, x1_obj, x2_obj, dtype=dtype, out=out, where=where)
67+
return call_fptr_2in_1out_new(DPNP_FN_RIGHT_SHIFT, x1_obj, x2_obj, dtype=dtype, out=out, where=where)

dpnp/dpnp_iface_bitwise.py

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -61,23 +61,26 @@
6161

6262
def _check_nd_call(origin_func, dpnp_func, x1, x2, dtype=None, out=None, where=True, **kwargs):
6363
"""Choose function to call based on input and call chosen fucntion."""
64-
x1_is_scalar, x2_is_scalar = dpnp.isscalar(x1), dpnp.isscalar(x2)
65-
x1_is_dparray, x2_is_dparray = isinstance(x1, dparray), isinstance(x2, dparray)
6664

67-
if not use_origin_backend(x1) and not kwargs:
68-
if not x1_is_dparray and not x1_is_scalar:
65+
x1_is_scalar = dpnp.isscalar(x1)
66+
x2_is_scalar = dpnp.isscalar(x2)
67+
x1_desc = dpnp.get_dpnp_descriptor(x1)
68+
x2_desc = dpnp.get_dpnp_descriptor(x2)
69+
70+
if x1_desc and x2_desc and not kwargs:
71+
if not x1_desc and not x1_is_scalar:
6972
pass
70-
elif not x2_is_dparray and not x2_is_scalar:
73+
elif not x2_desc and not x2_is_scalar:
7174
pass
7275
elif x1_is_scalar and x2_is_scalar:
7376
pass
74-
elif x1_is_dparray and x1.ndim == 0:
77+
elif x1_desc and x1_desc.ndim == 0:
7578
pass
76-
elif x2_is_dparray and x2.ndim == 0:
79+
elif x2_desc and x2_desc.ndim == 0:
7780
pass
78-
elif x1_is_dparray and x2_is_dparray and x1.size != x2.size:
81+
elif x1_desc and x2_desc and x1_desc.size != x2_desc.size:
7982
pass
80-
elif x1_is_dparray and x2_is_dparray and x1.shape != x2.shape:
83+
elif x1_desc and x2_desc and x1_desc.shape != x2_desc.shape:
8184
pass
8285
elif out is not None and not isinstance(out, dparray):
8386
pass
@@ -88,7 +91,7 @@ def _check_nd_call(origin_func, dpnp_func, x1, x2, dtype=None, out=None, where=T
8891
elif not where:
8992
pass
9093
else:
91-
return dpnp_func(x1, x2, dtype=dtype, out=out, where=where)
94+
return dpnp_func(x1_desc, x2_desc, dtype=dtype, out=out, where=where)
9295

9396
return call_origin(origin_func, x1, x2, dtype=dtype, out=out, where=where, **kwargs)
9497

0 commit comments

Comments
 (0)