Go to the documentation of this file.
44 #ifndef MXNET_RUNTIME_REGISTRY_H_
45 #define MXNET_RUNTIME_REGISTRY_H_
83 template <
typename FType,
typename FLambda>
110 template <
typename R,
typename... Args>
136 template <
typename T,
typename R,
typename... Args>
138 return set_body_typed<R(T, Args...)>([f](T target, Args... params) -> R {
140 return (target.*f)(params...);
165 template <
typename T,
typename R,
typename... Args>
167 return set_body_typed<R(T, Args...)>([f](
const T target, Args... params) -> R {
169 return (target.*f)(params...);
204 template <
typename TObjectRef,
208 typename =
typename std::enable_if<std::is_base_of<ObjectRef, TObjectRef>::value>::type>
210 return set_body_typed<R(TObjectRef, Args...)>([f](TObjectRef ref, Args... params) {
211 TNode* target = ref.operator->();
213 return (target->*f)(params...);
248 template <
typename TObjectRef,
252 typename =
typename std::enable_if<std::is_base_of<ObjectRef, TObjectRef>::value>::type>
254 return set_body_typed<R(TObjectRef, Args...)>([f](TObjectRef ref, Args... params) {
255 const TNode* target = ref.operator->();
257 return (target->*f)(params...);
299 #if defined(__GNUC__)
300 #define MXNET_ATTRIBUTE_UNUSED __attribute__((unused))
302 #define MXNET_ATTRIBUTE_UNUSED
305 #define MXNET_STR_CONCAT_(__x, __y) __x##__y
306 #define MXNET_STR_CONCAT(__x, __y) MXNET_STR_CONCAT_(__x, __y)
308 #define MXNET_FUNC_REG_VAR_DEF \
309 static MXNET_ATTRIBUTE_UNUSED ::mxnet::runtime::Registry& __mk_##MXNET
319 #define MXNET_REGISTER_GLOBAL(OpName) \
320 MXNET_STR_CONCAT(MXNET_FUNC_REG_VAR_DEF, __COUNTER__) = \
321 ::mxnet::runtime::Registry::Register(OpName)
325 #endif // MXNET_RUNTIME_REGISTRY_H_
namespace of mxnet
Definition: api_registry.h:33
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:166
Registry & set_body(PackedFunc::FType f)
set the body of the function to be f
Definition: registry.h:66
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:111
static MXNET_DLL bool Remove(const std::string &name)
Erase global function from registry, if exist.
PackedFunc func_
internal packed function
Definition: registry.h:294
Registry for global function.
Definition: registry.h:55
Type-erased function used across MXNET API.
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:253
Please refer to TypedPackedFunc<R(Args..)>.
Definition: packed_func.h:152
Registry & set_body_typed(FLambda f)
set the body of the function to be TypedPackedFunc.
Definition: registry.h:84
static MXNET_DLL std::vector< std::string > ListNames()
Get the names of currently registered global function.
static const MXNET_DLL PackedFunc * Get(const std::string &name)
Get the global function by name.
#define MXNET_DLL
MXNET_DLL prefix for windows.
Definition: c_api.h:53
static MXNET_DLL Registry & Register(const std::string &name, bool override=false)
Register a function with given name.
std::string name_
name of the function
Definition: registry.h:288
std::function< void(MXNetArgs args, MXNetRetValue *rv)> FType
The internal std::function.
Definition: packed_func.h:100
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:137
friend struct Manager
Definition: registry.h:295
Packed function is a type-erased function. The arguments are passed by packed format.
Definition: packed_func.h:80
MXNET_DLL Registry & set_body(PackedFunc f)
set the body of the function to be f
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:209