Skip to content

custom_op

Classes

fastvideo.layers.custom_op.CustomOp

CustomOp()

Bases: Module

Base class for custom ops. Dispatches the forward method to the appropriate backend.

Source code in fastvideo/layers/custom_op.py
def __init__(self) -> None:
    super().__init__()
    self._forward_method = self.dispatch_forward()

Functions

fastvideo.layers.custom_op.CustomOp.default_on staticmethod
default_on() -> bool

On by default if level < CompilationLevel.PIECEWISE Specifying 'all' or 'none' in custom_op takes precedence.

Source code in fastvideo/layers/custom_op.py
@staticmethod
def default_on() -> bool:
    """
    On by default if level < CompilationLevel.PIECEWISE
    Specifying 'all' or 'none' in custom_op takes precedence.
    """
    raise NotImplementedError
fastvideo.layers.custom_op.CustomOp.forward_native
forward_native(*args, **kwargs) -> Any

PyTorch-native implementation of the forward method. This method is optional. If implemented, it can be used with compilers such as torch.compile or PyTorch XLA. Also, it can be used for testing purposes.

Source code in fastvideo/layers/custom_op.py
def forward_native(self, *args, **kwargs) -> Any:
    """PyTorch-native implementation of the forward method.
    This method is optional. If implemented, it can be used with compilers
    such as torch.compile or PyTorch XLA. Also, it can be used for testing
    purposes.
    """
    raise NotImplementedError

Functions