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  *
11  *
12  * Unless required by applicable law or agreed to in writing,
13  * software distributed under the License is distributed on an
15  * KIND, either express or implied. See the License for the
16  * specific language governing permissions and limitations
17  * under the License.
18  */
26 #ifndef NNVM_C_API_H_
27 #define NNVM_C_API_H_
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
41 typedef unsigned int nn_uint;
44 typedef void *OpHandle;
46 typedef void *SymbolHandle;
48 typedef void *GraphHandle;
50 #ifdef __cplusplus
51 extern "C" {
52 #endif
57 NNVM_DLL void NNAPISetLastError(const char* msg);
68 NNVM_DLL const char *NNGetLastError(void);
76 NNVM_DLL int NNListAllOpNames(nn_uint *out_size,
77  const char*** out_array);
84 NNVM_DLL int NNGetOpHandle(const char* op_name,
85  OpHandle* op_out);
96 NNVM_DLL int NNListUniqueOps(nn_uint *out_size,
97  OpHandle **out_array);
113  const char **real_name,
114  const char **description,
115  nn_uint *num_doc_args,
116  const char ***arg_names,
117  const char ***arg_type_infos,
118  const char ***arg_descriptions,
119  const char **return_type);
130  nn_uint num_param,
131  const char **keys,
132  const char **vals,
133  SymbolHandle *out);
140 NNVM_DLL int NNSymbolCreateVariable(const char *name, SymbolHandle *out);
148 NNVM_DLL int NNSymbolCreateGroup(nn_uint num_symbols,
149  SymbolHandle *symbols,
150  SymbolHandle *out);
157  SymbolHandle src_dep);
177 NNVM_DLL int NNSymbolPrint(SymbolHandle symbol, const char **out_str);
187  const char* key,
188  const char** out,
189  int *success);
208  nn_uint num_param,
209  const char** keys,
210  const char** values);
220  int recursive_option,
221  nn_uint *out_size,
222  const char*** out);
236  int option,
237  nn_uint *out_size,
238  SymbolHandle** out_sym_array);
252  int option,
253  nn_uint *out_size,
254  const char ***out_str_array);
263  nn_uint *out_size,
264  const char ***out_str_array);
274  nn_uint *output_count);
283  SymbolHandle *out);
291  SymbolHandle *out);
300  nn_uint index,
301  SymbolHandle *out);
318  const char* name,
319  nn_uint num_args,
320  const char** keys,
321  SymbolHandle* args);
323 // Graph IR API
330 NNVM_DLL int NNGraphCreate(SymbolHandle symbol, GraphHandle *graph);
335 NNVM_DLL int NNGraphFree(GraphHandle handle);
355  const char* key,
356  const char* json_value);
371  const char* key,
372  const char** json_out,
373  int *success);
387  const char* key,
388  SymbolHandle list);
398  nn_uint num_pass,
399  const char** pass_names,
400  GraphHandle *dst);
402 #ifdef __cplusplus
403 } /* end extern "C" */
404 #endif
406 #endif // NNVM_C_API_H_
void * GraphHandle
handle to Graph
Definition: c_api.h:48
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:37
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:41
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:44