tvm
|
Non-recursive DFS Graph Traversal for Custom Rewriting Passes. More...
#include <expr_functor.h>
Public Member Functions | |
MixedModeMutator (bool pre=false) | |
Expr | VisitExpr (const Expr &expr) final |
virtual Expr | DispatchVisitExpr (const Expr &expr) |
Expr | VisitExpr_ (const TupleNode *op) final |
Expr | VisitExpr_ (const CallNode *call_node) final |
Expr | VisitExpr_ (const TupleGetItemNode *op) final |
virtual Expr | Rewrite_ (const TupleNode *pre, const Expr &post) |
Users should override Rewrite_ methods to implement their pass. Rewrite_ functions will be able to rewrite the op only with data about the original node pre and the same node with modified inputs post and should not recurse. More... | |
virtual Expr | Rewrite_ (const CallNode *pre, const Expr &post) |
virtual Expr | Rewrite_ (const TupleGetItemNode *pre, const Expr &post) |
Public Member Functions inherited from tvm::relay::ExprMutator | |
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 Member Functions | |
template<typename T > | |
Expr | Rewrite (const T *op) |
Implement Rewrite API by calling ExprMutator's VisitExpr_(op) to get a post node with changed inputs. More... | |
virtual void | VisitLeaf (const Expr &expr) |
virtual bool | CheckVisited (const Expr &expr) |
Protected Attributes | |
bool | pre_ |
Protected Attributes inherited from tvm::relay::ExprMutator | |
std::unordered_map< Expr, Expr, ObjectPtrHash, ObjectPtrEqual > | memo_ |
Internal map used for memoization. More... | |
Non-recursive DFS Graph Traversal for Custom Rewriting Passes.
MixedModeMutator treats Expr as dataflow graph, and only Rewrites each Expr once. The mutated results are memoized in a map and reused so that local transformation on the dataflow preserves the graph structure.
MixedModeMutator provides the same recursive API as ExprMutator, and uses recursion to traverse most forms of the IR, but under the hood it expands nested dataflow regions of the graph and processes them iteratatively to prevent stack overflows
Uses Rewrite_ API of ExprRewriter for a cleaner split between recrusive and non-recursive behavior.
|
inline |
|
protectedvirtual |
|
inlineprotected |
Implement Rewrite API by calling ExprMutator's VisitExpr_(op) to get a post
node with changed inputs.
|
inlinevirtual |
|
inlinevirtual |
|
inlinevirtual |
Users should override Rewrite_ methods to implement their pass. Rewrite_ functions will be able to rewrite the op only with data about the original node pre
and the same node with modified inputs post
and should not recurse.
pre | The expression node before rewriting. |
post | The expression with rewritten inputs. |
|
inlinefinal |
|
protectedvirtual |
|
protected |