Device#

class ivy.data_classes.array.device._ArrayWithDevice[source]#

Bases: ABC

_abc_impl = <_abc._abc_data object>#
dev(*, as_native=False)[source]#

ivy.Array instance method variant of ivy.dev. This method simply wraps the function, and so the docstring for ivy.dev also applies to this method with minimal changes.

Parameters:
  • self (Array) – array for which to get the device handle.

  • as_native (bool, default: False) – Whether or not to return the dev in native format. Default is False.

Return type:

Union[Device, NativeDevice]

Examples

>>> x = ivy.array([[2, 5, 4, 1], [3, 1, 5, 2]])
>>> y = x.dev(as_native=True)
>>> print(y)
cpu
to_device(device, *, stream=None, out=None)[source]#

ivy.Array instance method variant of ivy.to_device. This method simply wraps the function, and so the docstring for ivy.to_device also applies to this method with minimal changes.

Parameters:
  • self (Array) – input array to be moved to the desired device

  • device (Union[Device, NativeDevice]) – device to move the input array x to

  • stream (Optional[Union[int, Any]], default: None) – 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.

  • out (Optional[Array], default: None) – optional output array, for writing the result to. It must have a shape that the inputs broadcast to.

Return type:

Array

Examples

>>> x = ivy.array([2, 5, 4, 1])
>>> y = x.to_device('cpu')
>>> print(y.device)
cpu