Execution Scope IR

Execution Scope IR#

tvm.tirx.exec_scope#

Definition of execution scope.

class tvm.tirx.exec_scope.ScopeIdDef(def_ids: list[Var], extents: list[Expr] | None, parent: str, cur: str, preferred_extents: list[Expr] | None = None)

Definition of scope identifiers with their extents and parent-child relationships.

The constructor accepts parent and cur as scope-name strings; they are converted by the FFI into the closed ScopeBinding enum and stored on the scope field (an int value of that enum).

extents=None defers the extent: the value is inferred from sibling ScopeIdDef relationships at LowerTIRx entry via the verifier’s closure. Deferred form requires def_ids to contain exactly one Var.

class tvm.tirx.exec_scope.ExecScope(name: str)

An execution scope, identified by one of {cluster, cta, warpgroup, warp, thread}. The ctor FATALs on any other name.

property name: str

Human-readable name of this scope (derived from kind).

tvm.tirx.exec_context#

ExecContext: per-program-point active-thread state.

The active thread set is represented as a TileLayout: active axes live in layout.shard and per-axis lower bounds live in layout.offset. Filters narrow that layout; scope switches derive the current inter/intra view.

exception tvm.tirx.exec_context.ExecContextError

Raised on structural violations of the ExecContext model.

class tvm.tirx.exec_context.AxisRange(extent: int, offset: int = 0, stride: int = 1)

An active slice offset + stride * [0, extent) on one TileLayout axis.

class tvm.tirx.exec_context.ActiveSet(layout: TileLayout)

Active thread set represented by a TileLayout.

class tvm.tirx.exec_context.LaneBinding(axis: str, kind: str, declared_extent: int)

Resolution of a user-declared ScopeIdDef tirx.Var to one active-set axis.

tvm.tirx.exec_context.initial_A(*, lane_ext: int = 32, warp_ext: int, cta_ext: int = 1) ActiveSet

Build A at PrimFunc device entry: all threads active, offsets all zero.

tvm.tirx.exec_context.filter_narrow(A: ActiveSet, binding: LaneBinding, lo: int, hi: int) ActiveSet

Intersect A’s binding axis with [lo, hi).

tvm.tirx.exec_context.filter_modulo(A: ActiveSet, axis: str, modulus: int, residue: int) ActiveSet

Intersect an active-set axis with axis % modulus == residue.

class tvm.tirx.exec_context.Split(inter: dict[str, AxisRange], intra: dict[str, AxisRange])

A scope_switch split of A.

tvm.tirx.exec_context.scope_switch(A: ActiveSet, scope_kind: str) Split

Split A into (inter, intra) for the target scope kind.

class tvm.tirx.exec_context.ExecContext(A: ActiveSet, scope_kind: str, inter: dict[str, AxisRange], intra: dict[str, AxisRange])

Per-program-point compiler state: active set + scope kind + split.