tvm
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
tvm::NodeFunctor< FType > Class Template Reference

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

#include <functor.h>

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");
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: