Skip to content

operator

Classes

AotOperator

AotOperator(op: AirOperator, model: AirModel, platform: SocPlatform, prefix: str = 'aot', attributes: dict[str, str] = {})

Base class for all AOT operators.

Execution flow: 1. Initialize the operator. 2. Call resolve() to validate and prepare the operator. 3. Call plan() to set up any necessary planning. 4. Call emit() to generate the operator's code.

Parameters:

  • op

    (AirOperator) –

    The AIR operator to wrap.

  • model

    (AirModel) –

    The AIR model.

  • platform

    (SocPlatform) –

    The target platform for code generation.

  • prefix

    (str, default: 'aot' ) –

    Prefix for generated code files. Defaults to "aot".

  • attributes

    (dict[str, str], default: {} ) –

    Attributes for template values. Defaults to {}.

Attributes

id property
id: str

Return the operator ID.

name property
name: str

Return the operator name.

input_tensors property
input_tensors: list[AirTensor]

Return the input tensors.

output_tensors property
output_tensors: list[AirTensor]

Return the output tensors.

local_tensors property
local_tensors: list[AirTensor]

Get all local tensors used by the operator.

Functions

get_local_tensor
get_local_tensor(name: str) -> AirTensor

Get a local tensor by name.

validate
validate()

Validate the operator configuration.

resolve
resolve()

Public entry point—only runs once, even if called repeatedly.

This method validates the AIR operator and performs any model mutations needed.

on_resolve
on_resolve()

Override this in subclasses to do the actual work.

plan
plan()

Operator planning step.

compute_values
compute_values() -> dict[str, str]

Compute the values for the operator source code template.

Args:

Returns:

  • dict[str, str]

    dict[str, str]: Dictionary of values for the operator template.

print_info
print_info(verbose: int = 0)

Debug print the template values for the operator.

emit
emit(save_path: Path)

Generate the source code for the operator.

This method should be overridden by subclasses.

Parameters:

  • save_path
    (Path) –

    Path to save the generated source code.

Functions

run_once

run_once(method)

Decorator to run a method only once per instance.