dl::AOTInductorBackend
dl::AOTInductorBackend
AOT Inductor inference backend — loads .pt2 packages via torch::inductor::AOTIModelPackageLoader. More…
#include <AOTInductorBackend.hpp>
Inherits from dl::InferenceBackend
Public Classes
| Name | |
|---|---|
| struct | Impl |
Public Functions
| Name | |
|---|---|
| AOTInductorBackend() | |
| ~AOTInductorBackend() override | |
| AOTInductorBackend(AOTInductorBackend && ) | |
| AOTInductorBackend & | operator=(AOTInductorBackend && ) |
| virtual std::string | name() const override Human-readable backend name (e.g. “TorchScript”, “AOTInductor”). |
| virtual BackendType | type() const override The BackendType enum value for this backend. |
| virtual std::string | fileExtension() const override File extension this backend handles (e.g. “.pt”, “.pt2”, “.pte”). |
| virtual bool | load(std::filesystem::path const & path) override Load model weights/program from a file. |
| virtual bool | isLoaded() const override Whether a model is loaded and ready for execution. |
| virtual std::filesystem::path | loadedPath() const override Get the path of the currently loaded model. |
| virtual std::vector< at::Tensor > | execute(std::vector< at::Tensor > const & inputs) override Execute the default method (typically “forward”) with ordered inputs. |
| virtual std::vector< at::Tensor > | execute(std::string const & method_name, std::vector< at::Tensor > const & inputs) override Execute a named method with ordered inputs. |
Additional inherited members
Public Functions inherited from dl::InferenceBackend
| Name | |
|---|---|
| virtual | ~InferenceBackend() =default |
| InferenceBackend(InferenceBackend const & ) =delete |
Protected Functions inherited from dl::InferenceBackend
| Name | |
|---|---|
| InferenceBackend() =default | |
| InferenceBackend(InferenceBackend && ) =default |
Detailed Description
class dl::AOTInductorBackend;AOT Inductor inference backend — loads .pt2 packages via torch::inductor::AOTIModelPackageLoader.
Note: AOT Inductor does not support multiple named methods per package. The method_name parameter in [execute()](/api_generated/Classes/classdl_1_1AOTInductorBackend.md#function-execute) is ignored; the compiled model’s single entry point is always invoked.
This is the recommended backend for new model deployment. AOT Inductor produces ahead-of-time compiled native code (CPU or CUDA kernels) from torch.export() + aoti_compile_and_package() in Python.
Key characteristics:
- Best inference performance — native compiled kernels with autotuning
- Operator fusion and optimization done at compile time
- Supports dynamic shapes (specified at export via
torch.export.Dim()) - Supports CUDA and CPU execution
- Headers are part of the bundled libtorch 2.9.0 distribution
Public Functions Documentation
function AOTInductorBackend
AOTInductorBackend()function ~AOTInductorBackend
~AOTInductorBackend() overridefunction AOTInductorBackend
AOTInductorBackend(
AOTInductorBackend &&
)function operator=
AOTInductorBackend & operator=(
AOTInductorBackend &&
)function name
virtual std::string name() const overrideHuman-readable backend name (e.g. “TorchScript”, “AOTInductor”).
Reimplements: dl::InferenceBackend::name
function type
virtual BackendType type() const overrideThe BackendType enum value for this backend.
Reimplements: dl::InferenceBackend::type
function fileExtension
virtual std::string fileExtension() const overrideFile extension this backend handles (e.g. “.pt”, “.pt2”, “.pte”).
Reimplements: dl::InferenceBackend::fileExtension
function load
virtual bool load(
std::filesystem::path const & path
) overrideLoad model weights/program from a file.
Parameters:
- path Path to the model file.
Return: true if loading succeeded.
Reimplements: dl::InferenceBackend::load
function isLoaded
virtual bool isLoaded() const overrideWhether a model is loaded and ready for execution.
Reimplements: dl::InferenceBackend::isLoaded
function loadedPath
virtual std::filesystem::path loadedPath() const overrideGet the path of the currently loaded model.
Reimplements: dl::InferenceBackend::loadedPath
function execute
virtual std::vector< at::Tensor > execute(
std::vector< at::Tensor > const & inputs
) overrideExecute the default method (typically “forward”) with ordered inputs.
Parameters:
- inputs Ordered vector of input tensors.
Exceptions:
- std::runtime_error if the model is not loaded or execution fails.
Return: Ordered vector of output tensors.
Reimplements: dl::InferenceBackend::execute
All tensors are at::Tensor (libtorch) — the common currency across all backends.
function execute
virtual std::vector< at::Tensor > execute(
std::string const & method_name,
std::vector< at::Tensor > const & inputs
) overrideExecute a named method with ordered inputs.
Parameters:
- method_name Name of the method to execute (e.g. “forward”, “encode”).
- inputs Ordered vector of input tensors.
Exceptions:
- std::runtime_error if the model is not loaded or execution fails.
Return: Ordered vector of output tensors.
Reimplements: dl::InferenceBackend::execute
Not all backends support multiple methods. Backends that don’t should ignore the method_name and execute the default model.
Updated on 2026-11-13 at 20:25:42 +0000