Skip to content

Commit 3371abd

Browse files
committed
All in-place operators now use call operator of BinaryElementwiseFunc
1 parent 0017a7d commit 3371abd

File tree

1 file changed

+9
-45
lines changed

1 file changed

+9
-45
lines changed

dpctl/tensor/_usmarray.pyx

Lines changed: 9 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1289,25 +1289,13 @@ cdef class usm_ndarray:
12891289
return dpctl.tensor.add(self, other, out=self)
12901290

12911291
def __iand__(self, other):
1292-
res = self.__and__(other)
1293-
if res is NotImplemented:
1294-
return res
1295-
self.__setitem__(Ellipsis, res)
1296-
return self
1292+
return dpctl.tensor.bitwise_and(self, other, out=self)
12971293

12981294
def __ifloordiv__(self, other):
1299-
res = self.__floordiv__(other)
1300-
if res is NotImplemented:
1301-
return res
1302-
self.__setitem__(Ellipsis, res)
1303-
return self
1295+
return dpctl.tensor.floor_divide(self, other, out=self)
13041296

13051297
def __ilshift__(self, other):
1306-
res = self.__lshift__(other)
1307-
if res is NotImplemented:
1308-
return res
1309-
self.__setitem__(Ellipsis, res)
1310-
return self
1298+
return dpctl.tensor.bitwise_left_shift(self, other, out=self)
13111299

13121300
def __imatmul__(self, other):
13131301
res = self.__matmul__(other)
@@ -1317,52 +1305,28 @@ cdef class usm_ndarray:
13171305
return self
13181306

13191307
def __imod__(self, other):
1320-
res = self.__mod__(other)
1321-
if res is NotImplemented:
1322-
return res
1323-
self.__setitem__(Ellipsis, res)
1324-
return self
1308+
return dpctl.tensor.remainder(self, other, out=self)
13251309

13261310
def __imul__(self, other):
13271311
return dpctl.tensor.multiply(self, other, out=self)
13281312

13291313
def __ior__(self, other):
1330-
res = self.__or__(other)
1331-
if res is NotImplemented:
1332-
return res
1333-
self.__setitem__(Ellipsis, res)
1334-
return self
1314+
return dpctl.tensor.bitwise_or(self, other, out=self)
13351315

13361316
def __ipow__(self, other):
1337-
res = self.__pow__(other, None)
1338-
if res is NotImplemented:
1339-
return res
1340-
self.__setitem__(Ellipsis, res)
1341-
return self
1317+
return dpctl.tensor.pow(self, other, out=self)
13421318

13431319
def __irshift__(self, other):
1344-
res = self.__rshift__(other)
1345-
if res is NotImplemented:
1346-
return res
1347-
self.__setitem__(Ellipsis, res)
1348-
return self
1320+
return dpctl.tensor.bitwise_right_shift(self, other, out=self)
13491321

13501322
def __isub__(self, other):
13511323
return dpctl.tensor.subtract(self, other, out=self)
13521324

13531325
def __itruediv__(self, other):
1354-
res = self.__truediv__(other)
1355-
if res is NotImplemented:
1356-
return res
1357-
self.__setitem__(Ellipsis, res)
1358-
return self
1326+
return dpctl.tensor.divide(self, other, out=self)
13591327

13601328
def __ixor__(self, other):
1361-
res = self.__xor__(other)
1362-
if res is NotImplemented:
1363-
return res
1364-
self.__setitem__(Ellipsis, res)
1365-
return self
1329+
return dpctl.tensor.bitwise_xor(self, other, out=self)
13661330

13671331
def __str__(self):
13681332
return usm_ndarray_str(self)

0 commit comments

Comments
 (0)