tilelang.language.frame

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

類別

FrameStack

A stack-like container for managing TIR frame objects and their variable bindings.

LetFrame

A TIR frame for let bindings that manages variable scope and value tracking.

函式

has_let_value(var)

Check if a variable has a binding in the current let frame stack.

get_let_value(var)

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.

參數:

item -- The frame object to push onto the stack

pop()

Remove and return the top item from the stack.

回傳:

The top frame object from the stack

引發:

IndexError -- If the stack is empty

get_value(var)

Retrieve the value associated with a variable.

參數:

var -- The variable to look up

回傳:

The value associated with the variable, or None if not found

has_value(var)

Check if a variable has an associated value.

參數:

var -- The variable to check

回傳:

True if the variable has an associated value, False otherwise

回傳型別:

bool

top()

Return the top item of the stack without removing it.

回傳:

The top frame object from the stack

引發:

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.

回傳:

The variable bound in this frame

回傳型別:

Var

__exit__(ptype, value, trace)

Exit the let frame scope and clean up the stack.

參數:
  • 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.

回傳:

The current let frame

回傳型別:

LetFrame

引發:

IndexError -- If there are no active let frames

static get_value(var)

Get the value bound to a variable in any active frame.

參數:

var (Var) -- The variable to look up

回傳:

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.

參數:

var (Var) -- The variable to check

回傳:

True if the variable has a binding, False otherwise

回傳型別:

bool

tilelang.language.frame.has_let_value(var)

Check if a variable has a binding in the current let frame stack.

參數:

var (Var) -- The variable to check

回傳:

True if the variable has a binding, False otherwise

回傳型別:

bool

tilelang.language.frame.get_let_value(var)

Get the value bound to a variable in the current let frame stack.

參數:

var (Var) -- The variable to look up

回傳:

The bound value if found, None otherwise

回傳型別:

Optional[PrimExpr]