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 
25 #ifndef MXNET_C_API_H_
26 #define MXNET_C_API_H_
27 
29 #ifdef __cplusplus
30 extern "C" {
31 #endif // __cplusplus
32 
34 #ifdef __cplusplus
35 #define DEFAULT(x) = x
36 #else
37 #define DEFAULT(x)
38 #endif // __cplusplus
39 
40 #include <stdint.h>
41 
42 #include <stdint.h>
43 #include <stddef.h>
44 #include <stdbool.h>
45 
47 #ifdef _WIN32
48 #ifdef MXNET_EXPORTS
49 #define MXNET_DLL __declspec(dllexport)
50 #else
51 #define MXNET_DLL __declspec(dllimport)
52 #endif
53 #else
54 #define MXNET_DLL
55 #endif
56 
58 typedef unsigned int mx_uint;
60 typedef float mx_float;
62 typedef int64_t dim_t;
63 // all the handles are simply void *
64 // will be casted internally to specific pointers types
65 // these typedefs are mainly used for readablity reasons
67 typedef void *NDArrayHandle;
69 typedef const void *FunctionHandle;
71 typedef void *AtomicSymbolCreator;
73 typedef void *CachedOpHandle;
75 typedef void *SymbolHandle;
77 typedef void *AtomicSymbolHandle;
79 typedef void *ExecutorHandle;
81 typedef void *DataIterCreator;
83 typedef void *DataIterHandle;
85 typedef void *KVStoreHandle;
87 typedef void *RecordIOHandle;
89 typedef void *RtcHandle;
91 typedef void *CudaModuleHandle;
93 typedef void *CudaKernelHandle;
95 typedef void *ProfileHandle;
96 
97 typedef void (*ExecutorMonitorCallback)(const char*,
99  void *);
100 
101 struct NativeOpInfo {
102  void (*forward)(int, float**, int*, unsigned**, int*, void*);
103  void (*backward)(int, float**, int*, unsigned**, int*, void*);
104  void (*infer_shape)(int, int*, unsigned**, void*);
105  void (*list_outputs)(char***, void*);
106  void (*list_arguments)(char***, void*);
107  // all functions also pass a payload void* pointer
108  void* p_forward;
109  void* p_backward;
113 };
114 
116  bool (*forward)(int, void**, int*, void*);
117  bool (*backward)(int, void**, int*, void*);
118  bool (*infer_shape)(int, int*, unsigned**, void*);
119  bool (*list_outputs)(char***, void*);
120  bool (*list_arguments)(char***, void*);
121  bool (*declare_backward_dependency)(const int*, const int*, const int*,
122  int*, int**, void*);
123  // all functions also pass a payload void* pointer
124  void* p_forward;
125  void* p_backward;
130 };
131 
132 typedef int (*MXGenericCallback)(void);
133 
136  int (**callbacks)(void);
137  void **contexts;
138 };
139 
144 };
145 
157 };
158 
159 
160 typedef int (*CustomOpFBFunc)(int /*size*/, void** /*ptrs*/, int* /*tags*/,
161  const int* /*reqs*/, const int /*is_train*/,
162  void* /*state*/);
163 typedef int (*CustomOpDelFunc)(void* /*state*/);
164 typedef int (*CustomOpListFunc)(char*** /*args*/, void* /*state*/);
165 typedef int (*CustomOpInferShapeFunc)(int /*num_input*/, int* /*ndims*/,
166  unsigned** /*shapes*/, void* /*state*/);
167 typedef int (*CustomOpInferStorageTypeFunc)(int /*num_input*/, int* /*stypes*/, void* /*state*/);
168 typedef int (*CustomOpBackwardInferStorageTypeFunc)(int /*num_input*/,
169  int * /*stypes*/,
170  int * /*tags*/,
171  void * /*state*/);
172 typedef int (*CustomOpInferTypeFunc)(int /*num_input*/, int* /*types*/, void* /*state*/);
173 typedef int (*CustomOpBwdDepFunc)(const int* /*out_grad*/, const int* /*in_data*/,
174  const int* /*out_data*/, int* /*num_deps*/,
175  int** /*rdeps*/, void* /*state*/);
176 typedef int (*CustomOpCreateFunc)(const char* /*ctx*/, int /*num_inputs*/,
177  unsigned** /*shapes*/, const int* /*ndims*/,
178  const int* /*dtypes*/, struct MXCallbackList* /*ret*/,
179  void* /*state*/);
180 typedef int (*CustomOpPropCreator)(const char* /*op_type*/, const int /*num_kwargs*/,
181  const char** /*keys*/, const char** /*values*/,
182  struct MXCallbackList* /*ret*/);
183 
184 
188 };
189 
190 typedef int (*CustomFunctionBwdFunc)(int /*num_ograds*/, int /*num_igrads*/, void** /*ptrs*/,
191  const int* /*reqs*/, const int /*is_train*/,
192  void* /*state*/);
193 typedef int (*CustomFunctionDelFunc)(void* /*state*/);
194 
204 MXNET_DLL const char *MXGetLastError();
205 
206 //-------------------------------------
207 // Part 0: Global State setups
208 //-------------------------------------
214 MXNET_DLL int MXRandomSeed(int seed);
215 
221 MXNET_DLL int MXRandomSeedContext(int seed, int dev_type, int dev_id);
222 
231 
239 MXNET_DLL int MXSetProfilerConfig(int num_params, const char* const* keys, const char* const* vals);
240 
248 MXNET_DLL int MXSetProfilerState(int state);
249 
255 MXNET_DLL int MXDumpProfile(int finished);
256 
257 
265 MXNET_DLL int MXAggregateProfileStatsPrint(const char **out_str, int reset);
266 
273 MXNET_DLL int MXProfilePause(int paused);
274 
281 MXNET_DLL int MXProfileCreateDomain(const char *domain, ProfileHandle *out);
282 
290 MXNET_DLL int MXProfileCreateTask(ProfileHandle domain,
291  const char *task_name,
292  ProfileHandle *out);
293 
301 MXNET_DLL int MXProfileCreateFrame(ProfileHandle domain,
302  const char *frame_name,
303  ProfileHandle *out);
304 
311 MXNET_DLL int MXProfileCreateEvent(const char *event_name, ProfileHandle *out);
312 
320 MXNET_DLL int MXProfileCreateCounter(ProfileHandle domain,
321  const char *counter_name,
322  ProfileHandle *out);
323 
329 MXNET_DLL int MXProfileDestroyHandle(ProfileHandle frame_handle);
330 
336 MXNET_DLL int MXProfileDurationStart(ProfileHandle duration_handle);
337 
343 MXNET_DLL int MXProfileDurationStop(ProfileHandle duration_handle);
344 
351 MXNET_DLL int MXProfileSetCounter(ProfileHandle counter_handle, uint64_t value);
352 
359 MXNET_DLL int MXProfileAdjustCounter(ProfileHandle counter_handle, int64_t value);
360 
368 MXNET_DLL int MXProfileSetMarker(ProfileHandle domain,
369  const char *instant_marker_name,
370  const char *scope);
371 
377 MXNET_DLL int MXSetNumOMPThreads(int thread_num);
378 
384 MXNET_DLL int MXEngineSetBulkSize(int bulk_size, int* prev_bulk_size);
385 
391 MXNET_DLL int MXGetGPUCount(int* out);
392 
398 MXNET_DLL int MXGetVersion(int *out);
399 
400 //-------------------------------------
401 // Part 1: NDArray creation and deletion
402 //-------------------------------------
410 MXNET_DLL int MXNDArrayCreateNone(NDArrayHandle *out);
422 MXNET_DLL int MXNDArrayCreate(const mx_uint *shape,
423  mx_uint ndim,
424  int dev_type,
425  int dev_id,
426  int delay_alloc,
427  NDArrayHandle *out);
428 
441 MXNET_DLL int MXNDArrayCreateEx(const mx_uint *shape,
442  mx_uint ndim,
443  int dev_type,
444  int dev_id,
445  int delay_alloc,
446  int dtype,
447  NDArrayHandle *out);
448 
449 
467 MXNET_DLL int MXNDArrayCreateSparseEx(int storage_type,
468  const mx_uint *shape,
469  mx_uint ndim,
470  int dev_type,
471  int dev_id,
472  int delay_alloc,
473  int dtype,
474  mx_uint num_aux,
475  int *aux_type,
476  mx_uint *aux_ndims,
477  const mx_uint *aux_shape,
478  NDArrayHandle *out);
479 
487 MXNET_DLL int MXNDArrayLoadFromRawBytes(const void *buf,
488  size_t size,
489  NDArrayHandle *out);
497 MXNET_DLL int MXNDArraySaveRawBytes(NDArrayHandle handle,
498  size_t *out_size,
499  const char **out_buf);
508 MXNET_DLL int MXNDArraySave(const char* fname,
509  mx_uint num_args,
510  NDArrayHandle* args,
511  const char** keys);
521 MXNET_DLL int MXNDArrayLoad(const char* fname,
522  mx_uint *out_size,
523  NDArrayHandle** out_arr,
524  mx_uint *out_name_size,
525  const char*** out_names);
526 
541 MXNET_DLL int MXNDArrayLoadFromBuffer(const void *ndarray_buffer,
542  size_t size,
543  mx_uint *out_size,
544  NDArrayHandle** out_arr,
545  mx_uint *out_name_size,
546  const char*** out_names);
547 
559 MXNET_DLL int MXNDArraySyncCopyFromCPU(NDArrayHandle handle,
560  const void *data,
561  size_t size);
573 MXNET_DLL int MXNDArraySyncCopyToCPU(NDArrayHandle handle,
574  void *data,
575  size_t size);
583 MXNET_DLL int MXNDArraySyncCopyFromNDArray(NDArrayHandle handle_dst,
584  const NDArrayHandle handle_src,
585  const int i);
586 
592 MXNET_DLL int MXNDArraySyncCheckFormat(NDArrayHandle handle, const bool full_check);
599 MXNET_DLL int MXNDArrayWaitToRead(NDArrayHandle handle);
606 MXNET_DLL int MXNDArrayWaitToWrite(NDArrayHandle handle);
618 MXNET_DLL int MXNDArrayFree(NDArrayHandle handle);
627 MXNET_DLL int MXNDArraySlice(NDArrayHandle handle,
628  mx_uint slice_begin,
629  mx_uint slice_end,
630  NDArrayHandle *out);
631 
639 MXNET_DLL int MXNDArrayAt(NDArrayHandle handle,
640  mx_uint idx,
641  NDArrayHandle *out);
642 
646 MXNET_DLL int MXNDArrayGetStorageType(NDArrayHandle handle,
647  int *out_storage_type);
648 
657 MXNET_DLL int MXNDArrayReshape(NDArrayHandle handle,
658  int ndim,
659  int *dims,
660  NDArrayHandle *out);
661 
670 MXNET_DLL int MXNDArrayReshape64(NDArrayHandle handle,
671  int ndim,
672  dim_t *dims,
673  bool reverse,
674  NDArrayHandle *out);
682 MXNET_DLL int MXNDArrayGetShape(NDArrayHandle handle,
683  mx_uint *out_dim,
684  const mx_uint **out_pdata);
691 MXNET_DLL int MXNDArrayGetData(NDArrayHandle handle,
692  void **out_pdata);
699 MXNET_DLL int MXNDArrayGetDType(NDArrayHandle handle,
700  int *out_dtype);
701 
709 MXNET_DLL int MXNDArrayGetAuxType(NDArrayHandle handle,
710  mx_uint i,
711  int *out_type);
712 
718 MXNET_DLL int MXNDArrayGetAuxNDArray(NDArrayHandle handle,
719  mx_uint i,
720  NDArrayHandle *out);
721 
727 MXNET_DLL int MXNDArrayGetDataNDArray(NDArrayHandle handle,
728  NDArrayHandle *out);
736 MXNET_DLL int MXNDArrayGetContext(NDArrayHandle handle,
737  int *out_dev_type,
738  int *out_dev_id);
744 MXNET_DLL int MXNDArrayGetGrad(NDArrayHandle handle, NDArrayHandle *out);
750 MXNET_DLL int MXNDArrayDetach(NDArrayHandle handle, NDArrayHandle *out);
757 MXNET_DLL int MXNDArraySetGradState(NDArrayHandle handle, int state);
764 MXNET_DLL int MXNDArrayGetGradState(NDArrayHandle handle, int *out);
765 //--------------------------------
766 // Part 2: functions on NDArray
767 //--------------------------------
775 MXNET_DLL int MXListFunctions(mx_uint *out_size,
776  FunctionHandle **out_array);
783 MXNET_DLL int MXGetFunction(const char *name,
784  FunctionHandle *out);
797 MXNET_DLL int MXFuncGetInfo(FunctionHandle fun,
798  const char **name,
799  const char **description,
800  mx_uint *num_args,
801  const char ***arg_names,
802  const char ***arg_type_infos,
803  const char ***arg_descriptions,
804  const char **return_type DEFAULT(NULL));
815 MXNET_DLL int MXFuncDescribe(FunctionHandle fun,
816  mx_uint *num_use_vars,
817  mx_uint *num_scalars,
818  mx_uint *num_mutate_vars,
819  int *type_mask);
830 MXNET_DLL int MXFuncInvoke(FunctionHandle fun,
831  NDArrayHandle *use_vars,
832  mx_float *scalar_args,
833  NDArrayHandle *mutate_vars);
847 MXNET_DLL int MXFuncInvokeEx(FunctionHandle fun,
848  NDArrayHandle *use_vars,
849  mx_float *scalar_args,
850  NDArrayHandle *mutate_vars,
851  int num_params,
852  char **param_keys,
853  char **param_vals);
866 MXNET_DLL int MXImperativeInvoke(AtomicSymbolCreator creator,
867  int num_inputs,
868  NDArrayHandle *inputs,
869  int *num_outputs,
870  NDArrayHandle **outputs,
871  int num_params,
872  const char **param_keys,
873  const char **param_vals);
887 MXNET_DLL int MXImperativeInvokeEx(AtomicSymbolCreator creator,
888  int num_inputs,
889  NDArrayHandle *inputs,
890  int *num_outputs,
891  NDArrayHandle **outputs,
892  int num_params,
893  const char **param_keys,
894  const char **param_vals,
895  const int **out_stypes);
902 MXNET_DLL int MXAutogradSetIsRecording(int is_recording, int* prev);
909 MXNET_DLL int MXAutogradSetIsTraining(int is_training, int* prev);
915 MXNET_DLL int MXAutogradIsRecording(bool* curr);
921 MXNET_DLL int MXAutogradIsTraining(bool* curr);
928 MXNET_DLL int MXAutogradMarkVariables(mx_uint num_var,
929  NDArrayHandle *var_handles,
930  mx_uint *reqs_array,
931  NDArrayHandle *grad_handles);
938 MXNET_DLL int MXAutogradComputeGradient(mx_uint num_output,
939  NDArrayHandle* output_handles);
948 MXNET_DLL int MXAutogradBackward(mx_uint num_output,
949  NDArrayHandle* output_handles,
950  NDArrayHandle* ograd_handles,
951  int retain_graph);
963 MXNET_DLL int MXAutogradBackwardEx(mx_uint num_output,
964  NDArrayHandle *output_handles,
965  NDArrayHandle *ograd_handles,
966  mx_uint num_variables,
967  NDArrayHandle *var_handles,
968  int retain_graph,
969  int create_graph,
970  int is_train,
971  NDArrayHandle **grad_handles,
972  int **grad_stypes);
973 /*
974  * \brief get the graph constructed by autograd.
975  * \param handle ndarray handle
976  * \param out output symbol handle
977  */
978 MXNET_DLL int MXAutogradGetSymbol(NDArrayHandle handle, SymbolHandle *out);
982 MXNET_DLL int MXCreateCachedOp(SymbolHandle handle, CachedOpHandle *out);
986 MXNET_DLL int MXCreateCachedOpEx(SymbolHandle handle,
987  int num_flags,
988  const char** keys,
989  const char** vals,
990  CachedOpHandle *out);
994 MXNET_DLL int MXFreeCachedOp(CachedOpHandle handle);
998 MXNET_DLL int MXInvokeCachedOp(CachedOpHandle handle,
999  int num_inputs,
1000  NDArrayHandle *inputs,
1001  int *num_outputs,
1002  NDArrayHandle **outputs);
1013 MXNET_DLL int MXInvokeCachedOpEx(CachedOpHandle handle,
1014  int num_inputs,
1015  NDArrayHandle *inputs,
1016  int *num_outputs,
1017  NDArrayHandle **outputs,
1018  const int** out_stypes);
1022 MXNET_DLL int MXInvokeCachedOp(CachedOpHandle handle,
1023  int num_inputs,
1024  NDArrayHandle *inputs,
1025  int *num_outputs,
1026  NDArrayHandle **outputs);
1027 //--------------------------------------------
1028 // Part 3: symbolic configuration generation
1029 //--------------------------------------------
1036 MXNET_DLL int MXListAllOpNames(mx_uint *out_size,
1037  const char ***out_array);
1044 MXNET_DLL int MXSymbolListAtomicSymbolCreators(mx_uint *out_size,
1045  AtomicSymbolCreator **out_array);
1046 
1052 MXNET_DLL int MXSymbolGetAtomicSymbolName(AtomicSymbolCreator creator,
1053  const char **name);
1054 
1061 MXNET_DLL int MXSymbolGetInputSymbols(SymbolHandle sym, SymbolHandle **inputs,
1062  int *input_size);
1063 
1073 MXNET_DLL int MXSymbolCutSubgraph(SymbolHandle sym, SymbolHandle **inputs,
1074  int *input_size);
1075 
1093 MXNET_DLL int MXSymbolGetAtomicSymbolInfo(AtomicSymbolCreator creator,
1094  const char **name,
1095  const char **description,
1096  mx_uint *num_args,
1097  const char ***arg_names,
1098  const char ***arg_type_infos,
1099  const char ***arg_descriptions,
1100  const char **key_var_num_args,
1101  const char **return_type DEFAULT(NULL));
1111 MXNET_DLL int MXSymbolCreateAtomicSymbol(AtomicSymbolCreator creator,
1112  mx_uint num_param,
1113  const char **keys,
1114  const char **vals,
1115  SymbolHandle *out);
1122 MXNET_DLL int MXSymbolCreateVariable(const char *name, SymbolHandle *out);
1130 MXNET_DLL int MXSymbolCreateGroup(mx_uint num_symbols,
1131  SymbolHandle *symbols,
1132  SymbolHandle *out);
1139 MXNET_DLL int MXSymbolCreateFromFile(const char *fname, SymbolHandle *out);
1146 MXNET_DLL int MXSymbolCreateFromJSON(const char *json, SymbolHandle *out);
1153 MXNET_DLL int MXSymbolSaveToFile(SymbolHandle symbol, const char *fname);
1160 MXNET_DLL int MXSymbolSaveToJSON(SymbolHandle symbol, const char **out_json);
1166 MXNET_DLL int MXSymbolFree(SymbolHandle symbol);
1173 MXNET_DLL int MXSymbolCopy(SymbolHandle symbol, SymbolHandle *out);
1180 MXNET_DLL int MXSymbolPrint(SymbolHandle symbol, const char **out_str);
1188 MXNET_DLL int MXSymbolGetName(SymbolHandle symbol,
1189  const char** out,
1190  int *success);
1199 MXNET_DLL int MXSymbolGetAttr(SymbolHandle symbol,
1200  const char* key,
1201  const char** out,
1202  int *success);
1219 MXNET_DLL int MXSymbolSetAttr(SymbolHandle symbol,
1220  const char* key,
1221  const char* value);
1229 MXNET_DLL int MXSymbolListAttr(SymbolHandle symbol,
1230  mx_uint *out_size,
1231  const char*** out);
1239 MXNET_DLL int MXSymbolListAttrShallow(SymbolHandle symbol,
1240  mx_uint *out_size,
1241  const char*** out);
1249 MXNET_DLL int MXSymbolListArguments(SymbolHandle symbol,
1250  mx_uint *out_size,
1251  const char ***out_str_array);
1259 MXNET_DLL int MXSymbolListOutputs(SymbolHandle symbol,
1260  mx_uint *out_size,
1261  const char ***out_str_array);
1262 
1269 MXNET_DLL int MXSymbolGetNumOutputs(SymbolHandle symbol,
1270  mx_uint *output_count);
1271 
1278 MXNET_DLL int MXSymbolGetInternals(SymbolHandle symbol,
1279  SymbolHandle *out);
1286 MXNET_DLL int MXSymbolGetChildren(SymbolHandle symbol,
1287  SymbolHandle *out);
1295 MXNET_DLL int MXSymbolGetOutput(SymbolHandle symbol,
1296  mx_uint index,
1297  SymbolHandle *out);
1298 
1306 MXNET_DLL int MXSymbolListAuxiliaryStates(SymbolHandle symbol,
1307  mx_uint *out_size,
1308  const char ***out_str_array);
1323 MXNET_DLL int MXSymbolCompose(SymbolHandle sym,
1324  const char *name,
1325  mx_uint num_args,
1326  const char** keys,
1327  SymbolHandle* args);
1337 MXNET_DLL int MXSymbolGrad(SymbolHandle sym,
1338  mx_uint num_wrt,
1339  const char** wrt,
1340  SymbolHandle* out);
1363 MXNET_DLL int MXSymbolInferShape(SymbolHandle sym,
1364  mx_uint num_args,
1365  const char** keys,
1366  const mx_uint *arg_ind_ptr,
1367  const mx_uint *arg_shape_data,
1368  mx_uint *in_shape_size,
1369  const mx_uint **in_shape_ndim,
1370  const mx_uint ***in_shape_data,
1371  mx_uint *out_shape_size,
1372  const mx_uint **out_shape_ndim,
1373  const mx_uint ***out_shape_data,
1374  mx_uint *aux_shape_size,
1375  const mx_uint **aux_shape_ndim,
1376  const mx_uint ***aux_shape_data,
1377  int *complete);
1402 MXNET_DLL int MXSymbolInferShapePartial(SymbolHandle sym,
1403  mx_uint num_args,
1404  const char** keys,
1405  const mx_uint *arg_ind_ptr,
1406  const mx_uint *arg_shape_data,
1407  mx_uint *in_shape_size,
1408  const mx_uint **in_shape_ndim,
1409  const mx_uint ***in_shape_data,
1410  mx_uint *out_shape_size,
1411  const mx_uint **out_shape_ndim,
1412  const mx_uint ***out_shape_data,
1413  mx_uint *aux_shape_size,
1414  const mx_uint **aux_shape_ndim,
1415  const mx_uint ***aux_shape_data,
1416  int *complete);
1417 
1436 MXNET_DLL int MXSymbolInferType(SymbolHandle sym,
1437  mx_uint num_args,
1438  const char** keys,
1439  const int *arg_type_data,
1440  mx_uint *in_type_size,
1441  const int **in_type_data,
1442  mx_uint *out_type_size,
1443  const int **out_type_data,
1444  mx_uint *aux_type_size,
1445  const int **aux_type_data,
1446  int *complete);
1447 
1458 MXNET_DLL int MXQuantizeSymbol(SymbolHandle sym_handle,
1459  SymbolHandle *ret_sym_handle,
1460  const mx_uint num_excluded_symbols,
1461  const SymbolHandle *excluded_symbols,
1462  const mx_uint num_offline,
1463  const char **offline_params,
1464  const char *quantized_dtype);
1465 
1475 MXNET_DLL int MXSetCalibTableToQuantizedSymbol(SymbolHandle qsym_handle,
1476  const mx_uint num_layers,
1477  const char** layer_names,
1478  const float* low_quantiles,
1479  const float* high_quantiles,
1480  SymbolHandle* ret_sym_handle);
1481 
1482 //--------------------------------------------
1483 // Part 4: Executor interface
1484 //--------------------------------------------
1490 MXNET_DLL int MXExecutorFree(ExecutorHandle handle);
1497 MXNET_DLL int MXExecutorPrint(ExecutorHandle handle, const char **out_str);
1505 MXNET_DLL int MXExecutorForward(ExecutorHandle handle, int is_train);
1515 MXNET_DLL int MXExecutorBackward(ExecutorHandle handle,
1516  mx_uint len,
1517  NDArrayHandle *head_grads);
1528 MXNET_DLL int MXExecutorBackwardEx(ExecutorHandle handle,
1529  mx_uint len,
1530  NDArrayHandle *head_grads,
1531  int is_train);
1540 MXNET_DLL int MXExecutorOutputs(ExecutorHandle handle,
1541  mx_uint *out_size,
1542  NDArrayHandle **out);
1543 
1559 MXNET_DLL int MXExecutorBind(SymbolHandle symbol_handle,
1560  int dev_type,
1561  int dev_id,
1562  mx_uint len,
1563  NDArrayHandle *in_args,
1564  NDArrayHandle *arg_grad_store,
1565  mx_uint *grad_req_type,
1566  mx_uint aux_states_len,
1567  NDArrayHandle *aux_states,
1568  ExecutorHandle *out);
1590 MXNET_DLL int MXExecutorBindX(SymbolHandle symbol_handle,
1591  int dev_type,
1592  int dev_id,
1593  mx_uint num_map_keys,
1594  const char** map_keys,
1595  const int* map_dev_types,
1596  const int* map_dev_ids,
1597  mx_uint len,
1598  NDArrayHandle *in_args,
1599  NDArrayHandle *arg_grad_store,
1600  mx_uint *grad_req_type,
1601  mx_uint aux_states_len,
1602  NDArrayHandle *aux_states,
1603  ExecutorHandle *out);
1626 MXNET_DLL int MXExecutorBindEX(SymbolHandle symbol_handle,
1627  int dev_type,
1628  int dev_id,
1629  mx_uint num_map_keys,
1630  const char** map_keys,
1631  const int* map_dev_types,
1632  const int* map_dev_ids,
1633  mx_uint len,
1634  NDArrayHandle *in_args,
1635  NDArrayHandle *arg_grad_store,
1636  mx_uint *grad_req_type,
1637  mx_uint aux_states_len,
1638  NDArrayHandle *aux_states,
1639  ExecutorHandle shared_exec,
1640  ExecutorHandle *out);
1641 
1642 MXNET_DLL int MXExecutorSimpleBind(SymbolHandle symbol_handle,
1643  int dev_type,
1644  int dev_id,
1645  const mx_uint num_g2c_keys,
1646  const char** g2c_keys,
1647  const int* g2c_dev_types,
1648  const int* g2c_dev_ids,
1649  const mx_uint provided_grad_req_list_len,
1650  const char** provided_grad_req_names,
1651  const char** provided_grad_req_types,
1652  const mx_uint num_provided_arg_shapes,
1653  const char** provided_arg_shape_names,
1654  const mx_uint* provided_arg_shape_data,
1655  const mx_uint* provided_arg_shape_idx,
1656  const mx_uint num_provided_arg_dtypes,
1657  const char** provided_arg_dtype_names,
1658  const int* provided_arg_dtypes,
1659  const mx_uint num_provided_arg_stypes,
1660  const char** provided_arg_stype_names,
1661  const int* provided_arg_stypes,
1662  const mx_uint num_shared_arg_names,
1663  const char** shared_arg_name_list,
1664  int* shared_buffer_len,
1665  const char** shared_buffer_name_list,
1666  NDArrayHandle* shared_buffer_handle_list,
1667  const char*** updated_shared_buffer_name_list,
1668  NDArrayHandle** updated_shared_buffer_handle_list,
1669  mx_uint* num_in_args,
1670  NDArrayHandle** in_args,
1671  NDArrayHandle** arg_grads,
1672  mx_uint* num_aux_states,
1673  NDArrayHandle** aux_states,
1674  ExecutorHandle shared_exec_handle,
1675  ExecutorHandle* out);
1676 
1698 MXNET_DLL int MXExecutorReshape(int partial_shaping,
1699  int allow_up_sizing,
1700  int dev_type,
1701  int dev_id,
1702  mx_uint num_map_keys,
1703  const char** map_keys,
1704  const int* map_dev_types,
1705  const int* map_dev_ids,
1706  const mx_uint num_provided_arg_shapes,
1707  const char** provided_arg_shape_names,
1708  const mx_uint* provided_arg_shape_data,
1709  const mx_uint* provided_arg_shape_idx,
1710  mx_uint* num_in_args,
1711  NDArrayHandle** in_args,
1712  NDArrayHandle** arg_grads,
1713  mx_uint* num_aux_states,
1714  NDArrayHandle** aux_states,
1715  ExecutorHandle shared_exec,
1716  ExecutorHandle *out);
1720 MXNET_DLL int MXExecutorSetMonitorCallback(ExecutorHandle handle,
1721  ExecutorMonitorCallback callback,
1722  void* callback_handle);
1723 //--------------------------------------------
1724 // Part 5: IO Interface
1725 //--------------------------------------------
1732 MXNET_DLL int MXListDataIters(mx_uint *out_size,
1733  DataIterCreator **out_array);
1744 MXNET_DLL int MXDataIterCreateIter(DataIterCreator handle,
1745  mx_uint num_param,
1746  const char **keys,
1747  const char **vals,
1748  DataIterHandle *out);
1760 MXNET_DLL int MXDataIterGetIterInfo(DataIterCreator creator,
1761  const char **name,
1762  const char **description,
1763  mx_uint *num_args,
1764  const char ***arg_names,
1765  const char ***arg_type_infos,
1766  const char ***arg_descriptions);
1772 MXNET_DLL int MXDataIterFree(DataIterHandle handle);
1779 MXNET_DLL int MXDataIterNext(DataIterHandle handle,
1780  int *out);
1786 MXNET_DLL int MXDataIterBeforeFirst(DataIterHandle handle);
1787 
1794 MXNET_DLL int MXDataIterGetData(DataIterHandle handle,
1795  NDArrayHandle *out);
1803 MXNET_DLL int MXDataIterGetIndex(DataIterHandle handle,
1804  uint64_t **out_index,
1805  uint64_t *out_size);
1812 MXNET_DLL int MXDataIterGetPadNum(DataIterHandle handle,
1813  int *pad);
1814 
1821 MXNET_DLL int MXDataIterGetLabel(DataIterHandle handle,
1822  NDArrayHandle *out);
1823 //--------------------------------------------
1824 // Part 6: basic KVStore interface
1825 //--------------------------------------------
1832 MXNET_DLL int MXInitPSEnv(mx_uint num_vars,
1833  const char **keys,
1834  const char **vals);
1835 
1836 
1843 MXNET_DLL int MXKVStoreCreate(const char *type,
1844  KVStoreHandle *out);
1845 
1853 MXNET_DLL int MXKVStoreSetGradientCompression(KVStoreHandle handle,
1854  mx_uint num_params,
1855  const char** keys,
1856  const char** vals);
1857 
1863 MXNET_DLL int MXKVStoreFree(KVStoreHandle handle);
1872 MXNET_DLL int MXKVStoreInit(KVStoreHandle handle,
1873  mx_uint num,
1874  const int* keys,
1875  NDArrayHandle* vals);
1876 
1885 MXNET_DLL int MXKVStoreInitEx(KVStoreHandle handle,
1886  mx_uint num,
1887  const char** keys,
1888  NDArrayHandle* vals);
1889 
1899 MXNET_DLL int MXKVStorePush(KVStoreHandle handle,
1900  mx_uint num,
1901  const int* keys,
1902  NDArrayHandle* vals,
1903  int priority);
1913 MXNET_DLL int MXKVStorePushEx(KVStoreHandle handle,
1914  mx_uint num,
1915  const char** keys,
1916  NDArrayHandle* vals,
1917  int priority);
1928 MXNET_DLL int MXKVStorePullWithSparse(KVStoreHandle handle,
1929  mx_uint num,
1930  const int* keys,
1931  NDArrayHandle* vals,
1932  int priority,
1933  bool ignore_sparse);
1944 MXNET_DLL int MXKVStorePullWithSparseEx(KVStoreHandle handle,
1945  mx_uint num,
1946  const char** keys,
1947  NDArrayHandle* vals,
1948  int priority,
1949  bool ignore_sparse);
1959 MXNET_DLL int MXKVStorePull(KVStoreHandle handle,
1960  mx_uint num,
1961  const int* keys,
1962  NDArrayHandle* vals,
1963  int priority);
1973 MXNET_DLL int MXKVStorePullEx(KVStoreHandle handle,
1974  mx_uint num,
1975  const char** keys,
1976  NDArrayHandle* vals,
1977  int priority);
1978 
1991 MXNET_DLL int MXKVStorePullRowSparse(KVStoreHandle handle,
1992  mx_uint num,
1993  const int* keys,
1994  NDArrayHandle* vals,
1995  const NDArrayHandle* row_ids,
1996  int priority);
2009 MXNET_DLL int MXKVStorePullRowSparseEx(KVStoreHandle handle,
2010  mx_uint num,
2011  const char** keys,
2012  NDArrayHandle* vals,
2013  const NDArrayHandle* row_ids,
2014  int priority);
2015 
2024 typedef void (MXKVStoreUpdater)(int key,
2025  NDArrayHandle recv,
2026  NDArrayHandle local,
2027  void *handle);
2036 typedef void (MXKVStoreStrUpdater)(const char* key,
2037  NDArrayHandle recv,
2038  NDArrayHandle local,
2039  void *handle);
2047 MXNET_DLL int MXKVStoreSetUpdater(KVStoreHandle handle,
2048  MXKVStoreUpdater updater,
2049  void *updater_handle);
2058 MXNET_DLL int MXKVStoreSetUpdaterEx(KVStoreHandle handle,
2059  MXKVStoreUpdater updater,
2060  MXKVStoreStrUpdater str_updater,
2061  void *updater_handle);
2068 MXNET_DLL int MXKVStoreGetType(KVStoreHandle handle,
2069  const char** type);
2070 //--------------------------------------------
2071 // Part 6: advanced KVStore for multi-machines
2072 //--------------------------------------------
2073 
2081 MXNET_DLL int MXKVStoreGetRank(KVStoreHandle handle,
2082  int *ret);
2083 
2093 MXNET_DLL int MXKVStoreGetGroupSize(KVStoreHandle handle,
2094  int *ret);
2095 
2101 MXNET_DLL int MXKVStoreIsWorkerNode(int *ret);
2102 
2103 
2109 MXNET_DLL int MXKVStoreIsServerNode(int *ret);
2110 
2111 
2117 MXNET_DLL int MXKVStoreIsSchedulerNode(int *ret);
2118 
2125 MXNET_DLL int MXKVStoreBarrier(KVStoreHandle handle);
2126 
2134 MXNET_DLL int MXKVStoreSetBarrierBeforeExit(KVStoreHandle handle,
2135  const int barrier_before_exit);
2136 
2143 typedef void (MXKVStoreServerController)(int head,
2144  const char *body,
2145  void *controller_handle);
2146 
2155 MXNET_DLL int MXKVStoreRunServer(KVStoreHandle handle,
2156  MXKVStoreServerController controller,
2157  void *controller_handle);
2158 
2167 MXNET_DLL int MXKVStoreSendCommmandToServers(KVStoreHandle handle,
2168  int cmd_id,
2169  const char* cmd_body);
2170 
2181 MXNET_DLL int MXKVStoreGetNumDeadNode(KVStoreHandle handle,
2182  const int node_id,
2183  int *number,
2184  const int timeout_sec DEFAULT(60));
2185 
2192 MXNET_DLL int MXRecordIOWriterCreate(const char *uri, RecordIOHandle *out);
2193 
2199 MXNET_DLL int MXRecordIOWriterFree(RecordIOHandle handle);
2200 
2208 MXNET_DLL int MXRecordIOWriterWriteRecord(RecordIOHandle handle,
2209  const char *buf, size_t size);
2210 
2217 MXNET_DLL int MXRecordIOWriterTell(RecordIOHandle handle, size_t *pos);
2218 
2225 MXNET_DLL int MXRecordIOReaderCreate(const char *uri, RecordIOHandle *out);
2226 
2232 MXNET_DLL int MXRecordIOReaderFree(RecordIOHandle handle);
2233 
2241 MXNET_DLL int MXRecordIOReaderReadRecord(RecordIOHandle handle,
2242  char const **buf, size_t *size);
2243 
2250 MXNET_DLL int MXRecordIOReaderSeek(RecordIOHandle handle, size_t pos);
2251 
2258 MXNET_DLL int MXRecordIOReaderTell(RecordIOHandle handle, size_t *pos);
2259 
2263 MXNET_DLL int MXRtcCreate(char* name, mx_uint num_input, mx_uint num_output,
2264  char** input_names, char** output_names,
2265  NDArrayHandle* inputs, NDArrayHandle* outputs,
2266  char* kernel, RtcHandle *out);
2267 
2271 MXNET_DLL int MXRtcPush(RtcHandle handle, mx_uint num_input, mx_uint num_output,
2272  NDArrayHandle* inputs, NDArrayHandle* outputs,
2273  mx_uint gridDimX,
2274  mx_uint gridDimY,
2275  mx_uint gridDimZ,
2276  mx_uint blockDimX,
2277  mx_uint blockDimY,
2278  mx_uint blockDimZ);
2279 
2283 MXNET_DLL int MXRtcFree(RtcHandle handle);
2284 /*
2285  * \brief register custom operators from frontend.
2286  * \param op_type name of custom op
2287  * \param creator
2288  */
2289 MXNET_DLL int MXCustomOpRegister(const char* op_type, CustomOpPropCreator creator);
2290 /*
2291  * \brief record custom function for backward later.
2292  * \param num_inputs number of input NDArrays.
2293  * \param inputs handle to input NDArrays.
2294  * \param num_outputs number of output NDArrays.
2295  * \param outputs handle to output NDArrays.
2296  * \param callbacks callbacks for backward function.
2297  */
2298 MXNET_DLL int MXCustomFunctionRecord(int num_inputs, NDArrayHandle *inputs,
2299  int num_outputs, NDArrayHandle *outputs,
2300  struct MXCallbackList *callbacks);
2301 /*
2302  * \brief create cuda rtc module
2303  * \param source cuda source code
2304  * \param num_options number of compiler flags
2305  * \param options compiler flags
2306  * \param num_exports number of exported function names
2307  * \param exported function names
2308  * \param out handle to created module
2309  */
2310 MXNET_DLL int MXRtcCudaModuleCreate(const char* source, int num_options,
2311  const char** options, int num_exports,
2312  const char** exports, CudaModuleHandle *out);
2313 /*
2314  * \brief delete cuda rtc module
2315  * \param handle handle to cuda module
2316  */
2317 MXNET_DLL int MXRtcCudaModuleFree(CudaModuleHandle handle);
2318 /*
2319  * \brief get kernel from module
2320  * \param handle handle to cuda module
2321  * \param name name of kernel function
2322  * \param num_args number of arguments
2323  * \param is_ndarray whether argument is ndarray
2324  * \param is_const whether argument is constant
2325  * \param arg_types data type of arguments
2326  * \param out created kernel
2327  */
2328 MXNET_DLL int MXRtcCudaKernelCreate(CudaModuleHandle handle, const char* name,
2329  int num_args, int* is_ndarray, int* is_const,
2330  int* arg_types, CudaKernelHandle *out);
2331 /*
2332  * \brief delete kernel
2333  * \param handle handle to previously created kernel
2334  */
2335 MXNET_DLL int MXRtcCudaKernelFree(CudaKernelHandle handle);
2336 /*
2337  * \brief launch cuda kernel
2338  * \param handle handle to kernel
2339  * \param dev_id (GPU) device id
2340  * \param args pointer to arguments
2341  * \param grid_dim_x grid dimension x
2342  * \param grid_dim_y grid dimension y
2343  * \param grid_dim_z grid dimension z
2344  * \param block_dim_x block dimension x
2345  * \param block_dim_y block dimension y
2346  * \param block_dim_z block dimension z
2347  * \param shared_mem size of dynamically allocated shared memory
2348  */
2349 MXNET_DLL int MXRtcCudaKernelCall(CudaKernelHandle handle, int dev_id, void** args,
2350  mx_uint grid_dim_x, mx_uint grid_dim_y,
2351  mx_uint grid_dim_z, mx_uint block_dim_x,
2352  mx_uint block_dim_y, mx_uint block_dim_z,
2353  mx_uint shared_mem);
2360 MXNET_DLL int MXNDArrayGetSharedMemHandle(NDArrayHandle handle, int* shared_pid,
2361  int* shared_id);
2371 MXNET_DLL int MXNDArrayCreateFromSharedMem(int shared_pid, int shared_id, const mx_uint *shape,
2372  mx_uint ndim, int dtype, NDArrayHandle *out);
2373 
2374 
2375 #ifdef __cplusplus
2376 }
2377 #endif // __cplusplus
2378 
2379 #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:193
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 MXNDArrayCreateFromSharedMem(int shared_pid, int shared_id, const mx_uint *shape, mx_uint ndim, int dtype, NDArrayHandle *out)
Reconstruct NDArray from shared memory handle.
MXNET_DLL int MXNDArrayGetAuxType(NDArrayHandle handle, mx_uint i, int *out_type)
get the type of the ith aux data in NDArray
MXNET_DLL int MXGetGPUCount(int *out)
Get the number of GPUs.
MXNET_DLL int MXKVStoreSetUpdater(KVStoreHandle handle, MXKVStoreUpdater updater, void *updater_handle)
register a push updater
MXNET_DLL int MXKVStoreBarrier(KVStoreHandle handle)
global barrier among all worker machines
MXNET_DLL int MXSymbolGetNumOutputs(SymbolHandle symbol, mx_uint *output_count)
Get number of outputs of the symbol.
void * DataIterHandle
handle to a DataIterator
Definition: c_api.h:83
MXNET_DLL int MXSymbolListAtomicSymbolCreators(mx_uint *out_size, AtomicSymbolCreator **out_array)
list all the available AtomicSymbolEntry
Definition: c_api.h:141
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 MXProfileSetCounter(ProfileHandle counter_handle, uint64_t value)
Set a counter, given its handle.
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:126
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:151
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 MXSetProfilerConfig(int num_params, const char *const *keys, const char *const *vals)
Set up configuration of profiler.
void(* list_arguments)(char ***, void *)
Definition: c_api.h:106
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 MXProfileCreateEvent(const char *event_name, ProfileHandle *out)
Create profile event.
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:124
MXNET_DLL int MXKVStorePullRowSparse(KVStoreHandle handle, mx_uint num, const int *keys, NDArrayHandle *vals, const NDArrayHandle *row_ids, int priority)
pull a list of (key, value) pairs from the kvstore, where each key is an integer. The NDArray pulled ...
MXNET_DLL int MXDumpProfile(int finished)
Save profile and stop profiler.
MXNET_DLL int MXDataIterFree(DataIterHandle handle)
Free the handle to the IO module.
MXNET_DLL int MXKVStoreSetUpdaterEx(KVStoreHandle handle, MXKVStoreUpdater updater, MXKVStoreStrUpdater str_updater, void *updater_handle)
register a push updater with int keys and one with string keys
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:87
CustomOpCallbacks
Definition: c_api.h:140
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 MXProfileCreateTask(ProfileHandle domain, const char *task_name, ProfileHandle *out)
Create profile task.
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:79
CustomFunctionCallbacks
Definition: c_api.h:185
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:77
MXNET_DLL int MXProfilePause(int paused)
Pause profiler tuning collection.
void * p_backward
Definition: c_api.h:109
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:146
int(* CustomOpInferTypeFunc)(int, int *, void *)
Definition: c_api.h:172
MXNET_DLL int MXKVStoreIsSchedulerNode(int *ret)
return whether or not this process is a scheduler node.
MXNET_DLL int MXInvokeCachedOpEx(CachedOpHandle handle, int num_inputs, NDArrayHandle *inputs, int *num_outputs, NDArrayHandle **outputs, const int **out_stypes)
invoke a cached op
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:37
MXNET_DLL int MXNDArrayLoadFromBuffer(const void *ndarray_buffer, size_t size, mx_uint *out_size, NDArrayHandle **out_arr, mx_uint *out_name_size, const char ***out_names)
Load list / dictionary of narrays from file content loaded into memory. This will load a list of ndar...
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 MXProfileDestroyHandle(ProfileHandle frame_handle)
Destroy a frame.
MXNET_DLL int MXNDArrayReshape64(NDArrayHandle handle, int ndim, dim_t *dims, bool reverse, NDArrayHandle *out)
Reshape the NDArray.
MXNET_DLL int MXSymbolListAttr(SymbolHandle symbol, mx_uint *out_size, const char ***out)
Get all attributes from symbol, including all descendents.
MXNET_DLL int MXRtcCudaKernelFree(CudaKernelHandle handle)
MXNET_DLL int MXExecutorReshape(int partial_shaping, int allow_up_sizing, 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, 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, mx_uint *num_in_args, NDArrayHandle **in_args, NDArrayHandle **arg_grads, mx_uint *num_aux_states, NDArrayHandle **aux_states, ExecutorHandle shared_exec, ExecutorHandle *out)
Return a new executor with the same symbol and shared memory, but different input/output shapes...
MXNET_DLL int MXNDArrayAt(NDArrayHandle handle, mx_uint idx, NDArrayHandle *out)
Index the NDArray along axis 0.
MXNET_DLL int MXNDArrayGetAuxNDArray(NDArrayHandle handle, mx_uint i, NDArrayHandle *out)
Get a deep copy of the ith aux data blob in the form of an NDArray of default storage type...
MXNET_DLL int MXProfileCreateCounter(ProfileHandle domain, const char *counter_name, ProfileHandle *out)
Create profile counter.
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 MXRtcCudaKernelCreate(CudaModuleHandle handle, const char *name, int num_args, int *is_ndarray, int *is_const, int *arg_types, CudaKernelHandle *out)
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.
void( MXKVStoreStrUpdater)(const char *key, NDArrayHandle recv, NDArrayHandle local, void *handle)
user-defined updater for the kvstore with string keys It&#39;s this updater&#39;s responsibility to delete re...
Definition: c_api.h:2036
Definition: c_api.h:115
MXNET_DLL int MXNDArrayCreateSparseEx(int storage_type, const mx_uint *shape, mx_uint ndim, int dev_type, int dev_id, int delay_alloc, int dtype, mx_uint num_aux, int *aux_type, mx_uint *aux_ndims, const mx_uint *aux_shape, NDArrayHandle *out)
create an empty sparse NDArray with specified shape and data type
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_provided_arg_stypes, const char **provided_arg_stype_names, const int *provided_arg_stypes, 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)
void(* ExecutorMonitorCallback)(const char *, NDArrayHandle, void *)
Definition: c_api.h:97
void * p_forward
Definition: c_api.h:108
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 MXEngineSetBulkSize(int bulk_size, int *prev_bulk_size)
set bulk execution limit
int(* CustomOpBackwardInferStorageTypeFunc)(int, int *, int *, void *)
Definition: c_api.h:168
void * p_list_arguments
Definition: c_api.h:112
MXNET_DLL int MXKVStoreCreate(const char *type, KVStoreHandle *out)
Create a kvstore.
int(* CustomOpDelFunc)(void *)
Definition: c_api.h:163
void * p_declare_backward_dependency
Definition: c_api.h:129
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:128
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:75
MXNET_DLL int MXProfileCreateDomain(const char *domain, ProfileHandle *out)
Create profiling domain.
void * CudaModuleHandle
handle to rtc cuda module
Definition: c_api.h:91
MXNET_DLL int MXSymbolCopy(SymbolHandle symbol, SymbolHandle *out)
Copy the symbol to another handle.
MXNET_DLL int MXGetVersion(int *out)
get the MXNet library version as an integer
int(** callbacks)(void)
Definition: c_api.h:136
void * CachedOpHandle
handle to cached operator
Definition: c_api.h:73
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 MXProfileSetMarker(ProfileHandle domain, const char *instant_marker_name, const char *scope)
Mark a single instant in time.
MXNET_DLL int MXNDArrayGetShape(NDArrayHandle handle, mx_uint *out_dim, const mx_uint **out_pdata)
get the shape of the array
MXNET_DLL int MXCreateCachedOpEx(SymbolHandle handle, int num_flags, const char **keys, const char **vals, CachedOpHandle *out)
create cached operator
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 MXNDArrayGetSharedMemHandle(NDArrayHandle handle, int *shared_pid, int *shared_id)
Get shared memory handle from NDArray.
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 MXRtcCudaModuleCreate(const char *source, int num_options, const char **options, int num_exports, const char **exports, CudaModuleHandle *out)
int num_callbacks
Definition: c_api.h:135
MXNET_DLL int MXRandomSeed(int seed)
Seed all global random number generators in mxnet.
Definition: c_api.h:155
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
MXNET_DLL int MXAutogradBackwardEx(mx_uint num_output, NDArrayHandle *output_handles, NDArrayHandle *ograd_handles, mx_uint num_variables, NDArrayHandle *var_handles, int retain_graph, int create_graph, int is_train, NDArrayHandle **grad_handles, int **grad_stypes)
compute the gradient of outputs w.r.t variabels
void(* forward)(int, float **, int *, unsigned **, int *, void *)
Definition: c_api.h:102
int(* MXGenericCallback)(void)
Definition: c_api.h:132
MXNET_DLL int MXSetCalibTableToQuantizedSymbol(SymbolHandle qsym_handle, const mx_uint num_layers, const char **layer_names, const float *low_quantiles, const float *high_quantiles, SymbolHandle *ret_sym_handle)
Set calibration table to node attributes in the sym.
MXNET_DLL int MXSymbolGetInputSymbols(SymbolHandle sym, SymbolHandle **inputs, int *input_size)
Get the input symbols of the graph.
Definition: c_api.h:186
MXNET_DLL int MXSymbolGetInternals(SymbolHandle symbol, SymbolHandle *out)
Get a symbol that contains all the internals.
MXNET_DLL int MXNDArrayGetDataNDArray(NDArrayHandle handle, NDArrayHandle *out)
Get a deep copy of the data blob in the form of an NDArray of default storage type. This function blocks. Do not use it in performance critical code.
MXNET_DLL int MXInitPSEnv(mx_uint num_vars, const char **keys, const char **vals)
Initialized ps-lite environment variables.
MXNET_DLL int MXRandomSeedContext(int seed, int dev_type, int dev_id)
Seed the global random number generator of the given device.
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:2143
Definition: c_api.h:142
void * KVStoreHandle
handle to KVStore
Definition: c_api.h:85
void * NDArrayHandle
handle to NDArray
Definition: c_api.h:67
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:127
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:148
int(* CustomOpCreateFunc)(const char *, int, unsigned **, const int *, const int *, struct MXCallbackList *, void *)
Definition: c_api.h:176
int(* CustomOpFBFunc)(int, void **, int *, const int *, const int, void *)
Definition: c_api.h:160
MXNET_DLL int MXNDArraySyncCopyFromNDArray(NDArrayHandle handle_dst, const NDArrayHandle handle_src, const int i)
Copy src.data() to dst.data() if i = -1, else dst.aux_data(i) if i >= 0 This function blocks...
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 MXNDArrayGetStorageType(NDArrayHandle handle, int *out_storage_type)
get the storage type of the array
MXNET_DLL int MXRecordIOWriterCreate(const char *uri, RecordIOHandle *out)
Create a RecordIO writer object.
void * p_infer_shape
Definition: c_api.h:110
MXNET_DLL int MXKVStorePullRowSparseEx(KVStoreHandle handle, mx_uint num, const char **keys, NDArrayHandle *vals, const NDArrayHandle *row_ids, int priority)
pull a list of (key, value) pairs from the kvstore, where each key is a string. The NDArray pulled ba...
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 MXProfileDurationStop(ProfileHandle duration_handle)
Stop timing the duration of a profile duration object such as an event, task or frame.
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}.
MXNET_DLL int MXProfileAdjustCounter(ProfileHandle counter_handle, int64_t value)
Adjust a counter by the given amount, given its handle.
unsigned int mx_uint
manually define unsigned int
Definition: c_api.h:58
Definition: c_api.h:143
MXNET_DLL int MXAggregateProfileStatsPrint(const char **out_str, int reset)
Print aggregate stats to the a string.
MXNET_DLL int MXRecordIOWriterTell(RecordIOHandle handle, size_t *pos)
Get the current writer pointer position.
Definition: c_api.h:154
MXNET_DLL int MXRecordIOReaderTell(RecordIOHandle handle, size_t *pos)
Get the current writer pointer position.
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.
MXNET_DLL int MXKVStoreSetGradientCompression(KVStoreHandle handle, mx_uint num_params, const char **keys, const char **vals)
Set parameters to use low-bit compressed gradients.
void * p_backward
Definition: c_api.h:125
Definition: c_api.h:147
MXNET_DLL int MXSymbolCutSubgraph(SymbolHandle sym, SymbolHandle **inputs, int *input_size)
Cut a subgraph whose nodes are marked with a subgraph attribute. The input graph will be modified...
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 MXKVStorePullWithSparse(KVStoreHandle handle, mx_uint num, const int *keys, NDArrayHandle *vals, int priority, bool ignore_sparse)
pull a list of (key, value) pairs from the kvstore
MXNET_DLL int MXAutogradIsRecording(bool *curr)
get whether autograd recording is on
Definition: c_api.h:187
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 MXCustomFunctionRecord(int num_inputs, NDArrayHandle *inputs, int num_outputs, NDArrayHandle *outputs, struct MXCallbackList *callbacks)
int64_t dim_t
data type to store dim size
Definition: c_api.h:62
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:180
MXNET_DLL int MXSymbolCreateVariable(const char *name, SymbolHandle *out)
Create a Variable Symbol.
MXNET_DLL int MXProfileDurationStart(ProfileHandle duration_handle)
Start timing the duration of a profile duration object such as an event, task or frame.
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:190
MXNET_DLL int MXQuantizeSymbol(SymbolHandle sym_handle, SymbolHandle *ret_sym_handle, const mx_uint num_excluded_symbols, const SymbolHandle *excluded_symbols, const mx_uint num_offline, const char **offline_params, const char *quantized_dtype)
Convert a symbol into a quantized symbol where FP32 operators are replaced with INT8.
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
void * CudaKernelHandle
handle to rtc cuda kernel
Definition: c_api.h:93
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:60
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:54
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 int MXNDArraySyncCheckFormat(NDArrayHandle handle, const bool full_check)
check whether the NDArray format is valid
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:137
void * AtomicSymbolCreator
handle to a function that takes param and creates symbol
Definition: c_api.h:71
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:104
void * ProfileHandle
handle to a Profile object (domain, duration, counter, etc.)
Definition: c_api.h:95
MXNET_DLL int MXKVStorePullWithSparseEx(KVStoreHandle handle, mx_uint num, const char **keys, NDArrayHandle *vals, int priority, bool ignore_sparse)
pull a list of (key, value) pairs from the kvstore, where each key is a string
void * p_list_outputs
Definition: c_api.h:111
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:2024
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:81
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:89
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:173
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:149
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:103
int(* CustomOpInferStorageTypeFunc)(int, int *, void *)
Definition: c_api.h:167
Definition: c_api.h:134
MXNET_DLL int MXImperativeInvokeEx(AtomicSymbolCreator creator, int num_inputs, NDArrayHandle *inputs, int *num_outputs, NDArrayHandle **outputs, int num_params, const char **param_keys, const char **param_vals, const int **out_stypes)
invoke a nnvm op and imperative function
MXNET_DLL int MXRtcCudaModuleFree(CudaModuleHandle handle)
const void * FunctionHandle
handle to a mxnet narray function that changes NDArray
Definition: c_api.h:69
Definition: c_api.h:101
MXNET_DLL int MXRecordIOReaderReadRecord(RecordIOHandle handle, char const **buf, size_t *size)
Write a record to a RecordIO object.
MXNET_DLL int MXProfileCreateFrame(ProfileHandle domain, const char *frame_name, ProfileHandle *out)
Create profile frame.
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:105
Definition: c_api.h:150
Definition: c_api.h:153
MXNET_DLL int MXRtcCudaKernelCall(CudaKernelHandle handle, int dev_id, void **args, mx_uint grid_dim_x, mx_uint grid_dim_y, mx_uint grid_dim_z, mx_uint block_dim_x, mx_uint block_dim_y, mx_uint block_dim_z, mx_uint shared_mem)
int(* CustomOpInferShapeFunc)(int, int *, unsigned **, void *)
Definition: c_api.h:165
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:164
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