abracudabra.device.conversion#

Move an array, series, or tensor to a device.

Functions#

to_cupy_array(→ object)

Convert a sequence to a cupy array.

array_to_device(→ abracudabra.annotations.Array)

Move a numpy/cupy array to a device.

frame_to_device(…)

Move a pandas/cudf series or dataframe to a device.

tensor_to_device(→ torch.Tensor)

Move a torch tensor to a device.

to_device(...)

Move an array, series, or tensor to a device.

Module Contents#

abracudabra.device.conversion.to_cupy_array(sequence: object, /, device_idx: int | None = None) object[source]#

Convert a sequence to a cupy array.

abracudabra.device.conversion.array_to_device(array: object, /, device: abracudabra.device.base.Device | str) abracudabra.annotations.Array[source]#

Move a numpy/cupy array to a device.

abracudabra.device.conversion.frame_to_device(frame: abracudabra.annotations.Index, /, device_type: Literal['cpu']) pandas.Index[source]#
abracudabra.device.conversion.frame_to_device(frame: abracudabra.annotations.Index, /, device_type: Literal['cuda']) cudf.Index
abracudabra.device.conversion.frame_to_device(frame: abracudabra.annotations.Series, /, device_type: Literal['cpu']) pandas.Series
abracudabra.device.conversion.frame_to_device(frame: abracudabra.annotations.Series, /, device_type: Literal['cuda']) cudf.Series
abracudabra.device.conversion.frame_to_device(frame: abracudabra.annotations.DataFrame, /, device_type: Literal['cpu']) pandas.DataFrame
abracudabra.device.conversion.frame_to_device(frame: abracudabra.annotations.DataFrame, /, device_type: Literal['cuda']) cudf.DataFrame
abracudabra.device.conversion.frame_to_device(frame: object, /, device_type: abracudabra.device.base.DeviceType) abracudabra.annotations.Index | abracudabra.annotations.Series | abracudabra.annotations.DataFrame

Move a pandas/cudf series or dataframe to a device.

Parameters:
  • frame – The series or dataframe to move.

  • device_type – The device type to move the frame to.

Returns:

The series or dataframe on the specified device.

abracudabra.device.conversion.tensor_to_device(tensor: object, /, device: abracudabra.device.base.Device | str) torch.Tensor[source]#

Move a torch tensor to a device.

abracudabra.device.conversion.to_device(sequence: abracudabra.annotations.Array | abracudabra.annotations.Series | torch.Tensor, /, device: abracudabra.device.base.Device | str) abracudabra.annotations.Array | abracudabra.annotations.Series | torch.Tensor[source]#

Move an array, series, or tensor to a device.

Call the appropriate function to move the element to the device: