mxnet
Public Member Functions | Static Public Member Functions | Protected Attributes | Friends | List of all members
mxnet::runtime::Registry Class Reference

Registry for global function. More...

#include <registry.h>

Collaboration diagram for mxnet::runtime::Registry:
Collaboration graph

Public Member Functions

MXNET_DLL Registryset_body (PackedFunc f)
 set the body of the function to be f More...
 
Registryset_body (PackedFunc::FType f)
 set the body of the function to be f More...
 
template<typename FType , typename FLambda >
Registryset_body_typed (FLambda f)
 set the body of the function to be TypedPackedFunc. More...
 
template<typename R , typename... Args>
Registryset_body_typed (R(*f)(Args...))
 set the body of the function to the given function pointer. Note that this doesn't work with lambdas, you need to explicitly give a type for those. Note that this will ignore default arg values and always require all arguments to be provided. More...
 
template<typename T , typename R , typename... Args>
Registryset_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 values and always require all arguments to be provided. More...
 
template<typename T , typename R , typename... Args>
Registryset_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 values and always require all arguments to be provided. More...
 
template<typename TObjectRef , typename TNode , typename R , typename... Args, typename = typename std::enable_if<std::is_base_of<ObjectRef, TObjectRef>::value>::type>
Registryset_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 subclass through a ObjectRef subclass. Note that this will ignore default arg values and always require all arguments to be provided. More...
 
template<typename TObjectRef , typename TNode , typename R , typename... Args, typename = typename std::enable_if<std::is_base_of<ObjectRef, TObjectRef>::value>::type>
Registryset_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 subclass through a ObjectRef subclass. Note that this will ignore default arg values and always require all arguments to be provided. More...
 

Static Public Member Functions

static MXNET_DLL RegistryRegister (const std::string &name, bool override=false)
 Register a function with given name. More...
 
static MXNET_DLL bool Remove (const std::string &name)
 Erase global function from registry, if exist. More...
 
static MXNET_DLL const PackedFuncGet (const std::string &name)
 Get the global function by name. More...
 
static MXNET_DLL std::vector< std::string > ListNames ()
 Get the names of currently registered global function. More...
 

Protected Attributes

std::string name_
 name of the function More...
 
PackedFunc func_
 internal packed function More...
 

Friends

struct Manager
 

Detailed Description

Registry for global function.

Member Function Documentation

static MXNET_DLL const PackedFunc* mxnet::runtime::Registry::Get ( const std::string &  name)
static

Get the global function by name.

Parameters
nameThe name of the function.
Returns
pointer to the registered function, nullptr if it does not exist.
static MXNET_DLL std::vector<std::string> mxnet::runtime::Registry::ListNames ( )
static

Get the names of currently registered global function.

Returns
The names
static MXNET_DLL Registry& mxnet::runtime::Registry::Register ( const std::string &  name,
bool  override = false 
)
static

Register a function with given name.

Parameters
nameThe name of the function.
overrideWhether allow oveeride existing function.
Returns
Reference to theregistry.
static MXNET_DLL bool mxnet::runtime::Registry::Remove ( const std::string &  name)
static

Erase global function from registry, if exist.

Parameters
nameThe name of the function.
Returns
Whether function exist.
MXNET_DLL Registry& mxnet::runtime::Registry::set_body ( PackedFunc  f)

set the body of the function to be f

Parameters
fThe body of the function.
Registry& mxnet::runtime::Registry::set_body ( PackedFunc::FType  f)
inline

set the body of the function to be f

Parameters
fThe body of the function.
template<typename T , typename R , typename... Args>
Registry& mxnet::runtime::Registry::set_body_method ( R(T::*)(Args...)  f)
inline

set the body of the function to be the passed method pointer. Note that this will ignore default arg values and always require all arguments to be provided.

// node subclass:
struct Example {
int doThing(int x);
}
TVM_REGISTER_API("Example_doThing")
.set_body_method(&Example::doThing); // will have type int(Example, int)
Parameters
fthe method pointer to forward to.
Template Parameters
Tthe type containing the method (inferred).
Rthe return type of the function (inferred).
Argsthe argument types of the function (inferred).
template<typename T , typename R , typename... Args>
Registry& mxnet::runtime::Registry::set_body_method ( R(T::*)(Args...) const  f)
inline

set the body of the function to be the passed method pointer. Note that this will ignore default arg values and always require all arguments to be provided.

// node subclass:
struct Example {
int doThing(int x);
}
TVM_REGISTER_API("Example_doThing")
.set_body_method(&Example::doThing); // will have type int(Example, int)
Parameters
fthe method pointer to forward to.
Template Parameters
Tthe type containing the method (inferred).
Rthe return type of the function (inferred).
Argsthe argument types of the function (inferred).
template<typename TObjectRef , typename TNode , typename R , typename... Args, typename = typename std::enable_if<std::is_base_of<ObjectRef, TObjectRef>::value>::type>
Registry& mxnet::runtime::Registry::set_body_method ( R(TNode::*)(Args...)  f)
inline

set the body of the function to be the passed method pointer. Used when calling a method on a Node subclass through a ObjectRef subclass. Note that this will ignore default arg values and always require all arguments to be provided.

// node subclass:
struct ExampleNode: BaseNode {
int doThing(int x);
}
// noderef subclass
struct Example;
TVM_REGISTER_API("Example_doThing")
.set_body_method<Example>(&ExampleNode::doThing); // will have type int(Example, int)
// note that just doing:
// .set_body_method(&ExampleNode::doThing);
// wouldn't work, because ExampleNode can't be taken from a TVMArgValue.
Parameters
fthe method pointer to forward to.
Template Parameters
TObjectRefthe node reference type to call the method on
TNodethe node type containing the method (inferred).
Rthe return type of the function (inferred).
Argsthe argument types of the function (inferred).
template<typename TObjectRef , typename TNode , typename R , typename... Args, typename = typename std::enable_if<std::is_base_of<ObjectRef, TObjectRef>::value>::type>
Registry& mxnet::runtime::Registry::set_body_method ( R(TNode::*)(Args...) const  f)
inline

set the body of the function to be the passed method pointer. Used when calling a method on a Node subclass through a ObjectRef subclass. Note that this will ignore default arg values and always require all arguments to be provided.

// node subclass:
struct ExampleNode: BaseNode {
int doThing(int x);
}
// noderef subclass
struct Example;
TVM_REGISTER_API("Example_doThing")
.set_body_method<Example>(&ExampleNode::doThing); // will have type int(Example, int)
// note that just doing:
// .set_body_method(&ExampleNode::doThing);
// wouldn't work, because ExampleNode can't be taken from a TVMArgValue.
Parameters
fthe method pointer to forward to.
Template Parameters
TObjectRefthe node reference type to call the method on
TNodethe node type containing the method (inferred).
Rthe return type of the function (inferred).
Argsthe argument types of the function (inferred).
template<typename FType , typename FLambda >
Registry& mxnet::runtime::Registry::set_body_typed ( FLambda  f)
inline

set the body of the function to be TypedPackedFunc.

TVM_REGISTER_API("addone")
.set_body_typed<int(int)>([](int x) { return x + 1; });
Parameters
fThe body of the function.
Template Parameters
FTypethe signature of the function.
FLambdaThe type of f.
template<typename R , typename... Args>
Registry& mxnet::runtime::Registry::set_body_typed ( R(*)(Args...)  f)
inline

set the body of the function to the given function pointer. Note that this doesn't work with lambdas, you need to explicitly give a type for those. Note that this will ignore default arg values and always require all arguments to be provided.

int multiply(int x, int y) {
return x * y;
}
TVM_REGISTER_API("multiply")
.set_body_typed(multiply); // will have type int(int, int)
Parameters
fThe function to forward to.
Template Parameters
Rthe return type of the function (inferred).
Argsthe argument types of the function (inferred).

Friends And Related Function Documentation

friend struct Manager
friend

Member Data Documentation

PackedFunc mxnet::runtime::Registry::func_
protected

internal packed function

std::string mxnet::runtime::Registry::name_
protected

name of the function


The documentation for this class was generated from the following file: