Skip to content

Commit 9b62161

Browse files
Reuse dpctl for matrix_transpose
1 parent 6d1757c commit 9b62161

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

dpnp/dpnp_array.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ def mT(self):
149149
if self.ndim < 2:
150150
raise ValueError("matrix transpose with ndim < 2 is undefined")
151151

152-
return self.swapaxes(-1, -2)
152+
return self._array_obj.mT
153153

154154
def to_device(self, target_device):
155155
"""Transfer array to target device."""

dpnp/dpnp_iface_manipulation.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1799,7 +1799,10 @@ def matrix_transpose(x, /):
17991799
raise ValueError(
18001800
f"Input array must be at least 2-dimensional, but it is {x.ndim}"
18011801
)
1802-
return dpnp.swapaxes(x, -1, -2)
1802+
1803+
usm_x = dpnp.get_usm_ndarray(x)
1804+
usm_res = dpt.matrix_transpose(usm_x)
1805+
return dpnp_array._create_from_usm_ndarray(usm_res)
18031806

18041807

18051808
def moveaxis(a, source, destination):

0 commit comments

Comments
 (0)