to_device¶
- array.to_device(device: device, /, *, stream: int | Any | None = None) array¶
Copy the array from the device on which it currently resides to the specified
device.- Parameters:
self (array) – array instance.
device (device) – a
deviceobject (see Device support).stream (Optional[Union[int, Any]]) – 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.
- Returns:
out (array) – an array with the same data and data type as
selfand located on the specifieddevice.
Notes
When a provided
deviceobject corresponds to the same device on which an array instance resides, implementations may choose to perform an explicit copy or returnself.If
streamis provided, the copy operation should be enqueued on the providedstream; 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 array library’s documentation.
Changed in version 2023.12: Clarified behavior when a provided
deviceobject corresponds to the device on which an array instance resides.