Defines the Functor data structures.
More...
#include <tvm/ffi/error.h>
#include <cstring>
#include <type_traits>
#include <utility>
#include <vector>
Go to the source code of this file.
|
| | tvm |
| | An object that builds and maintains block scope and StmtSref mapping for Dependence analysis.
|
| |
Defines the Functor data structures.
◆ TVM_REG_FUNC_VAR_DEF
| #define TVM_REG_FUNC_VAR_DEF |
( |
|
ClsName | ) |
[[maybe_unused]] static auto& __make_functor##_##ClsName |
◆ TVM_STATIC_IR_FUNCTOR
| #define TVM_STATIC_IR_FUNCTOR |
( |
|
ClsName, |
|
|
|
FField |
|
) |
| TVM_FFI_STR_CONCAT(TVM_REG_FUNC_VAR_DEF(ClsName), __COUNTER__) = ClsName::FField() |
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());
});
std::string Script(const ffi::ObjectRef &node, const ffi::Optional< PrinterConfig > &config=std::nullopt)
Print node as TVMScript with the given config.
#define TVM_STATIC_IR_FUNCTOR(ClsName, FField)
Useful macro to set NodeFunctor dispatch in a global static field.
Definition: node_functor.h:191
- Parameters
-
| ClsName | The name of the class |
| FField | The static function that returns a singleton of NodeFunctor. |