Skip to content

Commit 79af46a

Browse files
committed
Reorder methods by lexicographical order
1 parent 93b50cb commit 79af46a

File tree

1 file changed

+153
-154
lines changed

1 file changed

+153
-154
lines changed

dpnp/dpnp_array.py

Lines changed: 153 additions & 154 deletions
Original file line numberDiff line numberDiff line change
@@ -108,159 +108,6 @@ def __init__(
108108
array_namespace=dpnp,
109109
)
110110

111-
@property
112-
def __sycl_usm_array_interface__(self):
113-
"""
114-
Give ``__sycl_usm_array_interface__`` dictionary describing the array.
115-
116-
"""
117-
return self._array_obj.__sycl_usm_array_interface__
118-
119-
def get_array(self):
120-
"""Get :class:`dpctl.tensor.usm_ndarray` object."""
121-
return self._array_obj
122-
123-
@property
124-
def T(self):
125-
"""
126-
View of the transposed array.
127-
128-
Same as ``self.transpose()``.
129-
130-
See Also
131-
--------
132-
:obj:`dpnp.transpose` : Equivalent function.
133-
134-
Examples
135-
--------
136-
>>> import dpnp as np
137-
>>> a = np.array([[1, 2], [3, 4]])
138-
>>> a
139-
array([[1, 2],
140-
[3, 4]])
141-
>>> a.T
142-
array([[1, 3],
143-
[2, 4]])
144-
145-
>>> a = np.array([1, 2, 3, 4])
146-
>>> a
147-
array([1, 2, 3, 4])
148-
>>> a.T
149-
array([1, 2, 3, 4])
150-
151-
"""
152-
153-
return self.transpose()
154-
155-
@property
156-
def mT(self):
157-
"""
158-
View of the matrix transposed array.
159-
160-
The matrix transpose is the transpose of the last two dimensions, even
161-
if the array is of higher dimension.
162-
163-
Raises
164-
------
165-
ValueError
166-
If the array is of dimension less than ``2``.
167-
168-
Examples
169-
--------
170-
>>> import dpnp as np
171-
>>> a = np.array([[1, 2], [3, 4]])
172-
>>> a
173-
array([[1, 2],
174-
[3, 4]])
175-
>>> a.mT
176-
array([[1, 3],
177-
[2, 4]])
178-
179-
>>> a = np.arange(8).reshape((2, 2, 2))
180-
>>> a
181-
array([[[0, 1],
182-
[2, 3]],
183-
[[4, 5],
184-
[6, 7]]])
185-
>>> a.mT
186-
array([[[0, 2],
187-
[1, 3]],
188-
[[4, 6],
189-
[5, 7]]])
190-
191-
"""
192-
193-
if self.ndim < 2:
194-
raise ValueError("matrix transpose with ndim < 2 is undefined")
195-
196-
return dpnp_array._create_from_usm_ndarray(self._array_obj.mT)
197-
198-
@property
199-
def device(self):
200-
"""
201-
Return :class:`dpctl.tensor.Device` object representing residence of
202-
the array data.
203-
204-
The ``Device`` object represents Array API notion of the device, and
205-
contains :class:`dpctl.SyclQueue` associated with this array. Hence,
206-
``.device`` property provides information distinct from ``.sycl_device``
207-
property.
208-
209-
Examples
210-
--------
211-
>>> import dpnp as np
212-
>>> x = np.ones(10)
213-
>>> x.device
214-
Device(level_zero:gpu:0)
215-
216-
"""
217-
218-
return self._array_obj.device
219-
220-
@property
221-
def sycl_context(self):
222-
"""
223-
Return :class:`dpctl.SyclContext` object to which USM data is bound.
224-
225-
"""
226-
return self._array_obj.sycl_context
227-
228-
@property
229-
def sycl_device(self):
230-
"""
231-
Return :class:`dpctl.SyclDevice` object on which USM data was
232-
allocated.
233-
234-
"""
235-
return self._array_obj.sycl_device
236-
237-
@property
238-
def sycl_queue(self):
239-
"""
240-
Return :class:`dpctl.SyclQueue` object associated with USM data.
241-
242-
"""
243-
return self._array_obj.sycl_queue
244-
245-
@property
246-
def usm_type(self):
247-
"""
248-
USM type of underlying memory. Possible values are:
249-
250-
* ``"device"``
251-
USM-device allocation in device memory, only accessible to kernels
252-
executed on the device
253-
* ``"shared"``
254-
USM-shared allocation in device memory, accessible both from the
255-
device and from the host
256-
* ``"host"``
257-
USM-host allocation in host memory, accessible both from the device
258-
and from the host
259-
260-
"""
261-
262-
return self._array_obj.usm_type
263-
264111
def __abs__(self):
265112
"""Return :math:`|self|`."""
266113
return dpnp.abs(self)
@@ -714,6 +561,14 @@ def __sub__(self, other):
714561

715562
# '__subclasshook__',
716563

564+
@property
565+
def __sycl_usm_array_interface__(self):
566+
"""
567+
Give ``__sycl_usm_array_interface__`` dictionary describing the array.
568+
569+
"""
570+
return self._array_obj.__sycl_usm_array_interface__
571+
717572
def __truediv__(self, other):
718573
"""Return :math:`self/value`."""
719574
return dpnp.true_divide(self, other)
@@ -1133,6 +988,28 @@ def cumsum(self, axis=None, dtype=None, out=None):
1133988

1134989
# 'data',
1135990

991+
@property
992+
def device(self):
993+
"""
994+
Return :class:`dpctl.tensor.Device` object representing residence of
995+
the array data.
996+
997+
The ``Device`` object represents Array API notion of the device, and
998+
contains :class:`dpctl.SyclQueue` associated with this array. Hence,
999+
``.device`` property provides information distinct from ``.sycl_device``
1000+
property.
1001+
1002+
Examples
1003+
--------
1004+
>>> import dpnp as np
1005+
>>> x = np.ones(10)
1006+
>>> x.device
1007+
Device(level_zero:gpu:0)
1008+
1009+
"""
1010+
1011+
return self._array_obj.device
1012+
11361013
def diagonal(self, offset=0, axis1=0, axis2=1):
11371014
"""
11381015
Return specified diagonals.
@@ -1280,6 +1157,10 @@ def flatten(self, order="C"):
12801157

12811158
return self.reshape(-1, order=order, copy=True)
12821159

1160+
def get_array(self):
1161+
"""Get :class:`dpctl.tensor.usm_ndarray` object."""
1162+
return self._array_obj
1163+
12831164
# 'getfield',
12841165

12851166
@property
@@ -1440,6 +1321,49 @@ def min(
14401321
where=where,
14411322
)
14421323

1324+
@property
1325+
def mT(self):
1326+
"""
1327+
View of the matrix transposed array.
1328+
1329+
The matrix transpose is the transpose of the last two dimensions, even
1330+
if the array is of higher dimension.
1331+
1332+
Raises
1333+
------
1334+
ValueError
1335+
If the array is of dimension less than ``2``.
1336+
1337+
Examples
1338+
--------
1339+
>>> import dpnp as np
1340+
>>> a = np.array([[1, 2], [3, 4]])
1341+
>>> a
1342+
array([[1, 2],
1343+
[3, 4]])
1344+
>>> a.mT
1345+
array([[1, 3],
1346+
[2, 4]])
1347+
1348+
>>> a = np.arange(8).reshape((2, 2, 2))
1349+
>>> a
1350+
array([[[0, 1],
1351+
[2, 3]],
1352+
[[4, 5],
1353+
[6, 7]]])
1354+
>>> a.mT
1355+
array([[[0, 2],
1356+
[1, 3]],
1357+
[[4, 6],
1358+
[5, 7]]])
1359+
1360+
"""
1361+
1362+
if self.ndim < 2:
1363+
raise ValueError("matrix transpose with ndim < 2 is undefined")
1364+
1365+
return dpnp_array._create_from_usm_ndarray(self._array_obj.mT)
1366+
14431367
@property
14441368
def nbytes(self):
14451369
"""Total bytes consumed by the elements of the array."""
@@ -1941,6 +1865,63 @@ def swapaxes(self, axis1, axis2):
19411865

19421866
return dpnp.swapaxes(self, axis1=axis1, axis2=axis2)
19431867

1868+
@property
1869+
def sycl_context(self):
1870+
"""
1871+
Return :class:`dpctl.SyclContext` object to which USM data is bound.
1872+
1873+
"""
1874+
return self._array_obj.sycl_context
1875+
1876+
@property
1877+
def sycl_device(self):
1878+
"""
1879+
Return :class:`dpctl.SyclDevice` object on which USM data was
1880+
allocated.
1881+
1882+
"""
1883+
return self._array_obj.sycl_device
1884+
1885+
@property
1886+
def sycl_queue(self):
1887+
"""
1888+
Return :class:`dpctl.SyclQueue` object associated with USM data.
1889+
1890+
"""
1891+
return self._array_obj.sycl_queue
1892+
1893+
@property
1894+
def T(self):
1895+
"""
1896+
View of the transposed array.
1897+
1898+
Same as ``self.transpose()``.
1899+
1900+
See Also
1901+
--------
1902+
:obj:`dpnp.transpose` : Equivalent function.
1903+
1904+
Examples
1905+
--------
1906+
>>> import dpnp as np
1907+
>>> a = np.array([[1, 2], [3, 4]])
1908+
>>> a
1909+
array([[1, 2],
1910+
[3, 4]])
1911+
>>> a.T
1912+
array([[1, 3],
1913+
[2, 4]])
1914+
1915+
>>> a = np.array([1, 2, 3, 4])
1916+
>>> a
1917+
array([1, 2, 3, 4])
1918+
>>> a.T
1919+
array([1, 2, 3, 4])
1920+
1921+
"""
1922+
1923+
return self.transpose()
1924+
19441925
def take(self, indices, axis=None, out=None, mode="wrap"):
19451926
"""
19461927
Take elements from an array along an axis.
@@ -2113,5 +2094,23 @@ def var(
21132094
correction=correction,
21142095
)
21152096

2097+
# 'view'
2098+
2099+
@property
2100+
def usm_type(self):
2101+
"""
2102+
USM type of underlying memory. Possible values are:
21162103
2117-
# 'view'
2104+
* ``"device"``
2105+
USM-device allocation in device memory, only accessible to kernels
2106+
executed on the device
2107+
* ``"shared"``
2108+
USM-shared allocation in device memory, accessible both from the
2109+
device and from the host
2110+
* ``"host"``
2111+
USM-host allocation in host memory, accessible both from the device
2112+
and from the host
2113+
2114+
"""
2115+
2116+
return self._array_obj.usm_type

0 commit comments

Comments
 (0)