mxnet
c_api.h
Go to the documentation of this file.
1 /*
2  * Licensed to the Apache Software Foundation (ASF) under one
3  * or more contributor license agreements. See the NOTICE file
4  * distributed with this work for additional information
5  * regarding copyright ownership. The ASF licenses this file
6  * to you under the Apache License, Version 2.0 (the
7  * "License"); you may not use this file except in compliance
8  * with the License. You may obtain a copy of the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing,
13  * software distributed under the License is distributed on an
14  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15  * KIND, either express or implied. See the License for the
16  * specific language governing permissions and limitations
17  * under the License.
18  */
19 
26 #ifndef NNVM_C_API_H_
27 #define NNVM_C_API_H_
28 
30 #ifdef _WIN32
31 #ifdef NNVM_EXPORTS
32 #define NNVM_DLL __declspec(dllexport)
33 #else
34 #define NNVM_DLL __declspec(dllimport)
35 #endif
36 #else
37 #define NNVM_DLL __attribute__((visibility("default")))
38 #endif
39 
41 typedef unsigned int nn_uint;
42 
44 typedef void* OpHandle;
46 typedef void* SymbolHandle;
48 typedef void* GraphHandle;
49 
50 #ifdef __cplusplus
51 extern "C" {
52 #endif
53 
57 NNVM_DLL void NNAPISetLastError(const char* msg);
58 
68 NNVM_DLL const char* NNGetLastError(void);
69 
76 NNVM_DLL int NNListAllOpNames(nn_uint* out_size, const char*** out_array);
77 
83 NNVM_DLL int NNGetOpHandle(const char* op_name, OpHandle* op_out);
84 
94 NNVM_DLL int NNListUniqueOps(nn_uint* out_size, OpHandle** out_array);
95 
109 NNVM_DLL int NNGetOpInfo(OpHandle op, const char** real_name, const char** description,
110  nn_uint* num_doc_args, const char*** arg_names,
111  const char*** arg_type_infos, const char*** arg_descriptions,
112  const char** return_type);
122 NNVM_DLL int NNSymbolCreateAtomicSymbol(OpHandle op, nn_uint num_param, const char** keys,
123  const char** vals, SymbolHandle* out);
130 NNVM_DLL int NNSymbolCreateVariable(const char* name, SymbolHandle* out);
138 NNVM_DLL int NNSymbolCreateGroup(nn_uint num_symbols, SymbolHandle* symbols, SymbolHandle* out);
164 NNVM_DLL int NNSymbolPrint(SymbolHandle symbol, const char** out_str);
173 NNVM_DLL int NNSymbolGetAttr(SymbolHandle symbol, const char* key, const char** out, int* success);
192 NNVM_DLL int NNSymbolSetAttrs(SymbolHandle symbol, nn_uint num_param, const char** keys,
193  const char** values);
202 NNVM_DLL int NNSymbolListAttrs(SymbolHandle symbol, int recursive_option, nn_uint* out_size,
203  const char*** out);
204 
216 NNVM_DLL int NNSymbolListInputVariables(SymbolHandle symbol, int option, nn_uint* out_size,
217  SymbolHandle** out_sym_array);
218 
230 NNVM_DLL int NNSymbolListInputNames(SymbolHandle symbol, int option, nn_uint* out_size,
231  const char*** out_str_array);
240  const char*** out_str_array);
241 
248 NNVM_DLL int NNSymbolGetNumOutputs(SymbolHandle symbol, nn_uint* output_count);
249 
272 
287 NNVM_DLL int NNSymbolCompose(SymbolHandle sym, const char* name, nn_uint num_args,
288  const char** keys, SymbolHandle* args);
289 
290 // Graph IR API
297 NNVM_DLL int NNGraphCreate(SymbolHandle symbol, GraphHandle* graph);
302 NNVM_DLL int NNGraphFree(GraphHandle handle);
310 
321 NNVM_DLL int NNGraphSetJSONAttr(GraphHandle handle, const char* key, const char* json_value);
322 
335 NNVM_DLL int NNGraphGetJSONAttr(GraphHandle handle, const char* key, const char** json_out,
336  int* success);
337 
349 NNVM_DLL int NNGraphSetNodeEntryListAttr_(GraphHandle handle, const char* key, SymbolHandle list);
358 NNVM_DLL int NNGraphApplyPasses(GraphHandle src, nn_uint num_pass, const char** pass_names,
359  GraphHandle* dst);
360 
361 #ifdef __cplusplus
362 } /* end extern "C" */
363 #endif
364 
365 #endif // NNVM_C_API_H_
NNAddControlDeps
NNVM_DLL int NNAddControlDeps(SymbolHandle handle, SymbolHandle src_dep)
Add src_dep to the handle as control dep.
NNSymbolCompose
NNVM_DLL int NNSymbolCompose(SymbolHandle sym, const char *name, nn_uint num_args, const char **keys, SymbolHandle *args)
Compose the symbol on other symbols.
NNSymbolGetNumOutputs
NNVM_DLL int NNSymbolGetNumOutputs(SymbolHandle symbol, nn_uint *output_count)
Supply number of outputs of the symbol.
OpHandle
void * OpHandle
handle to a function that takes param and creates symbol
Definition: c_api.h:44
NNGetOpInfo
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.
NNSymbolListInputNames
NNVM_DLL int NNSymbolListInputNames(SymbolHandle symbol, int option, nn_uint *out_size, const char ***out_str_array)
List input names in the symbol.
NNGraphGetSymbol
NNVM_DLL int NNGraphGetSymbol(GraphHandle graph, SymbolHandle *symbol)
Get a new symbol from the graph.
NNSymbolListInputVariables
NNVM_DLL int NNSymbolListInputVariables(SymbolHandle symbol, int option, nn_uint *out_size, SymbolHandle **out_sym_array)
List inputs variables in the symbol.
NNGraphApplyPasses
NNVM_DLL int NNGraphApplyPasses(GraphHandle src, nn_uint num_pass, const char **pass_names, GraphHandle *dst)
Apply passes on the src graph.
NNSymbolGetChildren
NNVM_DLL int NNSymbolGetChildren(SymbolHandle symbol, SymbolHandle *out)
Get a symbol that contains only direct children.
NNSymbolListAttrs
NNVM_DLL int NNSymbolListAttrs(SymbolHandle symbol, int recursive_option, nn_uint *out_size, const char ***out)
Get all attributes from symbol, including all descendents.
NNListAllOpNames
NNVM_DLL int NNListAllOpNames(nn_uint *out_size, const char ***out_array)
list all the available operator names, include entries.
nn_uint
unsigned int nn_uint
manually define unsigned int
Definition: c_api.h:41
NNGraphSetNodeEntryListAttr_
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...
NNSymbolGetOutput
NNVM_DLL int NNSymbolGetOutput(SymbolHandle symbol, nn_uint index, SymbolHandle *out)
Get index-th outputs of the symbol.
NNGraphSetJSONAttr
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 reaso...
NNSymbolListOutputNames
NNVM_DLL int NNSymbolListOutputNames(SymbolHandle symbol, nn_uint *out_size, const char ***out_str_array)
List returns names in the symbol.
NNGetOpHandle
NNVM_DLL int NNGetOpHandle(const char *op_name, OpHandle *op_out)
Get operator handle given name.
NNGraphCreate
NNVM_DLL int NNGraphCreate(SymbolHandle symbol, GraphHandle *graph)
create a graph handle from symbol
NNListUniqueOps
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 a...
NNSymbolCopy
NNVM_DLL int NNSymbolCopy(SymbolHandle symbol, SymbolHandle *out)
Copy the symbol to another handle.
NNSymbolCreateVariable
NNVM_DLL int NNSymbolCreateVariable(const char *name, SymbolHandle *out)
Create a Variable Symbol.
NNSymbolGetInternals
NNVM_DLL int NNSymbolGetInternals(SymbolHandle symbol, SymbolHandle *out)
Get a symbol that contains all the internals.
NNSymbolFree
NNVM_DLL int NNSymbolFree(SymbolHandle symbol)
Free the symbol handle.
GraphHandle
void * GraphHandle
handle to Graph
Definition: c_api.h:48
NNSymbolSetAttrs
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(mutabl...
NNSymbolCreateGroup
NNVM_DLL int NNSymbolCreateGroup(nn_uint num_symbols, SymbolHandle *symbols, SymbolHandle *out)
Create a Symbol by grouping list of symbols together.
SymbolHandle
void * SymbolHandle
handle to a symbol that can be bind as operator
Definition: c_api.h:82
NNGetLastError
const NNVM_DLL char * NNGetLastError(void)
return str message of the last error all function in this file will return 0 when success and -1 when...
NNAPISetLastError
NNVM_DLL void NNAPISetLastError(const char *msg)
Set the last error message needed by C API.
NNGraphFree
NNVM_DLL int NNGraphFree(GraphHandle handle)
free the graph handle
NNSymbolGetAttr
NNVM_DLL int NNSymbolGetAttr(SymbolHandle symbol, const char *key, const char **out, int *success)
Get string attribute from symbol.
NNVM_DLL
#define NNVM_DLL
NNVM_DLL prefix for windows.
Definition: c_api.h:37
NNSymbolPrint
NNVM_DLL int NNSymbolPrint(SymbolHandle symbol, const char **out_str)
Print the content of symbol, used for debug.
NNSymbolCreateAtomicSymbol
NNVM_DLL int NNSymbolCreateAtomicSymbol(OpHandle op, nn_uint num_param, const char **keys, const char **vals, SymbolHandle *out)
Create an AtomicSymbol functor.
NNGraphGetJSONAttr
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 r...