tvm
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

void VisitAttrs (tvm::AttrVisitor *v)
 
 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...
 
- Public Member Functions inherited from tvm::runtime::Object
uint32_t type_index () const
 
std::string GetTypeKey () const
 
size_t GetTypeKeyHash () const
 
template<typename TargetType >
bool IsInstance () const
 
bool unique () const
 
 Object ()
 
 Object (const Object &other)
 
 Object (Object &&other)
 
Objectoperator= (const Object &other)
 
Objectoperator= (Object &&other)
 

Public Attributes

runtime::Array< IRBuilderFrameframes
 A stack of context frames in the IRBuilder. More...
 
Optional< ObjectRefresult
 The outcome of IR construction. More...
 

Static Public Attributes

static constexpr const char * _type_key = "script.ir_builder.IRBuilder"
 
- Static Public Attributes inherited from tvm::runtime::Object
static constexpr const char * _type_key = "runtime.Object"
 
static constexpr bool _type_final = false
 
static constexpr uint32_t _type_child_slots = 0
 
static constexpr bool _type_child_slots_can_overflow = true
 
static constexpr bool _type_has_method_visit_attrs = true
 
static constexpr bool _type_has_method_sequal_reduce = false
 
static constexpr bool _type_has_method_shash_reduce = false
 
static constexpr uint32_t _type_index = TypeIndex::kDynamic
 

Additional Inherited Members

- Public Types inherited from tvm::runtime::Object
typedef void(* FDeleter) (Object *self)
 Object deleter. More...
 
using RefCounterType = std::atomic< int32_t >
 
- Static Public Member Functions inherited from tvm::runtime::Object
static std::string TypeIndex2Key (uint32_t tindex)
 Get the type key of the corresponding index from runtime. More...
 
static size_t TypeIndex2KeyHash (uint32_t tindex)
 Get the type key hash of the corresponding index from runtime. More...
 
static uint32_t TypeKey2Index (const std::string &key)
 Get the type index of the corresponding key from runtime. More...
 
static uint32_t _GetOrAllocRuntimeTypeIndex ()
 
static uint32_t RuntimeTypeIndex ()
 
- Protected Member Functions inherited from tvm::runtime::Object
void IncRef ()
 developer function, increases reference counter. More...
 
void DecRef ()
 developer function, decrease reference counter. More...
 
- Static Protected Member Functions inherited from tvm::runtime::Object
static uint32_t GetOrAllocRuntimeTypeIndex (const std::string &key, uint32_t static_tindex, uint32_t parent_tindex, uint32_t type_child_slots, bool type_child_slots_can_overflow)
 Get the type index using type key. More...
 
- Protected Attributes inherited from tvm::runtime::Object
uint32_t type_index_ {0}
 Type index(tag) that indicates the type of the object. More...
 
RefCounterType ref_counter_ {0}
 The internal reference counter. More...
 
FDeleter deleter_ = nullptr
 deleter of this object to enable customized allocation. If the deleter is nullptr, no deletion will be performed. The creator of the object must always set the deleter field properly. More...
 

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:200
Definition: frame.h:29
PrimFuncFrame PrimFunc(bool is_private)
The primitive function statement.
Buffer MatchBuffer(ObjectRef param, Array< PrimExpr > shape, DataType dtype=DataType::Float(32), Optional< Var > data=NullOpt, Array< PrimExpr > strides={}, PrimExpr elem_offset=PrimExpr(), String storage_scope="global", int align=-1, int offset_factor=0, String buffer_type="default", Array< IntImm > axis_separators={})
The buffer match 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 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 NullOpt.
Examples
/workspace/include/tvm/script/ir_builder/base.h.

◆ TVM_DECLARE_FINAL_OBJECT_INFO()

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

◆ VisitAttrs()

void tvm::script::ir_builder::IRBuilderNode::VisitAttrs ( tvm::AttrVisitor v)
inline

Member Data Documentation

◆ _type_key

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

◆ frames

runtime::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: