tilelang.language.frame¶
Override the LetFrame to print a message when entering the frame.
Classes¶
A stack-like container for managing TIR frame objects and their variable bindings. |
|
A TIR frame for let bindings that manages variable scope and value tracking. |
Functions¶
|
Record the value behind a flat tirx Bind. |
Clear all Python-side bindings recorded for the current thread. |
|
|
Check if a variable has a binding in the current let frame stack. |
|
Get the value bound to a variable in the current let frame stack. |
Module Contents¶
- class tilelang.language.frame.FrameStack¶
A stack-like container for managing TIR frame objects and their variable bindings.
This class implements a stack data structure using a deque and maintains a mapping of variables to their values. It provides methods for stack operations and variable value lookups.
- push(item)¶
Push an item onto the stack and update variable mapping if applicable.
- Parameters:
item – The frame object to push onto the stack
- pop()¶
Remove and return the top item from the stack.
- Returns:
The top frame object from the stack
- Raises:
IndexError – If the stack is empty
- get_value(var)¶
Retrieve the value associated with a variable.
- Parameters:
var – The variable to look up
- Returns:
The value associated with the variable, or None if not found
- set_value(var, value)¶
Record a variable binding that is not represented by a scoped frame.
- clear_values()¶
Clear all tracked variable bindings.
- has_value(var)¶
Check if a variable has an associated value.
- Parameters:
var – The variable to check
- Returns:
True if the variable has an associated value, False otherwise
- Return type:
- top()¶
Return the top item of the stack without removing it.
- Returns:
The top frame object from the stack
- Raises:
IndexError – If the stack is empty
- __len__()¶
Returns the number of items in the stack.
- __bool__()¶
Allows truthy checks on the stack object itself, e.g., ‘if stack: …’
- tilelang.language.frame.register_let_value(var, value)¶
Record the value behind a flat tirx Bind.
The legacy LetFrame path updated FrameStack through __enter__/__exit__. tirx emits flat Bind statements instead, so callers that need to recover BufferRegion aliases must explicitly register the Python-side mapping.
- Parameters:
var (tvm.tirx.Var)
value (tvm.tirx.PrimExpr | tvm.tirx.BufferRegion)
- tilelang.language.frame.clear_let_values()¶
Clear all Python-side bindings recorded for the current thread.
- class tilelang.language.frame.LetFrame¶
Bases:
tvm.tirx.script.builder.frame.TIRFrameA TIR frame for let bindings that manages variable scope and value tracking.
This frame type extends TIRFrame to provide variable binding functionality and maintains a global stack of active bindings.
- __enter__()¶
Enter the let frame scope and process buffer loads.
- Returns:
The variable bound in this frame
- Return type:
Var
- __exit__(ptype, value, trace)¶
Exit the let frame scope and clean up the stack.
- Parameters:
ptype – Exception type if an exception occurred
value – Exception value if an exception occurred
trace – Exception traceback if an exception occurred
- classmethod Current()¶
Get the current (topmost) let frame.
- Returns:
The current let frame
- Return type:
- Raises:
IndexError – If there are no active let frames
- static get_value(var)¶
Get the value bound to a variable in any active frame.
- Parameters:
var (Var) – The variable to look up
- Returns:
The value bound to the variable, or None if not found
- tilelang.language.frame.has_let_value(var)¶
Check if a variable has a binding in the current let frame stack.
- Parameters:
var (Var) – The variable to check
- Returns:
True if the variable has a binding, False otherwise
- Return type:
- tilelang.language.frame.get_let_value(var)¶
Get the value bound to a variable in the current let frame stack.
- Parameters:
var (Var) – The variable to look up
- Returns:
The bound value if found, None otherwise
- Return type:
Optional[PrimExpr]