abracudabra.device.query ======================== .. py:module:: abracudabra.device.query .. autoapi-nested-parse:: Query the device of a numpy/cupy array, series or torch tensor. Functions --------- .. autoapisummary:: abracudabra.device.query._cupy_get_device abracudabra.device.query.frame_get_device_type abracudabra.device.query._torch_get_device abracudabra.device.query.get_device abracudabra.device.query.guess_device Module Contents --------------- .. py:function:: _cupy_get_device(array: object, /) -> abracudabra.device.base.Device Get the device of a cupy array. :param array: The array to check. :returns: The device of the array. .. py:function:: frame_get_device_type(frame: abracudabra.annotations.Series | abracudabra.annotations.DataFrame, /, *, raise_if_unknown: Literal[True] = ...) -> abracudabra.device.base.DeviceType frame_get_device_type(frame: abracudabra.annotations.Series | abracudabra.annotations.DataFrame, /, *, raise_if_unknown: bool = ...) -> abracudabra.device.base.DeviceType | None Get the device type of a pandas or cudf series or dataframe. .. py:function:: _torch_get_device(tensor: torch.Tensor, /) -> abracudabra.device.base.Device Get the device of a torch tensor. :param tensor: The tensor to check. :returns: The device of the tensor. .. py:function:: get_device(element: abracudabra.annotations.Array | torch.Tensor, /, *, raise_if_unknown: Literal[True] = ...) -> abracudabra.device.base.Device get_device(element: abracudabra.annotations.Array | torch.Tensor, /, *, raise_if_unknown: bool = ...) -> abracudabra.device.base.Device | None Get the device of a numpy/cupy array or series. :param element: The element to check. :param raise_if_unknown: Whether to raise an error if the element is not a known array or tensor. :returns: The device of the element. .. py:function:: guess_device(*elements: abracudabra.annotations.Array | torch.Tensor, skip_unknown: bool = True) -> abracudabra.device.base.Device Guess the device of a numpy/cupy array or series. :param \*elements: The elements to check. :param skip_unknown: Whether to skip elements that are not known arrays or tensors. :returns: The device of the elements. :raises ValueError: If no elements are given. :raises ValueError: If the elements are on different devices.