@@ -113,159 +113,6 @@ def __init__(
113
113
array_namespace = dpnp ,
114
114
)
115
115
116
- @property
117
- def __sycl_usm_array_interface__ (self ):
118
- """
119
- Give ``__sycl_usm_array_interface__`` dictionary describing the array.
120
-
121
- """
122
- return self ._array_obj .__sycl_usm_array_interface__
123
-
124
- def get_array (self ):
125
- """Get :class:`dpctl.tensor.usm_ndarray` object."""
126
- return self ._array_obj
127
-
128
- @property
129
- def T (self ):
130
- """
131
- View of the transposed array.
132
-
133
- Same as ``self.transpose()``.
134
-
135
- See Also
136
- --------
137
- :obj:`dpnp.transpose` : Equivalent function.
138
-
139
- Examples
140
- --------
141
- >>> import dpnp as np
142
- >>> a = np.array([[1, 2], [3, 4]])
143
- >>> a
144
- array([[1, 2],
145
- [3, 4]])
146
- >>> a.T
147
- array([[1, 3],
148
- [2, 4]])
149
-
150
- >>> a = np.array([1, 2, 3, 4])
151
- >>> a
152
- array([1, 2, 3, 4])
153
- >>> a.T
154
- array([1, 2, 3, 4])
155
-
156
- """
157
-
158
- return self .transpose ()
159
-
160
- @property
161
- def mT (self ):
162
- """
163
- View of the matrix transposed array.
164
-
165
- The matrix transpose is the transpose of the last two dimensions, even
166
- if the array is of higher dimension.
167
-
168
- Raises
169
- ------
170
- ValueError
171
- If the array is of dimension less than ``2``.
172
-
173
- Examples
174
- --------
175
- >>> import dpnp as np
176
- >>> a = np.array([[1, 2], [3, 4]])
177
- >>> a
178
- array([[1, 2],
179
- [3, 4]])
180
- >>> a.mT
181
- array([[1, 3],
182
- [2, 4]])
183
-
184
- >>> a = np.arange(8).reshape((2, 2, 2))
185
- >>> a
186
- array([[[0, 1],
187
- [2, 3]],
188
- [[4, 5],
189
- [6, 7]]])
190
- >>> a.mT
191
- array([[[0, 2],
192
- [1, 3]],
193
- [[4, 6],
194
- [5, 7]]])
195
-
196
- """
197
-
198
- if self .ndim < 2 :
199
- raise ValueError ("matrix transpose with ndim < 2 is undefined" )
200
-
201
- return dpnp_array ._create_from_usm_ndarray (self ._array_obj .mT )
202
-
203
- @property
204
- def device (self ):
205
- """
206
- Return :class:`dpctl.tensor.Device` object representing residence of
207
- the array data.
208
-
209
- The ``Device`` object represents Array API notion of the device, and
210
- contains :class:`dpctl.SyclQueue` associated with this array. Hence,
211
- ``.device`` property provides information distinct from ``.sycl_device``
212
- property.
213
-
214
- Examples
215
- --------
216
- >>> import dpnp as np
217
- >>> x = np.ones(10)
218
- >>> x.device
219
- Device(level_zero:gpu:0)
220
-
221
- """
222
-
223
- return self ._array_obj .device
224
-
225
- @property
226
- def sycl_context (self ):
227
- """
228
- Return :class:`dpctl.SyclContext` object to which USM data is bound.
229
-
230
- """
231
- return self ._array_obj .sycl_context
232
-
233
- @property
234
- def sycl_device (self ):
235
- """
236
- Return :class:`dpctl.SyclDevice` object on which USM data was
237
- allocated.
238
-
239
- """
240
- return self ._array_obj .sycl_device
241
-
242
- @property
243
- def sycl_queue (self ):
244
- """
245
- Return :class:`dpctl.SyclQueue` object associated with USM data.
246
-
247
- """
248
- return self ._array_obj .sycl_queue
249
-
250
- @property
251
- def usm_type (self ):
252
- """
253
- USM type of underlying memory. Possible values are:
254
-
255
- * ``"device"``
256
- USM-device allocation in device memory, only accessible to kernels
257
- executed on the device
258
- * ``"shared"``
259
- USM-shared allocation in device memory, accessible both from the
260
- device and from the host
261
- * ``"host"``
262
- USM-host allocation in host memory, accessible both from the device
263
- and from the host
264
-
265
- """
266
-
267
- return self ._array_obj .usm_type
268
-
269
116
def __abs__ (self ):
270
117
"""Return :math:`|self|`."""
271
118
return dpnp .abs (self )
@@ -719,6 +566,14 @@ def __sub__(self, other):
719
566
720
567
# '__subclasshook__',
721
568
569
+ @property
570
+ def __sycl_usm_array_interface__ (self ):
571
+ """
572
+ Give ``__sycl_usm_array_interface__`` dictionary describing the array.
573
+
574
+ """
575
+ return self ._array_obj .__sycl_usm_array_interface__
576
+
722
577
def __truediv__ (self , other ):
723
578
"""Return :math:`self/value`."""
724
579
return dpnp .true_divide (self , other )
@@ -1146,6 +1001,28 @@ def data(self):
1146
1001
1147
1002
return dpm .create_data (self ._array_obj )
1148
1003
1004
+ @property
1005
+ def device (self ):
1006
+ """
1007
+ Return :class:`dpctl.tensor.Device` object representing residence of
1008
+ the array data.
1009
+
1010
+ The ``Device`` object represents Array API notion of the device, and
1011
+ contains :class:`dpctl.SyclQueue` associated with this array. Hence,
1012
+ ``.device`` property provides information distinct from ``.sycl_device``
1013
+ property.
1014
+
1015
+ Examples
1016
+ --------
1017
+ >>> import dpnp as np
1018
+ >>> x = np.ones(10)
1019
+ >>> x.device
1020
+ Device(level_zero:gpu:0)
1021
+
1022
+ """
1023
+
1024
+ return self ._array_obj .device
1025
+
1149
1026
def diagonal (self , offset = 0 , axis1 = 0 , axis2 = 1 ):
1150
1027
"""
1151
1028
Return specified diagonals.
@@ -1293,6 +1170,10 @@ def flatten(self, order="C"):
1293
1170
1294
1171
return self .reshape (- 1 , order = order , copy = True )
1295
1172
1173
+ def get_array (self ):
1174
+ """Get :class:`dpctl.tensor.usm_ndarray` object."""
1175
+ return self ._array_obj
1176
+
1296
1177
# 'getfield',
1297
1178
1298
1179
@property
@@ -1453,6 +1334,49 @@ def min(
1453
1334
where = where ,
1454
1335
)
1455
1336
1337
+ @property
1338
+ def mT (self ):
1339
+ """
1340
+ View of the matrix transposed array.
1341
+
1342
+ The matrix transpose is the transpose of the last two dimensions, even
1343
+ if the array is of higher dimension.
1344
+
1345
+ Raises
1346
+ ------
1347
+ ValueError
1348
+ If the array is of dimension less than ``2``.
1349
+
1350
+ Examples
1351
+ --------
1352
+ >>> import dpnp as np
1353
+ >>> a = np.array([[1, 2], [3, 4]])
1354
+ >>> a
1355
+ array([[1, 2],
1356
+ [3, 4]])
1357
+ >>> a.mT
1358
+ array([[1, 3],
1359
+ [2, 4]])
1360
+
1361
+ >>> a = np.arange(8).reshape((2, 2, 2))
1362
+ >>> a
1363
+ array([[[0, 1],
1364
+ [2, 3]],
1365
+ [[4, 5],
1366
+ [6, 7]]])
1367
+ >>> a.mT
1368
+ array([[[0, 2],
1369
+ [1, 3]],
1370
+ [[4, 6],
1371
+ [5, 7]]])
1372
+
1373
+ """
1374
+
1375
+ if self .ndim < 2 :
1376
+ raise ValueError ("matrix transpose with ndim < 2 is undefined" )
1377
+
1378
+ return dpnp_array ._create_from_usm_ndarray (self ._array_obj .mT )
1379
+
1456
1380
@property
1457
1381
def nbytes (self ):
1458
1382
"""Total bytes consumed by the elements of the array."""
@@ -1954,6 +1878,63 @@ def swapaxes(self, axis1, axis2):
1954
1878
1955
1879
return dpnp .swapaxes (self , axis1 = axis1 , axis2 = axis2 )
1956
1880
1881
+ @property
1882
+ def sycl_context (self ):
1883
+ """
1884
+ Return :class:`dpctl.SyclContext` object to which USM data is bound.
1885
+
1886
+ """
1887
+ return self ._array_obj .sycl_context
1888
+
1889
+ @property
1890
+ def sycl_device (self ):
1891
+ """
1892
+ Return :class:`dpctl.SyclDevice` object on which USM data was
1893
+ allocated.
1894
+
1895
+ """
1896
+ return self ._array_obj .sycl_device
1897
+
1898
+ @property
1899
+ def sycl_queue (self ):
1900
+ """
1901
+ Return :class:`dpctl.SyclQueue` object associated with USM data.
1902
+
1903
+ """
1904
+ return self ._array_obj .sycl_queue
1905
+
1906
+ @property
1907
+ def T (self ):
1908
+ """
1909
+ View of the transposed array.
1910
+
1911
+ Same as ``self.transpose()``.
1912
+
1913
+ See Also
1914
+ --------
1915
+ :obj:`dpnp.transpose` : Equivalent function.
1916
+
1917
+ Examples
1918
+ --------
1919
+ >>> import dpnp as np
1920
+ >>> a = np.array([[1, 2], [3, 4]])
1921
+ >>> a
1922
+ array([[1, 2],
1923
+ [3, 4]])
1924
+ >>> a.T
1925
+ array([[1, 3],
1926
+ [2, 4]])
1927
+
1928
+ >>> a = np.array([1, 2, 3, 4])
1929
+ >>> a
1930
+ array([1, 2, 3, 4])
1931
+ >>> a.T
1932
+ array([1, 2, 3, 4])
1933
+
1934
+ """
1935
+
1936
+ return self .transpose ()
1937
+
1957
1938
def take (self , indices , axis = None , out = None , mode = "wrap" ):
1958
1939
"""
1959
1940
Take elements from an array along an axis.
@@ -2249,3 +2230,22 @@ def view(self, dtype=None, *, type=None):
2249
2230
buffer = self ,
2250
2231
strides = new_strides ,
2251
2232
)
2233
+
2234
+ @property
2235
+ def usm_type (self ):
2236
+ """
2237
+ USM type of underlying memory. Possible values are:
2238
+
2239
+ * ``"device"``
2240
+ USM-device allocation in device memory, only accessible to kernels
2241
+ executed on the device
2242
+ * ``"shared"``
2243
+ USM-shared allocation in device memory, accessible both from the
2244
+ device and from the host
2245
+ * ``"host"``
2246
+ USM-host allocation in host memory, accessible both from the device
2247
+ and from the host
2248
+
2249
+ """
2250
+
2251
+ return self ._array_obj .usm_type
0 commit comments