Skip to content
heliaAOT
API Reference
HELIA HUB

shape_propagation

Machine-readable model

  • ShapeRuleResultclassBase type for shape propagation rule outcomes.
  • NotApplicableclassRule does not own this operator case and generic fallback may run.
  • UpdatedclassRule produced concrete output shape updates.
  • NoUpdateclassRule owns this operator case and no shape update is required.
  • BlockedclassRule owns this operator case and cannot safely infer an update.
  • RejectedclassRule owns this operator case and its operands are invalid, whatever their values.
  • ShapeInferenceResultclassShape propagation outcome.
  • propagate_shapesfunctionInfer tensor shapes and shape-expression values over the graph until fixed point.
class

Base type for shape propagation rule outcomes.

helia_aot/air/shape_propagation.py:78

ShapeRuleResult()

Base type for shape propagation rule outcomes.

Provisional: importable, but outside the compatibility promise; a minor release can change or remove it.

class

Rule does not own this operator case and generic fallback may run.

helia_aot/air/shape_propagation.py:82

NotApplicable() -> None

dataclass

Rule does not own this operator case and generic fallback may run.

Provisional: importable, but outside the compatibility promise; a minor release can change or remove it.

class

Rejected

Python

Rule owns this operator case and its operands are invalid, whatever their values.

helia_aot/air/shape_propagation.py:112

Rejected(reason: str) -> None

dataclass

Rule owns this operator case and its operands are invalid, whatever their values.

Provisional: importable, but outside the compatibility promise; a minor release can change or remove it.

Once the operator’s inputs are proven, shape propagation raises UnsupportedModelError with the reason. LiteRT rejects such operands before executing the operator.

class

Shape propagation outcome.

helia_aot/air/shape_propagation.py:126

ShapeInferenceResult(
changed_tensor_ids: set[str] = set(),
confirmed_tensor_ids: set[str] = set(),
evaluated_tensor_ids: set[str] = set(),
unresolved_tensor_ids: set[str] = set(),
deferred_conflict_tensor_ids: set[str] = set(),
diagnostics: list[str] = list(),
) -> None

dataclass

Shape propagation outcome.

Provisional: importable, but outside the compatibility promise; a minor release can change or remove it.

attribute

helia_aot/air/shape_propagation.py:149

confirmed_tensor_ids: set[str] = field(default_factory=set)

Tensor IDs whose shapes a rule computed from proven operands, whether or not the stored shape changed, plus concrete graph inputs with a dynamic signature. A dynamic-signature tensor whose inferred shape already matched is resolved, not unresolved.

attribute

helia_aot/air/shape_propagation.py:152

deferred_conflict_tensor_ids: set[str] = field(default_factory=set)

Unresolved tensor IDs whose inferred shape conflicted with their declared contract while computed from an unresolved operand. Such a shape can come from a placeholder, so the update was dropped rather than raised.

attribute

helia_aot/air/shape_propagation.py:153

diagnostics: list[str] = field(default_factory=list)

Human-readable diagnostics describing inference updates and unresolved tensors. Skip diagnostics (rule/fallback skipped) are only included when DEBUG logging is enabled to avoid unbounded growth on large graphs.

function

Infer tensor shapes and shape-expression values over the graph until fixed point.

helia_aot/air/shape_propagation.py:1389

propagate_shapes(model: AirModel, *, strict: bool = False, warn_unresolved: bool = True) -> ShapeInferenceResult

Infer tensor shapes and shape-expression values over the graph until fixed point.

Provisional: importable, but outside the compatibility promise; a minor release can change or remove it.

Shapes and values depend on each other: SHAPE turns a tensor’s shape into a value, and a RESHAPE turns its target value back into a shape. Both are facts in the same worklist, so a chain of any depth resolves without a fixed pass order. Values are computed only for SHAPE and for STRIDED_SLICE and PACK nodes over shape-derived tensors (see shape_expressions), and only from proven shapes, so a placeholder can never become a value. A shape the model declares fully static counts as proven, so a value can come from declared metadata as well as from the graph-input shapes. Each value is stored in AirTensor._inferred_value, never in data, and the graph structure is left unchanged; FoldStaticShapeExpressions turns the values into constants afterwards.

A rule computes its operator’s outputs whether or not they are declared static. A declared static output is never rewritten: once the rule’s inputs are proven, a computed shape that differs from it is rejected, because the generated code would size the tensor by the declaration (#680).

Parameters of propagate_shapes
NameTypeDefaultDescription
modelAirModelRequiredAIR model to update in place.
strictboolFalseIf True, raise when unresolved dynamic tensors remain or a tensor's shape does not fit int32 (#677).
warn_unresolvedboolTrueIf True, log unresolved tensors when not raising.
Returns of propagate_shapes
TypeDescription
ShapeInferenceResultShape inference result with updated tensors and diagnostics.
Errors raised by propagate_shapes
TypeDescription
UnsupportedModelErrorIf ``strict`` is True and unresolved dynamic tensors remain or a tensor's extents do not fit int32, or if a shape or value computed from proven inputs contradicts a tensor's declared static shape or shape signature. Also, whatever ``strict``, if a shape rule rejects an operator's proven operands (``Rejected``), or if a convolution or pool has a stride or dilation below 1 and its shape rule reaches the output size: the rule needs a known rank-4 input (and, for a convolution, rank-4 weights), a recorded padding type, a window of at least 1 and no implicit upscale, and otherwise returns before checking.
TypeErrorIf an operator's options type does not match its shape rule's contract, or a rule returns an unknown result type.