TVM_DLL
#ifndef TVM_DLL#ifdef _WIN32#ifdef TVM_EXPORTS#define TVM_DLL __declspec(dllexport)#else#define TVM_DLL __declspec(dllimport)#endif#else#define TVM_DLL __attribute__((visibility("default")))#endif#endif
TVM_VERSION
// TVM version#define TVM_VERSION "0.6.0"
TVM_REGISTER_GLOBAL / TVM_REGISTER_API
注册一个全局宏
例如:
TVM_REGISTER_GLOBAL("MyPrint").set_body([](TVMArgs args, TVMRetValue* rv) {});static __attribute__((unused)) ::tvm::runtime::Registry& __mk_ ## TVM##__COUNTER__ = ::tvm::runtime::Registry::Register(OpName)
TVM_REGISTER_OBJECT_TYPE
_
TVMREGISTER_NODE_TYPE
_Register a node type to object registry and reflection registry.
TVMDECLARE_INTRIN_UNARY
_Intrinsic operators
TVM_CHECK_TYPE_CODE
RELAY_REGISTER_OP
Register a new operator, or set attribute of the corresponding op.
RELAY_REGISTER_UNARY_OP
RELAY_REGISTER_BINARY_OP
RELAY_REGISTER_CMP_OP
这三个宏是对TVM_REGISTER_API和RELAY_REGISTER_OP的进一步封装,如下:
/*! Quick helper macro* - Expose a positional make function to construct the node.* - Register op to the registry.** We make the decision to always only expose positional argument.* We will do rewrapping in the frontend to support language* sugars such as keyword arguments and default value.* \param OpName the name of registry.*/#define RELAY_REGISTER_UNARY_OP(OpName) \TVM_REGISTER_API("relay.op._make." OpName) \.set_body_typed<Expr(Expr)>([](Expr data) { \static const Op& op = Op::Get(OpName); \return CallNode::make(op, {data}, Attrs(), {}); \}); \RELAY_REGISTER_OP(OpName) \.set_num_inputs(1) \.add_argument("data", "Tensor", "The input tensor.") \.add_type_rel("Identity", IdentityRel) \.set_attr<TOpPattern>("TOpPattern", kElemWise) \.set_attr<TOpIsStateful>("TOpIsStateful", false) \.set_attr<FInferCorrectLayout>("FInferCorrectLayout", \ElemwiseArbitraryLayout) \/*! Quick helper macro* - Expose a positional make function to construct the node.* - Register op to the registry.** We make the decision to always only expose positional argument.* We will do rewrapping in the frontend to support language* sugars such as keyword arguments and default value.** \param OpName the name of registry.*/#define RELAY_REGISTER_BINARY_OP(OpName) \TVM_REGISTER_API("relay.op._make." OpName) \.set_body_typed<Expr(Expr, Expr)>([](Expr lhs, Expr rhs) { \static const Op& op = Op::Get(OpName); \return CallNode::make(op, {lhs, rhs}, Attrs(), {}); \}); \RELAY_REGISTER_OP(OpName) \.set_num_inputs(2) \.add_argument("lhs", "Tensor", "The left hand side tensor.") \.add_argument("rhs", "Tensor", "The right hand side tensor.") \.add_type_rel("Broadcast", BroadcastRel) \.set_attr<TOpPattern>("TOpPattern", kBroadcast) \.set_attr<TOpIsStateful>("TOpIsStateful", false) \.set_attr<FInferCorrectLayout>("FInferCorrectLayout", \BinaryBroadcastLayout)// Comparisons#define RELAY_REGISTER_CMP_OP(OpName) \TVM_REGISTER_API("relay.op._make." OpName) \.set_body_typed<Expr(Expr, Expr)>([](Expr lhs, Expr rhs) { \static const Op& op = Op::Get(OpName); \return CallNode::make(op, {lhs, rhs}, Attrs(), {}); \}); \RELAY_REGISTER_OP(OpName) \.set_num_inputs(2) \.add_argument("lhs", "Tensor", "The left hand side tensor.") \.add_argument("rhs", "Tensor", "The right hand side tensor.") \.add_type_rel("BroadcastComp", BroadcastCompRel) \.set_attr<TOpPattern>("TOpPattern", kBroadcast) \.set_attr<TOpIsStateful>("TOpIsStateful", false) \.set_attr<FInferCorrectLayout>("FInferCorrectLayout", \BinaryBroadcastLayout)
