tvm
Public Member Functions | Protected Attributes | List of all members
tvm::relay::ExprMutator Class Reference

A wrapper around ExprFunctor which functionally updates the AST. More...

#include <expr_functor.h>

Inheritance diagram for tvm::relay::ExprMutator:
Collaboration diagram for tvm::relay::ExprMutator:

Public Member Functions

Expr Mutate (const Expr &expr)
 Mutate is alias for VisitExpr. More...
 
Expr VisitExpr (const Expr &expr) override
 
Expr VisitExpr_ (const VarNode *op) override
 
Expr VisitExpr_ (const ConstantNode *op) override
 
Expr VisitExpr_ (const GlobalVarNode *op) override
 
Expr VisitExpr_ (const OpNode *op) override
 
Expr VisitExpr_ (const TupleNode *op) override
 
Expr VisitExpr_ (const FunctionNode *op) override
 
Expr VisitExpr_ (const CallNode *call_node) override
 
Expr VisitExpr_ (const LetNode *op) override
 
Expr VisitExpr_ (const IfNode *op) override
 
Expr VisitExpr_ (const TupleGetItemNode *op) override
 
Expr VisitExpr_ (const RefCreateNode *op) override
 
Expr VisitExpr_ (const RefReadNode *op) override
 
Expr VisitExpr_ (const RefWriteNode *op) override
 
Expr VisitExpr_ (const ConstructorNode *op) override
 
Expr VisitExpr_ (const MatchNode *op) override
 
virtual Type VisitType (const Type &t)
 Used to visit the types inside of expressions. More...
 
virtual Clause VisitClause (const Clause &c)
 
virtual Pattern VisitPattern (const Pattern &c)
 

Protected Attributes

std::unordered_map< Expr, Expr, ObjectPtrHash, ObjectPtrEqualmemo_
 Internal map used for memoization. More...
 

Detailed Description

A wrapper around ExprFunctor which functionally updates the AST.

ExprMutator treats Expr as dataflow graph, and only Mutate each Expr once. The mutated results are memoized in a map and reused so that local transformation on the dataflow preserves the graph structure.

Member Function Documentation

◆ Mutate()

Expr tvm::relay::ExprMutator::Mutate ( const Expr expr)
inline

Mutate is alias for VisitExpr.

Returns
expr.

◆ VisitClause()

virtual Clause tvm::relay::ExprMutator::VisitClause ( const Clause c)
virtual

◆ VisitExpr()

Expr tvm::relay::ExprMutator::VisitExpr ( const Expr expr)
override

◆ VisitExpr_() [1/15]

Expr tvm::relay::ExprMutator::VisitExpr_ ( const CallNode call_node)
override

◆ VisitExpr_() [2/15]

Expr tvm::relay::ExprMutator::VisitExpr_ ( const ConstantNode op)
override

◆ VisitExpr_() [3/15]

Expr tvm::relay::ExprMutator::VisitExpr_ ( const ConstructorNode op)
override

◆ VisitExpr_() [4/15]

Expr tvm::relay::ExprMutator::VisitExpr_ ( const FunctionNode op)
override

◆ VisitExpr_() [5/15]

Expr tvm::relay::ExprMutator::VisitExpr_ ( const GlobalVarNode op)
override

◆ VisitExpr_() [6/15]

Expr tvm::relay::ExprMutator::VisitExpr_ ( const IfNode op)
override

◆ VisitExpr_() [7/15]

Expr tvm::relay::ExprMutator::VisitExpr_ ( const LetNode op)
override

◆ VisitExpr_() [8/15]

Expr tvm::relay::ExprMutator::VisitExpr_ ( const MatchNode op)
override

◆ VisitExpr_() [9/15]

Expr tvm::relay::ExprMutator::VisitExpr_ ( const OpNode op)
override

◆ VisitExpr_() [10/15]

Expr tvm::relay::ExprMutator::VisitExpr_ ( const RefCreateNode op)
override

◆ VisitExpr_() [11/15]

Expr tvm::relay::ExprMutator::VisitExpr_ ( const RefReadNode op)
override

◆ VisitExpr_() [12/15]

Expr tvm::relay::ExprMutator::VisitExpr_ ( const RefWriteNode op)
override

◆ VisitExpr_() [13/15]

Expr tvm::relay::ExprMutator::VisitExpr_ ( const TupleGetItemNode op)
override

◆ VisitExpr_() [14/15]

Expr tvm::relay::ExprMutator::VisitExpr_ ( const TupleNode op)
override

◆ VisitExpr_() [15/15]

Expr tvm::relay::ExprMutator::VisitExpr_ ( const VarNode op)
override

◆ VisitPattern()

virtual Pattern tvm::relay::ExprMutator::VisitPattern ( const Pattern c)
virtual

◆ VisitType()

virtual Type tvm::relay::ExprMutator::VisitType ( const Type t)
virtual

Used to visit the types inside of expressions.

Can be overloaded to transform the types in arbitrary ways, one way would be to define a sub-class of type visitor for types which transform them appropriately.

Member Data Documentation

◆ memo_

std::unordered_map<Expr, Expr, ObjectPtrHash, ObjectPtrEqual> tvm::relay::ExprMutator::memo_
protected

Internal map used for memoization.


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