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¶
|
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
- 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:
bool
- 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: …’
- class tilelang.language.frame.LetFrame¶
Bases:
tvm.script.ir_builder.tir.frame.TIRFrame
A 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
- static has_value(var)¶
Check if a variable has a binding in any active frame.
- Parameters:
var (Var) – The variable to check
- Returns:
True if the variable has a binding, False otherwise
- Return type:
bool
- 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:
bool
- 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]