tvm
Loading...
Searching...
No Matches
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_FFI_DECLARE_OBJECT_INFO_FINAL ("script.ir_builder.IRBuilder", IRBuilderNode, ffi::Object)
 
template<typename TFrame >
ffi::Optional< TFrameFindFrame () const
 Find a frame of the given type in the stack this->frames from top to bottom.
 
template<typename TFrame >
ffi::Optional< TFrameGetLastFrame () const
 Get the frame on top of the stack this->frames if its type is TFrame.
 
template<typename TObjectRef >
TObjectRef Get () const
 Get the IR being constructed.
 
void PushSourceSpan (Span span)
 Push a frontend source span for IR constructed in the nested scope.
 
void PopSourceSpan ()
 Pop the innermost frontend source span.
 
Span GetCurrentSourceSpan () const
 Return the normalized active source span, including expansion history.
 
ffi::ObjectRef SetCurrentSourceSpan (ffi::ObjectRef obj) const
 Attach the active source span to an expression that has no span yet.
 

Static Public Member Functions

static void RegisterReflection ()
 

Public Attributes

ffi::Array< IRBuilderFrameframes
 A stack of context frames in the IRBuilder.
 
ffi::Optional< ffi::ObjectRef > result
 The outcome of IR construction.
 
std::vector< Spansource_spans
 Active frontend source spans, from outermost to innermost.
 

Static Public Attributes

static constexpr const bool _type_mutable = true
 

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() {
// Step 1. Place IRBuilder inside the with-scope.
{
// Step 2. Call dialect-specific methods.
T::MatchBuffer(...);
}
// Step 3. Return the constructed PrimFunc.
return builder->Get<PrimFunc>();
}
RAII wrapper function to enter and exit a context object similar to python's with syntax.
Definition with_context.h:59
Managed reference to an IRBuilderNode.
Definition base.h:214
Definition frame.h:32

Member Function Documentation

◆ FindFrame()

template<typename TFrame >
ffi::Optional< TFrame > tvm::script::ir_builder::IRBuilderNode::FindFrame ( ) const
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 ( ) const
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.

◆ GetCurrentSourceSpan()

Span tvm::script::ir_builder::IRBuilderNode::GetCurrentSourceSpan ( ) const

Return the normalized active source span, including expansion history.

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

◆ GetLastFrame()

template<typename TFrame >
ffi::Optional< TFrame > tvm::script::ir_builder::IRBuilderNode::GetLastFrame ( ) const
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.

◆ PopSourceSpan()

void tvm::script::ir_builder::IRBuilderNode::PopSourceSpan ( )

Pop the innermost frontend source span.

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

◆ PushSourceSpan()

void tvm::script::ir_builder::IRBuilderNode::PushSourceSpan ( Span  span)

Push a frontend source span for IR constructed in the nested scope.

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

◆ RegisterReflection()

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

◆ SetCurrentSourceSpan()

ffi::ObjectRef tvm::script::ir_builder::IRBuilderNode::SetCurrentSourceSpan ( ffi::ObjectRef  obj) const

Attach the active source span to an expression that has no span yet.

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

◆ TVM_FFI_DECLARE_OBJECT_INFO_FINAL()

tvm::script::ir_builder::IRBuilderNode::TVM_FFI_DECLARE_OBJECT_INFO_FINAL ( "script.ir_builder.IRBuilder"  ,
IRBuilderNode  ,
ffi::Object   
)

Member Data Documentation

◆ _type_mutable

constexpr const bool tvm::script::ir_builder::IRBuilderNode::_type_mutable = true
staticconstexpr

◆ frames

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

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

The outcome of IR construction.

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

◆ source_spans

std::vector<Span> tvm::script::ir_builder::IRBuilderNode::source_spans

Active frontend source spans, from outermost to innermost.

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

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