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

A more powerful visitor which enables defining arbitrary function signatures with type based dispatch on first argument. More...

#include <tvm/node/functor.h>
#include <tvm/relax/block_builder.h>
#include <tvm/relax/expr.h>
#include <tvm/relax/struct_info.h>
#include <tvm/relax/struct_info_functor.h>
#include <tvm/relay/op.h>
#include <tvm/tir/function.h>
#include <deque>
#include <string>
#include <unordered_map>
#include <utility>
#include <vector>
Include dependency graph for expr_functor.h:

Go to the source code of this file.

Classes

class  tvm::relax::ExprFunctor< R(const Expr &n, Args...)>
 
class  tvm::relax::ExprVisitor
 A simple visitor wrapper around ExprFunctor. Recursively visit the content. More...
 
class  tvm::relax::ExprMutatorBase
 A mutator works in unnormalized form. More...
 
class  tvm::relax::ExprMutator
 A mutator works in normal form. More...
 

Namespaces

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

Macros

#define EXPR_FUNCTOR_DEFAULT    { return VisitExprDefault_(op, std::forward<Args>(args)...); }
 
#define RELAX_EXPR_FUNCTOR_DISPATCH(OP)
 
#define PY_EXPR_VISITOR_DEFAULT(N, PY_FUNC, DEFAULT_FUNC)
 
#define PY_EXPR_MUTATOR_DEFAULT(N, PY_FUNC, DEFAULT_FUNC, RET_TYPE)
 
#define PY_EXPR_VISITOR_DISPATCH(OP, PY_FUNC)
 
#define PY_EXPR_MUTATOR_DISPATCH(OP, PY_FUNC)
 
#define PY_EXPR_MUTATOR_VISIT_EXPR_POST_ORDER_DISPATCH(OP)
 

Functions

void tvm::relax::PostOrderVisit (const Expr &node, std::function< void(const Expr &)> fvisit)
 

Detailed Description

A more powerful visitor which enables defining arbitrary function signatures with type based dispatch on first argument.

Macro Definition Documentation

◆ EXPR_FUNCTOR_DEFAULT

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

◆ PY_EXPR_MUTATOR_DEFAULT

#define PY_EXPR_MUTATOR_DEFAULT (   N,
  PY_FUNC,
  DEFAULT_FUNC,
  RET_TYPE 
)
Value:
{ \
if (PY_FUNC != nullptr) { \
RET_TYPE ret = PY_FUNC(N); \
return ret; \
} else { \
return DEFAULT_FUNC; \
} \
}
const Op & ret()
Return value.

◆ PY_EXPR_MUTATOR_DISPATCH

#define PY_EXPR_MUTATOR_DISPATCH (   OP,
  PY_FUNC 
)
Value:
vtable.template set_dispatch<OP>([](const ObjectRef& n, TSelf* self) { \
if (self->PY_FUNC != nullptr) { \
Expr expr = self->PY_FUNC(n); \
return expr; \
} else { \
return self->VisitExpr_(static_cast<const OP*>(n.get())); \
} \
});

◆ PY_EXPR_MUTATOR_VISIT_EXPR_POST_ORDER_DISPATCH

#define PY_EXPR_MUTATOR_VISIT_EXPR_POST_ORDER_DISPATCH (   OP)
Value:
post_order_vtable.template set_dispatch<OP>([](const ObjectRef& n, TSelf* self) { \
return self->VisitExprPostOrder_(static_cast<const OP*>(n.get())); \
});

◆ PY_EXPR_VISITOR_DEFAULT

#define PY_EXPR_VISITOR_DEFAULT (   N,
  PY_FUNC,
  DEFAULT_FUNC 
)
Value:
{ \
if (PY_FUNC != nullptr) \
PY_FUNC(N); \
else \
DEFAULT_FUNC; \
}

◆ PY_EXPR_VISITOR_DISPATCH

#define PY_EXPR_VISITOR_DISPATCH (   OP,
  PY_FUNC 
)
Value:
vtable.template set_dispatch<OP>([](const ObjectRef& n, TSelf* self) { \
if (self->PY_FUNC != nullptr) \
self->PY_FUNC(n); \
else \
self->VisitExpr_(static_cast<const OP*>(n.get())); \
});

◆ RELAX_EXPR_FUNCTOR_DISPATCH

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