tvm
Loading...
Searching...
No Matches
Classes | Functions
tvm::script::ir_builder::ir Namespace Reference

Classes

class  AssertFrame
 Managed reference to AssertFrameObj. More...
 
class  AssertFrameObj
 A frame that represents the assert statement. Proceeds if the condition is true, otherwise aborts with the message. More...
 
class  ElseFrame
 Managed reference to ElseFrameObj. More...
 
class  ElseFrameObj
 A frame that represents else. More...
 
class  ForFrame
 Managed reference to ForFrameObj. More...
 
class  ForFrameObj
 A frame that represents the for loop. More...
 
class  IfFrame
 Managed reference to IfFrameObj. More...
 
class  IfFrameObj
 A frame that represents if statement. More...
 
class  IRModuleFrame
 Managed reference to IRModuleFrameObj. More...
 
class  IRModuleFrameObj
 A frame that represents the IRModule frame with functions and global variables. More...
 
class  RegionFrame
 Managed reference to RegionFrameObj. More...
 
class  RegionFrameObj
 A result-free region with lexical body parameters. More...
 
class  StmtFrame
 Managed reference to StmtFrameObj. More...
 
class  StmtFrameObj
 A shared frame containing a sequence of core IR statements. More...
 
class  ThenFrame
 Managed reference to ThenFrameObj. More...
 
class  ThenFrameObj
 A frame that represents then. More...
 
class  WhileFrame
 Managed reference to WhileFrameObj. More...
 
class  WhileFrameObj
 A frame that represents while loop. More...
 

Functions

TVM_TIRX_DLL IRModuleFrame IRModule ()
 The IRModule declaration statement.
 
TVM_TIRX_DLL GlobalVar DeclFunction (const ffi::String &func_name, const BaseFunc &func_signature)
 Declare a Function without given the specific function implementation.
 
TVM_TIRX_DLL void DefFunction (const ffi::String &func_name, const BaseFunc &func)
 Define the function which is declared before.
 
ForFrame For (ForKind kind, PrimExpr start, PrimExpr stop, ffi::Optional< PrimExpr > step=std::nullopt, ffi::Optional< PrimType > dtype=std::nullopt, ffi::Optional< ffi::Map< ffi::String, Any > > annotations=std::nullopt)
 Construct a For statement of the given kind.
 
ForFrame Grid (ffi::Array< ffi::Variant< PrimExpr, ffi::Tuple< PrimExpr, PrimExpr > > > extents, ffi::Optional< PrimType > dtype=std::nullopt)
 The grid For statement.
 
AssertFrame Assert (PrimExpr condition, ffi::String error_kind, ffi::Array< ffi::String > message_parts)
 The assertion statement.
 
Var Bind (Expr value, ffi::Optional< Type > type_annotation=std::nullopt, ffi::Optional< Var > var=std::nullopt)
 Create a Bind (variable binding).
 
WhileFrame While (PrimExpr condition)
 Create a while loop.
 
tvm::Stmt Return (Expr value)
 Create a return statement.
 
tvm::Stmt Break ()
 Create a break statement.
 
tvm::Stmt Continue ()
 Create a continue statement.
 
IfFrame If (PrimExpr condition)
 Create an if statement.
 
ThenFrame Then ()
 Create a then.
 
ElseFrame Else ()
 Create an else.
 
RegionFrame Region (Op op, ffi::Array< Expr > args, ffi::Optional< ffi::Array< Var > > body_params=std::nullopt, DictAttrs attrs=DictAttrs())
 Construct a result-free region with lexical body parameters.
 
tvm::Stmt Evaluate (Expr value)
 Evaluate the input expression.
 

Function Documentation

◆ Assert()

AssertFrame tvm::script::ir_builder::ir::Assert ( PrimExpr  condition,
ffi::String  error_kind,
ffi::Array< ffi::String >  message_parts 
)

The assertion statement.

Parameters
conditionThe assertion condition.
error_kindThe error kind (e.g. "RuntimeError", "TypeError", "ValueError").
message_partsThe error message parts (stored as separate fragments in the IR).
Returns
The AssertFrame.

◆ Bind()

Var tvm::script::ir_builder::ir::Bind ( Expr  value,
ffi::Optional< Type >  type_annotation = std::nullopt,
ffi::Optional< Var >  var = std::nullopt 
)

Create a Bind (variable binding).

Emits a flat Bind statement to the current frame and returns the bound variable.

Parameters
valueThe value to be bound.
type_annotationThe type annotation of the binding. Usually it is used for fine-grained var typing, particularly, PtrType.
varThe variable to be bound. If not specified, a new variable will be created.
Returns
The bound Var.

◆ Break()

tvm::Stmt tvm::script::ir_builder::ir::Break ( )

Create a break statement.

Returns
The same statement that was added to the parent frame.

◆ Continue()

tvm::Stmt tvm::script::ir_builder::ir::Continue ( )

Create a continue statement.

Returns
The same statement that was added to the parent frame.

◆ DeclFunction()

TVM_TIRX_DLL GlobalVar tvm::script::ir_builder::ir::DeclFunction ( const ffi::String &  func_name,
const BaseFunc &  func_signature 
)

Declare a Function without given the specific function implementation.

Note
It is usually used in cross-function call. And we can specify the function by DefFunction
Parameters
func_nameThe function unique name.
func_signatureA Function w/o body, which used to specify the function signature (i.e. func params and func return type/shape).
Returns
The corresponding GlobalVar.

◆ DefFunction()

TVM_TIRX_DLL void tvm::script::ir_builder::ir::DefFunction ( const ffi::String &  func_name,
const BaseFunc &  func 
)

Define the function which is declared before.

Parameters
func_nameThe function unique name.
funcThe given function implementation

◆ Else()

ElseFrame tvm::script::ir_builder::ir::Else ( )

Create an else.

Returns
The result ElseFrame.

◆ Evaluate()

tvm::Stmt tvm::script::ir_builder::ir::Evaluate ( Expr  value)

Evaluate the input expression.

Parameters
valueThe input expression to evaluate.
Returns
The same statement that was added to the parent frame.

◆ For()

ForFrame tvm::script::ir_builder::ir::For ( ForKind  kind,
PrimExpr  start,
PrimExpr  stop,
ffi::Optional< PrimExpr >  step = std::nullopt,
ffi::Optional< PrimType >  dtype = std::nullopt,
ffi::Optional< ffi::Map< ffi::String, Any > >  annotations = std::nullopt 
)

Construct a For statement of the given kind.

Parameters
kindThe kind of iteration.
startThe minimum value of iteration.
stopThe maximum value of iteration.
stepThe optional step value of iteration.
dtypeThe optional dtype of the loop var ("int32" or "uint32"). When omitted it is inferred from the bounds.
annotationsThe optional annotations of the For statement.
Returns
The ForFrame.

◆ Grid()

ForFrame tvm::script::ir_builder::ir::Grid ( ffi::Array< ffi::Variant< PrimExpr, ffi::Tuple< PrimExpr, PrimExpr > > >  extents,
ffi::Optional< PrimType >  dtype = std::nullopt 
)

The grid For statement.

Parameters
extentsThe extents of the iteration.
dtypeThe optional dtype of every loop var ("int32" or "uint32"). When omitted each loop var takes the dtype of its own extent.
Returns
The ForFrame.

◆ If()

IfFrame tvm::script::ir_builder::ir::If ( PrimExpr  condition)

Create an if statement.

Parameters
conditionThe condition of if statement.
Returns
The result IfFrame.

◆ IRModule()

TVM_TIRX_DLL IRModuleFrame tvm::script::ir_builder::ir::IRModule ( )

The IRModule declaration statement.

Returns
The IRModuleFrame.

◆ Region()

RegionFrame tvm::script::ir_builder::ir::Region ( Op  op,
ffi::Array< Expr >  args,
ffi::Optional< ffi::Array< Var > >  body_params = std::nullopt,
DictAttrs  attrs = DictAttrs() 
)

Construct a result-free region with lexical body parameters.

Parameters
opThe region operation.
argsOperands evaluated outside the region body.
body_paramsExisting body parameters, or omitted to generate them from the operation.
attrsAdditional operation attributes.

◆ Return()

tvm::Stmt tvm::script::ir_builder::ir::Return ( Expr  value)

Create a return statement.

Parameters
valueThe value to return.
Returns
The same statement that was added to the parent frame.

◆ Then()

ThenFrame tvm::script::ir_builder::ir::Then ( )

Create a then.

Returns
The result ThenFrame.

◆ While()

WhileFrame tvm::script::ir_builder::ir::While ( PrimExpr  condition)

Create a while loop.

Parameters
conditionThe termination condition of the loop.
Returns
The result WhileFrame.