@@ -125,19 +125,29 @@ def from_numpy(np_ary, device=None, usm_type="device", sycl_queue=None):
125
125
from_numpy(arg, device=None, usm_type="device", sycl_queue=None)
126
126
127
127
Creates :class:`dpctl.tensor.usm_ndarray` from instance of
128
- `numpy.ndarray`.
128
+ :class: `numpy.ndarray`.
129
129
130
130
Args:
131
- arg: An instance of input `numpy.ndarray`
132
- device: array API specification of device where the output array
133
- is created
134
- usm_type: The requested USM allocation type for the output array
135
- sycl_queue: a :class:`dpctl.SyclQueue` instance that determines
136
- output array allocation device as well as placement of data
137
- movement operation. The `device` and `sycl_queue` arguments
131
+ arg (array-like): An instance of input convertible to
132
+ :class:`numpy.ndarray`
133
+ device (object): array API specification of device where the
134
+ output array is created. Device can be specified by a
135
+ a filter selector string, an instance of
136
+ :class:`dpctl.SyclDevice`, an instance of
137
+ :class:`dpctl.SyclQueue`, an instance of
138
+ :class:`dpctl.tensor.Device`. If the value is `None`,
139
+ returned array is created on the default-selected device.
140
+ Default: `None`.
141
+ usm_type (str): The requested USM allocation type for the
142
+ output array. Recognized values are `"device"`, `"shared"`,
143
+ or `"host"`.
144
+ sycl_queue (:class:`dpctl.SyclQueue`, optional):
145
+ A SYCL queue that determines output array allocation device
146
+ as well as execution placement of data movement operations.
147
+ The `device` and `sycl_queue` arguments
138
148
are equivalent. Only one of them should be specified. If both
139
149
are provided, they must be consistent and result in using the
140
- same execution queue.
150
+ same execution queue. Default: `None`.
141
151
142
152
The returned array has the same shape, and the same data type kind.
143
153
If the device does not support the data type of input array, a
@@ -154,12 +164,15 @@ def to_numpy(usm_ary):
154
164
to_numpy(usm_ary)
155
165
156
166
Copies content of :class:`dpctl.tensor.usm_ndarray` instance `usm_ary`
157
- into `numpy.ndarray` instance of the same shape and same data type.
167
+ into :class: `numpy.ndarray` instance of the same shape and same data type.
158
168
159
169
Args:
160
- usm_ary: An instance of :class:`dpctl.tensor.usm_ndarray`
170
+ usm_ary (usm_ndarray):
171
+ Input array
161
172
Returns:
162
- An instance of `numpy.ndarray` populated with content of `usm_ary`.
173
+ :class:`numpy.ndarray`:
174
+ An instance of :class:`numpy.ndarray` populated with content of
175
+ `usm_ary`
163
176
"""
164
177
return _copy_to_numpy (usm_ary )
165
178
@@ -169,18 +182,24 @@ def asnumpy(usm_ary):
169
182
asnumpy(usm_ary)
170
183
171
184
Copies content of :class:`dpctl.tensor.usm_ndarray` instance `usm_ary`
172
- into `numpy.ndarray` instance of the same shape and same data type.
185
+ into :class:`numpy.ndarray` instance of the same shape and same data
186
+ type.
173
187
174
188
Args:
175
- usm_ary: An instance of :class:`dpctl.tensor.usm_ndarray`
189
+ usm_ary (usm_ndarray):
190
+ Input array
176
191
Returns:
177
- An instance of `numpy.ndarray` populated with content of `usm_ary`.
192
+ :class:`numpy.ndarray`:
193
+ An instance of :class:`numpy.ndarray` populated with content
194
+ of `usm_ary`
178
195
"""
179
196
return _copy_to_numpy (usm_ary )
180
197
181
198
182
199
class Dummy :
183
- "Helper class with specified __sycl_usm_array_interface__ attribute"
200
+ """
201
+ Helper class with specified ``__sycl_usm_array_interface__`` attribute
202
+ """
184
203
185
204
def __init__ (self , iface ):
186
205
self .__sycl_usm_array_interface__ = iface
@@ -280,10 +299,20 @@ def _copy_from_usm_ndarray_to_usm_ndarray(dst, src):
280
299
281
300
282
301
def copy (usm_ary , order = "K" ):
283
- """
284
- Creates a copy of given instance of `usm_ndarray`.
302
+ """copy(ary, order="K")
303
+
304
+ Creates a copy of given instance of :class:`dpctl.tensor.usm_ndarray`.
305
+
306
+ Args:
307
+ ary (usm_ndarray):
308
+ Input array.
309
+ order ({"C", "F", "A", "K"}, optional):
310
+ Controls the memory layout of the output array.
311
+ Returns:
312
+ usm_ndarray:
313
+ A copy of the input array.
285
314
286
- Memory layour of the copy is controlled by `order` keyword,
315
+ Memory layout of the copy is controlled by `order` keyword,
287
316
following NumPy's conventions. The `order` keywords can be
288
317
one of the following:
289
318
@@ -342,10 +371,31 @@ def copy(usm_ary, order="K"):
342
371
343
372
344
373
def astype (usm_ary , newdtype , order = "K" , casting = "unsafe" , copy = True ):
345
- """
346
- astype(usm_array, new_dtype, order="K", casting="unsafe", copy=True)
374
+ """ astype(array, new_dtype, order="K", casting="unsafe", \
375
+ copy=True)
376
+
377
+ Returns a copy of the :class:`dpctl.tensor.usm_ndarray`, cast to a
378
+ specified type.
347
379
348
- Returns a copy of the array, cast to a specified type.
380
+ Args:
381
+ array (usm_ndarray):
382
+ An input array.
383
+ new_dtype (dtype):
384
+ The data type of the resulting array.
385
+ order ({"C", "F", "A", "K"}, optional):
386
+ Controls memory layout of the resulting array if a copy
387
+ is returned.
388
+ casting ({'no', 'equiv', 'safe', 'same_kind', 'unsafe'}, optional):
389
+ Controls what kind of data casting may occur. Please see
390
+ :meth:`numpy.ndarray.astype` for description of casting modes.
391
+ copy (bool, optional):
392
+ By default, `astype` always returns a newly allocated array.
393
+ If this keyword is set to `False`, a view of the input array
394
+ may be returned when possible.
395
+
396
+ Returns:
397
+ usm_ndarray:
398
+ An array with requested data type.
349
399
350
400
A view can be returned, if possible, when `copy=False` is used.
351
401
"""
0 commit comments