tilelang.language.frame module#

Override the LetFrame to print a message when entering the frame.

class tilelang.language.frame.FrameStack#

Bases: object

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.

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

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

push(item)#

Push an item onto the stack and update variable mapping if applicable.

Parameters:

item – The frame object to push onto the stack

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

class tilelang.language.frame.LetFrame#

Bases: 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.

classmethod Current() LetFrame#

Get the current (topmost) let frame.

Returns:

The current let frame

Return type:

LetFrame

Raises:

IndexError – If there are no active let frames

static get_value(var: 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: Var) bool#

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.get_let_value(var: Var) Optional[PrimExpr]#

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]

tilelang.language.frame.has_let_value(var: Var) bool#

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