@@ -108,19 +108,29 @@ def from_numpy(np_ary, device=None, usm_type="device", sycl_queue=None):
108
108
from_numpy(arg, device=None, usm_type="device", sycl_queue=None)
109
109
110
110
Creates :class:`dpctl.tensor.usm_ndarray` from instance of
111
- `numpy.ndarray`.
111
+ :class: `numpy.ndarray`.
112
112
113
113
Args:
114
- arg: An instance of input `numpy.ndarray`
115
- device: array API specification of device where the output array
116
- is created
117
- usm_type: The requested USM allocation type for the output array
118
- sycl_queue: a :class:`dpctl.SyclQueue` instance that determines
119
- output array allocation device as well as placement of data
120
- movement operation. The `device` and `sycl_queue` arguments
114
+ arg (array-like): An instance of input convertible to
115
+ :class:`numpy.ndarray`
116
+ device (object): array API specification of device where the
117
+ output array is created. Device can be specified by a
118
+ a filter selector string, an instance of
119
+ :class:`dpctl.SyclDevice`, an instance of
120
+ :class:`dpctl.SyclQueue`, an instance of
121
+ :class:`dpctl.tensor.Device`. If the value is `None`,
122
+ returned array is created on the default-selected device.
123
+ Default: `None`.
124
+ usm_type (str): The requested USM allocation type for the
125
+ output array. Recognized values are `"device"`, `"shared"`,
126
+ or `"host"`.
127
+ sycl_queue (:class:`dpctl.SyclQueue`, optional):
128
+ A SYCL queue that determines output array allocation device
129
+ as well as execution placement of data movement operations.
130
+ The `device` and `sycl_queue` arguments
121
131
are equivalent. Only one of them should be specified. If both
122
132
are provided, they must be consistent and result in using the
123
- same execution queue.
133
+ same execution queue. Default: `None`.
124
134
125
135
The returned array has the same shape, and the same data type kind.
126
136
If the device does not support the data type of input array, a
@@ -137,12 +147,15 @@ def to_numpy(usm_ary):
137
147
to_numpy(usm_ary)
138
148
139
149
Copies content of :class:`dpctl.tensor.usm_ndarray` instance `usm_ary`
140
- into `numpy.ndarray` instance of the same shape and same data type.
150
+ into :class: `numpy.ndarray` instance of the same shape and same data type.
141
151
142
152
Args:
143
- usm_ary: An instance of :class:`dpctl.tensor.usm_ndarray`
153
+ usm_ary (usm_ndarray):
154
+ Input array
144
155
Returns:
145
- An instance of `numpy.ndarray` populated with content of `usm_ary`.
156
+ :class:`numpy.ndarray`:
157
+ An instance of :class:`numpy.ndarray` populated with content of
158
+ `usm_ary`
146
159
"""
147
160
return _copy_to_numpy (usm_ary )
148
161
@@ -152,18 +165,24 @@ def asnumpy(usm_ary):
152
165
asnumpy(usm_ary)
153
166
154
167
Copies content of :class:`dpctl.tensor.usm_ndarray` instance `usm_ary`
155
- into `numpy.ndarray` instance of the same shape and same data type.
168
+ into :class:`numpy.ndarray` instance of the same shape and same data
169
+ type.
156
170
157
171
Args:
158
- usm_ary: An instance of :class:`dpctl.tensor.usm_ndarray`
172
+ usm_ary (usm_ndarray):
173
+ Input array
159
174
Returns:
160
- An instance of `numpy.ndarray` populated with content of `usm_ary`.
175
+ :class:`numpy.ndarray`:
176
+ An instance of :class:`numpy.ndarray` populated with content
177
+ of `usm_ary`
161
178
"""
162
179
return _copy_to_numpy (usm_ary )
163
180
164
181
165
182
class Dummy :
166
- "Helper class with specified __sycl_usm_array_interface__ attribute"
183
+ """
184
+ Helper class with specified ``__sycl_usm_array_interface__`` attribute
185
+ """
167
186
168
187
def __init__ (self , iface ):
169
188
self .__sycl_usm_array_interface__ = iface
@@ -263,10 +282,20 @@ def _copy_from_usm_ndarray_to_usm_ndarray(dst, src):
263
282
264
283
265
284
def copy (usm_ary , order = "K" ):
266
- """
267
- Creates a copy of given instance of `usm_ndarray`.
285
+ """copy(ary, order="K")
286
+
287
+ Creates a copy of given instance of :class:`dpctl.tensor.usm_ndarray`.
288
+
289
+ Args:
290
+ ary (usm_ndarray):
291
+ Input array.
292
+ order ({"C", "F", "A", "K"}, optional):
293
+ Controls the memory layout of the output array.
294
+ Returns:
295
+ usm_ndarray:
296
+ A copy of the input array.
268
297
269
- Memory layour of the copy is controlled by `order` keyword,
298
+ Memory layout of the copy is controlled by `order` keyword,
270
299
following NumPy's conventions. The `order` keywords can be
271
300
one of the following:
272
301
@@ -325,10 +354,31 @@ def copy(usm_ary, order="K"):
325
354
326
355
327
356
def astype (usm_ary , newdtype , order = "K" , casting = "unsafe" , copy = True ):
328
- """
329
- astype(usm_array, new_dtype, order="K", casting="unsafe", copy=True)
357
+ """ astype(array, new_dtype, order="K", casting="unsafe", \
358
+ copy=True)
359
+
360
+ Returns a copy of the :class:`dpctl.tensor.usm_ndarray`, cast to a
361
+ specified type.
330
362
331
- Returns a copy of the array, cast to a specified type.
363
+ Args:
364
+ array (usm_ndarray):
365
+ An input array.
366
+ new_dtype (dtype):
367
+ The data type of the resulting array.
368
+ order ({"C", "F", "A", "K"}, optional):
369
+ Controls memory layout of the resulting array if a copy
370
+ is returned.
371
+ casting ({'no', 'equiv', 'safe', 'same_kind', 'unsafe'}, optional):
372
+ Controls what kind of data casting may occur. Please see
373
+ :meth:`numpy.ndarray.astype` for description of casting modes.
374
+ copy (bool, optional):
375
+ By default, `astype` always returns a newly allocated array.
376
+ If this keyword is set to `False`, a view of the input array
377
+ may be returned when possible.
378
+
379
+ Returns:
380
+ usm_ndarray:
381
+ An array with requested data type.
332
382
333
383
A view can be returned, if possible, when `copy=False` is used.
334
384
"""
0 commit comments