44 #ifndef MXNET_RUNTIME_REGISTRY_H_ 45 #define MXNET_RUNTIME_REGISTRY_H_ 83 template<
typename FType,
typename FLambda>
109 template<
typename R,
typename ...Args>
134 template<
typename T,
typename R,
typename ...Args>
136 return set_body_typed<R(T, Args...)>([f](T target, Args... params) -> R {
138 return (target.*f)(params...);
162 template<
typename T,
typename R,
typename ...Args>
164 return set_body_typed<R(T, Args...)>([f](
const T target, Args... params) -> R {
166 return (target.*f)(params...);
200 template<
typename TObjectRef,
typename TNode,
typename R,
typename ...Args,
201 typename =
typename std::enable_if<std::is_base_of<ObjectRef, TObjectRef>::value>::type>
203 return set_body_typed<R(TObjectRef, Args...)>([f](TObjectRef ref, Args... params) {
204 TNode* target = ref.operator->();
206 return (target->*f)(params...);
240 template<
typename TObjectRef,
typename TNode,
typename R,
typename ...Args,
241 typename =
typename std::enable_if<std::is_base_of<ObjectRef, TObjectRef>::value>::type>
243 return set_body_typed<R(TObjectRef, Args...)>([f](TObjectRef ref, Args... params) {
244 const TNode* target = ref.operator->();
246 return (target->*f)(params...);
288 #if defined(__GNUC__) 289 #define MXNET_ATTRIBUTE_UNUSED __attribute__((unused)) 291 #define MXNET_ATTRIBUTE_UNUSED 294 #define MXNET_STR_CONCAT_(__x, __y) __x##__y 295 #define MXNET_STR_CONCAT(__x, __y) MXNET_STR_CONCAT_(__x, __y) 297 #define MXNET_FUNC_REG_VAR_DEF \ 298 static MXNET_ATTRIBUTE_UNUSED ::mxnet::runtime::Registry& __mk_ ## MXNET 308 #define MXNET_REGISTER_GLOBAL(OpName) \ 309 MXNET_STR_CONCAT(MXNET_FUNC_REG_VAR_DEF, __COUNTER__) = \ 310 ::mxnet::runtime::Registry::Register(OpName) 314 #endif // MXNET_RUNTIME_REGISTRY_H_ Registry & set_body_method(R(TNode::*f)(Args...) const)
set the body of the function to be the passed method pointer. Used when calling a method on a Node su...
Definition: registry.h:242
std::function< void(MXNetArgs args, MXNetRetValue *rv)> FType
The internal std::function.
Definition: packed_func.h:97
Registry & set_body_method(R(T::*f)(Args...) const)
set the body of the function to be the passed method pointer. Note that this will ignore default arg ...
Definition: registry.h:163
MXNET_DLL Registry & set_body(PackedFunc f)
set the body of the function to be f
namespace of mxnet
Definition: api_registry.h:33
static MXNET_DLL Registry & Register(const std::string &name, bool override=false)
Register a function with given name.
static MXNET_DLL std::vector< std::string > ListNames()
Get the names of currently registered global function.
Registry & set_body_typed(R(*f)(Args...))
set the body of the function to the given function pointer. Note that this doesn't work with lambdas...
Definition: registry.h:110
Packed function is a type-erased function. The arguments are passed by packed format.
Definition: packed_func.h:77
Registry & set_body(PackedFunc::FType f)
set the body of the function to be f
Definition: registry.h:66
friend struct Manager
Definition: registry.h:284
Registry & set_body_method(R(T::*f)(Args...))
set the body of the function to be the passed method pointer. Note that this will ignore default arg ...
Definition: registry.h:135
Registry for global function.
Definition: registry.h:55
Please refer to TypedPackedFunc<R(Args..)>.
Definition: packed_func.h:149
Registry & set_body_typed(FLambda f)
set the body of the function to be TypedPackedFunc.
Definition: registry.h:84
static MXNET_DLL const PackedFunc * Get(const std::string &name)
Get the global function by name.
#define MXNET_DLL
MXNET_DLL prefix for windows.
Definition: c_api.h:54
Registry & set_body_method(R(TNode::*f)(Args...))
set the body of the function to be the passed method pointer. Used when calling a method on a Node su...
Definition: registry.h:202
std::string name_
name of the function
Definition: registry.h:277
PackedFunc func_
internal packed function
Definition: registry.h:283
static MXNET_DLL bool Remove(const std::string &name)
Erase global function from registry, if exist.
Type-erased function used across MXNET API.