aitune.torch.backend.torch_eager
aitune.torch.backend.torch_eager
Torch eager backend.
Module Contents
Classes
API
Bases: Backend
Backend that runs the model in eager mode with/without autocast.
Note: inference is done with torch.no_grad() context. The torch.inference_mode() context must not be used as it would require outputs from a model to be used with same inference mode - this would be confusing to a user and required code changes from the user.
Activates runner.
Builds the model.
Deactivates runner.
Deploys the backend.
Get the required casting dtype of the module by running a sample inference with and without autocast.
If the dtype of the output is different with and without autocast, return the dtype of the output without autocast. Otherwise, return None.
Parameters:
The module to get the dtype from.
List of sample inputs to run through the module.
Returns: torch.dtype | None
torch.dtype: The required casting dtype. Returns None if no casting is required.
Runs inference with the given arguments. Does not use autocast.
It can be replaced at runtime by _infer_with_autocast.
Parameters:
inference arguments
inference keyword arguments
Returns: Any
The result of the inference.
Runs inference with the given arguments.
Parameters:
inference arguments
inference keyword arguments
Returns: Any
The result of the inference.
Store the backend configuration to a file.
Returns the description of the backend.
Creates a backend from a state_dict.
Returns True if the backend is a JIT backend.
Returns the key of the backend.
Returns the state_dict of the backend.
Bases: BackendConfig
Configuration for torch eager backend.
Parameters:
If True, enable autocast.
The dtype to use for autocast.