tvm
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
tvm::tir::StmtMutator Class Reference

StmtMutator that mutates the statements. More...

#include <stmt_functor.h>

Inheritance diagram for tvm::tir::StmtMutator:
Collaboration diagram for tvm::tir::StmtMutator:

Public Member Functions

Stmt operator() (Stmt stmt)
 Mutate stmt. More...
 

Protected Member Functions

template<typename TNode >
ObjectPtr< TNode > CopyOnWrite (const TNode *node)
 Perform copy on write on node. More...
 
Stmt VisitStmt (const Stmt &stmt) override
 Internal mutator that everyone calls. More...
 
virtual PrimExpr VisitExpr (const PrimExpr &e)
 Visitor to Exprs, can be overriden to do recursive changes to Exprs. More...
 
Stmt VisitStmt_ (const AttrStmtNode *op) override
 
Stmt VisitStmt_ (const IfThenElseNode *op) override
 
Stmt VisitStmt_ (const LetStmtNode *op) override
 
Stmt VisitStmt_ (const ForNode *op) override
 
Stmt VisitStmt_ (const WhileNode *op) override
 
Stmt VisitStmt_ (const AllocateNode *op) override
 
Stmt VisitStmt_ (const AllocateConstNode *op) override
 
Stmt VisitStmt_ (const DeclBufferNode *op) override
 
Stmt VisitStmt_ (const BufferStoreNode *op) override
 
Stmt VisitStmt_ (const BufferRealizeNode *op) override
 
Stmt VisitStmt_ (const AssertStmtNode *op) override
 
Stmt VisitStmt_ (const ProducerStoreNode *op) override
 
Stmt VisitStmt_ (const ProducerRealizeNode *op) override
 
Stmt VisitStmt_ (const PrefetchNode *op) override
 
Stmt VisitStmt_ (const SeqStmtNode *op) override
 
Stmt VisitStmt_ (const EvaluateNode *op) override
 
Stmt VisitStmt_ (const BlockNode *op) override
 
Stmt VisitStmt_ (const BlockRealizeNode *op) override
 
Stmt VisitSeqStmt_ (const SeqStmtNode *op, bool flatten_before_visit, std::function< Stmt(const Stmt &)> fmutate=nullptr)
 Alternative advance method for SeqStmtNode. More...
 

Protected Attributes

bool allow_copy_on_write_ {false}
 Internal state to indicate whether copy on write is enabled. COW is enabled iff all the parents of the node are unique. More...
 

Detailed Description

StmtMutator that mutates the statements.

Member Function Documentation

◆ CopyOnWrite()

template<typename TNode >
ObjectPtr<TNode> tvm::tir::StmtMutator::CopyOnWrite ( const TNode *  node)
inlineprotected

Perform copy on write on node.

If CopyOnWrite is allowed, directly return a strong reference to the node container. Otherwise, return a copy of the node.

Returns
The result object pointer.

◆ operator()()

Stmt tvm::tir::StmtMutator::operator() ( Stmt  stmt)
inline

Mutate stmt.

Parameters
stmtThe input statement to be mutated.
Returns
The result of the call
Note
It is important that stmt is passed by value. so copy on write can be triggered correctly. do mutator(std::move(stmt)) or when copy elison is triggered.

◆ VisitExpr()

virtual PrimExpr tvm::tir::StmtMutator::VisitExpr ( const PrimExpr e)
inlineprotectedvirtual

Visitor to Exprs, can be overriden to do recursive changes to Exprs.

Note
A common pattern is to call ExprMutator here, or have a class sub-class both StmtMutator and ExprMutator and redirect Mutate to ExprMutator::Mutate(Expr)

Reimplemented in tvm::tir::StmtExprMutator.

◆ VisitSeqStmt_()

Stmt tvm::tir::StmtMutator::VisitSeqStmt_ ( const SeqStmtNode op,
bool  flatten_before_visit,
std::function< Stmt(const Stmt &)>  fmutate = nullptr 
)
protected

Alternative advance method for SeqStmtNode.

This function can be called when a child class override VisitStmt_(const SeqStmtNode*) to introduce the special behavior to visit

Parameters
opThe sequence.
flatten_before_visitWhether to flatten the sequence before visit.
fmutateThe mutate function, can be nullptr, which defaults to Visit.
Returns
The mutated result.

◆ VisitStmt()

Stmt tvm::tir::StmtMutator::VisitStmt ( const Stmt stmt)
inlineoverrideprotected

Internal mutator that everyone calls.

Note
To override mutate's behavior, override VisitExpr instead.
Parameters
stmtThe input stmt.
Returns
The mutated results.

◆ VisitStmt_() [1/18]

Stmt tvm::tir::StmtMutator::VisitStmt_ ( const AllocateConstNode op)
overrideprotected

◆ VisitStmt_() [2/18]

Stmt tvm::tir::StmtMutator::VisitStmt_ ( const AllocateNode op)
overrideprotected

◆ VisitStmt_() [3/18]

Stmt tvm::tir::StmtMutator::VisitStmt_ ( const AssertStmtNode op)
overrideprotected

◆ VisitStmt_() [4/18]

Stmt tvm::tir::StmtMutator::VisitStmt_ ( const AttrStmtNode op)
overrideprotected

◆ VisitStmt_() [5/18]

Stmt tvm::tir::StmtMutator::VisitStmt_ ( const BlockNode op)
overrideprotected

◆ VisitStmt_() [6/18]

Stmt tvm::tir::StmtMutator::VisitStmt_ ( const BlockRealizeNode op)
overrideprotected

◆ VisitStmt_() [7/18]

Stmt tvm::tir::StmtMutator::VisitStmt_ ( const BufferRealizeNode op)
overrideprotected

◆ VisitStmt_() [8/18]

Stmt tvm::tir::StmtMutator::VisitStmt_ ( const BufferStoreNode op)
overrideprotected

◆ VisitStmt_() [9/18]

Stmt tvm::tir::StmtMutator::VisitStmt_ ( const DeclBufferNode op)
overrideprotected

◆ VisitStmt_() [10/18]

Stmt tvm::tir::StmtMutator::VisitStmt_ ( const EvaluateNode op)
overrideprotected

◆ VisitStmt_() [11/18]

Stmt tvm::tir::StmtMutator::VisitStmt_ ( const ForNode op)
overrideprotected

◆ VisitStmt_() [12/18]

Stmt tvm::tir::StmtMutator::VisitStmt_ ( const IfThenElseNode op)
overrideprotected

◆ VisitStmt_() [13/18]

Stmt tvm::tir::StmtMutator::VisitStmt_ ( const LetStmtNode op)
overrideprotected

◆ VisitStmt_() [14/18]

Stmt tvm::tir::StmtMutator::VisitStmt_ ( const PrefetchNode op)
overrideprotected

◆ VisitStmt_() [15/18]

Stmt tvm::tir::StmtMutator::VisitStmt_ ( const ProducerRealizeNode op)
overrideprotected

◆ VisitStmt_() [16/18]

Stmt tvm::tir::StmtMutator::VisitStmt_ ( const ProducerStoreNode op)
overrideprotected

◆ VisitStmt_() [17/18]

Stmt tvm::tir::StmtMutator::VisitStmt_ ( const SeqStmtNode op)
overrideprotected

◆ VisitStmt_() [18/18]

Stmt tvm::tir::StmtMutator::VisitStmt_ ( const WhileNode op)
overrideprotected

Member Data Documentation

◆ allow_copy_on_write_

bool tvm::tir::StmtMutator::allow_copy_on_write_ {false}
protected

Internal state to indicate whether copy on write is enabled. COW is enabled iff all the parents of the node are unique.


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