FFCV Operations
Loader
fastxtend provides multiple FFCV operations, including existing FFCV operations as a reference, a fastai compatible ToDevice
, and fastai compatible Tensor conversions.
By default, these operations are imported under ft
if using from fastxtend.ffcv.all import *
.
FFCV Operations Reference
These operations are from FFCV. You can find the original documentation at the FFCV API Reference.
Convert
Convert (target_dtype)
Convert to target data type.
View
View (target_dtype)
View array using np.view or torch.view.
ToDevice
While FFCV has a ToDevice
operation, it is recommended to use the fastxtend ToDevice
operation for compatability with fastai features.
ToDevice
ToDevice (device:int|str|torch.device|None=None, non_blocking:bool=True)
Copy tensor to Cuda device and retains metadata
Type | Default | Details | |
---|---|---|---|
device | int | str | torch.device | None | None | Copy tensor to this Cuda device. Defaults to fastai’s default_device() |
non_blocking | bool | True | Asynchronous if copying from CPU to GPU |
Convert to fastai Tensors
While FFCV has ToTensor
and ToTorchImage
operations for converting NumPy arrays to PyTorch Tensors, it is recommended to use these fastxtend operations for compatability with fastai features.
ToTensorBase
ToTensorBase (tensor_cls:TensorBase=<class 'fastai.torch_core.TensorBase'>)
Convert from Numpy array to fastai TensorBase or tensor_cls
.
ToTensorImage
ToTensorImage (tensor_cls:TensorImageBase=<class 'fastai.torch_core.TensorImage'>)
Convenience operation to convert from Numpy array to fastai TensorImage or tensor_cls
.
ToTensorImageBW
ToTensorImageBW ()
Convenience operation to convert from Numpy array to fastai TensorImageBW.
ToTensorMask
ToTensorMask ()
Convenience operation to convert from Numpy array to fastai TensorMask.
ToTensorCategory
ToTensorCategory ()
Convenience operation to convert from Numpy array to fastxtend TensorCategory.
ToTensorMultiCategory
ToTensorMultiCategory ()
Convenience operation convert from Numpy array to fastxtend TensorMultiCategory.
ToTensorTitledTensorScalar
ToTensorTitledTensorScalar ()
Convenience operation convert from Numpy array to fastai TitledTensorScalar.