torch#
- mvpy.utilities.compile.torch(*args: List[Any], **kwargs: Dict[str, Any]) Callable[source]#
Decorator that compiles a function with torch.compile, if available.
- Parameters:
- *argsList[Any]
Arguments to pass.
- **kwargsDict[str, Any]
Keyword arguments to pass.
- Returns:
- compiledCallable
Compiled function.
Examples
Let’s look at a very silly toy example: >>> import torch >>> from mvpy.utilities import compile >>> @compile.torch >>> def maths_a(x: torch.Tensor, y: torch.Tensor) -> torch.Tensor: >>> return x @ y.t() >>> @compile.torch(disable = True) >>> def maths_b(x: torch.Tensor, y: torch.Tensor) -> torch.Tensor: >>> return x @ y.t()