tvm
Classes | Namespaces | Macros | Functions
stmt_functor.h File Reference

Functors for tir stmts utility functions to call common functors. More...

#include <tvm/node/functor.h>
#include <tvm/tir/expr.h>
#include <tvm/tir/expr_functor.h>
#include <tvm/tir/function.h>
#include <tvm/tir/stmt.h>
#include <unordered_map>
#include <utility>
Include dependency graph for stmt_functor.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  tvm::tir::StmtFunctor< R(const Stmt &n, Args... args)>
 
class  tvm::tir::StmtVisitor
 StmtVisitor. More...
 
class  tvm::tir::StmtMutator
 StmtMutator that mutates the statements. More...
 
class  tvm::tir::StmtExprVisitor
 Visitor that recursively visit stmts and exprs on them. More...
 
class  tvm::tir::StmtExprMutator
 Mutator that recursively mutates stmts and exprs on them. More...
 

Namespaces

 tvm
 runtime implementation for LibTorch/TorchScript.
 
 tvm::tir
 

Macros

#define STMT_FUNCTOR_DEFAULT    { return VisitStmtDefault_(op, std::forward<Args>(args)...); }
 
#define IR_STMT_FUNCTOR_DISPATCH(OP)
 

Functions

Stmt tvm::tir::IRTransform (Stmt stmt, const runtime::PackedFunc &preorder, const runtime::PackedFunc &postorder, Optional< Array< String >> only_enable=NullOpt)
 recursively visit the ir nodes in post DFS order, and transform it More...
 
void tvm::tir::PostOrderVisit (const ObjectRef &node, std::function< void(const ObjectRef &)> fvisit)
 Recursively visit the ir in post DFS order node, apply fvisit Each node is guaranteed to be visited only once. More...
 
Stmt tvm::tir::Substitute (Stmt stmt, std::function< Optional< PrimExpr >(const Var &var)> vmap)
 Substitute the var specified by vmap. More...
 
PrimExpr tvm::tir::Substitute (PrimExpr expr, std::function< Optional< PrimExpr >(const Var &var)> vmap)
 Substitute the var specified by vmap. More...
 
template<typename T >
Array< T > tvm::tir::Substitute (const Array< T > &arr, std::function< Optional< PrimExpr >(const Var &var)> vmap)
 Substitute the var specified by vmap. More...
 
Range tvm::tir::Substitute (const Range &range, std::function< Optional< PrimExpr >(const Var &var)> vmap)
 Substitute the vars specified by vmap. More...
 
template<typename Obj >
auto tvm::tir::Substitute (Obj &&obj, const Map< Var, PrimExpr > &vmap)
 Substitute the vars specified by vmap. More...
 
template<typename Obj , typename Expr , typename = std::enable_if_t<std::is_base_of_v<PrimExpr, Expr>>>
auto tvm::tir::Substitute (Obj &&obj, const Map< Var, Expr > &vmap)
 Substitute the vars specified by vmap. More...
 
template<typename Obj , typename Expr , typename = std::enable_if_t<std::is_base_of_v<PrimExpr, Expr>>>
auto tvm::tir::Substitute (Obj &&obj, const std::unordered_map< const VarNode *, Expr > &vmap)
 Substitute the vars specified by vmap. More...
 
template<typename Obj , typename Expr , typename Hasher , typename EqualityChecker , typename = std::enable_if_t<std::is_base_of_v<PrimExpr, Expr>>>
auto tvm::tir::Substitute (Obj &&obj, const std::unordered_map< Var, Expr, Hasher, EqualityChecker > &vmap)
 Substitute the vars specified by vmap. More...
 
template<typename Obj , typename Expr , typename = std::enable_if_t<std::is_base_of_v<PrimExpr, Expr>>>
auto tvm::tir::Substitute (Obj &&obj, const std::unordered_map< IterVar, Expr > &iter_vmap)
 Substitute the vars specified by vmap. More...
 
Stmt tvm::tir::SubstituteWithDataTypeLegalization (Stmt stmt, std::function< Optional< PrimExpr >(const Var &)> vmap)
 Substitute the var specified by vmap and legalize data types after substitution. More...
 
PrimExpr tvm::tir::SubstituteWithDataTypeLegalization (PrimExpr expr, std::function< Optional< PrimExpr >(const Var &)> vmap)
 Substitute the var specified by vmap and legalize data types after substitution. More...
 
void tvm::tir::PreOrderVisit (const ObjectRef &stmt_or_expr, const std::function< bool(const ObjectRef &)> &fvisit)
 Recursively visit the IR in pre DFS order node, apply fvisit. If fvisit returns false, it won't visit the children of the node. More...
 
PrimFunc tvm::tir::RenewDefs (const PrimFunc &func)
 Renew the definition nodes for a TIR, including Var, Buffer and IterVar. This pass works as a simple DeepCopy to duplicate a function with different Vars and Buffers but the same behavior. More...
 
template<typename Node , typename = std::enable_if_t<std::is_base_of_v<StmtNode, Node>>>
bool tvm::tir::ContainsNode (const Stmt &stmt)
 Check if the statement contains the specified node type. More...
 

Detailed Description

Functors for tir stmts utility functions to call common functors.

Macro Definition Documentation

◆ IR_STMT_FUNCTOR_DISPATCH

#define IR_STMT_FUNCTOR_DISPATCH (   OP)
Value:
vtable.template set_dispatch<OP>([](const ObjectRef& n, TSelf* self, Args... args) { \
return self->VisitStmt_(static_cast<const OP*>(n.get()), std::forward<Args>(args)...); \
});

◆ STMT_FUNCTOR_DEFAULT

#define STMT_FUNCTOR_DEFAULT    { return VisitStmtDefault_(op, std::forward<Args>(args)...); }