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 
24 #ifndef MXNET_C_API_H_
25 #define MXNET_C_API_H_
26 
28 #ifdef __cplusplus
29 extern "C" {
30 #endif // __cplusplus
31 
33 #ifdef __cplusplus
34 #define DEFAULT(x) = x
35 #else
36 #define DEFAULT(x)
37 #endif // __cplusplus
38 
39 #include <stdint.h>
40 
41 #include <stdint.h>
42 #include <stddef.h>
43 #include <stdbool.h>
44 
46 #ifdef _WIN32
47 #ifdef MXNET_EXPORTS
48 #define MXNET_DLL __declspec(dllexport)
49 #else
50 #define MXNET_DLL __declspec(dllimport)
51 #endif
52 #else
53 #define MXNET_DLL
54 #endif
55 
57 typedef unsigned int mx_uint;
59 typedef float mx_float;
60 // all the handles are simply void *
61 // will be casted internally to specific pointers types
62 // these typedefs are mainly used for readablity reasons
64 typedef void *NDArrayHandle;
66 typedef const void *FunctionHandle;
68 typedef void *AtomicSymbolCreator;
70 typedef void *CachedOpHandle;
72 typedef void *SymbolHandle;
74 typedef void *AtomicSymbolHandle;
76 typedef void *ExecutorHandle;
78 typedef void *DataIterCreator;
80 typedef void *DataIterHandle;
82 typedef void *KVStoreHandle;
84 typedef void *RecordIOHandle;
86 typedef void *RtcHandle;
87 
88 typedef void (*ExecutorMonitorCallback)(const char*,
90  void *);
91 
92 struct NativeOpInfo {
93  void (*forward)(int, float**, int*, unsigned**, int*, void*);
94  void (*backward)(int, float**, int*, unsigned**, int*, void*);
95  void (*infer_shape)(int, int*, unsigned**, void*);
96  void (*list_outputs)(char***, void*);
97  void (*list_arguments)(char***, void*);
98  // all functions also pass a payload void* pointer
99  void* p_forward;
100  void* p_backward;
104 };
105 
107  bool (*forward)(int, void**, int*, void*);
108  bool (*backward)(int, void**, int*, void*);
109  bool (*infer_shape)(int, int*, unsigned**, void*);
110  bool (*list_outputs)(char***, void*);
111  bool (*list_arguments)(char***, void*);
112  bool (*declare_backward_dependency)(const int*, const int*, const int*,
113  int*, int**, void*);
114  // all functions also pass a payload void* pointer
115  void* p_forward;
116  void* p_backward;
121 };
122 
123 typedef int (*MXGenericCallback)(void);
124 
127  int (**callbacks)(void);
128  void **contexts;
129 };
130 
135 };
136 
146 };
147 
148 
149 typedef int (*CustomOpFBFunc)(int /*size*/, void** /*ptrs*/, int* /*tags*/,
150  const int* /*reqs*/, const int /*is_train*/,
151  void* /*state*/);
152 typedef int (*CustomOpDelFunc)(void* /*state*/);
153 typedef int (*CustomOpListFunc)(char*** /*args*/, void* /*state*/);
154 typedef int (*CustomOpInferShapeFunc)(int /*num_input*/, int* /*ndims*/,
155  unsigned** /*shapes*/, void* /*state*/);
156 typedef int (*CustomOpInferTypeFunc)(int /*num_input*/, int* /*types*/, void* /*state*/);
157 typedef int (*CustomOpBwdDepFunc)(const int* /*out_grad*/, const int* /*in_data*/,
158  const int* /*out_data*/, int* /*num_deps*/,
159  int** /*rdeps*/, void* /*state*/);
160 typedef int (*CustomOpCreateFunc)(const char* /*ctx*/, int /*num_inputs*/,
161  unsigned** /*shapes*/, const int* /*ndims*/,
162  const int* /*dtypes*/, struct MXCallbackList* /*ret*/,
163  void* /*state*/);
164 typedef int (*CustomOpPropCreator)(const char* /*op_type*/, const int /*num_kwargs*/,
165  const char** /*keys*/, const char** /*values*/,
166  struct MXCallbackList* /*ret*/);
167 
168 
172 };
173 
174 typedef int (*CustomFunctionBwdFunc)(int /*num_ograds*/, int /*num_igrads*/, void** /*ptrs*/,
175  const int* /*reqs*/, const int /*is_train*/,
176  void* /*state*/);
177 typedef int (*CustomFunctionDelFunc)(void* /*state*/);
178 
188 MXNET_DLL const char *MXGetLastError();
189 
190 //-------------------------------------
191 // Part 0: Global State setups
192 //-------------------------------------
198 MXNET_DLL int MXRandomSeed(int seed);
215 MXNET_DLL int MXSetProfilerConfig(int mode, const char* filename);
223 MXNET_DLL int MXSetProfilerState(int state);
224 
227 
229 MXNET_DLL int MXSetNumOMPThreads(int thread_num);
230 
231 //-------------------------------------
232 // Part 1: NDArray creation and deletion
233 //-------------------------------------
241 MXNET_DLL int MXNDArrayCreateNone(NDArrayHandle *out);
253 MXNET_DLL int MXNDArrayCreate(const mx_uint *shape,
254  mx_uint ndim,
255  int dev_type,
256  int dev_id,
257  int delay_alloc,
258  NDArrayHandle *out);
259 
272 MXNET_DLL int MXNDArrayCreateEx(const mx_uint *shape,
273  mx_uint ndim,
274  int dev_type,
275  int dev_id,
276  int delay_alloc,
277  int dtype,
278  NDArrayHandle *out);
286 MXNET_DLL int MXNDArrayLoadFromRawBytes(const void *buf,
287  size_t size,
288  NDArrayHandle *out);
296 MXNET_DLL int MXNDArraySaveRawBytes(NDArrayHandle handle,
297  size_t *out_size,
298  const char **out_buf);
307 MXNET_DLL int MXNDArraySave(const char* fname,
308  mx_uint num_args,
309  NDArrayHandle* args,
310  const char** keys);
320 MXNET_DLL int MXNDArrayLoad(const char* fname,
321  mx_uint *out_size,
322  NDArrayHandle** out_arr,
323  mx_uint *out_name_size,
324  const char*** out_names);
336 MXNET_DLL int MXNDArraySyncCopyFromCPU(NDArrayHandle handle,
337  const void *data,
338  size_t size);
350 MXNET_DLL int MXNDArraySyncCopyToCPU(NDArrayHandle handle,
351  void *data,
352  size_t size);
359 MXNET_DLL int MXNDArrayWaitToRead(NDArrayHandle handle);
366 MXNET_DLL int MXNDArrayWaitToWrite(NDArrayHandle handle);
378 MXNET_DLL int MXNDArrayFree(NDArrayHandle handle);
387 MXNET_DLL int MXNDArraySlice(NDArrayHandle handle,
388  mx_uint slice_begin,
389  mx_uint slice_end,
390  NDArrayHandle *out);
398 MXNET_DLL int MXNDArrayAt(NDArrayHandle handle,
399  mx_uint idx,
400  NDArrayHandle *out);
409 MXNET_DLL int MXNDArrayReshape(NDArrayHandle handle,
410  int ndim,
411  int *dims,
412  NDArrayHandle *out);
420 MXNET_DLL int MXNDArrayGetShape(NDArrayHandle handle,
421  mx_uint *out_dim,
422  const mx_uint **out_pdata);
429 MXNET_DLL int MXNDArrayGetData(NDArrayHandle handle,
430  void **out_pdata);
437 MXNET_DLL int MXNDArrayGetDType(NDArrayHandle handle,
438  int *out_dtype);
446 MXNET_DLL int MXNDArrayGetContext(NDArrayHandle handle,
447  int *out_dev_type,
448  int *out_dev_id);
454 MXNET_DLL int MXNDArrayGetGrad(NDArrayHandle handle, NDArrayHandle *out);
460 MXNET_DLL int MXNDArrayDetach(NDArrayHandle handle, NDArrayHandle *out);
467 MXNET_DLL int MXNDArraySetGradState(NDArrayHandle handle, int state);
474 MXNET_DLL int MXNDArrayGetGradState(NDArrayHandle handle, int *out);
475 //--------------------------------
476 // Part 2: functions on NDArray
477 //--------------------------------
485 MXNET_DLL int MXListFunctions(mx_uint *out_size,
486  FunctionHandle **out_array);
493 MXNET_DLL int MXGetFunction(const char *name,
494  FunctionHandle *out);
507 MXNET_DLL int MXFuncGetInfo(FunctionHandle fun,
508  const char **name,
509  const char **description,
510  mx_uint *num_args,
511  const char ***arg_names,
512  const char ***arg_type_infos,
513  const char ***arg_descriptions,
514  const char **return_type DEFAULT(NULL));
525 MXNET_DLL int MXFuncDescribe(FunctionHandle fun,
526  mx_uint *num_use_vars,
527  mx_uint *num_scalars,
528  mx_uint *num_mutate_vars,
529  int *type_mask);
540 MXNET_DLL int MXFuncInvoke(FunctionHandle fun,
541  NDArrayHandle *use_vars,
542  mx_float *scalar_args,
543  NDArrayHandle *mutate_vars);
557 MXNET_DLL int MXFuncInvokeEx(FunctionHandle fun,
558  NDArrayHandle *use_vars,
559  mx_float *scalar_args,
560  NDArrayHandle *mutate_vars,
561  int num_params,
562  char **param_keys,
563  char **param_vals);
576 MXNET_DLL int MXImperativeInvoke(AtomicSymbolCreator creator,
577  int num_inputs,
578  NDArrayHandle *inputs,
579  int *num_outputs,
580  NDArrayHandle **outputs,
581  int num_params,
582  const char **param_keys,
583  const char **param_vals);
590 MXNET_DLL int MXAutogradSetIsRecording(int is_recording, int* prev);
597 MXNET_DLL int MXAutogradSetIsTraining(int is_training, int* prev);
603 MXNET_DLL int MXAutogradIsRecording(bool* curr);
609 MXNET_DLL int MXAutogradIsTraining(bool* curr);
616 MXNET_DLL int MXAutogradMarkVariables(mx_uint num_var,
617  NDArrayHandle *var_handles,
618  mx_uint *reqs_array,
619  NDArrayHandle *grad_handles);
626 MXNET_DLL int MXAutogradComputeGradient(mx_uint num_output,
627  NDArrayHandle* output_handles);
636 MXNET_DLL int MXAutogradBackward(mx_uint num_output,
637  NDArrayHandle* output_handles,
638  NDArrayHandle* ograd_handles,
639  int retain_graph);
649 MXNET_DLL int MXAutogradBackwardEx(mx_uint num_output,
650  NDArrayHandle* output_handles,
651  NDArrayHandle* ograd_handles,
652  int retain_graph,
653  int is_train);
654 /*
655  * \brief get the graph constructed by autograd.
656  * \param handle ndarray handle
657  * \param out output symbol handle
658  */
659 MXNET_DLL int MXAutogradGetSymbol(NDArrayHandle handle, SymbolHandle *out);
663 MXNET_DLL int MXCreateCachedOp(SymbolHandle handle,
664  CachedOpHandle *out);
668 MXNET_DLL int MXFreeCachedOp(CachedOpHandle handle);
672 MXNET_DLL int MXInvokeCachedOp(CachedOpHandle handle,
673  int num_inputs,
674  NDArrayHandle *inputs,
675  int *num_outputs,
676  NDArrayHandle **outputs);
677 //--------------------------------------------
678 // Part 3: symbolic configuration generation
679 //--------------------------------------------
686 MXNET_DLL int MXListAllOpNames(mx_uint *out_size,
687  const char ***out_array);
694 MXNET_DLL int MXSymbolListAtomicSymbolCreators(mx_uint *out_size,
695  AtomicSymbolCreator **out_array);
696 
702 MXNET_DLL int MXSymbolGetAtomicSymbolName(AtomicSymbolCreator creator,
703  const char **name);
721 MXNET_DLL int MXSymbolGetAtomicSymbolInfo(AtomicSymbolCreator creator,
722  const char **name,
723  const char **description,
724  mx_uint *num_args,
725  const char ***arg_names,
726  const char ***arg_type_infos,
727  const char ***arg_descriptions,
728  const char **key_var_num_args,
729  const char **return_type DEFAULT(NULL));
739 MXNET_DLL int MXSymbolCreateAtomicSymbol(AtomicSymbolCreator creator,
740  mx_uint num_param,
741  const char **keys,
742  const char **vals,
743  SymbolHandle *out);
750 MXNET_DLL int MXSymbolCreateVariable(const char *name, SymbolHandle *out);
758 MXNET_DLL int MXSymbolCreateGroup(mx_uint num_symbols,
759  SymbolHandle *symbols,
760  SymbolHandle *out);
767 MXNET_DLL int MXSymbolCreateFromFile(const char *fname, SymbolHandle *out);
774 MXNET_DLL int MXSymbolCreateFromJSON(const char *json, SymbolHandle *out);
781 MXNET_DLL int MXSymbolSaveToFile(SymbolHandle symbol, const char *fname);
788 MXNET_DLL int MXSymbolSaveToJSON(SymbolHandle symbol, const char **out_json);
794 MXNET_DLL int MXSymbolFree(SymbolHandle symbol);
801 MXNET_DLL int MXSymbolCopy(SymbolHandle symbol, SymbolHandle *out);
808 MXNET_DLL int MXSymbolPrint(SymbolHandle symbol, const char **out_str);
816 MXNET_DLL int MXSymbolGetName(SymbolHandle symbol,
817  const char** out,
818  int *success);
827 MXNET_DLL int MXSymbolGetAttr(SymbolHandle symbol,
828  const char* key,
829  const char** out,
830  int *success);
847 MXNET_DLL int MXSymbolSetAttr(SymbolHandle symbol,
848  const char* key,
849  const char* value);
857 MXNET_DLL int MXSymbolListAttr(SymbolHandle symbol,
858  mx_uint *out_size,
859  const char*** out);
867 MXNET_DLL int MXSymbolListAttrShallow(SymbolHandle symbol,
868  mx_uint *out_size,
869  const char*** out);
877 MXNET_DLL int MXSymbolListArguments(SymbolHandle symbol,
878  mx_uint *out_size,
879  const char ***out_str_array);
887 MXNET_DLL int MXSymbolListOutputs(SymbolHandle symbol,
888  mx_uint *out_size,
889  const char ***out_str_array);
896 MXNET_DLL int MXSymbolGetInternals(SymbolHandle symbol,
897  SymbolHandle *out);
904 MXNET_DLL int MXSymbolGetChildren(SymbolHandle symbol,
905  SymbolHandle *out);
913 MXNET_DLL int MXSymbolGetOutput(SymbolHandle symbol,
914  mx_uint index,
915  SymbolHandle *out);
923 MXNET_DLL int MXSymbolListAuxiliaryStates(SymbolHandle symbol,
924  mx_uint *out_size,
925  const char ***out_str_array);
940 MXNET_DLL int MXSymbolCompose(SymbolHandle sym,
941  const char *name,
942  mx_uint num_args,
943  const char** keys,
944  SymbolHandle* args);
954 MXNET_DLL int MXSymbolGrad(SymbolHandle sym,
955  mx_uint num_wrt,
956  const char** wrt,
957  SymbolHandle* out);
980 MXNET_DLL int MXSymbolInferShape(SymbolHandle sym,
981  mx_uint num_args,
982  const char** keys,
983  const mx_uint *arg_ind_ptr,
984  const mx_uint *arg_shape_data,
985  mx_uint *in_shape_size,
986  const mx_uint **in_shape_ndim,
987  const mx_uint ***in_shape_data,
988  mx_uint *out_shape_size,
989  const mx_uint **out_shape_ndim,
990  const mx_uint ***out_shape_data,
991  mx_uint *aux_shape_size,
992  const mx_uint **aux_shape_ndim,
993  const mx_uint ***aux_shape_data,
994  int *complete);
1019 MXNET_DLL int MXSymbolInferShapePartial(SymbolHandle sym,
1020  mx_uint num_args,
1021  const char** keys,
1022  const mx_uint *arg_ind_ptr,
1023  const mx_uint *arg_shape_data,
1024  mx_uint *in_shape_size,
1025  const mx_uint **in_shape_ndim,
1026  const mx_uint ***in_shape_data,
1027  mx_uint *out_shape_size,
1028  const mx_uint **out_shape_ndim,
1029  const mx_uint ***out_shape_data,
1030  mx_uint *aux_shape_size,
1031  const mx_uint **aux_shape_ndim,
1032  const mx_uint ***aux_shape_data,
1033  int *complete);
1034 
1053 MXNET_DLL int MXSymbolInferType(SymbolHandle sym,
1054  mx_uint num_args,
1055  const char** keys,
1056  const int *arg_type_data,
1057  mx_uint *in_type_size,
1058  const int **in_type_data,
1059  mx_uint *out_type_size,
1060  const int **out_type_data,
1061  mx_uint *aux_type_size,
1062  const int **aux_type_data,
1063  int *complete);
1064 //--------------------------------------------
1065 // Part 4: Executor interface
1066 //--------------------------------------------
1072 MXNET_DLL int MXExecutorFree(ExecutorHandle handle);
1079 MXNET_DLL int MXExecutorPrint(ExecutorHandle handle, const char **out_str);
1087 MXNET_DLL int MXExecutorForward(ExecutorHandle handle, int is_train);
1097 MXNET_DLL int MXExecutorBackward(ExecutorHandle handle,
1098  mx_uint len,
1099  NDArrayHandle *head_grads);
1110 MXNET_DLL int MXExecutorBackwardEx(ExecutorHandle handle,
1111  mx_uint len,
1112  NDArrayHandle *head_grads,
1113  int is_train);
1122 MXNET_DLL int MXExecutorOutputs(ExecutorHandle handle,
1123  mx_uint *out_size,
1124  NDArrayHandle **out);
1125 
1141 MXNET_DLL int MXExecutorBind(SymbolHandle symbol_handle,
1142  int dev_type,
1143  int dev_id,
1144  mx_uint len,
1145  NDArrayHandle *in_args,
1146  NDArrayHandle *arg_grad_store,
1147  mx_uint *grad_req_type,
1148  mx_uint aux_states_len,
1149  NDArrayHandle *aux_states,
1150  ExecutorHandle *out);
1172 MXNET_DLL int MXExecutorBindX(SymbolHandle symbol_handle,
1173  int dev_type,
1174  int dev_id,
1175  mx_uint num_map_keys,
1176  const char** map_keys,
1177  const int* map_dev_types,
1178  const int* map_dev_ids,
1179  mx_uint len,
1180  NDArrayHandle *in_args,
1181  NDArrayHandle *arg_grad_store,
1182  mx_uint *grad_req_type,
1183  mx_uint aux_states_len,
1184  NDArrayHandle *aux_states,
1185  ExecutorHandle *out);
1208 MXNET_DLL int MXExecutorBindEX(SymbolHandle symbol_handle,
1209  int dev_type,
1210  int dev_id,
1211  mx_uint num_map_keys,
1212  const char** map_keys,
1213  const int* map_dev_types,
1214  const int* map_dev_ids,
1215  mx_uint len,
1216  NDArrayHandle *in_args,
1217  NDArrayHandle *arg_grad_store,
1218  mx_uint *grad_req_type,
1219  mx_uint aux_states_len,
1220  NDArrayHandle *aux_states,
1221  ExecutorHandle shared_exec,
1222  ExecutorHandle *out);
1223 
1224 MXNET_DLL int MXExecutorSimpleBind(SymbolHandle symbol_handle,
1225  int dev_type,
1226  int dev_id,
1227  const mx_uint num_g2c_keys,
1228  const char** g2c_keys,
1229  const int* g2c_dev_types,
1230  const int* g2c_dev_ids,
1231  const mx_uint provided_grad_req_list_len,
1232  const char** provided_grad_req_names,
1233  const char** provided_grad_req_types,
1234  const mx_uint num_provided_arg_shapes,
1235  const char** provided_arg_shape_names,
1236  const mx_uint* provided_arg_shape_data,
1237  const mx_uint* provided_arg_shape_idx,
1238  const mx_uint num_provided_arg_dtypes,
1239  const char** provided_arg_dtype_names,
1240  const int* provided_arg_dtypes,
1241  const mx_uint num_shared_arg_names,
1242  const char** shared_arg_name_list,
1243  int* shared_buffer_len,
1244  const char** shared_buffer_name_list,
1245  NDArrayHandle* shared_buffer_handle_list,
1246  const char*** updated_shared_buffer_name_list,
1247  NDArrayHandle** updated_shared_buffer_handle_list,
1248  mx_uint* num_in_args,
1249  NDArrayHandle** in_args,
1250  NDArrayHandle** arg_grads,
1251  mx_uint* num_aux_states,
1252  NDArrayHandle** aux_states,
1253  ExecutorHandle shared_exec_handle,
1254  ExecutorHandle* out);
1258 MXNET_DLL int MXExecutorSetMonitorCallback(ExecutorHandle handle,
1259  ExecutorMonitorCallback callback,
1260  void* callback_handle);
1261 //--------------------------------------------
1262 // Part 5: IO Interface
1263 //--------------------------------------------
1270 MXNET_DLL int MXListDataIters(mx_uint *out_size,
1271  DataIterCreator **out_array);
1282 MXNET_DLL int MXDataIterCreateIter(DataIterCreator handle,
1283  mx_uint num_param,
1284  const char **keys,
1285  const char **vals,
1286  DataIterHandle *out);
1298 MXNET_DLL int MXDataIterGetIterInfo(DataIterCreator creator,
1299  const char **name,
1300  const char **description,
1301  mx_uint *num_args,
1302  const char ***arg_names,
1303  const char ***arg_type_infos,
1304  const char ***arg_descriptions);
1310 MXNET_DLL int MXDataIterFree(DataIterHandle handle);
1317 MXNET_DLL int MXDataIterNext(DataIterHandle handle,
1318  int *out);
1324 MXNET_DLL int MXDataIterBeforeFirst(DataIterHandle handle);
1325 
1332 MXNET_DLL int MXDataIterGetData(DataIterHandle handle,
1333  NDArrayHandle *out);
1341 MXNET_DLL int MXDataIterGetIndex(DataIterHandle handle,
1342  uint64_t **out_index,
1343  uint64_t *out_size);
1350 MXNET_DLL int MXDataIterGetPadNum(DataIterHandle handle,
1351  int *pad);
1352 
1359 MXNET_DLL int MXDataIterGetLabel(DataIterHandle handle,
1360  NDArrayHandle *out);
1361 //--------------------------------------------
1362 // Part 6: basic KVStore interface
1363 //--------------------------------------------
1370 MXNET_DLL int MXInitPSEnv(mx_uint num_vars,
1371  const char **keys,
1372  const char **vals);
1373 
1374 
1381 MXNET_DLL int MXKVStoreCreate(const char *type,
1382  KVStoreHandle *out);
1388 MXNET_DLL int MXKVStoreFree(KVStoreHandle handle);
1397 MXNET_DLL int MXKVStoreInit(KVStoreHandle handle,
1398  mx_uint num,
1399  const int* keys,
1400  NDArrayHandle* vals);
1401 
1410 MXNET_DLL int MXKVStoreInitEx(KVStoreHandle handle,
1411  mx_uint num,
1412  const char** keys,
1413  NDArrayHandle* vals);
1414 
1424 MXNET_DLL int MXKVStorePush(KVStoreHandle handle,
1425  mx_uint num,
1426  const int* keys,
1427  NDArrayHandle* vals,
1428  int priority);
1438 MXNET_DLL int MXKVStorePushEx(KVStoreHandle handle,
1439  mx_uint num,
1440  const char** keys,
1441  NDArrayHandle* vals,
1442  int priority);
1452 MXNET_DLL int MXKVStorePull(KVStoreHandle handle,
1453  mx_uint num,
1454  const int* keys,
1455  NDArrayHandle* vals,
1456  int priority);
1466 MXNET_DLL int MXKVStorePullEx(KVStoreHandle handle,
1467  mx_uint num,
1468  const char** keys,
1469  NDArrayHandle* vals,
1470  int priority);
1479 typedef void (MXKVStoreUpdater)(int key,
1480  NDArrayHandle recv,
1481  NDArrayHandle local,
1482  void *handle);
1490 MXNET_DLL int MXKVStoreSetUpdater(KVStoreHandle handle,
1491  MXKVStoreUpdater updater,
1492  void *updater_handle);
1499 MXNET_DLL int MXKVStoreGetType(KVStoreHandle handle,
1500  const char** type);
1501 //--------------------------------------------
1502 // Part 6: advanced KVStore for multi-machines
1503 //--------------------------------------------
1504 
1512 MXNET_DLL int MXKVStoreGetRank(KVStoreHandle handle,
1513  int *ret);
1514 
1524 MXNET_DLL int MXKVStoreGetGroupSize(KVStoreHandle handle,
1525  int *ret);
1526 
1532 MXNET_DLL int MXKVStoreIsWorkerNode(int *ret);
1533 
1534 
1540 MXNET_DLL int MXKVStoreIsServerNode(int *ret);
1541 
1542 
1548 MXNET_DLL int MXKVStoreIsSchedulerNode(int *ret);
1549 
1556 MXNET_DLL int MXKVStoreBarrier(KVStoreHandle handle);
1557 
1565 MXNET_DLL int MXKVStoreSetBarrierBeforeExit(KVStoreHandle handle,
1566  const int barrier_before_exit);
1567 
1574 typedef void (MXKVStoreServerController)(int head,
1575  const char *body,
1576  void *controller_handle);
1577 
1586 MXNET_DLL int MXKVStoreRunServer(KVStoreHandle handle,
1587  MXKVStoreServerController controller,
1588  void *controller_handle);
1589 
1598 MXNET_DLL int MXKVStoreSendCommmandToServers(KVStoreHandle handle,
1599  int cmd_id,
1600  const char* cmd_body);
1601 
1612 MXNET_DLL int MXKVStoreGetNumDeadNode(KVStoreHandle handle,
1613  const int node_id,
1614  int *number,
1615  const int timeout_sec DEFAULT(60));
1616 
1623 MXNET_DLL int MXRecordIOWriterCreate(const char *uri, RecordIOHandle *out);
1624 
1630 MXNET_DLL int MXRecordIOWriterFree(RecordIOHandle handle);
1631 
1639 MXNET_DLL int MXRecordIOWriterWriteRecord(RecordIOHandle handle,
1640  const char *buf, size_t size);
1641 
1648 MXNET_DLL int MXRecordIOWriterTell(RecordIOHandle handle, size_t *pos);
1649 
1656 MXNET_DLL int MXRecordIOReaderCreate(const char *uri, RecordIOHandle *out);
1657 
1663 MXNET_DLL int MXRecordIOReaderFree(RecordIOHandle handle);
1664 
1672 MXNET_DLL int MXRecordIOReaderReadRecord(RecordIOHandle handle,
1673  char const **buf, size_t *size);
1674 
1681 MXNET_DLL int MXRecordIOReaderSeek(RecordIOHandle handle, size_t pos);
1682 
1686 MXNET_DLL int MXRtcCreate(char* name, mx_uint num_input, mx_uint num_output,
1687  char** input_names, char** output_names,
1688  NDArrayHandle* inputs, NDArrayHandle* outputs,
1689  char* kernel, RtcHandle *out);
1690 
1694 MXNET_DLL int MXRtcPush(RtcHandle handle, mx_uint num_input, mx_uint num_output,
1695  NDArrayHandle* inputs, NDArrayHandle* outputs,
1696  mx_uint gridDimX,
1697  mx_uint gridDimY,
1698  mx_uint gridDimZ,
1699  mx_uint blockDimX,
1700  mx_uint blockDimY,
1701  mx_uint blockDimZ);
1702 
1706 MXNET_DLL int MXRtcFree(RtcHandle handle);
1707 /*
1708  * \brief register custom operators from frontend.
1709  * \param op_type name of custom op
1710  * \param creator
1711  */
1712 MXNET_DLL int MXCustomOpRegister(const char* op_type, CustomOpPropCreator creator);
1713 /*
1714  * \brief record custom function for backward later.
1715  * \param num_inputs number of input NDArrays.
1716  * \param inputs handle to input NDArrays.
1717  * \param num_outputs number of output NDArrays.
1718  * \param outputs handle to output NDArrays.
1719  * \param callbacks callbacks for backward function.
1720  */
1721 MXNET_DLL int MXCustomFunctionRecord(int num_inputs, NDArrayHandle *inputs,
1722  int num_outputs, NDArrayHandle *outputs,
1724 
1725 #ifdef __cplusplus
1726 }
1727 #endif // __cplusplus
1728 
1729 #endif // MXNET_C_API_H_
MXNET_DLL int MXKVStoreSendCommmandToServers(KVStoreHandle handle, int cmd_id, const char *cmd_body)
int(* CustomFunctionDelFunc)(void *)
Definition: c_api.h:177
MXNET_DLL int MXNDArrayDetach(NDArrayHandle handle, NDArrayHandle *out)
detach and ndarray from computation graph by clearing entry_
MXNET_DLL int MXListAllOpNames(mx_uint *out_size, const char ***out_array)
list all the available operator names, include entries.
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:80
MXNET_DLL int MXSymbolListAtomicSymbolCreators(mx_uint *out_size, AtomicSymbolCreator **out_array)
list all the available AtomicSymbolEntry
Definition: c_api.h:132
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:117
MXNET_DLL int MXAutogradMarkVariables(mx_uint num_var, NDArrayHandle *var_handles, mx_uint *reqs_array, NDArrayHandle *grad_handles)
mark NDArrays as variables to compute gradient for autograd
Definition: c_api.h:142
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)
void(* list_arguments)(char ***, void *)
Definition: c_api.h:97
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 MXSymbolGetAtomicSymbolName(AtomicSymbolCreator creator, const char **name)
Get the name of an atomic symbol.
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:115
MXNET_DLL int MXDataIterFree(DataIterHandle handle)
Free the handle to the IO module.
MXNET_DLL int MXInvokeCachedOp(CachedOpHandle handle, int num_inputs, NDArrayHandle *inputs, int *num_outputs, NDArrayHandle **outputs)
invoke cached operator
MXNET_DLL int MXFreeCachedOp(CachedOpHandle handle)
free cached operator
void * RecordIOHandle
handle to RecordIO
Definition: c_api.h:84
CustomOpCallbacks
Definition: c_api.h:131
MXNET_DLL int MXSymbolGetChildren(SymbolHandle symbol, SymbolHandle *out)
Get a symbol that contains only direct children.
MXNET_DLL int MXRecordIOReaderFree(RecordIOHandle handle)
Delete a RecordIO reader object.
MXNET_DLL int MXExecutorOutputs(ExecutorHandle handle, mx_uint *out_size, NDArrayHandle **out)
Get executor&#39;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.
void * ExecutorHandle
handle to an Executor
Definition: c_api.h:76
MXNET_DLL int MXCustomFunctionRecord(int num_inputs, NDArrayHandle *inputs, int num_outputs, NDArrayHandle *outputs, MXCallbackList *callbacks)
CustomFunctionCallbacks
Definition: c_api.h:169
MXNET_DLL int MXSymbolSaveToFile(SymbolHandle symbol, const char *fname)
Save a symbol into a json file.
void * AtomicSymbolHandle
handle to a AtomicSymbol
Definition: c_api.h:74
void * p_backward
Definition: c_api.h:100
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 DEFAULT(NULL))
Get the information of the function handle.
MXNET_DLL int MXAutogradSetIsTraining(int is_training, int *prev)
set whether to record operator for autograd
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.
CustomOpPropCallbacks
Definition: c_api.h:137
int(* CustomOpInferTypeFunc)(int, int *, void *)
Definition: c_api.h:156
MXNET_DLL int MXKVStoreIsSchedulerNode(int *ret)
return whether or not this process is a scheduler node.
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 DEFAULT(NULL))
Get the detailed information about atomic symbol.
#define DEFAULT(x)
Inhibit C++ name-mangling for MXNet functions.
Definition: c_api.h:36
MXNET_DLL int MXAutogradBackwardEx(mx_uint num_output, NDArrayHandle *output_handles, NDArrayHandle *ograd_handles, int retain_graph, int is_train)
compute the gradient of outputs w.r.t variabels
MXNET_DLL int MXSetProfilerState(int state)
Set up state of profiler.
MXNET_DLL int MXImperativeInvoke(AtomicSymbolCreator creator, int num_inputs, NDArrayHandle *inputs, int *num_outputs, NDArrayHandle **outputs, int num_params, const char **param_keys, const char **param_vals)
invoke a nnvm op and imperative function
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.
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.
MXNET_DLL int MXKVStorePushEx(KVStoreHandle handle, mx_uint num, const char **keys, NDArrayHandle *vals, int priority)
Push a list of (key,value) pairs to kvstore, where each key is a string.
Definition: c_api.h:106
void(* ExecutorMonitorCallback)(const char *, NDArrayHandle, void *)
Definition: c_api.h:88
void * p_forward
Definition: c_api.h:99
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
void * p_list_arguments
Definition: c_api.h:103
MXNET_DLL int MXKVStoreCreate(const char *type, KVStoreHandle *out)
Create a kvstore.
int(* CustomOpDelFunc)(void *)
Definition: c_api.h:152
void * p_declare_backward_dependency
Definition: c_api.h:120
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:119
MXNET_DLL int MXCustomOpRegister(const char *op_type, CustomOpPropCreator creator)
MXNET_DLL int MXExecutorBackwardEx(ExecutorHandle handle, mx_uint len, NDArrayHandle *head_grads, int is_train)
Excecutor run backward.
void * SymbolHandle
handle to a symbol that can be bind as operator
Definition: c_api.h:72
MXNET_DLL int MXSymbolCopy(SymbolHandle symbol, SymbolHandle *out)
Copy the symbol to another handle.
int(** callbacks)(void)
Definition: c_api.h:127
void * CachedOpHandle
handle to cached operator
Definition: c_api.h:70
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...
MXNET_DLL int MXSetNumOMPThreads(int thread_num)
Set the number of OMP threads to use.
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.
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 MXAutogradComputeGradient(mx_uint num_output, NDArrayHandle *output_handles)
compute the gradient of outputs w.r.t variabels
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 ...
int num_callbacks
Definition: c_api.h:126
MXNET_DLL int MXRandomSeed(int seed)
Seed the global random number generators in mxnet.
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 MXAutogradIsTraining(bool *curr)
get whether training mode is on
void(* forward)(int, float **, int *, unsigned **, int *, void *)
Definition: c_api.h:93
int(* MXGenericCallback)(void)
Definition: c_api.h:123
Definition: c_api.h:170
MXNET_DLL int MXSymbolGetInternals(SymbolHandle symbol, SymbolHandle *out)
Get a symbol that contains all the internals.
MXNET_DLL int MXExecutorSimpleBind(SymbolHandle symbol_handle, int dev_type, int dev_id, const mx_uint num_g2c_keys, const char **g2c_keys, const int *g2c_dev_types, const int *g2c_dev_ids, const mx_uint provided_grad_req_list_len, const char **provided_grad_req_names, const char **provided_grad_req_types, const mx_uint num_provided_arg_shapes, const char **provided_arg_shape_names, const mx_uint *provided_arg_shape_data, const mx_uint *provided_arg_shape_idx, const mx_uint num_provided_arg_dtypes, const char **provided_arg_dtype_names, const int *provided_arg_dtypes, const mx_uint num_shared_arg_names, const char **shared_arg_name_list, int *shared_buffer_len, const char **shared_buffer_name_list, NDArrayHandle *shared_buffer_handle_list, const char ***updated_shared_buffer_name_list, NDArrayHandle **updated_shared_buffer_handle_list, mx_uint *num_in_args, NDArrayHandle **in_args, NDArrayHandle **arg_grads, mx_uint *num_aux_states, NDArrayHandle **aux_states, ExecutorHandle shared_exec_handle, ExecutorHandle *out)
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.
MXNET_DLL int MXRtcFree(RtcHandle handle)
Delete a MXRtc object.
MXNET_DLL int MXNDArraySyncCopyToCPU(NDArrayHandle handle, void *data, size_t size)
Perform a synchronize copyto a continugous CPU memory region.
MXNET_DLL int MXAutogradSetIsRecording(int is_recording, int *prev)
set whether to record operator for autograd
void( MXKVStoreServerController)(int head, const char *body, void *controller_handle)
the prototype of a server controller
Definition: c_api.h:1574
Definition: c_api.h:133
void * KVStoreHandle
handle to KVStore
Definition: c_api.h:82
MXNET_DLL int MXSetProfilerConfig(int mode, const char *filename)
Set up configuration of profiler.
void * NDArrayHandle
handle to NDArray
Definition: c_api.h:64
MXNET_DLL int MXNotifyShutdown()
Notify the engine about a shutdown, This can help engine to print less messages into display...
void * p_list_outputs
Definition: c_api.h:118
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.
Definition: c_api.h:139
int(* CustomOpCreateFunc)(const char *, int, unsigned **, const int *, const int *, struct MXCallbackList *, void *)
Definition: c_api.h:160
int(* CustomOpFBFunc)(int, void **, int *, const int *, const int, void *)
Definition: c_api.h:149
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 MXKVStoreSetBarrierBeforeExit(KVStoreHandle handle, const int barrier_before_exit)
whether to do barrier when finalize
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_infer_shape
Definition: c_api.h:101
MXNET_DLL int MXNDArrayWaitAll()
wait until all delayed operations in the system is completed
MXNET_DLL int MXKVStorePullEx(KVStoreHandle handle, mx_uint num, const char **keys, NDArrayHandle *vals, int priority)
pull a list of (key, value) pairs from the kvstore, where each key is a string
MXNET_DLL int MXRecordIOReaderCreate(const char *uri, RecordIOHandle *out)
Create a RecordIO reader object.
MXNET_DLL int MXKVStoreGetNumDeadNode(KVStoreHandle handle, const int node_id, int *number, const int timeout_sec DEFAULT(60))
Get the number of ps dead node(s) specified by {node_id}.
unsigned int mx_uint
manually define unsigned int
Definition: c_api.h:57
Definition: c_api.h:134
MXNET_DLL int MXRecordIOWriterTell(RecordIOHandle handle, size_t *pos)
Get the current writer pointer position.
Definition: c_api.h:145
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:116
Definition: c_api.h:138
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...
MXNET_DLL int MXAutogradIsRecording(bool *curr)
get whether autograd recording is on
Definition: c_api.h:171
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 MXRecordIOWriterWriteRecord(RecordIOHandle handle, const char *buf, size_t size)
Write a record to a RecordIO object.
int(* CustomOpPropCreator)(const char *, const int, const char **, const char **, struct MXCallbackList *)
Definition: c_api.h:164
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
int(* CustomFunctionBwdFunc)(int, int, void **, const int *, const int, void *)
Definition: c_api.h:174
MXNET_DLL int MXAutogradBackward(mx_uint num_output, NDArrayHandle *output_handles, NDArrayHandle *ograd_handles, int retain_graph)
compute the gradient of outputs w.r.t variabels
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:59
MXNET_DLL int MXCreateCachedOp(SymbolHandle handle, CachedOpHandle *out)
create cached operator
MXNET_DLL int MXRecordIOReaderSeek(RecordIOHandle handle, size_t pos)
Set the current reader pointer position.
#define MXNET_DLL
MXNET_DLL prefix for windows.
Definition: c_api.h:53
MXNET_DLL int MXSymbolCreateAtomicSymbol(AtomicSymbolCreator creator, mx_uint num_param, const char **keys, const char **vals, SymbolHandle *out)
Create an AtomicSymbol.
MXNET_DLL int MXNDArraySetGradState(NDArrayHandle handle, int state)
set the flag for gradient array state.
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...
MXNET_DLL int MXNDArrayGetGradState(NDArrayHandle handle, int *out)
set the flag for gradient array state.
void ** contexts
Definition: c_api.h:128
void * AtomicSymbolCreator
handle to a function that takes param and creates symbol
Definition: c_api.h:68
MXNET_DLL int MXKVStoreInitEx(KVStoreHandle handle, mx_uint num, const char **keys, NDArrayHandle *vals)
Init a list of (key,value) pairs in kvstore, where each key is a string.
MXNET_DLL int MXAutogradGetSymbol(NDArrayHandle handle, SymbolHandle *out)
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(* infer_shape)(int, int *, unsigned **, void *)
Definition: c_api.h:95
void * p_list_outputs
Definition: c_api.h:102
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.
void( MXKVStoreUpdater)(int key, NDArrayHandle recv, NDArrayHandle local, void *handle)
user-defined updater for the kvstore It&#39;s this updater&#39;s responsibility to delete recv and local ...
Definition: c_api.h:1479
MXNET_DLL int MXSymbolListAuxiliaryStates(SymbolHandle symbol, mx_uint *out_size, const char ***out_str_array)
List auxiliary states in the symbol.
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:78
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:86
MXNET_DLL int MXNDArrayGetGrad(NDArrayHandle handle, NDArrayHandle *out)
return gradient buffer attached to this NDArray
int(* CustomOpBwdDepFunc)(const int *, const int *, const int *, int *, int **, void *)
Definition: c_api.h:157
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...
Definition: c_api.h:140
MXNET_DLL int MXKVStoreInit(KVStoreHandle handle, mx_uint num, const int *keys, NDArrayHandle *vals)
Init a list of (key,value) pairs in kvstore.
void(* backward)(int, float **, int *, unsigned **, int *, void *)
Definition: c_api.h:94
MXNET_DLL int MXDumpProfile()
Save profile and stop profiler.
Definition: c_api.h:125
const void * FunctionHandle
handle to a mxnet narray function that changes NDArray
Definition: c_api.h:66
Definition: c_api.h:92
MXNET_DLL int MXRecordIOReaderReadRecord(RecordIOHandle handle, char const **buf, size_t *size)
Write a record to a RecordIO object.
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(* list_outputs)(char ***, void *)
Definition: c_api.h:96
Definition: c_api.h:141
Definition: c_api.h:144
int(* CustomOpInferShapeFunc)(int, int *, unsigned **, void *)
Definition: c_api.h:154
MXNET_DLL int MXSymbolFree(SymbolHandle symbol)
Free the symbol handle.
MXNET_DLL int MXExecutorFree(ExecutorHandle handle)
Delete the executor.
MXNET_DLL int MXNDArrayWaitToWrite(NDArrayHandle handle)
Wait until all the pending read/write with respect NDArray are finished. Always call this before writ...
int(* CustomOpListFunc)(char ***, void *)
Definition: c_api.h:153
MXNET_DLL int MXExecutorForward(ExecutorHandle handle, int is_train)
Executor forward method.
MXNET_DLL int MXNDArrayGetData(NDArrayHandle handle, void **out_pdata)
get the content of the data in NDArray