Skip to content
heliaAOT
API Reference
HELIA HUB

converter

The AotConverter class is responsible for converting a model into an AOT inference C module.

Classes

Name Description
AotConverter Performs the AOT conversion process.
ConversionResult What a finished conversion wrote.

Copyright 2025 Ambiq. All Rights Reserved.

Machine-readable model

  • ConversionResultclassWhat a finished conversion wrote, as AotConverter.convert() returns it.
  • AotConverterclassConverts a trained model into a self-contained AOT inference C module.
class

What a finished conversion wrote, as AotConverter.convert() returns it.

helia_aot/converter.py:135

ConversionResult(
output: Path,
prefix: str,
plan: OptimizationPlan,
report: OptimizationReport,
work_dir: Path | None,
operators: tuple[OperatorView, ...] | None = None,
tensors: tuple[TensorView, ...] | None = None,
regions: tuple[RegionView, ...] | None = None,
placements: Mapping[str, PlacementView] | None = None,
preparation: PreparationResult | None = None,
) -> None

dataclass

What a finished conversion wrote, as AotConverter.convert() returns it.

A result compares and hashes by identity, so it can key a dict or join a set. To compare two conversions, compare their plan and report, which compare by value.

attribute

output

Python

helia_aot/converter.py:168

output: Path

The module directory, module.path joined with module.name, or the .zip or .pack archive that module.path names.

attribute

work_dir

Python

helia_aot/converter.py:172

work_dir: Path | None

The temporary work directory, which holds the generated sources under module.name, when keep_work_dir kept it; otherwise None, as the conversion removed it.

attribute

operators

Python

helia_aot/converter.py:173

operators: tuple[OperatorView, ...] | None = None

With result_views, the generated operators in execution order, which is the order the generated operator callback reports them in; otherwise None.

attribute

tensors

Python

helia_aot/converter.py:174

tensors: tuple[TensorView, ...] | None = None

With result_views, the module’s tensors in the order of its tensor enumeration; otherwise None.

attribute

regions

Python

helia_aot/converter.py:175

regions: tuple[RegionView, ...] | None = None

With result_views, the module’s arena regions, where regions[i].id == i; otherwise None.

attribute

helia_aot/converter.py:176

placements: Mapping[str, PlacementView] | None = None

With result_views, each tensor’s placement, keyed by tensor id; otherwise None.

attribute

helia_aot/converter.py:177

preparation: PreparationResult | None = None

The retained record, source and prepared model identity when model preparation was requested.

class

Converts a trained model into a self-contained AOT inference C module.

helia_aot/converter.py:180

AotConverter(config: ConvertArgs, registry_context: RegistryContext | None = None)

Converts a trained model into a self-contained AOT inference C module.

The converter owns the six-stage pipeline (Load, Transform, Resolve, Plan, Emit, Export) described on convert(), which is the single entry point; the CLI is a thin wrapper around it. All behavior is driven by the ConvertArgs config supplied at construction, and every dispatch (parsers, operator classes, transforms) goes through the registry context, so a caller can extend the compiler without patching it.

Parameters of AotConverter
NameTypeDefaultDescription
configConvertArgsRequiredConversion parameters.
registry_contextRegistryContext | NoneNoneOptional registry context for parser/operator/transform dispatch. If omitted, a fresh default frozen context is created.
method

convert

Python

Convert a model to an AOT module: the model file model.path names, or an AIR model made from it.

helia_aot/converter.py:211

convert(model: AirModel | None = None) -> ConversionResult

Convert a model to an AOT module: the model file model.path names, or an AIR model made from it.

Without model, the converter reads the file model.path names. A front end that builds AIR itself, such as an importer for quantized PyTorch programs, passes its model, and model.path names the file it converted, such as the saved program: heliaAOT does not read a model out of that file, so its format is not checked. Either way the conversion is the same, and the plan identifies the model by model.path and model.subgraph: the file’s name, the SHA-256 heliaAOT takes of its bytes, and the subgraph or partition. The converter works on a copy of a model it is given, so the caller’s model is unchanged.

Code is generated in a temporary work directory that is removed once the conversion ends, whether it succeeds or fails, unless keep_work_dir is set.

Parameters of convert
NameTypeDefaultDescription
modelAirModel | NoneNoneAn AIR model to convert, made from the file ``model.path`` names. The argument is provisional: a minor release can change how a model is given. ``AirModel`` itself is a promised name (``helia_aot.air``), though building one uses names that are provisional there, such as the per-operator options and the quantization details. ``config.model``'s name, description and version replace the model's only where the configuration sets them to something other than their defaults.
Returns of convert
ValueTypeDescription
ConversionResultConversionResultWhere the module was written, its prefix, its
ConversionResultoptimization plan and report, the kept work directory, and, with
ConversionResult``result_views``, its operators, tensors, regions and placements.
Errors raised by convert
TypeDescription
InvalidConfigErrorBefore the model loads, if an ``operators[]`` attribute key or value is one that no operator the rule reaches in the registry context takes, or if ``module.path`` cannot be written: a directory path that names a file, an archive path that names a directory, a symbolic link to nothing, a path under a file or under a directory it cannot search, a location without write permission, or a file name the file system cannot hold. Also if ``optimization.plan`` names another subgraph. Before emission, if the model file digest differs from the input plan. For a model that is given, if ``model.path`` does not name a readable file, ``model.preparation`` is set (it prepares a model file for the converter to read, and a given model is not read), or ``test.enabled`` is set without ``test.golden_data`` or ``test.skip_verification``.
ModelLoadErrorIf the model file is missing, unreadable or not a LiteRT model.
ModelStructureErrorIf a given model names a tensor that does not exist, has a broken producer or alias, has a constant an operator reads without its data, or has an operator read a tensor that nothing gives a value.
OperatorOrderErrorIf a given model's operators are not in execution order.
HeliaAotErrorAnother subclass naming what stopped the conversion.