Skip to content

Commit 2be4fdf

Browse files
authored
Merge 49d4339 into ea718e3
2 parents ea718e3 + 49d4339 commit 2be4fdf

File tree

7 files changed

+1175
-897
lines changed

7 files changed

+1175
-897
lines changed

dpnp/dpnp_algo/dpnp_elementwise_common.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -375,6 +375,13 @@ def __call__(
375375
return out
376376
return dpnp_array._create_from_usm_ndarray(res_usm)
377377

378+
def _inplace_op(self, x1, x2):
379+
x1_usm = dpnp.get_usm_ndarray(x1)
380+
x2_usm = dpnp.get_usm_ndarray_or_scalar(x2)
381+
382+
super()._inplace_op(x1_usm, x2_usm)
383+
return x1
384+
378385
def outer(
379386
self,
380387
x1,

dpnp/dpnp_array.py

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -347,22 +347,22 @@ def __gt__(self, other):
347347

348348
def __iadd__(self, other):
349349
"""Return ``self+=value``."""
350-
dpnp.add(self, other, out=self)
350+
dpnp.add._inplace_op(self, other)
351351
return self
352352

353353
def __iand__(self, other):
354354
"""Return ``self&=value``."""
355-
dpnp.bitwise_and(self, other, out=self)
355+
dpnp.bitwise_and._inplace_op(self, other)
356356
return self
357357

358358
def __ifloordiv__(self, other):
359359
"""Return ``self//=value``."""
360-
dpnp.floor_divide(self, other, out=self)
360+
dpnp.floor_divide._inplace_op(self, other)
361361
return self
362362

363363
def __ilshift__(self, other):
364364
"""Return ``self<<=value``."""
365-
dpnp.left_shift(self, other, out=self)
365+
dpnp.left_shift._inplace_op(self, other)
366366
return self
367367

368368
def __imatmul__(self, other):
@@ -381,7 +381,7 @@ def __imatmul__(self, other):
381381
axes = [(-2, -1), (-2, -1), (-2, -1)]
382382

383383
try:
384-
dpnp.matmul(self, other, out=self, axes=axes)
384+
dpnp.matmul(self, other, out=self, dtype=self.dtype, axes=axes)
385385
except AxisError:
386386
# AxisError should indicate that the axes argument didn't work out
387387
# which should mean the second operand not being 2 dimensional.
@@ -393,12 +393,12 @@ def __imatmul__(self, other):
393393

394394
def __imod__(self, other):
395395
"""Return ``self%=value``."""
396-
dpnp.remainder(self, other, out=self)
396+
dpnp.remainder._inplace_op(self, other)
397397
return self
398398

399399
def __imul__(self, other):
400400
"""Return ``self*=value``."""
401-
dpnp.multiply(self, other, out=self)
401+
dpnp.multiply._inplace_op(self, other)
402402
return self
403403

404404
def __index__(self):
@@ -416,22 +416,22 @@ def __invert__(self):
416416

417417
def __ior__(self, other):
418418
"""Return ``self|=value``."""
419-
dpnp.bitwise_or(self, other, out=self)
419+
dpnp.bitwise_or._inplace_op(self, other)
420420
return self
421421

422422
def __ipow__(self, other):
423423
"""Return ``self**=value``."""
424-
dpnp.power(self, other, out=self)
424+
dpnp.power._inplace_op(self, other)
425425
return self
426426

427427
def __irshift__(self, other):
428428
"""Return ``self>>=value``."""
429-
dpnp.right_shift(self, other, out=self)
429+
dpnp.right_shift._inplace_op(self, other)
430430
return self
431431

432432
def __isub__(self, other):
433433
"""Return ``self-=value``."""
434-
dpnp.subtract(self, other, out=self)
434+
dpnp.subtract._inplace_op(self, other)
435435
return self
436436

437437
def __iter__(self):
@@ -442,12 +442,12 @@ def __iter__(self):
442442

443443
def __itruediv__(self, other):
444444
"""Return ``self/=value``."""
445-
dpnp.true_divide(self, other, out=self)
445+
dpnp.true_divide._inplace_op(self, other)
446446
return self
447447

448448
def __ixor__(self, other):
449449
"""Return ``self^=value``."""
450-
dpnp.bitwise_xor(self, other, out=self)
450+
dpnp.bitwise_xor._inplace_op(self, other)
451451
return self
452452

453453
def __le__(self, other):

dpnp/dpnp_iface_bitwise.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,7 @@ def binary_repr(num, width=None):
208208
ti._bitwise_and_result_type,
209209
ti._bitwise_and,
210210
_BITWISE_AND_DOCSTRING,
211+
binary_inplace_fn=ti._bitwise_and_inplace,
211212
)
212213

213214

@@ -285,6 +286,7 @@ def binary_repr(num, width=None):
285286
ti._bitwise_or_result_type,
286287
ti._bitwise_or,
287288
_BITWISE_OR_DOCSTRING,
289+
binary_inplace_fn=ti._bitwise_or_inplace,
288290
)
289291

290292

@@ -366,6 +368,7 @@ def binary_repr(num, width=None):
366368
ti._bitwise_xor_result_type,
367369
ti._bitwise_xor,
368370
_BITWISE_XOR_DOCSTRING,
371+
binary_inplace_fn=ti._bitwise_xor_inplace,
369372
)
370373

371374

@@ -518,6 +521,7 @@ def binary_repr(num, width=None):
518521
ti._bitwise_left_shift_result_type,
519522
ti._bitwise_left_shift,
520523
_LEFT_SHIFT_DOCSTRING,
524+
binary_inplace_fn=ti._bitwise_left_shift_inplace,
521525
)
522526

523527
bitwise_left_shift = left_shift # bitwise_left_shift is an alias for left_shift
@@ -595,6 +599,7 @@ def binary_repr(num, width=None):
595599
ti._bitwise_right_shift_result_type,
596600
ti._bitwise_right_shift,
597601
_RIGHT_SHIFT_DOCSTRING,
602+
binary_inplace_fn=ti._bitwise_right_shift_inplace,
598603
)
599604

600605
# bitwise_right_shift is an alias for right_shift

dpnp/dpnp_iface_trigonometric.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2450,7 +2450,5 @@ def unwrap(p, discont=None, axis=-1, *, period=2 * dpnp.pi):
24502450

24512451
up = dpnp.astype(p, dtype=dt, copy=True)
24522452
up[slice1] = p[slice1]
2453-
# TODO: replace, once dpctl-1757 resolved
2454-
# up[slice1] += ph_correct.cumsum(axis=axis)
2455-
up[slice1] += ph_correct.cumsum(axis=axis, dtype=dt)
2453+
up[slice1] += ph_correct.cumsum(axis=axis)
24562454
return up

0 commit comments

Comments
 (0)