mxnet
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
c_api.h
Go to the documentation of this file.
1 
6 #ifndef MXNET_C_API_H_
7 #define MXNET_C_API_H_
8 
9 #ifdef __cplusplus
10 #define MXNET_EXTERN_C extern "C"
11 #endif
12 
13 #include <stdint.h>
14 
16 #ifdef _WIN32
17 #ifdef MXNET_EXPORTS
18 #define MXNET_DLL MXNET_EXTERN_C __declspec(dllexport)
19 #else
20 #define MXNET_DLL MXNET_EXTERN_C __declspec(dllimport)
21 #endif
22 #else
23 #define MXNET_DLL MXNET_EXTERN_C
24 #endif
25 
27 typedef unsigned int mx_uint;
29 typedef float mx_float;
30 // all the handles are simply void *
31 // will be casted internally to specific pointers types
32 // these typedefs are mainly used for readablity reasons
34 typedef void *NDArrayHandle;
36 typedef const void *FunctionHandle;
38 typedef void *AtomicSymbolCreator;
40 typedef void *SymbolHandle;
42 typedef void *AtomicSymbolHandle;
44 typedef void *ExecutorHandle;
46 typedef void *DataIterCreator;
48 typedef void *DataIterHandle;
50 typedef void *KVStoreHandle;
52 typedef void *RecordIOHandle;
54 typedef void *RtcHandle;
56 typedef void *OptimizerCreator;
58 typedef void *OptimizerHandle;
59 
60 MXNET_EXTERN_C typedef void (*ExecutorMonitorCallback)(const char*,
62  void *);
63 
65 struct NativeOpInfo {
66  void (*forward)(int, float**, int*, unsigned**, int*, void*);
67  void (*backward)(int, float**, int*, unsigned**, int*, void*);
68  void (*infer_shape)(int, int*, unsigned**, void*);
69  void (*list_outputs)(char***, void*);
70  void (*list_arguments)(char***, void*);
71  // all functions also pass a payload void* pointer
72  void* p_forward;
73  void* p_backward;
74  void* p_infer_shape;
75  void* p_list_outputs;
76  void* p_list_arguments;
77 };
78 
79 struct NDArrayOpInfo {
80  bool (*forward)(int, void**, int*, void*);
81  bool (*backward)(int, void**, int*, void*);
82  bool (*infer_shape)(int, int*, unsigned**, void*);
83  bool (*list_outputs)(char***, void*);
84  bool (*list_arguments)(char***, void*);
85  bool (*declare_backward_dependency)(const int*, const int*, const int*,
86  int*, int**, void*);
87  // all functions also pass a payload void* pointer
88  void* p_forward;
89  void* p_backward;
94 };
95 
96 struct CustomOpInfo {
97  bool (*forward)(int /*size*/, void** /*ptrs*/, int* /*tags*/,
98  const int* /*reqs*/, const bool /*is_train*/, void* /*state*/);
99  bool (*backward)(int /*size*/, void** /*ptrs*/, int* /*tags*/,
100  const int* /*reqs*/, const bool /*is_train*/, void* /*state*/);
101  bool (*del)(void* /*state*/);
102  // all functions also pass a payload void* pointer
103  void* p_forward;
104  void* p_backward;
105  void* p_del;
106 };
107 
109  bool (*list_arguments)(char*** /*args*/, void* /*state*/);
110  bool (*list_outputs)(char*** /*outputs*/, void* /*state*/);
111  bool (*infer_shape)(int /*num_input*/, int* /*ndims*/, unsigned** /*shapes*/,
112  void* /*state*/);
113  bool (*declare_backward_dependency)(const int* /*out_grad*/, const int* /*in_data*/,
114  const int* /*out_data*/, int* /*num_deps*/,
115  int** /*rdeps*/, void* /*state*/);
116  bool (*create_operator)(const char* /*ctx*/, int /*num_inputs*/, unsigned** /*shapes*/,
117  int* /*ndims*/, int* /*dtypes*/,
118  CustomOpInfo* /*ret*/, void* /*state*/);
119  bool (*list_auxiliary_states)(char*** /*aux*/, void* /*state*/);
120  bool (*del)(void* /*state*/);
121  // all functions also pass a payload void* pointer
128  void* p_del;
129 };
130 
131 typedef bool (*CustomOpPropCreator)(const char* /*op_type*/, const int /*num_kwargs*/,
132  const char** /*keys*/, const char** /*values*/,
133  CustomOpPropInfo* /*ret*/);
134 }
144 MXNET_DLL const char *MXGetLastError();
145 
146 //-------------------------------------
147 // Part 0: Global State setups
148 //-------------------------------------
154 MXNET_DLL int MXRandomSeed(int seed);
163 //-------------------------------------
164 // Part 1: NDArray creation and deletion
165 //-------------------------------------
185 MXNET_DLL int MXNDArrayCreate(const mx_uint *shape,
186  mx_uint ndim,
187  int dev_type,
188  int dev_id,
189  int delay_alloc,
190  NDArrayHandle *out);
191 
204 MXNET_DLL int MXNDArrayCreateEx(const mx_uint *shape,
205  mx_uint ndim,
206  int dev_type,
207  int dev_id,
208  int delay_alloc,
209  int dtype,
210  NDArrayHandle *out);
218 MXNET_DLL int MXNDArrayLoadFromRawBytes(const void *buf,
219  size_t size,
220  NDArrayHandle *out);
229  size_t *out_size,
230  const char **out_buf);
239 MXNET_DLL int MXNDArraySave(const char* fname,
240  mx_uint num_args,
241  NDArrayHandle* args,
242  const char** keys);
252 MXNET_DLL int MXNDArrayLoad(const char* fname,
253  mx_uint *out_size,
254  NDArrayHandle** out_arr,
255  mx_uint *out_name_size,
256  const char*** out_names);
269  const void *data,
270  size_t size);
283  void *data,
284  size_t size);
320  mx_uint slice_begin,
321  mx_uint slice_end,
322  NDArrayHandle *out);
331  mx_uint idx,
332  NDArrayHandle *out);
342  int ndim,
343  int *dims,
344  NDArrayHandle *out);
353  mx_uint *out_dim,
354  const mx_uint **out_pdata);
362  mx_float **out_pdata);
370  int *out_dtype);
379  int *out_dev_type,
380  int *out_dev_id);
381 
382 //--------------------------------
383 // Part 2: functions on NDArray
384 //--------------------------------
392 MXNET_DLL int MXListFunctions(mx_uint *out_size,
393  FunctionHandle **out_array);
400 MXNET_DLL int MXGetFunction(const char *name,
401  FunctionHandle *out);
415  const char **name,
416  const char **description,
417  mx_uint *num_args,
418  const char ***arg_names,
419  const char ***arg_type_infos,
420  const char ***arg_descriptions,
421  const char **return_type = NULL);
433  mx_uint *num_use_vars,
434  mx_uint *num_scalars,
435  mx_uint *num_mutate_vars,
436  int *type_mask);
448  NDArrayHandle *use_vars,
449  mx_float *scalar_args,
450  NDArrayHandle *mutate_vars);
465  NDArrayHandle *use_vars,
466  mx_float *scalar_args,
467  NDArrayHandle *mutate_vars,
468  int num_params,
469  char **param_keys,
470  char **param_vals);
471 //--------------------------------------------
472 // Part 3: symbolic configuration generation
473 //--------------------------------------------
481  AtomicSymbolCreator **out_array);
500  const char **name,
501  const char **description,
502  mx_uint *num_args,
503  const char ***arg_names,
504  const char ***arg_type_infos,
505  const char ***arg_descriptions,
506  const char **key_var_num_args,
507  const char **return_type = NULL);
518  mx_uint num_param,
519  const char **keys,
520  const char **vals,
521  SymbolHandle *out);
528 MXNET_DLL int MXSymbolCreateVariable(const char *name, SymbolHandle *out);
536 MXNET_DLL int MXSymbolCreateGroup(mx_uint num_symbols,
537  SymbolHandle *symbols,
538  SymbolHandle *out);
545 MXNET_DLL int MXSymbolCreateFromFile(const char *fname, SymbolHandle *out);
552 MXNET_DLL int MXSymbolCreateFromJSON(const char *json, SymbolHandle *out);
559 MXNET_DLL int MXSymbolSaveToFile(SymbolHandle symbol, const char *fname);
566 MXNET_DLL int MXSymbolSaveToJSON(SymbolHandle symbol, const char **out_json);
586 MXNET_DLL int MXSymbolPrint(SymbolHandle symbol, const char **out_str);
595  const char** out,
596  int *success);
606  const char* key,
607  const char** out,
608  int *success);
626  const char* key,
627  const char* value);
636  mx_uint *out_size,
637  const char*** out);
646  mx_uint *out_size,
647  const char*** out);
656  mx_uint *out_size,
657  const char ***out_str_array);
666  mx_uint *out_size,
667  const char ***out_str_array);
675  SymbolHandle *out);
684  mx_uint index,
685  SymbolHandle *out);
694  mx_uint *out_size,
695  const char ***out_str_array);
711  const char *name,
712  mx_uint num_args,
713  const char** keys,
714  SymbolHandle* args);
725  mx_uint num_wrt,
726  const char** wrt,
727  SymbolHandle* out);
751  mx_uint num_args,
752  const char** keys,
753  const mx_uint *arg_ind_ptr,
754  const mx_uint *arg_shape_data,
755  mx_uint *in_shape_size,
756  const mx_uint **in_shape_ndim,
757  const mx_uint ***in_shape_data,
758  mx_uint *out_shape_size,
759  const mx_uint **out_shape_ndim,
760  const mx_uint ***out_shape_data,
761  mx_uint *aux_shape_size,
762  const mx_uint **aux_shape_ndim,
763  const mx_uint ***aux_shape_data,
764  int *complete);
790  mx_uint num_args,
791  const char** keys,
792  const mx_uint *arg_ind_ptr,
793  const mx_uint *arg_shape_data,
794  mx_uint *in_shape_size,
795  const mx_uint **in_shape_ndim,
796  const mx_uint ***in_shape_data,
797  mx_uint *out_shape_size,
798  const mx_uint **out_shape_ndim,
799  const mx_uint ***out_shape_data,
800  mx_uint *aux_shape_size,
801  const mx_uint **aux_shape_ndim,
802  const mx_uint ***aux_shape_data,
803  int *complete);
804 
824  mx_uint num_args,
825  const char** keys,
826  const int *arg_type_data,
827  mx_uint *in_type_size,
828  const int **in_type_data,
829  mx_uint *out_type_size,
830  const int **out_type_data,
831  mx_uint *aux_type_size,
832  const int **aux_type_data,
833  int *complete);
834 //--------------------------------------------
835 // Part 4: Executor interface
836 //--------------------------------------------
849 MXNET_DLL int MXExecutorPrint(ExecutorHandle handle, const char **out_str);
857 MXNET_DLL int MXExecutorForward(ExecutorHandle handle, int is_train);
868  mx_uint len,
869  NDArrayHandle *head_grads);
870 
880  mx_uint *out_size,
881  NDArrayHandle **out);
882 
898 MXNET_DLL int MXExecutorBind(SymbolHandle symbol_handle,
899  int dev_type,
900  int dev_id,
901  mx_uint len,
902  NDArrayHandle *in_args,
903  NDArrayHandle *arg_grad_store,
904  mx_uint *grad_req_type,
905  mx_uint aux_states_len,
906  NDArrayHandle *aux_states,
907  ExecutorHandle *out);
929 MXNET_DLL int MXExecutorBindX(SymbolHandle symbol_handle,
930  int dev_type,
931  int dev_id,
932  mx_uint num_map_keys,
933  const char** map_keys,
934  const int* map_dev_types,
935  const int* map_dev_ids,
936  mx_uint len,
937  NDArrayHandle *in_args,
938  NDArrayHandle *arg_grad_store,
939  mx_uint *grad_req_type,
940  mx_uint aux_states_len,
941  NDArrayHandle *aux_states,
942  ExecutorHandle *out);
965 MXNET_DLL int MXExecutorBindEX(SymbolHandle symbol_handle,
966  int dev_type,
967  int dev_id,
968  mx_uint num_map_keys,
969  const char** map_keys,
970  const int* map_dev_types,
971  const int* map_dev_ids,
972  mx_uint len,
973  NDArrayHandle *in_args,
974  NDArrayHandle *arg_grad_store,
975  mx_uint *grad_req_type,
976  mx_uint aux_states_len,
977  NDArrayHandle *aux_states,
978  ExecutorHandle shared_exec,
979  ExecutorHandle *out);
984  ExecutorMonitorCallback callback,
985  void* callback_handle);
986 //--------------------------------------------
987 // Part 5: IO Interface
988 //--------------------------------------------
995 MXNET_DLL int MXListDataIters(mx_uint *out_size,
996  DataIterCreator **out_array);
1008  mx_uint num_param,
1009  const char **keys,
1010  const char **vals,
1011  DataIterHandle *out);
1024  const char **name,
1025  const char **description,
1026  mx_uint *num_args,
1027  const char ***arg_names,
1028  const char ***arg_type_infos,
1029  const char ***arg_descriptions);
1043  int *out);
1050 
1058  NDArrayHandle *out);
1067  uint64_t **out_index,
1068  uint64_t *out_size);
1076  int *pad);
1077 
1085  NDArrayHandle *out);
1086 //--------------------------------------------
1087 // Part 6: basic KVStore interface
1088 //--------------------------------------------
1095 MXNET_DLL int MXInitPSEnv(mx_uint num_vars,
1096  const char **keys,
1097  const char **vals);
1104 MXNET_DLL int MXKVStoreCreate(const char *type,
1105  KVStoreHandle *out);
1121  mx_uint num,
1122  const int* keys,
1123  NDArrayHandle* vals);
1124 
1135  mx_uint num,
1136  const int* keys,
1137  NDArrayHandle* vals,
1138  int priority);
1149  mx_uint num,
1150  const int* keys,
1151  NDArrayHandle* vals,
1152  int priority);
1161 typedef void (MXKVStoreUpdater)(int key,
1162  NDArrayHandle recv,
1163  NDArrayHandle local,
1164  void *handle);
1173  MXKVStoreUpdater updater,
1174  void *updater_handle);
1182  const char** type);
1183 //--------------------------------------------
1184 // Part 6: advanced KVStore for multi-machines
1185 //--------------------------------------------
1186 
1195  int *ret);
1196 
1207  int *ret);
1208 
1214 MXNET_DLL int MXKVStoreIsWorkerNode(int *ret);
1215 
1216 
1222 MXNET_DLL int MXKVStoreIsServerNode(int *ret);
1223 
1224 
1230 MXNET_DLL int MXKVStoreIsSchedulerNode(int *ret);
1231 
1239 
1246 typedef void (MXKVStoreServerController)(int head,
1247  const char *body,
1248  void *controller_handle);
1249 
1259  MXKVStoreServerController controller,
1260  void *controller_handle);
1261 
1271  int cmd_id,
1272  const char* cmd_body);
1273 
1280 MXNET_DLL int MXRecordIOWriterCreate(const char *uri, RecordIOHandle *out);
1281 
1288 
1297  const char *buf, size_t size);
1298 
1305 MXNET_DLL int MXRecordIOReaderCreate(const char *uri, RecordIOHandle *out);
1306 
1313 
1322  char const **buf, size_t *size);
1323 
1327 MXNET_DLL int MXRtcCreate(char* name, mx_uint num_input, mx_uint num_output,
1328  char** input_names, char** output_names,
1329  NDArrayHandle* inputs, NDArrayHandle* outputs,
1330  char* kernel, RtcHandle *out);
1331 
1335 MXNET_DLL int MXRtcPush(RtcHandle handle, mx_uint num_input, mx_uint num_output,
1336  NDArrayHandle* inputs, NDArrayHandle* outputs,
1337  mx_uint gridDimX,
1338  mx_uint gridDimY,
1339  mx_uint gridDimZ,
1340  mx_uint blockDimX,
1341  mx_uint blockDimY,
1342  mx_uint blockDimZ);
1343 
1347 MXNET_DLL int MXRtcFree(RtcHandle handle);
1348 
1349 MXNET_DLL int MXOptimizerFindCreator(const char *key,
1350  OptimizerCreator *out);
1351 
1353  mx_uint num_param,
1354  const char **keys,
1355  const char **vals,
1356  OptimizerHandle *out);
1357 
1359 
1361  int index,
1362  NDArrayHandle weight,
1363  NDArrayHandle grad,
1364  mx_float lr,
1365  mx_float wd);
1366 
1367 MXNET_DLL int MXCustomOpRegister(const char* op_type, CustomOpPropCreator creator);
1368 
1369 #endif // MXNET_C_API_H_
MXNET_DLL int MXKVStoreSendCommmandToServers(KVStoreHandle handle, int cmd_id, const char *cmd_body)
bool(* list_arguments)(char ***, void *)
Definition: c_api.h:84
void * OptimizerCreator
handle to a function that takes param and creates optimizer
Definition: c_api.h:56
void * p_forward
Definition: c_api.h:103
MXNET_EXTERN_C
Definition: c_api.h:64
MXNET_DLL int MXKVStoreSetUpdater(KVStoreHandle handle, MXKVStoreUpdater updater, void *updater_handle)
register an push updater
MXNET_DLL int MXKVStoreBarrier(KVStoreHandle handle)
global barrier among all worker machines
void * DataIterHandle
handle to a DataIterator
Definition: c_api.h:48
MXNET_DLL int MXSymbolListAtomicSymbolCreators(mx_uint *out_size, AtomicSymbolCreator **out_array)
list all the available AtomicSymbolEntry
void * OptimizerHandle
handle to Optimizer
Definition: c_api.h:58
MXNET_DLL int MXOptimizerFree(OptimizerHandle handle)
MXNET_DLL int MXDataIterCreateIter(DataIterCreator handle, mx_uint num_param, const char **keys, const char **vals, DataIterHandle *out)
Init an iterator, init with parameters the array size of passed in arguments.
MXNET_DLL int MXDataIterNext(DataIterHandle handle, int *out)
Move iterator to next position.
MXNET_DLL int MXNDArrayReshape(NDArrayHandle handle, int ndim, int *dims, NDArrayHandle *out)
Reshape the NDArray.
void * p_infer_shape
Definition: c_api.h:90
MXNET_DLL int MXRecordIOReaderFree(RecordIOHandle *handle)
Delete a RecordIO reader object.
MXNET_DLL int MXExecutorPrint(ExecutorHandle handle, const char **out_str)
Print the content of execution plan, used for debug.
MXNET_DLL int MXKVStoreRunServer(KVStoreHandle handle, MXKVStoreServerController controller, void *controller_handle)
MXNET_DLL int MXSymbolSaveToJSON(SymbolHandle symbol, const char **out_json)
Save a symbol into a json string.
MXNET_DLL int MXSymbolInferShape(SymbolHandle sym, mx_uint num_args, const char **keys, const mx_uint *arg_ind_ptr, const mx_uint *arg_shape_data, mx_uint *in_shape_size, const mx_uint **in_shape_ndim, const mx_uint ***in_shape_data, mx_uint *out_shape_size, const mx_uint **out_shape_ndim, const mx_uint ***out_shape_data, mx_uint *aux_shape_size, const mx_uint **aux_shape_ndim, const mx_uint ***aux_shape_data, int *complete)
infer shape of unknown input shapes given the known one. The shapes are packed into a CSR matrix repr...
MXNET_DLL int MXSymbolGetAttr(SymbolHandle symbol, const char *key, const char **out, int *success)
Get string attribute from symbol.
MXNET_DLL int MXRtcCreate(char *name, mx_uint num_input, mx_uint num_output, char **input_names, char **output_names, NDArrayHandle *inputs, NDArrayHandle *outputs, char *kernel, RtcHandle *out)
Create a MXRtc object.
MXNET_DLL int MXKVStorePull(KVStoreHandle handle, mx_uint num, const int *keys, NDArrayHandle *vals, int priority)
pull a list of (key, value) pairs from the kvstore
MXNET_DLL int MXNDArrayWaitToRead(NDArrayHandle handle)
Wait until all the pending writes with respect NDArray are finished. Always call this before read dat...
MXNET_DLL int MXExecutorBind(SymbolHandle symbol_handle, int dev_type, int dev_id, mx_uint len, NDArrayHandle *in_args, NDArrayHandle *arg_grad_store, mx_uint *grad_req_type, mx_uint aux_states_len, NDArrayHandle *aux_states, ExecutorHandle *out)
Generate Executor from symbol.
void * p_forward
Definition: c_api.h:88
void * p_backward
Definition: c_api.h:104
MXNET_DLL int MXDataIterFree(DataIterHandle handle)
Free the handle to the IO module.
void * RecordIOHandle
handle to RecordIO
Definition: c_api.h:52
MXNET_DLL int MXExecutorOutputs(ExecutorHandle handle, mx_uint *out_size, NDArrayHandle **out)
Get executor's head NDArray.
MXNET_DLL int MXNDArrayGetContext(NDArrayHandle handle, int *out_dev_type, int *out_dev_id)
get the context of the NDArray
MXNET_DLL int MXFuncDescribe(FunctionHandle fun, mx_uint *num_use_vars, mx_uint *num_scalars, mx_uint *num_mutate_vars, int *type_mask)
get the argument requirements of the function
MXNET_DLL int MXKVStoreIsServerNode(int *ret)
return whether or not this process is a server node.
MXNET_DLL int MXNDArraySlice(NDArrayHandle handle, mx_uint slice_begin, mx_uint slice_end, NDArrayHandle *out)
Slice the NDArray along axis 0.
bool(* forward)(int, void **, int *, void *)
Definition: c_api.h:80
void * ExecutorHandle
handle to an Executor
Definition: c_api.h:44
bool(* forward)(int, void **, int *, const int *, const bool, void *)
Definition: c_api.h:97
MXNET_DLL int MXSymbolSaveToFile(SymbolHandle symbol, const char *fname)
Save a symbol into a json file.
MXNET_DLL int MXRecordIOReaderReadRecord(RecordIOHandle *handle, char const **buf, size_t *size)
Write a record to a RecordIO object.
void * AtomicSymbolHandle
handle to a AtomicSymbol
Definition: c_api.h:42
MXNET_DLL int MXFuncGetInfo(FunctionHandle fun, const char **name, const char **description, mx_uint *num_args, const char ***arg_names, const char ***arg_type_infos, const char ***arg_descriptions, const char **return_type=NULL)
Get the information of the function handle.
MXNET_DLL int MXNDArrayFree(NDArrayHandle handle)
free the narray handle
MXNET_DLL int MXSymbolCreateFromJSON(const char *json, SymbolHandle *out)
Load a symbol from a json string.
bool(* infer_shape)(int, int *, unsigned **, void *)
Definition: c_api.h:82
MXNET_DLL int MXKVStoreIsSchedulerNode(int *ret)
return whether or not this process is a scheduler node.
MXNET_EXTERN_C typedef void(* ExecutorMonitorCallback)(const char *, NDArrayHandle, void *)
Definition: c_api.h:60
MXNET_DLL int MXSymbolListAttr(SymbolHandle symbol, mx_uint *out_size, const char ***out)
Get all attributes from symbol, including all descendents.
MXNET_DLL int MXNDArrayAt(NDArrayHandle handle, mx_uint idx, NDArrayHandle *out)
Index the NDArray along axis 0.
Definition: c_api.h:96
Definition: c_api.h:108
MXNET_DLL int MXNDArrayLoad(const char *fname, mx_uint *out_size, NDArrayHandle **out_arr, mx_uint *out_name_size, const char ***out_names)
Load list of narray from the file.
MXNET_DLL int MXNDArraySyncCopyFromCPU(NDArrayHandle handle, const void *data, size_t size)
Perform a synchronize copy from a continugous CPU memory region.
MXNET_DLL int MXSymbolCreateFromFile(const char *fname, SymbolHandle *out)
Load a symbol from a json file.
Definition: c_api.h:79
MXNET_DLL int MXNDArrayCreateEx(const mx_uint *shape, mx_uint ndim, int dev_type, int dev_id, int delay_alloc, int dtype, NDArrayHandle *out)
create a NDArray with specified shape and data type
MXNET_DLL int MXKVStoreCreate(const char *type, KVStoreHandle *out)
Create a kvstore.
void * p_list_outputs
Definition: c_api.h:123
void * p_declare_backward_dependency
Definition: c_api.h:93
MXNET_DLL int MXSymbolGetAtomicSymbolInfo(AtomicSymbolCreator creator, const char **name, const char **description, mx_uint *num_args, const char ***arg_names, const char ***arg_type_infos, const char ***arg_descriptions, const char **key_var_num_args, const char **return_type=NULL)
Get the detailed information about atomic symbol.
MXNET_DLL int MXNDArrayCreateNone(NDArrayHandle *out)
create a NDArray handle that is not initialized can be used to pass in as mutate variables to hold th...
MXNET_DLL int MXKVStoreFree(KVStoreHandle handle)
Delete a KVStore handle.
void * p_list_arguments
Definition: c_api.h:92
MXNET_DLL int MXCustomOpRegister(const char *op_type, CustomOpPropCreator creator)
void * SymbolHandle
handle to a symbol that can be bind as operator
Definition: c_api.h:40
MXNET_DLL int MXSymbolCopy(SymbolHandle symbol, SymbolHandle *out)
Copy the symbol to another handle.
MXNET_DLL int MXSymbolSetAttr(SymbolHandle symbol, const char *key, const char *value)
Set string attribute from symbol. NOTE: Setting attribute to a symbol can affect the semantics(mutabl...
void * p_infer_shape
Definition: c_api.h:124
MXNET_DLL int MXDataIterBeforeFirst(DataIterHandle handle)
Call iterator.Reset.
MXNET_DLL int MXSymbolInferShapePartial(SymbolHandle sym, mx_uint num_args, const char **keys, const mx_uint *arg_ind_ptr, const mx_uint *arg_shape_data, mx_uint *in_shape_size, const mx_uint **in_shape_ndim, const mx_uint ***in_shape_data, mx_uint *out_shape_size, const mx_uint **out_shape_ndim, const mx_uint ***out_shape_data, mx_uint *aux_shape_size, const mx_uint **aux_shape_ndim, const mx_uint ***aux_shape_data, int *complete)
partially infer shape of unknown input shapes given the known one.
MXNET_DLL int MXSymbolListOutputs(SymbolHandle symbol, mx_uint *out_size, const char ***out_str_array)
List returns in the symbol.
void( MXKVStoreUpdater)(int key, NDArrayHandle recv, NDArrayHandle local, void *handle)
user-defined updater for the kvstore It's this updater's responsibility to delete recv and local ...
Definition: c_api.h:1161
MXNET_DLL int MXListDataIters(mx_uint *out_size, DataIterCreator **out_array)
List all the available iterator entries.
MXNET_DLL int MXNDArrayGetShape(NDArrayHandle handle, mx_uint *out_dim, const mx_uint **out_pdata)
get the shape of the array
MXNET_DLL int MXDataIterGetPadNum(DataIterHandle handle, int *pad)
Get the padding number in current data batch.
MXNET_DLL int MXFuncInvokeEx(FunctionHandle fun, NDArrayHandle *use_vars, mx_float *scalar_args, NDArrayHandle *mutate_vars, int num_params, char **param_keys, char **param_vals)
invoke a function, the array size of passed in arguments must match the values in the ...
MXNET_DLL int MXRandomSeed(int seed)
Seed the global random number generators in mxnet.
MXNET_DLL int MXOptimizerCreateOptimizer(OptimizerCreator creator, mx_uint num_param, const char **keys, const char **vals, OptimizerHandle *out)
MXNET_DLL int MXSymbolGetOutput(SymbolHandle symbol, mx_uint index, SymbolHandle *out)
Get index-th outputs of the symbol.
MXNET_DLL int MXNDArrayGetDType(NDArrayHandle handle, int *out_dtype)
get the type of the data in NDArray
MXNET_DLL int MXRecordIOWriterWriteRecord(RecordIOHandle *handle, const char *buf, size_t size)
Write a record to a RecordIO object.
MXNET_DLL int MXSymbolGetInternals(SymbolHandle symbol, SymbolHandle *out)
Get a symbol that contains all the internals.
bool(* list_arguments)(char ***, void *)
Definition: c_api.h:109
bool(* create_operator)(const char *, int, unsigned **, int *, int *, CustomOpInfo *, void *)
Definition: c_api.h:116
MXNET_DLL int MXInitPSEnv(mx_uint num_vars, const char **keys, const char **vals)
Initialized ps-lite environment variables.
MXNET_DLL int MXDataIterGetData(DataIterHandle handle, NDArrayHandle *out)
Get the handle to the NDArray of underlying data.
void * p_declare_backward_dependency
Definition: c_api.h:125
MXNET_DLL int MXRtcFree(RtcHandle handle)
Delete a MXRtc object.
MXNET_DLL int MXOptimizerUpdate(OptimizerHandle handle, int index, NDArrayHandle weight, NDArrayHandle grad, mx_float lr, mx_float wd)
MXNET_DLL int MXNDArraySyncCopyToCPU(NDArrayHandle handle, void *data, size_t size)
Perform a synchronize copyto a continugous CPU memory region.
void * KVStoreHandle
handle to KVStore
Definition: c_api.h:50
void * NDArrayHandle
handle to NDArray
Definition: c_api.h:34
MXNET_DLL int MXNotifyShutdown()
Notify the engine about a shutdown, This can help engine to print less messages into display...
bool(* list_outputs)(char ***, void *)
Definition: c_api.h:83
void * p_list_outputs
Definition: c_api.h:91
bool(* declare_backward_dependency)(const int *, const int *, const int *, int *, int **, void *)
Definition: c_api.h:85
MXNET_DLL int MXDataIterGetIndex(DataIterHandle handle, uint64_t **out_index, uint64_t *out_size)
Get the image index by array.
MXNET_DLL int MXDataIterGetLabel(DataIterHandle handle, NDArrayHandle *out)
Get the handle to the NDArray of underlying label.
void * p_del
Definition: c_api.h:105
MXNET_DLL int MXSymbolCreateGroup(mx_uint num_symbols, SymbolHandle *symbols, SymbolHandle *out)
Create a Symbol by grouping list of symbols together.
MXNET_DLL int MXNDArrayCreate(const mx_uint *shape, mx_uint ndim, int dev_type, int dev_id, int delay_alloc, NDArrayHandle *out)
create a NDArray with specified shape
MXNET_DLL int MXFuncInvoke(FunctionHandle fun, NDArrayHandle *use_vars, mx_float *scalar_args, NDArrayHandle *mutate_vars)
invoke a function, the array size of passed in arguments must match the values in the ...
MXNET_DLL int MXSymbolListArguments(SymbolHandle symbol, mx_uint *out_size, const char ***out_str_array)
List arguments in the symbol.
MXNET_DLL int MXRecordIOWriterCreate(const char *uri, RecordIOHandle *out)
Create a RecordIO writer object.
void * p_create_operator
Definition: c_api.h:126
MXNET_DLL int MXNDArrayWaitAll()
wait until all delayed operations in the system is completed
MXNET_DLL int MXRecordIOReaderCreate(const char *uri, RecordIOHandle *out)
Create a RecordIO reader object.
void * p_del
Definition: c_api.h:128
unsigned int mx_uint
manually define unsigned int
Definition: c_api.h:27
bool(* CustomOpPropCreator)(const char *, const int, const char **, const char **, CustomOpPropInfo *)
Definition: c_api.h:131
MXNET_DLL int MXNDArraySaveRawBytes(NDArrayHandle handle, size_t *out_size, const char **out_buf)
save the NDArray into raw bytes.
MXNET_DLL int MXSymbolGetName(SymbolHandle symbol, const char **out, int *success)
Get string name from symbol.
void * p_backward
Definition: c_api.h:89
MXNET_DLL int MXExecutorBindEX(SymbolHandle symbol_handle, int dev_type, int dev_id, mx_uint num_map_keys, const char **map_keys, const int *map_dev_types, const int *map_dev_ids, mx_uint len, NDArrayHandle *in_args, NDArrayHandle *arg_grad_store, mx_uint *grad_req_type, mx_uint aux_states_len, NDArrayHandle *aux_states, ExecutorHandle shared_exec, ExecutorHandle *out)
Generate Executor from symbol, This is advanced function, allow specify group2ctx map...
bool(* infer_shape)(int, int *, unsigned **, void *)
Definition: c_api.h:111
MXNET_DLL int MXRecordIOWriterFree(RecordIOHandle handle)
Delete a RecordIO writer object.
MXNET_DLL int MXExecutorBackward(ExecutorHandle handle, mx_uint len, NDArrayHandle *head_grads)
Excecutor run backward.
MXNET_DLL int MXKVStoreGetRank(KVStoreHandle handle, int *ret)
return The rank of this node in its group, which is in [0, GroupSize).
MXNET_DLL int MXKVStoreGetGroupSize(KVStoreHandle handle, int *ret)
return The number of nodes in this group, which is
MXNET_DLL int MXSymbolCreateVariable(const char *name, SymbolHandle *out)
Create a Variable Symbol.
MXNET_DLL int MXExecutorSetMonitorCallback(ExecutorHandle handle, ExecutorMonitorCallback callback, void *callback_handle)
set a call back to notify the completion of operation
MXNET_DLL int MXKVStoreIsWorkerNode(int *ret)
return whether or not this process is a worker node.
MXNET_DLL int MXSymbolPrint(SymbolHandle symbol, const char **out_str)
Print the content of symbol, used for debug.
MXNET_DLL int MXSymbolCompose(SymbolHandle sym, const char *name, mx_uint num_args, const char **keys, SymbolHandle *args)
Compose the symbol on other symbols.
MXNET_DLL int MXSymbolGrad(SymbolHandle sym, mx_uint num_wrt, const char **wrt, SymbolHandle *out)
Get the gradient graph of the symbol.
float mx_float
manually define float
Definition: c_api.h:29
bool(* del)(void *)
Definition: c_api.h:120
#define MXNET_DLL
MXNET_DLL prefix for windows.
Definition: c_api.h:23
MXNET_DLL int MXSymbolCreateAtomicSymbol(AtomicSymbolCreator creator, mx_uint num_param, const char **keys, const char **vals, SymbolHandle *out)
Create an AtomicSymbol.
bool(* backward)(int, void **, int *, void *)
Definition: c_api.h:81
MXNET_DLL const char * MXGetLastError()
return str message of the last error all function in this file will return 0 when success and -1 when...
void * AtomicSymbolCreator
handle to a function that takes param and creates symbol
Definition: c_api.h:38
bool(* list_auxiliary_states)(char ***, void *)
Definition: c_api.h:119
MXNET_DLL int MXExecutorBindX(SymbolHandle symbol_handle, int dev_type, int dev_id, mx_uint num_map_keys, const char **map_keys, const int *map_dev_types, const int *map_dev_ids, mx_uint len, NDArrayHandle *in_args, NDArrayHandle *arg_grad_store, mx_uint *grad_req_type, mx_uint aux_states_len, NDArrayHandle *aux_states, ExecutorHandle *out)
Generate Executor from symbol, This is advanced function, allow specify group2ctx map...
void( MXKVStoreServerController)(int head, const char *body, void *controller_handle)
the prototype of a server controller
Definition: c_api.h:1246
MXNET_DLL int MXNDArraySave(const char *fname, mx_uint num_args, NDArrayHandle *args, const char **keys)
Save list of narray into the file.
MXNET_DLL int MXNDArrayLoadFromRawBytes(const void *buf, size_t size, NDArrayHandle *out)
create a NDArray handle that is loaded from raw bytes.
MXNET_DLL int MXRtcPush(RtcHandle handle, mx_uint num_input, mx_uint num_output, NDArrayHandle *inputs, NDArrayHandle *outputs, mx_uint gridDimX, mx_uint gridDimY, mx_uint gridDimZ, mx_uint blockDimX, mx_uint blockDimY, mx_uint blockDimZ)
Run cuda kernel.
MXNET_DLL int MXSymbolListAuxiliaryStates(SymbolHandle symbol, mx_uint *out_size, const char ***out_str_array)
List auxiliary states in the symbol.
bool(* declare_backward_dependency)(const int *, const int *, const int *, int *, int **, void *)
Definition: c_api.h:113
MXNET_DLL int MXGetFunction(const char *name, FunctionHandle *out)
get the function handle by name
MXNET_DLL int MXSymbolListAttrShallow(SymbolHandle symbol, mx_uint *out_size, const char ***out)
Get all attributes from symbol, excluding descendents.
void * DataIterCreator
handle a dataiter creator
Definition: c_api.h:46
MXNET_DLL int MXDataIterGetIterInfo(DataIterCreator creator, const char **name, const char **description, mx_uint *num_args, const char ***arg_names, const char ***arg_type_infos, const char ***arg_descriptions)
Get the detailed information about data iterator.
MXNET_DLL int MXKVStoreGetType(KVStoreHandle handle, const char **type)
get the type of the kvstore
void * RtcHandle
handle to MXRtc
Definition: c_api.h:54
MXNET_DLL int MXSymbolInferType(SymbolHandle sym, mx_uint num_args, const char **keys, const int *arg_type_data, mx_uint *in_type_size, const int **in_type_data, mx_uint *out_type_size, const int **out_type_data, mx_uint *aux_type_size, const int **aux_type_data, int *complete)
infer type of unknown input types given the known one. The types are packed into a CSR matrix represe...
MXNET_DLL int MXKVStoreInit(KVStoreHandle handle, mx_uint num, const int *keys, NDArrayHandle *vals)
Init a list of (key,value) pairs in kvstore.
const void * FunctionHandle
handle to a mxnet narray function that changes NDArray
Definition: c_api.h:36
void * p_list_arguments
Definition: c_api.h:122
bool(* del)(void *)
Definition: c_api.h:101
MXNET_DLL int MXKVStorePush(KVStoreHandle handle, mx_uint num, const int *keys, NDArrayHandle *vals, int priority)
Push a list of (key,value) pairs to kvstore.
MXNET_DLL int MXListFunctions(mx_uint *out_size, FunctionHandle **out_array)
list all the available functions handles most user can use it to list all the needed functions ...
void * p_list_auxiliary_states
Definition: c_api.h:127
bool(* list_outputs)(char ***, void *)
Definition: c_api.h:110
MXNET_DLL int MXSymbolFree(SymbolHandle symbol)
Free the symbol handle.
MXNET_DLL int MXExecutorFree(ExecutorHandle handle)
Delete the executor.
MXNET_DLL int MXNDArrayGetData(NDArrayHandle handle, mx_float **out_pdata)
get the content of the data in NDArray
bool(* backward)(int, void **, int *, const int *, const bool, void *)
Definition: c_api.h:99
MXNET_DLL int MXNDArrayWaitToWrite(NDArrayHandle handle)
Wait until all the pending read/write with respect NDArray are finished. Always call this before writ...
MXNET_DLL int MXExecutorForward(ExecutorHandle handle, int is_train)
Executor forward method.
MXNET_DLL int MXOptimizerFindCreator(const char *key, OptimizerCreator *out)