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 
27 #ifndef NNVM_C_API_H_
28 #define NNVM_C_API_H_
29 
31 #ifdef _WIN32
32 #ifdef NNVM_EXPORTS
33 #define NNVM_DLL __declspec(dllexport)
34 #else
35 #define NNVM_DLL __declspec(dllimport)
36 #endif
37 #else
38 #define NNVM_DLL __attribute__((visibility("default")))
39 #endif
40 
42 typedef unsigned int nn_uint;
43 
45 typedef void *OpHandle;
47 typedef void *SymbolHandle;
49 typedef void *GraphHandle;
50 
51 #ifdef __cplusplus
52 extern "C" {
53 #endif
54 
58 NNVM_DLL void NNAPISetLastError(const char* msg);
59 
69 NNVM_DLL const char *NNGetLastError(void);
70 
77 NNVM_DLL int NNListAllOpNames(nn_uint *out_size,
78  const char*** out_array);
79 
85 NNVM_DLL int NNGetOpHandle(const char* op_name,
86  OpHandle* op_out);
87 
97 NNVM_DLL int NNListUniqueOps(nn_uint *out_size,
98  OpHandle **out_array);
99 
114  const char **real_name,
115  const char **description,
116  nn_uint *num_doc_args,
117  const char ***arg_names,
118  const char ***arg_type_infos,
119  const char ***arg_descriptions,
120  const char **return_type);
131  nn_uint num_param,
132  const char **keys,
133  const char **vals,
134  SymbolHandle *out);
141 NNVM_DLL int NNSymbolCreateVariable(const char *name, SymbolHandle *out);
149 NNVM_DLL int NNSymbolCreateGroup(nn_uint num_symbols,
150  SymbolHandle *symbols,
151  SymbolHandle *out);
158  SymbolHandle src_dep);
178 NNVM_DLL int NNSymbolPrint(SymbolHandle symbol, const char **out_str);
188  const char* key,
189  const char** out,
190  int *success);
209  nn_uint num_param,
210  const char** keys,
211  const char** values);
221  int recursive_option,
222  nn_uint *out_size,
223  const char*** out);
224 
237  int option,
238  nn_uint *out_size,
239  SymbolHandle** out_sym_array);
240 
253  int option,
254  nn_uint *out_size,
255  const char ***out_str_array);
264  nn_uint *out_size,
265  const char ***out_str_array);
266 
267 
275  nn_uint *output_count);
276 
284  SymbolHandle *out);
292  SymbolHandle *out);
301  nn_uint index,
302  SymbolHandle *out);
303 
319  const char* name,
320  nn_uint num_args,
321  const char** keys,
322  SymbolHandle* args);
323 
324 // Graph IR API
331 NNVM_DLL int NNGraphCreate(SymbolHandle symbol, GraphHandle *graph);
336 NNVM_DLL int NNGraphFree(GraphHandle handle);
344 
356  const char* key,
357  const char* json_value);
358 
372  const char* key,
373  const char** json_out,
374  int *success);
375 
388  const char* key,
389  SymbolHandle list);
399  nn_uint num_pass,
400  const char** pass_names,
401  GraphHandle *dst);
402 
403 #ifdef __cplusplus
404 } /* end extern "C" */
405 #endif
406 
407 #endif // NNVM_C_API_H_
void * GraphHandle
handle to Graph
Definition: c_api.h:49
void * SymbolHandle
handle to a symbol that can be bind as operator
Definition: c_api.h:75
NNVM_DLL int NNSymbolListInputNames(SymbolHandle symbol, int option, nn_uint *out_size, const char ***out_str_array)
List input names in the 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.
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...
NNVM_DLL int NNSymbolGetInternals(SymbolHandle symbol, SymbolHandle *out)
Get a symbol that contains all the internals.
NNVM_DLL int NNSymbolGetOutput(SymbolHandle symbol, nn_uint index, SymbolHandle *out)
Get index-th outputs of the symbol.
NNVM_DLL int NNGraphGetSymbol(GraphHandle graph, SymbolHandle *symbol)
Get a new symbol from the graph.
NNVM_DLL int NNSymbolPrint(SymbolHandle symbol, const char **out_str)
Print the content of symbol, used for debug.
NNVM_DLL int NNSymbolListOutputNames(SymbolHandle symbol, nn_uint *out_size, const char ***out_str_array)
List returns names in the symbol.
NNVM_DLL int NNGraphCreate(SymbolHandle symbol, GraphHandle *graph)
create a graph handle from symbol
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.
NNVM_DLL int NNSymbolCreateAtomicSymbol(OpHandle op, nn_uint num_param, const char **keys, const char **vals, SymbolHandle *out)
Create an AtomicSymbol functor.
#define NNVM_DLL
NNVM_DLL prefix for windows.
Definition: c_api.h:38
NNVM_DLL int NNGraphApplyPasses(GraphHandle src, nn_uint num_pass, const char **pass_names, GraphHandle *dst)
Apply passes on the src graph.
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...
NNVM_DLL int NNListAllOpNames(nn_uint *out_size, const char ***out_array)
list all the available operator names, include entries.
NNVM_DLL int NNGetOpHandle(const char *op_name, OpHandle *op_out)
Get operator handle given name.
NNVM_DLL int NNAddControlDeps(SymbolHandle handle, SymbolHandle src_dep)
Add src_dep to the handle as control dep.
NNVM_DLL void NNAPISetLastError(const char *msg)
Set the last error message needed by C API.
NNVM_DLL int NNGraphFree(GraphHandle handle)
free the graph handle
NNVM_DLL int NNSymbolFree(SymbolHandle symbol)
Free the symbol handle.
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...
unsigned int nn_uint
manually define unsigned int
Definition: c_api.h:42
NNVM_DLL int NNSymbolCreateVariable(const char *name, SymbolHandle *out)
Create a Variable Symbol.
NNVM_DLL int NNSymbolCopy(SymbolHandle symbol, SymbolHandle *out)
Copy the symbol to another handle.
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...
NNVM_DLL int NNSymbolGetNumOutputs(SymbolHandle symbol, nn_uint *output_count)
Supply number of outputs of the symbol.
NNVM_DLL int NNSymbolCompose(SymbolHandle sym, const char *name, nn_uint num_args, const char **keys, SymbolHandle *args)
Compose the symbol on other symbols.
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...
NNVM_DLL int NNSymbolCreateGroup(nn_uint num_symbols, SymbolHandle *symbols, SymbolHandle *out)
Create a Symbol by grouping list of symbols together.
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...
NNVM_DLL int NNSymbolGetChildren(SymbolHandle symbol, SymbolHandle *out)
Get a symbol that contains only direct children.
NNVM_DLL int NNSymbolGetAttr(SymbolHandle symbol, const char *key, const char **out, int *success)
Get string attribute from symbol.
NNVM_DLL int NNSymbolListInputVariables(SymbolHandle symbol, int option, nn_uint *out_size, SymbolHandle **out_sym_array)
List inputs variables in the symbol.
void * OpHandle
handle to a function that takes param and creates symbol
Definition: c_api.h:45