tvm
Public Member Functions | Static Public Member Functions | Public Attributes | Static Public Attributes | List of all members
tvm::script::ir_builder::IRBuilderNode Class Reference

A dialect-agnostic IRBuilder that constructs any IR of TVM. An idiomatic use of this class is to put this inside the RAII with-scope, call dialect-specific methods accordingly. Upon exiting the scope. More...

#include <base.h>

Inheritance diagram for tvm::script::ir_builder::IRBuilderNode:
Collaboration diagram for tvm::script::ir_builder::IRBuilderNode:

Public Member Functions

 TVM_DECLARE_FINAL_OBJECT_INFO (IRBuilderNode, runtime::Object)
 
template<typename TFrame >
Optional< TFrame > FindFrame () const
 Find a frame of the given type in the stack this->frames from top to bottom. More...
 
template<typename TFrame >
Optional< TFrame > GetLastFrame () const
 Get the frame on top of the stack this->frames if its type is TFrame. More...
 
template<typename TObjectRef >
TObjectRef Get () const
 Get the IR being constructed. More...
 

Static Public Member Functions

static void RegisterReflection ()
 

Public Attributes

Array< IRBuilderFrameframes
 A stack of context frames in the IRBuilder. More...
 
Optional< ObjectRef > result
 The outcome of IR construction. More...
 

Static Public Attributes

static constexpr const char * _type_key = "script.ir_builder.IRBuilder"
 

Detailed Description

A dialect-agnostic IRBuilder that constructs any IR of TVM. An idiomatic use of this class is to put this inside the RAII with-scope, call dialect-specific methods accordingly. Upon exiting the scope.

PrimFunc ConstructPrimFunc() {
IRBuilder builder;
// Step 1. Place IRBuilder inside the with-scope.
{
With<IRBuilder> _(builder);
// Step 2. Call dialect-specific methods.
With<T::PrimFuncFrame> _2(...);
}
// Step 3. Return the constructed PrimFunc.
return builder->Get<PrimFunc>();
}
Managed reference to an IRBuilderNode.
Definition: base.h:203
Definition: frame.h:29
Buffer MatchBuffer(ObjectRef param, Array< PrimExpr > shape, DataType dtype=DataType::Float(32), Optional< Var > data=std::nullopt, Array< PrimExpr > strides={}, PrimExpr elem_offset=PrimExpr(), String storage_scope="global", int align=-1, int offset_factor=0, String buffer_type="default", Optional< Array< IntImm >> axis_separators=std::nullopt)
The buffer match statement.
PrimFuncFrame PrimFunc(bool is_private)
The primitive function statement.

Member Function Documentation

◆ FindFrame()

template<typename TFrame >
Optional< TFrame > tvm::script::ir_builder::IRBuilderNode::FindFrame
inline

Find a frame of the given type in the stack this->frames from top to bottom.

Template Parameters
TThe type of the frame to find.
Returns
The frame if found, otherwise std::nullopt.
Examples
/workspace/include/tvm/script/ir_builder/base.h.

◆ Get()

template<typename TObjectRef >
TObjectRef tvm::script::ir_builder::IRBuilderNode::Get
inline

Get the IR being constructed.

Template Parameters
TObjectRefThe type of the IR being constructed.
Returns
The resulting IR. Throw an exception if the IR is not constructed yet.
Examples
/workspace/include/tvm/script/ir_builder/base.h.

◆ GetLastFrame()

template<typename TFrame >
Optional< TFrame > tvm::script::ir_builder::IRBuilderNode::GetLastFrame
inline

Get the frame on top of the stack this->frames if its type is TFrame.

Template Parameters
TFrameThe assumed type of the last frame on stack.
Returns
The frame if the stack is non-empty and the top of the stack is of type TFrame. Otherwise std::nullopt.
Examples
/workspace/include/tvm/script/ir_builder/base.h.

◆ RegisterReflection()

static void tvm::script::ir_builder::IRBuilderNode::RegisterReflection ( )
inlinestatic

◆ TVM_DECLARE_FINAL_OBJECT_INFO()

tvm::script::ir_builder::IRBuilderNode::TVM_DECLARE_FINAL_OBJECT_INFO ( IRBuilderNode  ,
runtime::Object   
)

Member Data Documentation

◆ _type_key

constexpr const char* tvm::script::ir_builder::IRBuilderNode::_type_key = "script.ir_builder.IRBuilder"
staticconstexpr

◆ frames

Array<IRBuilderFrame> tvm::script::ir_builder::IRBuilderNode::frames

A stack of context frames in the IRBuilder.

Examples
/workspace/include/tvm/script/ir_builder/base.h.

◆ result

Optional<ObjectRef> tvm::script::ir_builder::IRBuilderNode::result

The outcome of IR construction.

Examples
/workspace/include/tvm/script/ir_builder/base.h.

The documentation for this class was generated from the following file: