Useful macro to set NodeFunctor dispatch in a global static field.
class TVMScriptPrinter {
public:
static std::string Script(const ffi::ObjectRef& node, const PrinterConfig& cfg) {
return vtable()(node, cfg);
}
using FType = NodeFunctor<std::string(const ffi::ObjectRef&, const PrinterConfig&)>;
static FType& vtable();
};
TVMScriptPrinter::FType& TVMScriptPrinter::vtable() {
static FType inst; return inst;
}
.set_dispatch<AddNode>([](const ffi::ObjectRef& ref, const PrinterConfig& cfg) {
auto* n = static_cast<const AddNode*>(ref.get());
return Script(n->a, cfg) + " + " + Script(n->b, cfg);
});
#define TVM_STATIC_IR_FUNCTOR(ClsName, FField)
Useful macro to set NodeFunctor dispatch in a global static field.
Definition: node_functor.h:191