tvm
tvm::NodeFunctor< FType > Class Template Reference

A dynamically dispatched functor on the type of the first argument. More...

Collaboration diagram for tvm::NodeFunctor< FType >:

Detailed Description

template<typename FType>
class tvm::NodeFunctor< FType >

A dynamically dispatched functor on the type of the first argument.

This is a class that is useful to construct polymorphic dispatching base on the AST/IR node's type.

NodeFunctor<std::string (const ObjectRef& n, std::string prefix)> tostr;
tostr.set_dispatch<Add>([](const ObjectRef& op, std::string prefix) {
return prefix + "Add";
});
tostr.set_dispatch<IntImm>([](const ObjectRef& op, std::string prefix) {
return prefix + "IntImm"
});
Expr y = x + x;
// dispatch to IntImm, outputs "MyIntImm"
LOG(INFO) << tostr(x, "My");
// dispatch to IntImm, outputs "MyAdd"
LOG(INFO) << tostr(y, "My");
RelayExpr Expr
Definition: expr.h:37
PrimExpr make_const(DataType t, ValueType value, Span span=Span())
Make a const value with certain data type.
Definition: op.h:962
Template Parameters
FTypefunction signiture This type if only defined for FType with function signature

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