abracudabra.conversion.ctensor ============================== .. py:module:: abracudabra.conversion.ctensor .. autoapi-nested-parse:: Convert to torch tensor. Functions --------- .. autoapisummary:: abracudabra.conversion.ctensor._to_tensor abracudabra.conversion.ctensor.to_tensor Module Contents --------------- .. py:function:: _to_tensor(sequence: abracudabra.annotations.Array | abracudabra.annotations.Series | abracudabra.annotations.DataFrame | torch.Tensor, /, *, strict: bool = False) -> torch.Tensor Convert an array, series, or dataframe to a torch tensor. The device of the tensor is determined by the device of the input. .. py:function:: to_tensor(sequence: abracudabra.annotations.Array | abracudabra.annotations.Series | torch.Tensor, /, device: abracudabra.device.base.Device | str | None = None, *, strict: bool = False) -> torch.Tensor Convert an array, series, or dataframe to a torch tensor. :param sequence: The sequence to convert. :param device: The device to convert the sequence to. If None, the sequence stays on the same device. :param strict: Whether to raise an error if the sequence is not a valid type. A numpy/cupy array, pandas/cudf series or dataframe, or torch tensor are valid types. If False, the sequence is converted to a torch tensor if possible, but it might raise an error if the conversion is not possible. :returns: A torch tensor.