You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This helper is included because some array libraries do not have the
422
+
`to_device` method.
423
+
265
424
Parameters
266
425
----------
426
+
267
427
x: array
268
-
array instance from NumPy or an array API compatible library.
428
+
array instance from an array API compatible library.
429
+
269
430
device: device
270
-
a ``device`` object (see the "Device Support" section of the array API specification).
431
+
a ``device`` object (see the `Device Support <https://data-apis.org/array-api/latest/design_topics/device_support.html>`__
432
+
section of the array API specification).
433
+
271
434
stream: Optional[Union[int, Any]]
272
-
stream object to use during copy. In addition to the types supported in ``array.__dlpack__``, implementations may choose to support any library-specific stream object with the caveat that any code using such an object would not be portable.
435
+
stream object to use during copy. In addition to the types supported
436
+
in ``array.__dlpack__``, implementations may choose to support any
437
+
library-specific stream object with the caveat that any code using
438
+
such an object would not be portable.
273
439
274
440
Returns
275
441
-------
442
+
276
443
out: array
277
-
an array with the same data and data type as ``x`` and located on the specified ``device``.
444
+
an array with the same data and data type as ``x`` and located on the
445
+
specified ``device``.
446
+
447
+
Notes
448
+
-----
449
+
450
+
For NumPy, this function effectively does nothing since the only supported
451
+
device is the CPU. For CuPy, this method supports CuPy CUDA `Device
objects. For PyTorch, this is the same as ``x.to(device)
456
+
<https://pytorch.org/docs/stable/generated/torch.Tensor.to.html>`_ (the
457
+
``stream`` argument is not supported in PyTorch).
458
+
459
+
See Also
460
+
--------
461
+
462
+
device : Hardware device the array data resides on.
278
463
279
-
.. note::
280
-
If ``stream`` is given, the copy operation should be enqueued on the provided ``stream``; otherwise, the copy operation should be enqueued on the default stream/queue. Whether the copy is performed synchronously or asynchronously is implementation-dependent. Accordingly, if synchronization is required to guarantee data safety, this must be clearly explained in a conforming library's documentation.
0 commit comments