FFCV Operations

Operations for the fastxtend 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.


source

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.


source

ToTensorBase

 ToTensorBase (tensor_cls:TensorBase=<class
               'fastai.torch_core.TensorBase'>)

Convert from Numpy array to fastai TensorBase or tensor_cls.


source

ToTensorImage

 ToTensorImage (tensor_cls:TensorImageBase=<class
                'fastai.torch_core.TensorImage'>)

Convenience operation to convert from Numpy array to fastai TensorImage or tensor_cls.


source

ToTensorImageBW

 ToTensorImageBW ()

Convenience operation to convert from Numpy array to fastai TensorImageBW.


source

ToTensorMask

 ToTensorMask ()

Convenience operation to convert from Numpy array to fastai TensorMask.


source

ToTensorCategory

 ToTensorCategory ()

Convenience operation to convert from Numpy array to fastxtend TensorCategory.


source

ToTensorMultiCategory

 ToTensorMultiCategory ()

Convenience operation convert from Numpy array to fastxtend TensorMultiCategory.


source

ToTensorTitledTensorScalar

 ToTensorTitledTensorScalar ()

Convenience operation convert from Numpy array to fastai TitledTensorScalar.