Skip to content

Commit d04a31e

Browse files
committed
Implements DPNPBinaryFunc._inplace_op method
1 parent ed7bba2 commit d04a31e

File tree

2 files changed

+20
-13
lines changed

2 files changed

+20
-13
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,34 +416,34 @@ 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
# '__iter__',
438438

439439
def __itruediv__(self, other):
440440
"""Return ``self/=value``."""
441-
dpnp.true_divide(self, other, out=self)
441+
dpnp.true_divide._inplace_op(self, other)
442442
return self
443443

444444
def __ixor__(self, other):
445445
"""Return ``self^=value``."""
446-
dpnp.bitwise_xor(self, other, out=self)
446+
dpnp.bitwise_xor._inplace_op(self, other)
447447
return self
448448

449449
def __le__(self, other):

0 commit comments

Comments
 (0)