mxnet
|
C API of NNVM symbolic construction and pass. Enables construction and transformation of Graph in any other host languages. More...
Go to the source code of this file.
Macros | |
#define | NNVM_DLL __attribute__((visibility("default"))) |
NNVM_DLL prefix for windows. More... | |
Typedefs | |
typedef unsigned int | nn_uint |
manually define unsigned int More... | |
typedef void * | OpHandle |
handle to a function that takes param and creates symbol More... | |
typedef void * | SymbolHandle |
handle to a symbol that can be bind as operator More... | |
typedef void * | GraphHandle |
handle to Graph More... | |
Functions | |
NNVM_DLL void | NNAPISetLastError (const char *msg) |
Set the last error message needed by C API. More... | |
NNVM_DLL const char * | NNGetLastError (void) |
return str message of the last error all function in this file will return 0 when success and -1 when an error occurred, NNGetLastError can be called to retrieve the error More... | |
NNVM_DLL int | NNListAllOpNames (nn_uint *out_size, const char ***out_array) |
list all the available operator names, include entries. More... | |
NNVM_DLL int | NNGetOpHandle (const char *op_name, OpHandle *op_out) |
Get operator handle given name. More... | |
NNVM_DLL int | NNListUniqueOps (nn_uint *out_size, OpHandle **out_array) |
list all the available operators. This won't include the alias, use ListAllNames instead to get all alias names. More... | |
NNVM_DLL int | NNGetOpInfo (OpHandle op, const char **real_name, const char **description, nn_uint *num_doc_args, const char ***arg_names, const char ***arg_type_infos, const char ***arg_descriptions, const char **return_type) |
Get the detailed information about atomic symbol. More... | |
NNVM_DLL int | NNSymbolCreateAtomicSymbol (OpHandle op, nn_uint num_param, const char **keys, const char **vals, SymbolHandle *out) |
Create an AtomicSymbol functor. More... | |
NNVM_DLL int | NNSymbolCreateVariable (const char *name, SymbolHandle *out) |
Create a Variable Symbol. More... | |
NNVM_DLL int | NNSymbolCreateGroup (nn_uint num_symbols, SymbolHandle *symbols, SymbolHandle *out) |
Create a Symbol by grouping list of symbols together. More... | |
NNVM_DLL int | NNAddControlDeps (SymbolHandle handle, SymbolHandle src_dep) |
Add src_dep to the handle as control dep. More... | |
NNVM_DLL int | NNSymbolFree (SymbolHandle symbol) |
Free the symbol handle. More... | |
NNVM_DLL int | NNSymbolCopy (SymbolHandle symbol, SymbolHandle *out) |
Copy the symbol to another handle. More... | |
NNVM_DLL int | NNSymbolPrint (SymbolHandle symbol, const char **out_str) |
Print the content of symbol, used for debug. More... | |
NNVM_DLL int | NNSymbolGetAttr (SymbolHandle symbol, const char *key, const char **out, int *success) |
Get string attribute from symbol. More... | |
NNVM_DLL int | NNSymbolSetAttrs (SymbolHandle symbol, nn_uint num_param, const char **keys, const char **values) |
Set string attribute from symbol. NOTE: Setting attribute to a symbol can affect the semantics(mutable/immutable) of symbolic graph. More... | |
NNVM_DLL int | NNSymbolListAttrs (SymbolHandle symbol, int recursive_option, nn_uint *out_size, const char ***out) |
Get all attributes from symbol, including all descendents. More... | |
NNVM_DLL int | NNSymbolListInputVariables (SymbolHandle symbol, int option, nn_uint *out_size, SymbolHandle **out_sym_array) |
List inputs variables in the symbol. More... | |
NNVM_DLL int | NNSymbolListInputNames (SymbolHandle symbol, int option, nn_uint *out_size, const char ***out_str_array) |
List input names in the symbol. More... | |
NNVM_DLL int | NNSymbolListOutputNames (SymbolHandle symbol, nn_uint *out_size, const char ***out_str_array) |
List returns names in the symbol. More... | |
NNVM_DLL int | NNSymbolGetNumOutputs (SymbolHandle symbol, nn_uint *output_count) |
Supply number of outputs of the symbol. More... | |
NNVM_DLL int | NNSymbolGetInternals (SymbolHandle symbol, SymbolHandle *out) |
Get a symbol that contains all the internals. More... | |
NNVM_DLL int | NNSymbolGetChildren (SymbolHandle symbol, SymbolHandle *out) |
Get a symbol that contains only direct children. More... | |
NNVM_DLL int | NNSymbolGetOutput (SymbolHandle symbol, nn_uint index, SymbolHandle *out) |
Get index-th outputs of the symbol. More... | |
NNVM_DLL int | NNSymbolCompose (SymbolHandle sym, const char *name, nn_uint num_args, const char **keys, SymbolHandle *args) |
Compose the symbol on other symbols. More... | |
NNVM_DLL int | NNGraphCreate (SymbolHandle symbol, GraphHandle *graph) |
create a graph handle from symbol More... | |
NNVM_DLL int | NNGraphFree (GraphHandle handle) |
free the graph handle More... | |
NNVM_DLL int | NNGraphGetSymbol (GraphHandle graph, SymbolHandle *symbol) |
Get a new symbol from the graph. More... | |
NNVM_DLL int | NNGraphSetJSONAttr (GraphHandle handle, const char *key, const char *json_value) |
Get Set a attribute in json format. This feature allows pass graph attributes back and forth in reasonable speed. More... | |
NNVM_DLL int | NNGraphGetJSONAttr (GraphHandle handle, const char *key, const char **json_out, int *success) |
Get a serialized attrirbute from graph. This feature allows pass graph attributes back and forth in reasonable speed. More... | |
NNVM_DLL int | NNGraphSetNodeEntryListAttr_ (GraphHandle handle, const char *key, SymbolHandle list) |
Set a attribute whose type is std::vector<NodeEntry> in c++ This feature allows pass List of symbolic variables for gradient request. More... | |
NNVM_DLL int | NNGraphApplyPasses (GraphHandle src, nn_uint num_pass, const char **pass_names, GraphHandle *dst) |
Apply passes on the src graph. More... | |
C API of NNVM symbolic construction and pass. Enables construction and transformation of Graph in any other host languages.
#define NNVM_DLL __attribute__((visibility("default"))) |
NNVM_DLL prefix for windows.
typedef void* GraphHandle |
handle to Graph
typedef unsigned int nn_uint |
manually define unsigned int
typedef void* OpHandle |
handle to a function that takes param and creates symbol
typedef void* SymbolHandle |
handle to a symbol that can be bind as operator
NNVM_DLL int NNAddControlDeps | ( | SymbolHandle | handle, |
SymbolHandle | src_dep | ||
) |
Add src_dep to the handle as control dep.
handle | The symbol to add dependency edges on. |
src_dep | the source handles. |
NNVM_DLL void NNAPISetLastError | ( | const char * | msg | ) |
Set the last error message needed by C API.
msg | The error message to set. |
NNVM_DLL const char* NNGetLastError | ( | void | ) |
return str message of the last error all function in this file will return 0 when success and -1 when an error occurred, NNGetLastError can be called to retrieve the error
this function is threadsafe and can be called by different thread
Get operator handle given name.
op_name | The name of the operator. |
op_out | The returnning op handle. |
NNVM_DLL int NNGetOpInfo | ( | OpHandle | op, |
const char ** | real_name, | ||
const char ** | description, | ||
nn_uint * | num_doc_args, | ||
const char *** | arg_names, | ||
const char *** | arg_type_infos, | ||
const char *** | arg_descriptions, | ||
const char ** | return_type | ||
) |
Get the detailed information about atomic symbol.
op | The operator handle. |
real_name | The returned name of the creator. This name is not the alias name of the atomic symbol. |
description | The returned description of the symbol. |
num_doc_args | Number of arguments that contain documents. |
arg_names | Name of the arguments of doc args |
arg_type_infos | Type informations about the arguments. |
arg_descriptions | Description information about the arguments. |
return_type | Return type of the function, if any. |
NNVM_DLL int NNGraphApplyPasses | ( | GraphHandle | src, |
nn_uint | num_pass, | ||
const char ** | pass_names, | ||
GraphHandle * | dst | ||
) |
Apply passes on the src graph.
src | The source graph handle. |
num_pass | The number of pass to be applied. |
pass_names | The names of the pass. |
dst | The result graph. |
NNVM_DLL int NNGraphCreate | ( | SymbolHandle | symbol, |
GraphHandle * | graph | ||
) |
create a graph handle from symbol
symbol | The symbol representing the graph. |
graph | The graph handle created. |
NNVM_DLL int NNGraphFree | ( | GraphHandle | handle | ) |
free the graph handle
handle | The handle to be freed. |
NNVM_DLL int NNGraphGetJSONAttr | ( | GraphHandle | handle, |
const char * | key, | ||
const char ** | json_out, | ||
int * | success | ||
) |
Get a serialized attrirbute from graph. This feature allows pass graph attributes back and forth in reasonable speed.
handle | The graph handle. |
key | The key to the attribute. |
json_out | The result attribute, can be NULL if the attribute do not exist. The json_out is an array of [type_name, value]. Where the type_name is a registered type string in C++ side via DMLC_JSON_ENABLE_ANY. |
success | Whether the result is contained in out. |
NNVM_DLL int NNGraphGetSymbol | ( | GraphHandle | graph, |
SymbolHandle * | symbol | ||
) |
Get a new symbol from the graph.
graph | The graph handle. |
symbol | The corresponding symbol |
NNVM_DLL int NNGraphSetJSONAttr | ( | GraphHandle | handle, |
const char * | key, | ||
const char * | json_value | ||
) |
Get Set a attribute in json format. This feature allows pass graph attributes back and forth in reasonable speed.
handle | The graph handle. |
key | The key to the attribute. |
json_value | The value need to be in format [type_name, value], Where type_name is a registered type string in C++ side via DMLC_JSON_ENABLE_ANY. |
NNVM_DLL int NNGraphSetNodeEntryListAttr_ | ( | GraphHandle | handle, |
const char * | key, | ||
SymbolHandle | list | ||
) |
Set a attribute whose type is std::vector<NodeEntry> in c++ This feature allows pass List of symbolic variables for gradient request.
handle | The graph handle. |
key | The key to the attribute. |
list | The symbol whose outputs represents the list of NodeEntry to be passed. |
list all the available operator names, include entries.
out_size | the size of returned array |
out_array | the output operator name array. |
list all the available operators. This won't include the alias, use ListAllNames instead to get all alias names.
out_size | the size of returned array |
out_array | the output AtomicSymbolCreator array |
NNVM_DLL int NNSymbolCompose | ( | SymbolHandle | sym, |
const char * | name, | ||
nn_uint | num_args, | ||
const char ** | keys, | ||
SymbolHandle * | args | ||
) |
Compose the symbol on other symbols.
This function will change the sym hanlde. To achieve function apply behavior, copy the symbol first before apply.
sym | the symbol to apply |
name | the name of symbol |
num_args | number of arguments |
keys | the key of keyword args (optional) |
args | arguments to sym |
NNVM_DLL int NNSymbolCopy | ( | SymbolHandle | symbol, |
SymbolHandle * | out | ||
) |
Copy the symbol to another handle.
symbol | the source symbol |
out | used to hold the result of copy |
NNVM_DLL int NNSymbolCreateAtomicSymbol | ( | OpHandle | op, |
nn_uint | num_param, | ||
const char ** | keys, | ||
const char ** | vals, | ||
SymbolHandle * | out | ||
) |
Create an AtomicSymbol functor.
op | The operator handle |
num_param | the number of parameters |
keys | the keys to the params |
vals | the vals of the params |
out | pointer to the created symbol handle |
NNVM_DLL int NNSymbolCreateGroup | ( | nn_uint | num_symbols, |
SymbolHandle * | symbols, | ||
SymbolHandle * | out | ||
) |
Create a Symbol by grouping list of symbols together.
num_symbols | number of symbols to be grouped |
symbols | array of symbol handles |
out | pointer to the created symbol handle |
NNVM_DLL int NNSymbolCreateVariable | ( | const char * | name, |
SymbolHandle * | out | ||
) |
Create a Variable Symbol.
name | name of the variable |
out | pointer to the created symbol handle |
NNVM_DLL int NNSymbolFree | ( | SymbolHandle | symbol | ) |
Free the symbol handle.
symbol | the symbol |
NNVM_DLL int NNSymbolGetAttr | ( | SymbolHandle | symbol, |
const char * | key, | ||
const char ** | out, | ||
int * | success | ||
) |
Get string attribute from symbol.
symbol | the source symbol |
key | The key of the symbol. |
out | The result attribute, can be NULL if the attribute do not exist. |
success | Whether the result is contained in out. |
NNVM_DLL int NNSymbolGetChildren | ( | SymbolHandle | symbol, |
SymbolHandle * | out | ||
) |
Get a symbol that contains only direct children.
symbol | The symbol |
out | The output symbol whose outputs are the direct children. |
NNVM_DLL int NNSymbolGetInternals | ( | SymbolHandle | symbol, |
SymbolHandle * | out | ||
) |
Get a symbol that contains all the internals.
symbol | The symbol |
out | The output symbol whose outputs are all the internals. |
NNVM_DLL int NNSymbolGetNumOutputs | ( | SymbolHandle | symbol, |
nn_uint * | output_count | ||
) |
Supply number of outputs of the symbol.
symbol | the symbol |
output_count | number of outputs |
NNVM_DLL int NNSymbolGetOutput | ( | SymbolHandle | symbol, |
nn_uint | index, | ||
SymbolHandle * | out | ||
) |
Get index-th outputs of the symbol.
symbol | The symbol |
index | the Index of the output. |
out | The output symbol whose outputs are the index-th symbol. |
NNVM_DLL int NNSymbolListAttrs | ( | SymbolHandle | symbol, |
int | recursive_option, | ||
nn_uint * | out_size, | ||
const char *** | out | ||
) |
Get all attributes from symbol, including all descendents.
symbol | the source symbol |
recursive_option | 0 for recursive, 1 for shallow. |
out_size | The number of output attributes |
out | 2*out_size strings representing key value pairs. |
NNVM_DLL int NNSymbolListInputNames | ( | SymbolHandle | symbol, |
int | option, | ||
nn_uint * | out_size, | ||
const char *** | out_str_array | ||
) |
List input names in the symbol.
symbol | the symbol |
option | The option to list the inputs option=0 means list all arguments. option=1 means list arguments that are readed only by the graph. option=2 means list arguments that are mutated by the graph. |
out_size | output size |
out_str_array | pointer to hold the output string array |
NNVM_DLL int NNSymbolListInputVariables | ( | SymbolHandle | symbol, |
int | option, | ||
nn_uint * | out_size, | ||
SymbolHandle ** | out_sym_array | ||
) |
List inputs variables in the symbol.
symbol | the symbol |
option | The option to list the inputs option=0 means list all arguments. option=1 means list arguments that are readed only by the graph. option=2 means list arguments that are mutated by the graph. |
out_size | output size |
out_sym_array | the output array. |
NNVM_DLL int NNSymbolListOutputNames | ( | SymbolHandle | symbol, |
nn_uint * | out_size, | ||
const char *** | out_str_array | ||
) |
List returns names in the symbol.
symbol | the symbol |
out_size | output size |
out_str_array | pointer to hold the output string array |
NNVM_DLL int NNSymbolPrint | ( | SymbolHandle | symbol, |
const char ** | out_str | ||
) |
Print the content of symbol, used for debug.
symbol | the symbol |
out_str | pointer to hold the output string of the printing. |
NNVM_DLL int NNSymbolSetAttrs | ( | SymbolHandle | symbol, |
nn_uint | num_param, | ||
const char ** | keys, | ||
const char ** | values | ||
) |
Set string attribute from symbol. NOTE: Setting attribute to a symbol can affect the semantics(mutable/immutable) of symbolic graph.
Safe recommendaton: use immutable graph
Mutable graph (be careful about the semantics):
symbol | the source symbol |
num_param | Number of parameters to set. |
keys | The keys of the attribute |
values | The value to be set |