Skip to content

Commit ffeb0ae

Browse files
committed
utilize new functionality of dpctl for in-place operators
1 parent 79ac2b0 commit ffeb0ae

File tree

2 files changed

+0
-38
lines changed

2 files changed

+0
-38
lines changed

dpnp/dpnp_algo/dpnp_elementwise_common.py

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,6 @@
2727
# *****************************************************************************
2828

2929

30-
import dpctl
31-
import dpctl.tensor as dpt
3230
import dpctl.tensor._tensor_impl as ti
3331
from dpctl.tensor._elementwise_common import (
3432
BinaryElementwiseFunc,
@@ -538,32 +536,11 @@ def _call_divide(src1, src2, dst, sycl_queue, depends=None):
538536
return ti._divide(src1, src2, dst, sycl_queue, depends)
539537

540538

541-
def _call_divide_inplace(lhs, rhs, sycl_queue, depends=None):
542-
"""In place workaround until dpctl.tensor provides the functionality."""
543-
544-
if depends is None:
545-
depends = []
546-
547-
# allocate temporary memory for out array
548-
out = dpt.empty_like(lhs, dtype=dpnp.result_type(lhs.dtype, rhs.dtype))
549-
550-
# call a general callback
551-
div_ht_, div_ev_ = _call_divide(lhs, rhs, out, sycl_queue, depends)
552-
553-
# store the result into left input array and return events
554-
cp_ht_, cp_ev_ = ti._copy_usm_ndarray_into_usm_ndarray(
555-
src=out, dst=lhs, sycl_queue=sycl_queue, depends=[div_ev_]
556-
)
557-
dpctl.SyclEvent.wait_for([div_ht_])
558-
return (cp_ht_, cp_ev_)
559-
560-
561539
divide_func = BinaryElementwiseFunc(
562540
"divide",
563541
ti._divide_result_type,
564542
_call_divide,
565543
_divide_docstring_,
566-
_call_divide_inplace,
567544
)
568545

569546

tests/test_bitwise.py

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -67,50 +67,41 @@ def test_bitwise_and(self, lhs, rhs, dtype):
6767
)
6868
assert_array_equal(dp_a & dp_b, np_a & np_b)
6969

70-
"""
71-
TODO: unmute once dpctl support that
7270
if (
7371
not (inp.isscalar(dp_a) or inp.isscalar(dp_b))
7472
and dp_a.shape == dp_b.shape
7573
):
7674
dp_a &= dp_b
7775
np_a &= np_b
7876
assert_array_equal(dp_a, np_a)
79-
"""
8077

8178
def test_bitwise_or(self, lhs, rhs, dtype):
8279
dp_a, dp_b, np_a, np_b = self._test_binary_int(
8380
"bitwise_or", lhs, rhs, dtype
8481
)
8582
assert_array_equal(dp_a | dp_b, np_a | np_b)
8683

87-
"""
88-
TODO: unmute once dpctl support that
8984
if (
9085
not (inp.isscalar(dp_a) or inp.isscalar(dp_b))
9186
and dp_a.shape == dp_b.shape
9287
):
9388
dp_a |= dp_b
9489
np_a |= np_b
9590
assert_array_equal(dp_a, np_a)
96-
"""
9791

9892
def test_bitwise_xor(self, lhs, rhs, dtype):
9993
dp_a, dp_b, np_a, np_b = self._test_binary_int(
10094
"bitwise_xor", lhs, rhs, dtype
10195
)
10296
assert_array_equal(dp_a ^ dp_b, np_a ^ np_b)
10397

104-
"""
105-
TODO: unmute once dpctl support that
10698
if (
10799
not (inp.isscalar(dp_a) or inp.isscalar(dp_b))
108100
and dp_a.shape == dp_b.shape
109101
):
110102
dp_a ^= dp_b
111103
np_a ^= np_b
112104
assert_array_equal(dp_a, np_a)
113-
"""
114105

115106
def test_invert(self, lhs, rhs, dtype):
116107
dp_a, np_a = self._test_unary_int("invert", lhs, dtype)
@@ -122,30 +113,24 @@ def test_left_shift(self, lhs, rhs, dtype):
122113
)
123114
assert_array_equal(dp_a << dp_b, np_a << np_b)
124115

125-
"""
126-
TODO: unmute once dpctl support that
127116
if (
128117
not (inp.isscalar(dp_a) or inp.isscalar(dp_b))
129118
and dp_a.shape == dp_b.shape
130119
):
131120
dp_a <<= dp_b
132121
np_a <<= np_b
133122
assert_array_equal(dp_a, np_a)
134-
"""
135123

136124
def test_right_shift(self, lhs, rhs, dtype):
137125
dp_a, dp_b, np_a, np_b = self._test_binary_int(
138126
"right_shift", lhs, rhs, dtype
139127
)
140128
assert_array_equal(dp_a >> dp_b, np_a >> np_b)
141129

142-
"""
143-
TODO: unmute once dpctl support that
144130
if (
145131
not (inp.isscalar(dp_a) or inp.isscalar(dp_b))
146132
and dp_a.shape == dp_b.shape
147133
):
148134
dp_a >>= dp_b
149135
np_a >>= np_b
150136
assert_array_equal(dp_a, np_a)
151-
"""

0 commit comments

Comments
 (0)