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 uint32_t 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;
97 typedef void *DLManagedTensorHandle;
99 typedef const void *ContextHandle;
101 typedef const void *EngineFnPropertyHandle;
103 typedef void *EngineVarHandle;
104 
106 typedef void (*EngineAsyncFunc)(void*, void*, void*);
108 typedef void (*EngineSyncFunc)(void*, void*);
110 typedef void (*EngineFuncParamDeleter)(void*);
111 typedef void (*ExecutorMonitorCallback)(const char*,
113  void*);
115 typedef void (*CachedOpMonitorCallback)(const char*,
116  const char*,
117  NDArrayHandle);
118 
119 
120 struct NativeOpInfo {
121  void (*forward)(int, float**, int*, unsigned**, int*, void*);
122  void (*backward)(int, float**, int*, unsigned**, int*, void*);
123  void (*infer_shape)(int, int*, unsigned**, void*);
124  void (*list_outputs)(char***, void*);
125  void (*list_arguments)(char***, void*);
126  // all functions also pass a payload void* pointer
127  void* p_forward;
128  void* p_backward;
132 };
133 
135  bool (*forward)(int, void**, int*, void*);
136  bool (*backward)(int, void**, int*, void*);
137  bool (*infer_shape)(int, int*, unsigned**, void*);
138  bool (*list_outputs)(char***, void*);
139  bool (*list_arguments)(char***, void*);
140  bool (*declare_backward_dependency)(const int*, const int*, const int*,
141  int*, int**, void*);
142  // all functions also pass a payload void* pointer
143  void* p_forward;
144  void* p_backward;
149 };
150 
151 typedef int (*MXGenericCallback)(void);
152 
155  int (**callbacks)(void);
156  void **contexts;
157 };
158 
159 struct LibFeature {
160  const char* name;
161  bool enabled;
162 };
163 
168 };
169 
181 };
182 
183 
184 typedef int (*CustomOpFBFunc)(int /*size*/, void** /*ptrs*/, int* /*tags*/,
185  const int* /*reqs*/, const int /*is_train*/,
186  void* /*state*/);
187 typedef int (*CustomOpDelFunc)(void* /*state*/);
188 typedef int (*CustomOpListFunc)(char*** /*args*/, void* /*state*/);
189 typedef int (*CustomOpInferShapeFunc)(int /*num_input*/, int* /*ndims*/,
190  int** /*shapes*/, void* /*state*/);
191 typedef int (*CustomOpInferStorageTypeFunc)(int /*num_input*/, int* /*stypes*/, void* /*state*/);
192 typedef int (*CustomOpBackwardInferStorageTypeFunc)(int /*num_input*/,
193  int * /*stypes*/,
194  int * /*tags*/,
195  void * /*state*/);
196 typedef int (*CustomOpInferTypeFunc)(int /*num_input*/, int* /*types*/, void* /*state*/);
197 typedef int (*CustomOpBwdDepFunc)(const int* /*out_grad*/, const int* /*in_data*/,
198  const int* /*out_data*/, int* /*num_deps*/,
199  int** /*rdeps*/, void* /*state*/);
200 typedef int (*CustomOpCreateFunc)(const char* /*ctx*/, int /*num_inputs*/,
201  unsigned** /*shapes*/, const int* /*ndims*/,
202  const int* /*dtypes*/, struct MXCallbackList* /*ret*/,
203  void* /*state*/);
204 typedef int (*CustomOpPropCreator)(const char* /*op_type*/, const int /*num_kwargs*/,
205  const char** /*keys*/, const char** /*values*/,
206  struct MXCallbackList* /*ret*/);
207 
208 
212 };
213 
214 typedef int (*CustomFunctionBwdFunc)(int /*num_ograds*/, int /*num_igrads*/, void** /*ptrs*/,
215  const int* /*reqs*/, const int /*is_train*/,
216  void* /*state*/);
217 typedef int (*CustomFunctionDelFunc)(void* /*state*/);
218 
228 MXNET_DLL const char *MXGetLastError();
229 
230 //-------------------------------------
231 // Part 0: Global State setups
232 //-------------------------------------
233 
239 MXNET_DLL int MXLoadLib(const char *path);
240 
247 MXNET_DLL int MXLibInfoFeatures(const struct LibFeature **libFeature, size_t *size);
248 
254 MXNET_DLL int MXRandomSeed(int seed);
255 
261 MXNET_DLL int MXRandomSeedContext(int seed, int dev_type, int dev_id);
262 
271 
280 MXNET_DLL int MXSetProcessProfilerConfig(int num_params, const char* const* keys,
281  const char* const* vals,
282  KVStoreHandle kvstoreHandle);
283 
291 MXNET_DLL int MXSetProfilerConfig(int num_params, const char* const* keys, const char* const* vals);
292 
304 MXNET_DLL int MXSetProcessProfilerState(int state, int profile_process,
305  KVStoreHandle kvStoreHandle);
306 
314 MXNET_DLL int MXSetProfilerState(int state);
315 
325 MXNET_DLL int MXDumpProcessProfile(int finished, int profile_process, KVStoreHandle kvStoreHandle);
326 
327 
333 MXNET_DLL int MXDumpProfile(int finished);
334 
335 
343 MXNET_DLL int MXAggregateProfileStatsPrint(const char **out_str, int reset);
344 
356 MXNET_DLL int MXAggregateProfileStatsPrintEx(const char **out_str, int reset, int format,
357  int sort_by, int ascending);
358 
367 MXNET_DLL int MXProcessProfilePause(int paused, int profile_process, KVStoreHandle kvStoreHandle);
368 
375 MXNET_DLL int MXProfilePause(int paused);
376 
383 MXNET_DLL int MXProfileCreateDomain(const char *domain, ProfileHandle *out);
384 
392 MXNET_DLL int MXProfileCreateTask(ProfileHandle domain,
393  const char *task_name,
394  ProfileHandle *out);
395 
403 MXNET_DLL int MXProfileCreateFrame(ProfileHandle domain,
404  const char *frame_name,
405  ProfileHandle *out);
406 
413 MXNET_DLL int MXProfileCreateEvent(const char *event_name, ProfileHandle *out);
414 
422 MXNET_DLL int MXProfileCreateCounter(ProfileHandle domain,
423  const char *counter_name,
424  ProfileHandle *out);
425 
431 MXNET_DLL int MXProfileDestroyHandle(ProfileHandle frame_handle);
432 
438 MXNET_DLL int MXProfileDurationStart(ProfileHandle duration_handle);
439 
445 MXNET_DLL int MXProfileDurationStop(ProfileHandle duration_handle);
446 
453 MXNET_DLL int MXProfileSetCounter(ProfileHandle counter_handle, uint64_t value);
454 
461 MXNET_DLL int MXProfileAdjustCounter(ProfileHandle counter_handle, int64_t value);
462 
470 MXNET_DLL int MXProfileSetMarker(ProfileHandle domain,
471  const char *instant_marker_name,
472  const char *scope);
473 
479 MXNET_DLL int MXSetNumOMPThreads(int thread_num);
480 
486 MXNET_DLL int MXEngineSetBulkSize(int bulk_size, int* prev_bulk_size);
487 
493 MXNET_DLL int MXGetGPUCount(int* out);
494 
503 MXNET_DLL int MXGetGPUMemoryInformation(int dev, int *free_mem, int *total_mem);
504 
512 MXNET_DLL int MXGetGPUMemoryInformation64(int dev, uint64_t *free_mem, uint64_t *total_mem);
513 
519 MXNET_DLL int MXGetVersion(int *out);
520 
526 #if MXNET_USE_TVM_OP
527 MXNET_DLL int MXLoadTVMOp(const char *libpath);
528 
529 struct OtherOptionEntity {
530  int val;
531 };
532 
533 struct OtherOptionSpace {
534  OtherOptionEntity* entities;
535  int entities_size;
536 };
537 
538 struct ConfigSpace {
539  int entity_map_size;
540  char** entity_map_key;
541  OtherOptionEntity* entity_map_val;
542  int space_map_size;
543  char** space_map_key;
544  OtherOptionSpace* space_map_val;
545 };
546 
547 typedef struct ConfigSpaces {
548  int spaces_size;
549  char** spaces_key;
550  ConfigSpace* spaces_val;
551 } ConfigSpaces;
552 
553 MXNET_DLL int MXLoadTVMConfig(ConfigSpaces config);
554 #endif // MXNET_USE_TVM_OP
555 
556 
557 //-------------------------------------
558 // Part 1: NDArray creation and deletion
559 //-------------------------------------
567 MXNET_DLL int MXNDArrayCreateNone(NDArrayHandle *out);
579 MXNET_DLL int MXNDArrayCreate(const uint32_t *shape,
580  uint32_t ndim,
581  int dev_type,
582  int dev_id,
583  int delay_alloc,
584  NDArrayHandle *out);
585 
598 MXNET_DLL int MXNDArrayCreateEx(const uint32_t *shape,
599  uint32_t ndim,
600  int dev_type,
601  int dev_id,
602  int delay_alloc,
603  int dtype,
604  NDArrayHandle *out);
605 
606 MXNET_DLL int MXNDArrayCreateEx64(const int64_t *shape,
607  int ndim,
608  int dev_type,
609  int dev_id,
610  int delay_alloc,
611  int dtype,
612  NDArrayHandle *out);
613 
631 MXNET_DLL int MXNDArrayCreateSparseEx(int storage_type,
632  const uint32_t *shape,
633  uint32_t ndim,
634  int dev_type,
635  int dev_id,
636  int delay_alloc,
637  int dtype,
638  uint32_t num_aux,
639  int *aux_type,
640  uint32_t *aux_ndims,
641  const uint32_t *aux_shape,
642  NDArrayHandle *out);
643 
644 MXNET_DLL int MXNDArrayCreateSparseEx64(int storage_type,
645  const int64_t *shape,
646  int ndim,
647  int dev_type,
648  int dev_id,
649  int delay_alloc,
650  int dtype,
651  uint32_t num_aux,
652  int *aux_type,
653  int *aux_ndims,
654  const int64_t *aux_shape,
655  NDArrayHandle *out);
656 
664 MXNET_DLL int MXNDArrayLoadFromRawBytes(const void *buf,
665  size_t size,
666  NDArrayHandle *out);
674 MXNET_DLL int MXNDArraySaveRawBytes(NDArrayHandle handle,
675  size_t *out_size,
676  const char **out_buf);
685 MXNET_DLL int MXNDArraySave(const char* fname,
686  uint32_t num_args,
687  NDArrayHandle* args,
688  const char** keys);
698 MXNET_DLL int MXNDArrayLoad(const char* fname,
699  uint32_t *out_size,
700  NDArrayHandle** out_arr,
701  uint32_t *out_name_size,
702  const char*** out_names);
703 
718 MXNET_DLL int MXNDArrayLoadFromBuffer(const void *ndarray_buffer,
719  size_t size,
720  uint32_t *out_size,
721  NDArrayHandle** out_arr,
722  uint32_t *out_name_size,
723  const char*** out_names);
724 
736 MXNET_DLL int MXNDArraySyncCopyFromCPU(NDArrayHandle handle,
737  const void *data,
738  size_t size);
750 MXNET_DLL int MXNDArraySyncCopyToCPU(NDArrayHandle handle,
751  void *data,
752  size_t size);
753 
761 MXNET_DLL int MXNDArraySyncCopyFromNDArray(NDArrayHandle handle_dst,
762  const NDArrayHandle handle_src,
763  const int i);
764 
770 MXNET_DLL int MXNDArraySyncCheckFormat(NDArrayHandle handle, const bool full_check);
777 MXNET_DLL int MXNDArrayWaitToRead(NDArrayHandle handle);
784 MXNET_DLL int MXNDArrayWaitToWrite(NDArrayHandle handle);
796 MXNET_DLL int MXNDArrayFree(NDArrayHandle handle);
805 MXNET_DLL int MXNDArraySlice(NDArrayHandle handle,
806  uint32_t slice_begin,
807  uint32_t slice_end,
808  NDArrayHandle *out);
809 
810 MXNET_DLL int MXNDArraySlice64(NDArrayHandle handle,
811  int64_t slice_begin,
812  int64_t slice_end,
813  NDArrayHandle *out);
814 
822 MXNET_DLL int MXNDArrayAt(NDArrayHandle handle,
823  uint32_t idx,
824  NDArrayHandle *out);
825 
826 MXNET_DLL int MXNDArrayAt64(NDArrayHandle handle,
827  int64_t idx,
828  NDArrayHandle *out);
829 
833 MXNET_DLL int MXNDArrayGetStorageType(NDArrayHandle handle,
834  int *out_storage_type);
835 
844 MXNET_DLL int MXNDArrayReshape(NDArrayHandle handle,
845  int ndim,
846  int *dims,
847  NDArrayHandle *out);
848 
857 MXNET_DLL int MXNDArrayReshape64(NDArrayHandle handle,
858  int ndim,
859  dim_t *dims,
860  bool reverse,
861  NDArrayHandle *out);
870 MXNET_DLL int MXNDArrayGetShape(NDArrayHandle handle,
871  uint32_t *out_dim,
872  const uint32_t **out_pdata);
873 
874 MXNET_DLL int MXNDArrayGetShape64(NDArrayHandle handle,
875  int *out_dim,
876  const int64_t **out_pdata);
877 
885 MXNET_DLL int MXNDArrayGetShapeEx(NDArrayHandle handle,
886  int *out_dim,
887  const int **out_pdata);
888 
889 MXNET_DLL int MXNDArrayGetShapeEx64(NDArrayHandle handle,
890  int *out_dim,
891  const int64_t **out_pdata);
892 
899 MXNET_DLL int MXNDArrayGetData(NDArrayHandle handle,
900  void **out_pdata);
910 MXNET_DLL int MXNDArrayToDLPack(NDArrayHandle handle,
911  DLManagedTensorHandle *out_dlpack);
912 
928 MXNET_DLL int MXNDArrayFromDLPack(DLManagedTensorHandle dlpack,
929  NDArrayHandle *out_handle);
930 
945 MXNET_DLL int MXNDArrayFromDLPackEx(DLManagedTensorHandle dlpack,
946  const bool transient_handle,
947  NDArrayHandle *out_handle);
948 
954 MXNET_DLL int MXNDArrayCallDLPackDeleter(DLManagedTensorHandle dlpack);
955 
962 MXNET_DLL int MXNDArrayGetDType(NDArrayHandle handle,
963  int *out_dtype);
964 
972 MXNET_DLL int MXNDArrayGetAuxType(NDArrayHandle handle,
973  uint32_t i,
974  int *out_type);
975 
976 MXNET_DLL int MXNDArrayGetAuxType64(NDArrayHandle handle,
977  int64_t i,
978  int *out_type);
979 
985 MXNET_DLL int MXNDArrayGetAuxNDArray(NDArrayHandle handle,
986  uint32_t i,
987  NDArrayHandle *out);
988 
989 MXNET_DLL int MXNDArrayGetAuxNDArray64(NDArrayHandle handle,
990  int64_t i,
991  NDArrayHandle *out);
992 
998 MXNET_DLL int MXNDArrayGetDataNDArray(NDArrayHandle handle,
999  NDArrayHandle *out);
1007 MXNET_DLL int MXNDArrayGetContext(NDArrayHandle handle,
1008  int *out_dev_type,
1009  int *out_dev_id);
1015 MXNET_DLL int MXNDArrayGetGrad(NDArrayHandle handle, NDArrayHandle *out);
1021 MXNET_DLL int MXNDArrayDetach(NDArrayHandle handle, NDArrayHandle *out);
1028 MXNET_DLL int MXNDArraySetGradState(NDArrayHandle handle, int state);
1035 MXNET_DLL int MXNDArrayGetGradState(NDArrayHandle handle, int *out);
1036 //--------------------------------
1037 // Part 2: functions on NDArray
1038 //--------------------------------
1046 MXNET_DLL int MXListFunctions(uint32_t *out_size,
1047  FunctionHandle **out_array);
1048 
1055 MXNET_DLL int MXGetFunction(const char *name,
1056  FunctionHandle *out);
1069 MXNET_DLL int MXFuncGetInfo(FunctionHandle fun,
1070  const char **name,
1071  const char **description,
1072  uint32_t *num_args,
1073  const char ***arg_names,
1074  const char ***arg_type_infos,
1075  const char ***arg_descriptions,
1076  const char **return_type DEFAULT(NULL));
1087 MXNET_DLL int MXFuncDescribe(FunctionHandle fun,
1088  uint32_t *num_use_vars,
1089  uint32_t *num_scalars,
1090  uint32_t *num_mutate_vars,
1091  int *type_mask);
1102 MXNET_DLL int MXFuncInvoke(FunctionHandle fun,
1103  NDArrayHandle *use_vars,
1104  float *scalar_args,
1105  NDArrayHandle *mutate_vars);
1119 MXNET_DLL int MXFuncInvokeEx(FunctionHandle fun,
1120  NDArrayHandle *use_vars,
1121  float *scalar_args,
1122  NDArrayHandle *mutate_vars,
1123  int num_params,
1124  char **param_keys,
1125  char **param_vals);
1138 MXNET_DLL int MXImperativeInvoke(AtomicSymbolCreator creator,
1139  int num_inputs,
1140  NDArrayHandle *inputs,
1141  int *num_outputs,
1142  NDArrayHandle **outputs,
1143  int num_params,
1144  const char **param_keys,
1145  const char **param_vals);
1159 MXNET_DLL int MXImperativeInvokeEx(AtomicSymbolCreator creator,
1160  int num_inputs,
1161  NDArrayHandle *inputs,
1162  int *num_outputs,
1163  NDArrayHandle **outputs,
1164  int num_params,
1165  const char **param_keys,
1166  const char **param_vals,
1167  const int **out_stypes);
1174 MXNET_DLL int MXAutogradSetIsRecording(int is_recording, int* prev);
1181 MXNET_DLL int MXAutogradSetIsTraining(int is_training, int* prev);
1187 MXNET_DLL int MXAutogradIsRecording(bool* curr);
1193 MXNET_DLL int MXAutogradIsTraining(bool* curr);
1199 MXNET_DLL int MXIsNumpyShape(int* curr);
1207 MXNET_DLL int MXSetIsNumpyShape(int is_np_shape, int* prev);
1214 MXNET_DLL int MXAutogradMarkVariables(uint32_t num_var,
1215  NDArrayHandle *var_handles,
1216  uint32_t *reqs_array,
1217  NDArrayHandle *grad_handles);
1224 MXNET_DLL int MXAutogradComputeGradient(uint32_t num_output,
1225  NDArrayHandle* output_handles);
1234 MXNET_DLL int MXAutogradBackward(uint32_t num_output,
1235  NDArrayHandle* output_handles,
1236  NDArrayHandle* ograd_handles,
1237  int retain_graph);
1249 MXNET_DLL int MXAutogradBackwardEx(uint32_t num_output,
1250  NDArrayHandle *output_handles,
1251  NDArrayHandle *ograd_handles,
1252  uint32_t num_variables,
1253  NDArrayHandle *var_handles,
1254  int retain_graph,
1255  int create_graph,
1256  int is_train,
1257  NDArrayHandle **grad_handles,
1258  int **grad_stypes);
1259 /*
1260  * \brief get the graph constructed by autograd.
1261  * \param handle ndarray handle
1262  * \param out output symbol handle
1263  */
1264 MXNET_DLL int MXAutogradGetSymbol(NDArrayHandle handle, SymbolHandle *out);
1268 MXNET_DLL int MXCreateCachedOp(SymbolHandle handle, CachedOpHandle *out);
1272 MXNET_DLL int MXCreateCachedOpEx(SymbolHandle handle,
1273  int num_flags,
1274  const char** keys,
1275  const char** vals,
1276  CachedOpHandle *out);
1280 MXNET_DLL int MXFreeCachedOp(CachedOpHandle handle);
1284 MXNET_DLL int MXInvokeCachedOp(CachedOpHandle handle,
1285  int num_inputs,
1286  NDArrayHandle *inputs,
1287  int *num_outputs,
1288  NDArrayHandle **outputs);
1299 MXNET_DLL int MXInvokeCachedOpEx(CachedOpHandle handle,
1300  int num_inputs,
1301  NDArrayHandle *inputs,
1302  int *num_outputs,
1303  NDArrayHandle **outputs,
1304  const int** out_stypes);
1305 
1309 MXNET_DLL int MXCachedOpRegisterOpHook(NDArrayHandle handle,
1310  CachedOpMonitorCallback callback,
1311  bool monitor_all);
1312 
1313 //--------------------------------------------
1314 // Part 3: symbolic configuration generation
1315 //--------------------------------------------
1322 MXNET_DLL int MXListAllOpNames(uint32_t *out_size,
1323  const char ***out_array);
1324 
1331 MXNET_DLL int MXSymbolListAtomicSymbolCreators(uint32_t *out_size,
1332  AtomicSymbolCreator **out_array);
1333 
1339 MXNET_DLL int MXSymbolGetAtomicSymbolName(AtomicSymbolCreator creator,
1340  const char **name);
1341 
1348 MXNET_DLL int MXSymbolGetInputSymbols(SymbolHandle sym, SymbolHandle **inputs,
1349  int *input_size);
1350 
1360 MXNET_DLL int MXSymbolCutSubgraph(SymbolHandle sym, SymbolHandle **inputs,
1361  int *input_size);
1362 
1380 MXNET_DLL int MXSymbolGetAtomicSymbolInfo(AtomicSymbolCreator creator,
1381  const char **name,
1382  const char **description,
1383  uint32_t *num_args,
1384  const char ***arg_names,
1385  const char ***arg_type_infos,
1386  const char ***arg_descriptions,
1387  const char **key_var_num_args,
1388  const char **return_type DEFAULT(NULL));
1398 MXNET_DLL int MXSymbolCreateAtomicSymbol(AtomicSymbolCreator creator,
1399  uint32_t num_param,
1400  const char **keys,
1401  const char **vals,
1402  SymbolHandle *out);
1409 MXNET_DLL int MXSymbolCreateVariable(const char *name, SymbolHandle *out);
1417 MXNET_DLL int MXSymbolCreateGroup(uint32_t num_symbols,
1418  SymbolHandle *symbols,
1419  SymbolHandle *out);
1426 MXNET_DLL int MXSymbolCreateFromFile(const char *fname, SymbolHandle *out);
1433 MXNET_DLL int MXSymbolCreateFromJSON(const char *json, SymbolHandle *out);
1440 MXNET_DLL int MXSymbolRemoveAmpCast(SymbolHandle sym_handle, SymbolHandle* ret_sym_handle);
1447 MXNET_DLL int MXSymbolSaveToFile(SymbolHandle symbol, const char *fname);
1454 MXNET_DLL int MXSymbolSaveToJSON(SymbolHandle symbol, const char **out_json);
1460 MXNET_DLL int MXSymbolFree(SymbolHandle symbol);
1467 MXNET_DLL int MXSymbolCopy(SymbolHandle symbol, SymbolHandle *out);
1474 MXNET_DLL int MXSymbolPrint(SymbolHandle symbol, const char **out_str);
1482 MXNET_DLL int MXSymbolGetName(SymbolHandle symbol,
1483  const char** out,
1484  int *success);
1493 MXNET_DLL int MXSymbolGetAttr(SymbolHandle symbol,
1494  const char* key,
1495  const char** out,
1496  int *success);
1513 MXNET_DLL int MXSymbolSetAttr(SymbolHandle symbol,
1514  const char* key,
1515  const char* value);
1523 MXNET_DLL int MXSymbolListAttr(SymbolHandle symbol,
1524  uint32_t *out_size,
1525  const char*** out);
1533 MXNET_DLL int MXSymbolListAttrShallow(SymbolHandle symbol,
1534  uint32_t *out_size,
1535  const char*** out);
1543 MXNET_DLL int MXSymbolListArguments(SymbolHandle symbol,
1544  uint32_t *out_size,
1545  const char ***out_str_array);
1546 
1554 MXNET_DLL int MXSymbolListOutputs(SymbolHandle symbol,
1555  uint32_t *out_size,
1556  const char ***out_str_array);
1557 
1564 MXNET_DLL int MXSymbolGetNumOutputs(SymbolHandle symbol,
1565  uint32_t *output_count);
1566 
1573 MXNET_DLL int MXSymbolGetInternals(SymbolHandle symbol,
1574  SymbolHandle *out);
1581 MXNET_DLL int MXSymbolGetChildren(SymbolHandle symbol,
1582  SymbolHandle *out);
1590 MXNET_DLL int MXSymbolGetOutput(SymbolHandle symbol,
1591  uint32_t index,
1592  SymbolHandle *out);
1593 
1601 MXNET_DLL int MXSymbolListAuxiliaryStates(SymbolHandle symbol,
1602  uint32_t *out_size,
1603  const char ***out_str_array);
1604 
1619 MXNET_DLL int MXSymbolCompose(SymbolHandle sym,
1620  const char *name,
1621  uint32_t num_args,
1622  const char** keys,
1623  SymbolHandle* args);
1633 MXNET_DLL int MXSymbolGrad(SymbolHandle sym,
1634  uint32_t num_wrt,
1635  const char** wrt,
1636  SymbolHandle* out);
1660 MXNET_DLL int MXSymbolInferShape(SymbolHandle sym,
1661  uint32_t num_args,
1662  const char** keys,
1663  const uint32_t *arg_ind_ptr,
1664  const uint32_t *arg_shape_data,
1665  uint32_t *in_shape_size,
1666  const uint32_t **in_shape_ndim,
1667  const uint32_t ***in_shape_data,
1668  uint32_t *out_shape_size,
1669  const uint32_t **out_shape_ndim,
1670  const uint32_t ***out_shape_data,
1671  uint32_t *aux_shape_size,
1672  const uint32_t **aux_shape_ndim,
1673  const uint32_t ***aux_shape_data,
1674  int *complete);
1675 
1676 MXNET_DLL int MXSymbolInferShape64(SymbolHandle sym,
1677  uint32_t num_args,
1678  const char** keys,
1679  const int64_t *arg_ind_ptr,
1680  const int64_t *arg_shape_data,
1681  size_t *in_shape_size,
1682  const int **in_shape_ndim,
1683  const int64_t ***in_shape_data,
1684  size_t *out_shape_size,
1685  const int **out_shape_ndim,
1686  const int64_t ***out_shape_data,
1687  size_t *aux_shape_size,
1688  const int **aux_shape_ndim,
1689  const int64_t ***aux_shape_data,
1690  int *complete);
1691 
1714 MXNET_DLL int MXSymbolInferShapeEx(SymbolHandle sym,
1715  uint32_t num_args,
1716  const char** keys,
1717  const uint32_t *arg_ind_ptr,
1718  const int *arg_shape_data,
1719  uint32_t *in_shape_size,
1720  const int **in_shape_ndim,
1721  const int ***in_shape_data,
1722  uint32_t *out_shape_size,
1723  const int **out_shape_ndim,
1724  const int ***out_shape_data,
1725  uint32_t *aux_shape_size,
1726  const int **aux_shape_ndim,
1727  const int ***aux_shape_data,
1728  int *complete);
1729 
1730 MXNET_DLL int MXSymbolInferShapeEx64(SymbolHandle sym,
1731  uint32_t num_args,
1732  const char** keys,
1733  const int64_t *arg_ind_ptr,
1734  const int64_t *arg_shape_data,
1735  size_t *in_shape_size,
1736  const int **in_shape_ndim,
1737  const int64_t ***in_shape_data,
1738  size_t *out_shape_size,
1739  const int **out_shape_ndim,
1740  const int64_t ***out_shape_data,
1741  size_t *aux_shape_size,
1742  const int **aux_shape_ndim,
1743  const int64_t ***aux_shape_data,
1744  int *complete);
1745 
1771 MXNET_DLL int MXSymbolInferShapePartial(SymbolHandle sym,
1772  uint32_t num_args,
1773  const char** keys,
1774  const uint32_t *arg_ind_ptr,
1775  const uint32_t *arg_shape_data,
1776  uint32_t *in_shape_size,
1777  const uint32_t **in_shape_ndim,
1778  const uint32_t ***in_shape_data,
1779  uint32_t *out_shape_size,
1780  const uint32_t **out_shape_ndim,
1781  const uint32_t ***out_shape_data,
1782  uint32_t *aux_shape_size,
1783  const uint32_t **aux_shape_ndim,
1784  const uint32_t ***aux_shape_data,
1785  int *complete);
1786 
1787 MXNET_DLL int MXSymbolInferShapePartial64(SymbolHandle sym,
1788  uint32_t num_args,
1789  const char** keys,
1790  const int64_t *arg_ind_ptr,
1791  const int64_t *arg_shape_data,
1792  size_t *in_shape_size,
1793  const int **in_shape_ndim,
1794  const int64_t ***in_shape_data,
1795  size_t *out_shape_size,
1796  const int **out_shape_ndim,
1797  const int64_t ***out_shape_data,
1798  size_t *aux_shape_size,
1799  const int **aux_shape_ndim,
1800  const int64_t ***aux_shape_data,
1801  int *complete);
1802 
1827 MXNET_DLL int MXSymbolInferShapePartialEx(SymbolHandle sym,
1828  uint32_t num_args,
1829  const char** keys,
1830  const uint32_t *arg_ind_ptr,
1831  const int *arg_shape_data,
1832  uint32_t *in_shape_size,
1833  const int **in_shape_ndim,
1834  const int ***in_shape_data,
1835  uint32_t *out_shape_size,
1836  const int **out_shape_ndim,
1837  const int ***out_shape_data,
1838  uint32_t *aux_shape_size,
1839  const int **aux_shape_ndim,
1840  const int ***aux_shape_data,
1841  int *complete);
1842 
1843 MXNET_DLL int MXSymbolInferShapePartialEx64(SymbolHandle sym,
1844  uint32_t num_args,
1845  const char** keys,
1846  const int64_t *arg_ind_ptr,
1847  const int64_t *arg_shape_data,
1848  size_t *in_shape_size,
1849  const int **in_shape_ndim,
1850  const int64_t ***in_shape_data,
1851  size_t *out_shape_size,
1852  const int **out_shape_ndim,
1853  const int64_t ***out_shape_data,
1854  size_t *aux_shape_size,
1855  const int **aux_shape_ndim,
1856  const int64_t ***aux_shape_data,
1857  int *complete);
1858 
1877 MXNET_DLL int MXSymbolInferType(SymbolHandle sym,
1878  uint32_t num_args,
1879  const char** keys,
1880  const int *arg_type_data,
1881  uint32_t *in_type_size,
1882  const int **in_type_data,
1883  uint32_t *out_type_size,
1884  const int **out_type_data,
1885  uint32_t *aux_type_size,
1886  const int **aux_type_data,
1887  int *complete);
1888 
1909 MXNET_DLL int MXSymbolInferTypePartial(SymbolHandle sym,
1910  uint32_t num_args,
1911  const char** keys,
1912  const int *arg_type_data,
1913  uint32_t *in_type_size,
1914  const int **in_type_data,
1915  uint32_t *out_type_size,
1916  const int **out_type_data,
1917  uint32_t *aux_type_size,
1918  const int **aux_type_data,
1919  int *complete);
1920 
1938 MXNET_DLL int MXQuantizeSymbol(SymbolHandle sym_handle,
1939  SymbolHandle *ret_sym_handle,
1940  const int* dev_type,
1941  const uint32_t num_excluded_sym_names,
1942  const char **excluded_sym_names,
1943  const uint32_t num_excluded_op_names,
1944  const char **excluded_op_names,
1945  const uint32_t num_offline, const char **offline_params,
1946  const char *quantized_dtype, const bool calib_quantize,
1947  const char *quantize_mode, uint32_t* out_num_calib_names,
1948  const char ***out_calib_names);
1949 
1976 MXNET_DLL int MXReducePrecisionSymbol(SymbolHandle sym_handle,
1977  SymbolHandle *ret_sym_handle,
1978  uint32_t num_args,
1979  const int* arg_type_data,
1980  uint32_t num_ind_ptr,
1981  const int* ind_ptr,
1982  const int* target_dtype,
1983  const int cast_optional_params,
1984  const uint32_t num_target_dtype_op_names,
1985  const uint32_t num_fp32_op_names,
1986  const uint32_t num_widest_dtype_op_names,
1987  const uint32_t num_conditional_fp32_op_names,
1988  const uint32_t num_excluded_symbols,
1989  const uint32_t num_model_params,
1990  const char **target_dtype_op_names,
1991  const char **fp32_op_names,
1992  const char **widest_dtype_op_names,
1993  const char **conditional_fp32_op_names,
1994  const char **excluded_symbols,
1995  const char **conditional_param_names,
1996  const char **conditional_param_vals,
1997  const char **model_param_names,
1998  const char **arg_names);
2008 MXNET_DLL int MXSetCalibTableToQuantizedSymbol(SymbolHandle qsym_handle,
2009  const uint32_t num_layers,
2010  const char** layer_names,
2011  const float* low_quantiles,
2012  const float* high_quantiles,
2013  SymbolHandle* ret_sym_handle);
2014 
2021 MXNET_DLL int MXGenBackendSubgraph(SymbolHandle sym_handle, const char *backend,
2022  SymbolHandle *ret_sym_handle);
2023 
2029 MXNET_DLL int MXGenAtomicSymbolFromSymbol(SymbolHandle sym_handle, SymbolHandle *ret_sym_handle);
2042 MXNET_DLL int MXOptimizeForBackend(SymbolHandle sym_handle,
2043  const char* backend_name,
2044  const int dev_type,
2045  SymbolHandle* ret_sym_handle,
2046  const mx_uint len,
2047  NDArrayHandle* in_args_handle,
2048  const mx_uint num_options,
2049  const char** keys,
2050  const char** vals);
2051 
2052 
2053 //--------------------------------------------
2054 // Part 4: Executor interface
2055 //--------------------------------------------
2061 MXNET_DLL int MXExecutorFree(ExecutorHandle handle);
2068 MXNET_DLL int MXExecutorPrint(ExecutorHandle handle, const char **out_str);
2076 MXNET_DLL int MXExecutorForward(ExecutorHandle handle, int is_train);
2086 MXNET_DLL int MXExecutorBackward(ExecutorHandle handle,
2087  uint32_t len,
2088  NDArrayHandle *head_grads);
2099 MXNET_DLL int MXExecutorBackwardEx(ExecutorHandle handle,
2100  uint32_t len,
2101  NDArrayHandle *head_grads,
2102  int is_train);
2111 MXNET_DLL int MXExecutorOutputs(ExecutorHandle handle,
2112  uint32_t *out_size,
2113  NDArrayHandle **out);
2114 
2130 MXNET_DLL int MXExecutorBind(SymbolHandle symbol_handle,
2131  int dev_type,
2132  int dev_id,
2133  uint32_t len,
2134  NDArrayHandle *in_args,
2135  NDArrayHandle *arg_grad_store,
2136  uint32_t *grad_req_type,
2137  uint32_t aux_states_len,
2138  NDArrayHandle *aux_states,
2139  ExecutorHandle *out);
2161 MXNET_DLL int MXExecutorBindX(SymbolHandle symbol_handle,
2162  int dev_type,
2163  int dev_id,
2164  uint32_t num_map_keys,
2165  const char** map_keys,
2166  const int* map_dev_types,
2167  const int* map_dev_ids,
2168  uint32_t len,
2169  NDArrayHandle *in_args,
2170  NDArrayHandle *arg_grad_store,
2171  uint32_t *grad_req_type,
2172  uint32_t aux_states_len,
2173  NDArrayHandle *aux_states,
2174  ExecutorHandle *out);
2197 MXNET_DLL int MXExecutorBindEX(SymbolHandle symbol_handle,
2198  int dev_type,
2199  int dev_id,
2200  uint32_t num_map_keys,
2201  const char** map_keys,
2202  const int* map_dev_types,
2203  const int* map_dev_ids,
2204  uint32_t len,
2205  NDArrayHandle *in_args,
2206  NDArrayHandle *arg_grad_store,
2207  uint32_t *grad_req_type,
2208  uint32_t aux_states_len,
2209  NDArrayHandle *aux_states,
2210  ExecutorHandle shared_exec,
2211  ExecutorHandle *out);
2214 MXNET_DLL int MXExecutorSimpleBind(SymbolHandle symbol_handle,
2215  int dev_type,
2216  int dev_id,
2217  const uint32_t num_g2c_keys,
2218  const char** g2c_keys,
2219  const int* g2c_dev_types,
2220  const int* g2c_dev_ids,
2221  const uint32_t provided_grad_req_list_len,
2222  const char** provided_grad_req_names,
2223  const char** provided_grad_req_types,
2224  const uint32_t num_provided_arg_shapes,
2225  const char** provided_arg_shape_names,
2226  const uint32_t* provided_arg_shape_data,
2227  const uint32_t* provided_arg_shape_idx,
2228  const uint32_t num_provided_arg_dtypes,
2229  const char** provided_arg_dtype_names,
2230  const int* provided_arg_dtypes,
2231  const uint32_t num_provided_arg_stypes,
2232  const char** provided_arg_stype_names,
2233  const int* provided_arg_stypes,
2234  const uint32_t num_shared_arg_names,
2235  const char** shared_arg_name_list,
2236  int* shared_buffer_len,
2237  const char** shared_buffer_name_list,
2238  NDArrayHandle* shared_buffer_handle_list,
2239  const char*** updated_shared_buffer_name_list,
2240  NDArrayHandle** updated_shared_buffer_handle_list,
2241  uint32_t* num_in_args,
2242  NDArrayHandle** in_args,
2243  NDArrayHandle** arg_grads,
2244  uint32_t* num_aux_states,
2245  NDArrayHandle** aux_states,
2246  ExecutorHandle shared_exec_handle,
2247  ExecutorHandle* out);
2248 
2249 
2250 MXNET_DLL int MXExecutorSimpleBindEx(SymbolHandle symbol_handle,
2251  int dev_type,
2252  int dev_id,
2253  const uint32_t num_g2c_keys,
2254  const char** g2c_keys,
2255  const int* g2c_dev_types,
2256  const int* g2c_dev_ids,
2257  const uint32_t provided_grad_req_list_len,
2258  const char** provided_grad_req_names,
2259  const char** provided_grad_req_types,
2260  const uint32_t num_provided_arg_shapes,
2261  const char** provided_arg_shape_names,
2262  const int* provided_arg_shape_data,
2263  const uint32_t* provided_arg_shape_idx,
2264  const uint32_t num_provided_arg_dtypes,
2265  const char** provided_arg_dtype_names,
2266  const int* provided_arg_dtypes,
2267  const uint32_t num_provided_arg_stypes,
2268  const char** provided_arg_stype_names,
2269  const int* provided_arg_stypes,
2270  const uint32_t num_shared_arg_names,
2271  const char** shared_arg_name_list,
2272  int* shared_buffer_len,
2273  const char** shared_buffer_name_list,
2274  NDArrayHandle* shared_buffer_handle_list,
2275  const char*** updated_shared_buffer_name_list,
2276  NDArrayHandle** updated_shared_buffer_handle_list,
2277  uint32_t* num_in_args,
2278  NDArrayHandle** in_args,
2279  NDArrayHandle** arg_grads,
2280  uint32_t* num_aux_states,
2281  NDArrayHandle** aux_states,
2282  ExecutorHandle shared_exec_handle,
2283  ExecutorHandle* out);
2284 
2285 
2286 MXNET_DLL int MXExecutorSimpleBindEx64(SymbolHandle symbol_handle,
2287  int dev_type,
2288  int dev_id,
2289  const uint32_t num_g2c_keys,
2290  const char** g2c_keys,
2291  const int* g2c_dev_types,
2292  const int* g2c_dev_ids,
2293  const uint32_t provided_grad_req_list_len,
2294  const char** provided_grad_req_names,
2295  const char** provided_grad_req_types,
2296  const uint32_t num_provided_arg_shapes,
2297  const char** provided_arg_shape_names,
2298  const int64_t* provided_arg_shape_data,
2299  const uint32_t* provided_arg_shape_idx,
2300  const uint32_t num_provided_arg_dtypes,
2301  const char** provided_arg_dtype_names,
2302  const int* provided_arg_dtypes,
2303  const uint32_t num_provided_arg_stypes,
2304  const char** provided_arg_stype_names,
2305  const int* provided_arg_stypes,
2306  const uint32_t num_shared_arg_names,
2307  const char** shared_arg_name_list,
2308  int* shared_buffer_len,
2309  const char** shared_buffer_name_list,
2310  NDArrayHandle* shared_buffer_handle_list,
2311  const char*** updated_shared_buffer_name_list,
2312  NDArrayHandle** updated_shared_buffer_handle_list,
2313  uint32_t* num_in_args,
2314  NDArrayHandle** in_args,
2315  NDArrayHandle** arg_grads,
2316  uint32_t* num_aux_states,
2317  NDArrayHandle** aux_states,
2318  ExecutorHandle shared_exec_handle,
2319  ExecutorHandle* out);
2320 
2321 
2344 MXNET_DLL int MXExecutorReshape(int partial_shaping,
2345  int allow_up_sizing,
2346  int dev_type,
2347  int dev_id,
2348  uint32_t num_map_keys,
2349  const char** map_keys,
2350  const int* map_dev_types,
2351  const int* map_dev_ids,
2352  const uint32_t num_provided_arg_shapes,
2353  const char** provided_arg_shape_names,
2354  const uint32_t* provided_arg_shape_data,
2355  const uint32_t* provided_arg_shape_idx,
2356  uint32_t* num_in_args,
2357  NDArrayHandle** in_args,
2358  NDArrayHandle** arg_grads,
2359  uint32_t* num_aux_states,
2360  NDArrayHandle** aux_states,
2361  ExecutorHandle shared_exec,
2362  ExecutorHandle *out);
2384 MXNET_DLL int MXExecutorReshapeEx(int partial_shaping,
2385  int allow_up_sizing,
2386  int dev_type,
2387  int dev_id,
2388  uint32_t num_map_keys,
2389  const char** map_keys,
2390  const int* map_dev_types,
2391  const int* map_dev_ids,
2392  const uint32_t num_provided_arg_shapes,
2393  const char** provided_arg_shape_names,
2394  const int* provided_arg_shape_data,
2395  const uint32_t* provided_arg_shape_idx,
2396  uint32_t* num_in_args,
2397  NDArrayHandle** in_args,
2398  NDArrayHandle** arg_grads,
2399  uint32_t* num_aux_states,
2400  NDArrayHandle** aux_states,
2401  ExecutorHandle shared_exec,
2402  ExecutorHandle *out);
2403 
2407 MXNET_DLL int MXExecutorGetOptimizedSymbol(ExecutorHandle handle,
2408  SymbolHandle *out);
2412 MXNET_DLL int MXExecutorSetMonitorCallback(ExecutorHandle handle,
2413  ExecutorMonitorCallback callback,
2414  void* callback_handle);
2415 
2420 MXNET_DLL int MXExecutorSetMonitorCallbackEX(ExecutorHandle handle,
2421  ExecutorMonitorCallback callback,
2422  void *callback_handle, bool monitor_all);
2423 //--------------------------------------------
2424 // Part 5: IO Interface
2425 //--------------------------------------------
2432 MXNET_DLL int MXListDataIters(uint32_t *out_size,
2433  DataIterCreator **out_array);
2444 MXNET_DLL int MXDataIterCreateIter(DataIterCreator handle,
2445  uint32_t num_param,
2446  const char **keys,
2447  const char **vals,
2448  DataIterHandle *out);
2460 MXNET_DLL int MXDataIterGetIterInfo(DataIterCreator creator,
2461  const char **name,
2462  const char **description,
2463  uint32_t *num_args,
2464  const char ***arg_names,
2465  const char ***arg_type_infos,
2466  const char ***arg_descriptions);
2472 MXNET_DLL int MXDataIterFree(DataIterHandle handle);
2479 MXNET_DLL int MXDataIterNext(DataIterHandle handle,
2480  int *out);
2486 MXNET_DLL int MXDataIterBeforeFirst(DataIterHandle handle);
2487 
2494 MXNET_DLL int MXDataIterGetData(DataIterHandle handle,
2495  NDArrayHandle *out);
2503 MXNET_DLL int MXDataIterGetIndex(DataIterHandle handle,
2504  uint64_t **out_index,
2505  uint64_t *out_size);
2512 MXNET_DLL int MXDataIterGetPadNum(DataIterHandle handle,
2513  int *pad);
2514 
2521 MXNET_DLL int MXDataIterGetLabel(DataIterHandle handle,
2522  NDArrayHandle *out);
2523 //--------------------------------------------
2524 // Part 6: basic KVStore interface
2525 //--------------------------------------------
2532 MXNET_DLL int MXInitPSEnv(uint32_t num_vars,
2533  const char **keys,
2534  const char **vals);
2535 
2536 
2543 MXNET_DLL int MXKVStoreCreate(const char *type,
2544  KVStoreHandle *out);
2545 
2553 MXNET_DLL int MXKVStoreSetGradientCompression(KVStoreHandle handle,
2554  uint32_t num_params,
2555  const char** keys,
2556  const char** vals);
2557 
2563 MXNET_DLL int MXKVStoreFree(KVStoreHandle handle);
2572 MXNET_DLL int MXKVStoreInit(KVStoreHandle handle,
2573  uint32_t num,
2574  const int* keys,
2575  NDArrayHandle* vals);
2576 
2585 MXNET_DLL int MXKVStoreInitEx(KVStoreHandle handle,
2586  uint32_t num,
2587  const char** keys,
2588  NDArrayHandle* vals);
2589 
2599 MXNET_DLL int MXKVStorePush(KVStoreHandle handle,
2600  uint32_t num,
2601  const int* keys,
2602  NDArrayHandle* vals,
2603  int priority);
2613 MXNET_DLL int MXKVStorePushEx(KVStoreHandle handle,
2614  uint32_t num,
2615  const char** keys,
2616  NDArrayHandle* vals,
2617  int priority);
2628 MXNET_DLL int MXKVStorePullWithSparse(KVStoreHandle handle,
2629  uint32_t num,
2630  const int* keys,
2631  NDArrayHandle* vals,
2632  int priority,
2633  bool ignore_sparse);
2644 MXNET_DLL int MXKVStorePullWithSparseEx(KVStoreHandle handle,
2645  uint32_t num,
2646  const char** keys,
2647  NDArrayHandle* vals,
2648  int priority,
2649  bool ignore_sparse);
2659 MXNET_DLL int MXKVStorePull(KVStoreHandle handle,
2660  uint32_t num,
2661  const int* keys,
2662  NDArrayHandle* vals,
2663  int priority);
2673 MXNET_DLL int MXKVStorePullEx(KVStoreHandle handle,
2674  uint32_t num,
2675  const char** keys,
2676  NDArrayHandle* vals,
2677  int priority);
2678 
2691 MXNET_DLL int MXKVStorePullRowSparse(KVStoreHandle handle,
2692  uint32_t num,
2693  const int* keys,
2694  NDArrayHandle* vals,
2695  const NDArrayHandle* row_ids,
2696  int priority);
2709 MXNET_DLL int MXKVStorePullRowSparseEx(KVStoreHandle handle,
2710  uint32_t num,
2711  const char** keys,
2712  NDArrayHandle* vals,
2713  const NDArrayHandle* row_ids,
2714  int priority);
2715 
2728 MXNET_DLL int MXKVStorePushPull(KVStoreHandle handle,
2729  mx_uint vnum,
2730  const int* vkeys,
2731  mx_uint onum,
2732  const int* okeys,
2733  NDArrayHandle* vals,
2734  NDArrayHandle* outs,
2735  int priority);
2749 MXNET_DLL int MXKVStorePushPullEx(KVStoreHandle handle,
2750  mx_uint vnum,
2751  const char** vkeys,
2752  mx_uint onum,
2753  const char** okeys,
2754  NDArrayHandle* vals,
2755  NDArrayHandle* outs,
2756  int priority);
2757 
2766 typedef void (MXKVStoreUpdater)(int key,
2767  NDArrayHandle recv,
2768  NDArrayHandle local,
2769  void *handle);
2778 typedef void (MXKVStoreStrUpdater)(const char* key,
2779  NDArrayHandle recv,
2780  NDArrayHandle local,
2781  void *handle);
2789 MXNET_DLL int MXKVStoreSetUpdater(KVStoreHandle handle,
2790  MXKVStoreUpdater updater,
2791  void *updater_handle);
2800 MXNET_DLL int MXKVStoreSetUpdaterEx(KVStoreHandle handle,
2801  MXKVStoreUpdater updater,
2802  MXKVStoreStrUpdater str_updater,
2803  void *updater_handle);
2810 MXNET_DLL int MXKVStoreGetType(KVStoreHandle handle,
2811  const char** type);
2812 //--------------------------------------------
2813 // Part 6: advanced KVStore for multi-machines
2814 //--------------------------------------------
2815 
2823 MXNET_DLL int MXKVStoreGetRank(KVStoreHandle handle,
2824  int *ret);
2825 
2835 MXNET_DLL int MXKVStoreGetGroupSize(KVStoreHandle handle,
2836  int *ret);
2837 
2843 MXNET_DLL int MXKVStoreIsWorkerNode(int *ret);
2844 
2845 
2851 MXNET_DLL int MXKVStoreIsServerNode(int *ret);
2852 
2853 
2859 MXNET_DLL int MXKVStoreIsSchedulerNode(int *ret);
2860 
2867 MXNET_DLL int MXKVStoreBarrier(KVStoreHandle handle);
2868 
2876 MXNET_DLL int MXKVStoreSetBarrierBeforeExit(KVStoreHandle handle,
2877  const int barrier_before_exit);
2878 
2885 typedef void (MXKVStoreServerController)(int head,
2886  const char *body,
2887  void *controller_handle);
2888 
2896 MXNET_DLL int MXKVStoreRunServer(KVStoreHandle handle,
2897  MXKVStoreServerController controller,
2898  void *controller_handle);
2899 
2907 MXNET_DLL int MXKVStoreSendCommmandToServers(KVStoreHandle handle,
2908  int cmd_id,
2909  const char* cmd_body);
2910 
2921 MXNET_DLL int MXKVStoreGetNumDeadNode(KVStoreHandle handle,
2922  const int node_id,
2923  int *number,
2924  const int timeout_sec DEFAULT(60));
2925 
2932 MXNET_DLL int MXRecordIOWriterCreate(const char *uri, RecordIOHandle *out);
2933 
2939 MXNET_DLL int MXRecordIOWriterFree(RecordIOHandle handle);
2940 
2948 MXNET_DLL int MXRecordIOWriterWriteRecord(RecordIOHandle handle,
2949  const char *buf, size_t size);
2950 
2957 MXNET_DLL int MXRecordIOWriterTell(RecordIOHandle handle, size_t *pos);
2958 
2965 MXNET_DLL int MXRecordIOReaderCreate(const char *uri, RecordIOHandle *out);
2966 
2972 MXNET_DLL int MXRecordIOReaderFree(RecordIOHandle handle);
2973 
2981 MXNET_DLL int MXRecordIOReaderReadRecord(RecordIOHandle handle,
2982  char const **buf, size_t *size);
2983 
2990 MXNET_DLL int MXRecordIOReaderSeek(RecordIOHandle handle, size_t pos);
2991 
2998 MXNET_DLL int MXRecordIOReaderTell(RecordIOHandle handle, size_t *pos);
2999 
3003 MXNET_DLL int MXRtcCreate(char* name, uint32_t num_input, uint32_t num_output,
3004  char** input_names, char** output_names,
3005  NDArrayHandle* inputs, NDArrayHandle* outputs,
3006  char* kernel, RtcHandle *out);
3007 
3011 MXNET_DLL int MXRtcPush(RtcHandle handle, uint32_t num_input, uint32_t num_output,
3012  NDArrayHandle* inputs, NDArrayHandle* outputs,
3013  uint32_t gridDimX,
3014  uint32_t gridDimY,
3015  uint32_t gridDimZ,
3016  uint32_t blockDimX,
3017  uint32_t blockDimY,
3018  uint32_t blockDimZ);
3019 
3023 MXNET_DLL int MXRtcFree(RtcHandle handle);
3024 /*
3025  * \brief register custom operators from frontend.
3026  * \param op_type name of custom op
3027  * \param creator
3028  */
3029 MXNET_DLL int MXCustomOpRegister(const char* op_type, CustomOpPropCreator creator);
3030 /*
3031  * \brief record custom function for backward later.
3032  * \param num_inputs number of input NDArrays.
3033  * \param inputs handle to input NDArrays.
3034  * \param num_outputs number of output NDArrays.
3035  * \param outputs handle to output NDArrays.
3036  * \param callbacks callbacks for backward function.
3037  */
3038 MXNET_DLL int MXCustomFunctionRecord(int num_inputs, NDArrayHandle *inputs,
3039  int num_outputs, NDArrayHandle *outputs,
3040  struct MXCallbackList *callbacks);
3041 /*
3042  * \brief create cuda rtc module
3043  * \param source cuda source code
3044  * \param num_options number of compiler flags
3045  * \param options compiler flags
3046  * \param num_exports number of exported function names
3047  * \param exported function names
3048  * \param out handle to created module
3049  */
3050 MXNET_DLL int MXRtcCudaModuleCreate(const char* source, int num_options,
3051  const char** options, int num_exports,
3052  const char** exports, CudaModuleHandle *out);
3053 /*
3054  * \brief delete cuda rtc module
3055  * \param handle handle to cuda module
3056  */
3057 MXNET_DLL int MXRtcCudaModuleFree(CudaModuleHandle handle);
3058 /*
3059  * \brief get kernel from module
3060  * \param handle handle to cuda module
3061  * \param name name of kernel function
3062  * \param num_args number of arguments
3063  * \param is_ndarray whether argument is ndarray
3064  * \param is_const whether argument is constant
3065  * \param arg_types data type of arguments
3066  * \param out created kernel
3067  */
3068 MXNET_DLL int MXRtcCudaKernelCreate(CudaModuleHandle handle, const char* name,
3069  int num_args, int* is_ndarray, int* is_const,
3070  int* arg_types, CudaKernelHandle *out);
3071 /*
3072  * \brief delete kernel
3073  * \param handle handle to previously created kernel
3074  */
3075 MXNET_DLL int MXRtcCudaKernelFree(CudaKernelHandle handle);
3076 /*
3077  * \brief launch cuda kernel
3078  * \param handle handle to kernel
3079  * \param dev_id (GPU) device id
3080  * \param args pointer to arguments
3081  * \param grid_dim_x grid dimension x
3082  * \param grid_dim_y grid dimension y
3083  * \param grid_dim_z grid dimension z
3084  * \param block_dim_x block dimension x
3085  * \param block_dim_y block dimension y
3086  * \param block_dim_z block dimension z
3087  * \param shared_mem size of dynamically allocated shared memory
3088  */
3089 MXNET_DLL int MXRtcCudaKernelCall(CudaKernelHandle handle, int dev_id, void** args,
3090  uint32_t grid_dim_x, uint32_t grid_dim_y,
3091  uint32_t grid_dim_z, uint32_t block_dim_x,
3092  uint32_t block_dim_y, uint32_t block_dim_z,
3093  uint32_t shared_mem);
3100 MXNET_DLL int MXNDArrayGetSharedMemHandle(NDArrayHandle handle, int* shared_pid,
3101  int* shared_id);
3112 MXNET_DLL int MXNDArrayCreateFromSharedMem(int shared_pid, int shared_id, const uint32_t *shape,
3113  uint32_t ndim, int dtype, NDArrayHandle *out);
3114 
3120 MXNET_DLL int MXStorageEmptyCache(int dev_type, int dev_id);
3121 
3131 MXNET_DLL int MXNDArrayCreateFromSharedMemEx(int shared_pid, int shared_id, const int *shape,
3132  int ndim, int dtype, NDArrayHandle *out);
3133 
3151 MXNET_DLL int MXEnginePushAsync(EngineAsyncFunc async_func, void* func_param,
3152  EngineFuncParamDeleter deleter, ContextHandle ctx_handle,
3153  EngineVarHandle const_vars_handle, int num_const_vars,
3154  EngineVarHandle mutable_vars_handle, int num_mutable_vars,
3155  EngineFnPropertyHandle prop_handle DEFAULT(NULL),
3156  int priority DEFAULT(0), const char* opr_name DEFAULT(NULL),
3157  bool wait DEFAULT(false));
3158 
3174 MXNET_DLL int MXEnginePushSync(EngineSyncFunc sync_func, void* func_param,
3175  EngineFuncParamDeleter deleter, ContextHandle ctx_handle,
3176  EngineVarHandle const_vars_handle, int num_const_vars,
3177  EngineVarHandle mutable_vars_handle, int num_mutable_vars,
3178  EngineFnPropertyHandle prop_handle DEFAULT(NULL),
3179  int priority DEFAULT(0), const char* opr_name DEFAULT(NULL));
3185 MXNET_DLL int MXShallowCopyNDArray(NDArrayHandle src, NDArrayHandle* out);
3191 MXNET_DLL int MXShallowCopySymbol(SymbolHandle src, SymbolHandle * out);
3192 
3210 MXNET_DLL int MXEnginePushAsyncND(EngineAsyncFunc async_func, void* func_param,
3211  EngineFuncParamDeleter deleter, ContextHandle ctx_handle,
3212  NDArrayHandle* const_nds_handle, int num_const_nds,
3213  NDArrayHandle* mutable_nds_handle, int num_mutable_nds,
3214  EngineFnPropertyHandle prop_handle DEFAULT(NULL),
3215  int priority DEFAULT(0), const char* opr_name DEFAULT(NULL),
3216  bool wait DEFAULT(false));
3217 
3233 MXNET_DLL int MXEnginePushSyncND(EngineSyncFunc sync_func, void* func_param,
3234  EngineFuncParamDeleter deleter, ContextHandle ctx_handle,
3235  NDArrayHandle* const_nds_handle, int num_const_nds,
3236  NDArrayHandle* mutable_nds_handle, int num_mutable_nds,
3237  EngineFnPropertyHandle prop_handle DEFAULT(NULL),
3238  int priority DEFAULT(0), const char* opr_name DEFAULT(NULL));
3239 
3240 #ifdef __cplusplus
3241 }
3242 #endif // __cplusplus
3243 
3244 #endif // MXNET_C_API_H_
MXNET_DLL int MXKVStoreCreate(const char *type, KVStoreHandle *out)
Create a kvstore.
int(* CustomFunctionDelFunc)(void *)
Definition: c_api.h:217
MXNET_DLL int MXSymbolListAttr(SymbolHandle symbol, uint32_t *out_size, const char ***out)
Get all attributes from symbol, including all descendents.
MXNET_DLL int MXProfileAdjustCounter(ProfileHandle counter_handle, int64_t value)
Adjust a counter by the given amount, given its handle.
MXNET_DLL int MXProfileCreateFrame(ProfileHandle domain, const char *frame_name, ProfileHandle *out)
Create profile frame.
Definition: c_api.h:172
MXNET_DLL int MXSymbolRemoveAmpCast(SymbolHandle sym_handle, SymbolHandle *ret_sym_handle)
Remove the operators amp_cast and amp_multicast.
MXNET_DLL int MXDataIterGetLabel(DataIterHandle handle, NDArrayHandle *out)
Get the handle to the NDArray of underlying label.
MXNET_DLL int MXNDArrayCallDLPackDeleter(DLManagedTensorHandle dlpack)
Delete a dlpack tensor.
MXNET_DLL int MXNDArraySetGradState(NDArrayHandle handle, int state)
set the flag for gradient array state.
MXNET_DLL int MXNDArrayAt64(NDArrayHandle handle, int64_t idx, NDArrayHandle *out)
MXNET_DLL int MXSymbolListAuxiliaryStates(SymbolHandle symbol, uint32_t *out_size, const char ***out_str_array)
List auxiliary states in the symbol.
MXNET_DLL int MXSymbolListAttrShallow(SymbolHandle symbol, uint32_t *out_size, const char ***out)
Get all attributes from symbol, excluding descendents.
MXNET_DLL int MXProfilePause(int paused)
Pause profiler tuning collection for worker/current process.
MXNET_DLL int MXSetCalibTableToQuantizedSymbol(SymbolHandle qsym_handle, const uint32_t 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 MXAutogradComputeGradient(uint32_t num_output, NDArrayHandle *output_handles)
compute the gradient of outputs w.r.t variabels
MXNET_DLL int MXNDArrayGetShapeEx(NDArrayHandle handle, int *out_dim, const int **out_pdata)
get the shape of the array
MXNET_DLL int MXRecordIOReaderSeek(RecordIOHandle handle, size_t pos)
Set the current reader pointer position.
void * DataIterCreator
handle a dataiter creator
Definition: c_api.h:81
int(* CustomOpInferShapeFunc)(int, int *, int **, void *)
Definition: c_api.h:189
MXNET_DLL int MXDataIterGetIndex(DataIterHandle handle, uint64_t **out_index, uint64_t *out_size)
Get the image index by array.
MXNET_DLL int MXRtcPush(RtcHandle handle, uint32_t num_input, uint32_t num_output, NDArrayHandle *inputs, NDArrayHandle *outputs, uint32_t gridDimX, uint32_t gridDimY, uint32_t gridDimZ, uint32_t blockDimX, uint32_t blockDimY, uint32_t blockDimZ)
Run cuda kernel.
MXNET_DLL int MXKVStoreIsServerNode(int *ret)
return whether or not this process is a server node.
void * ExecutorHandle
handle to an Executor
Definition: c_api.h:79
MXNET_DLL int MXProfileCreateEvent(const char *event_name, ProfileHandle *out)
Create profile event.
MXNET_DLL int MXKVStorePull(KVStoreHandle handle, uint32_t num, const int *keys, NDArrayHandle *vals, int priority)
pull a list of (key, value) pairs from the kvstore
void * p_infer_shape
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.
PaddingExp< SrcExp, DType, ExpInfo< SrcExp >::kDim > pad(const Exp< SrcExp, DType, etype > &src, index_t pad)
padding expression, pad a image with zeros on boundaries, padding affects shape[0], and shape[1]
Definition: pad.h:53
Definition: c_api.h:177
MXNET_DLL int MXAutogradMarkVariables(uint32_t num_var, NDArrayHandle *var_handles, uint32_t *reqs_array, NDArrayHandle *grad_handles)
mark NDArrays as variables to compute gradient for autograd
void(* list_arguments)(char ***, void *)
Definition: c_api.h:125
void * SymbolHandle
handle to a symbol that can be bind as operator
Definition: c_api.h:75
MXNET_DLL int MXNDArrayGetDType(NDArrayHandle handle, int *out_dtype)
get the type of the data in NDArray
MXNET_DLL int MXRtcCudaKernelCall(CudaKernelHandle handle, int dev_id, void **args, uint32_t grid_dim_x, uint32_t grid_dim_y, uint32_t grid_dim_z, uint32_t block_dim_x, uint32_t block_dim_y, uint32_t block_dim_z, uint32_t shared_mem)
MXNET_DLL int MXAggregateProfileStatsPrint(const char **out_str, int reset)
Deprecated, use MXAggregateProfileStatsPrintEx instead.
MXNET_DLL int MXSymbolInferShapePartialEx64(SymbolHandle sym, uint32_t num_args, const char **keys, const int64_t *arg_ind_ptr, const int64_t *arg_shape_data, size_t *in_shape_size, const int **in_shape_ndim, const int64_t ***in_shape_data, size_t *out_shape_size, const int **out_shape_ndim, const int64_t ***out_shape_data, size_t *aux_shape_size, const int **aux_shape_ndim, const int64_t ***aux_shape_data, int *complete)
float mx_float
manually define float
Definition: c_api.h:60
MXNET_DLL int MXNDArraySlice(NDArrayHandle handle, uint32_t slice_begin, uint32_t slice_end, NDArrayHandle *out)
Slice the NDArray along axis 0.
MXNET_DLL int MXSetProfilerState(int state)
Set up state of profiler for current process.
int(* CustomOpBwdDepFunc)(const int *, const int *, const int *, int *, int **, void *)
Definition: c_api.h:197
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 MXNDArraySyncCheckFormat(NDArrayHandle handle, const bool full_check)
check whether the NDArray format is valid
MXNET_DLL int MXGenBackendSubgraph(SymbolHandle sym_handle, const char *backend, SymbolHandle *ret_sym_handle)
Run subgraph pass based on the backend provided.
MXNET_DLL int MXNDArrayCreateEx64(const int64_t *shape, int ndim, int dev_type, int dev_id, int delay_alloc, int dtype, NDArrayHandle *out)
int(* CustomFunctionBwdFunc)(int, int, void **, const int *, const int, void *)
Definition: c_api.h:214
void * p_forward
Definition: c_api.h:143
void * ProfileHandle
handle to a Profile object (domain, duration, counter, etc.)
Definition: c_api.h:95
MXNET_DLL int MXAutogradBackward(uint32_t num_output, NDArrayHandle *output_handles, NDArrayHandle *ograd_handles, int retain_graph)
compute the gradient of outputs w.r.t variabels
Definition: c_api.h:166
MXNET_DLL int MXCachedOpRegisterOpHook(NDArrayHandle handle, CachedOpMonitorCallback callback, bool monitor_all)
cached op set monitor callback
MXNET_DLL int MXSymbolGetNumOutputs(SymbolHandle symbol, uint32_t *output_count)
Get number of outputs of the symbol.
MXNET_DLL int MXProfileDestroyHandle(ProfileHandle frame_handle)
Destroy a frame.
CustomFunctionCallbacks
Definition: c_api.h:209
MXNET_DLL int MXSymbolGetInputSymbols(SymbolHandle sym, SymbolHandle **inputs, int *input_size)
Get the input symbols of the graph.
MXNET_DLL int MXSymbolInferShape64(SymbolHandle sym, uint32_t num_args, const char **keys, const int64_t *arg_ind_ptr, const int64_t *arg_shape_data, size_t *in_shape_size, const int **in_shape_ndim, const int64_t ***in_shape_data, size_t *out_shape_size, const int **out_shape_ndim, const int64_t ***out_shape_data, size_t *aux_shape_size, const int **aux_shape_ndim, const int64_t ***aux_shape_data, int *complete)
MXNET_DLL int MXExecutorSetMonitorCallbackEX(ExecutorHandle handle, ExecutorMonitorCallback callback, void *callback_handle, bool monitor_all)
set a call back to notify the completion of operation
MXNET_DLL int MXExecutorBindEX(SymbolHandle symbol_handle, int dev_type, int dev_id, uint32_t num_map_keys, const char **map_keys, const int *map_dev_types, const int *map_dev_ids, uint32_t len, NDArrayHandle *in_args, NDArrayHandle *arg_grad_store, uint32_t *grad_req_type, uint32_t 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 MXProfileSetMarker(ProfileHandle domain, const char *instant_marker_name, const char *scope)
Mark a single instant in time.
MXNET_DLL int MXKVStoreFree(KVStoreHandle handle)
Delete a KVStore handle.
MXNET_DLL int MXShallowCopySymbol(SymbolHandle src, SymbolHandle *out)
Create an Symbol from source sharing the same graph structure.
MXNET_DLL int MXRtcCudaModuleFree(CudaModuleHandle handle)
MXNET_DLL int MXIsNumpyShape(int *curr)
get whether numpy compatibility is on
MXNET_DLL int MXKVStorePullRowSparse(KVStoreHandle handle, uint32_t 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 ...
void * AtomicSymbolCreator
handle to a function that takes param and creates symbol
Definition: c_api.h:71
MXNET_DLL int MXNDArrayGetAuxType(NDArrayHandle handle, uint32_t i, int *out_type)
get the type of the ith aux data in NDArray
MXNET_DLL int MXRtcFree(RtcHandle handle)
Delete a MXRtc object.
MXNET_DLL int MXFuncDescribe(FunctionHandle fun, uint32_t *num_use_vars, uint32_t *num_scalars, uint32_t *num_mutate_vars, int *type_mask)
get the argument requirements of the function
void * p_backward
Definition: c_api.h:128
MXNET_DLL int MXCreateCachedOpEx(SymbolHandle handle, int num_flags, const char **keys, const char **vals, CachedOpHandle *out)
create cached operator
MXNET_DLL int MXSetIsNumpyShape(int is_np_shape, int *prev)
set numpy compatibility switch
MXNET_DLL int MXSymbolPrint(SymbolHandle symbol, const char **out_str)
Print the content of symbol, used for debug.
MXNET_DLL int MXGetGPUMemoryInformation64(int dev, uint64_t *free_mem, uint64_t *total_mem)
get the free and total available memory on a GPU
int(* CustomOpFBFunc)(int, void **, int *, const int *, const int, void *)
Definition: c_api.h:184
MXNET_DLL int MXKVStoreBarrier(KVStoreHandle handle)
global barrier among all worker machines
MXNET_DLL int MXExecutorSimpleBindEx(SymbolHandle symbol_handle, int dev_type, int dev_id, const uint32_t num_g2c_keys, const char **g2c_keys, const int *g2c_dev_types, const int *g2c_dev_ids, const uint32_t provided_grad_req_list_len, const char **provided_grad_req_names, const char **provided_grad_req_types, const uint32_t num_provided_arg_shapes, const char **provided_arg_shape_names, const int *provided_arg_shape_data, const uint32_t *provided_arg_shape_idx, const uint32_t num_provided_arg_dtypes, const char **provided_arg_dtype_names, const int *provided_arg_dtypes, const uint32_t num_provided_arg_stypes, const char **provided_arg_stype_names, const int *provided_arg_stypes, const uint32_t 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, uint32_t *num_in_args, NDArrayHandle **in_args, NDArrayHandle **arg_grads, uint32_t *num_aux_states, NDArrayHandle **aux_states, ExecutorHandle shared_exec_handle, ExecutorHandle *out)
MXNET_DLL int MXDataIterBeforeFirst(DataIterHandle handle)
Call iterator.Reset.
MXNET_DLL int MXNDArrayGetShape(NDArrayHandle handle, uint32_t *out_dim, const uint32_t **out_pdata)
DEPRECATED. Use MXNDArrayGetShapeEx instead. get the shape of the array.
MXNET_DLL int MXNDArrayGetAuxNDArray64(NDArrayHandle handle, int64_t i, NDArrayHandle *out)
MXNET_DLL int MXNDArrayCreateEx(const uint32_t *shape, uint32_t 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 MXNDArrayDetach(NDArrayHandle handle, NDArrayHandle *out)
detach and ndarray from computation graph by clearing entry_
void(* CachedOpMonitorCallback)(const char *, const char *, NDArrayHandle)
Monitor callback called at operator level for cached op.
Definition: c_api.h:115
MXNET_DLL int MXAggregateProfileStatsPrintEx(const char **out_str, int reset, int format, int sort_by, int ascending)
Print sorted aggregate stats to the a string How aggregate stats are stored will not change...
bool enabled
Definition: c_api.h:161
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 MXEngineSetBulkSize(int bulk_size, int *prev_bulk_size)
set bulk execution limit
MXNET_DLL int MXNDArrayFree(NDArrayHandle handle)
free the narray handle
MXNET_DLL int MXStorageEmptyCache(int dev_type, int dev_id)
Release all unreferenced memory from the devices storage managers memory pool.
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
void(* ExecutorMonitorCallback)(const char *, NDArrayHandle, void *)
Definition: c_api.h:111
Definition: c_api.h:167
MXNET_DLL int MXKVStoreGetGroupSize(KVStoreHandle handle, int *ret)
return The number of nodes in this group, which is
MXNET_DLL int MXSetNumOMPThreads(int thread_num)
Set the number of OMP threads to use.
MXNET_DLL int MXRandomSeed(int seed)
Seed all global random number generators in mxnet.
MXNET_DLL int MXExecutorOutputs(ExecutorHandle handle, uint32_t *out_size, NDArrayHandle **out)
Get executor&#39;s head NDArray.
MXNET_DLL int MXKVStorePullEx(KVStoreHandle handle, uint32_t 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 MXNDArrayAt(NDArrayHandle handle, uint32_t idx, NDArrayHandle *out)
Index the NDArray along axis 0.
MXNET_DLL int MXProfileCreateDomain(const char *domain, ProfileHandle *out)
Create profiling domain.
MXNET_DLL int MXSymbolFree(SymbolHandle symbol)
Free the symbol handle.
Definition: c_api.h:210
MXNET_DLL int MXSymbolGetAttr(SymbolHandle symbol, const char *key, const char **out, int *success)
Get string attribute from symbol.
MXNET_DLL int MXShallowCopyNDArray(NDArrayHandle src, NDArrayHandle *out)
Create an NDArray from source sharing the same data chunk.
Definition: c_api.h:134
void * p_forward
Definition: c_api.h:127
MXNET_DLL int MXExecutorBackward(ExecutorHandle handle, uint32_t len, NDArrayHandle *head_grads)
Excecutor run backward.
void * p_list_arguments
Definition: c_api.h:131
MXNET_DLL int MXKVStoreInitEx(KVStoreHandle handle, uint32_t num, const char **keys, NDArrayHandle *vals)
Init a list of (key,value) pairs in kvstore, where each key is a string.
MXNET_DLL int MXNDArrayCreate(const uint32_t *shape, uint32_t ndim, int dev_type, int dev_id, int delay_alloc, NDArrayHandle *out)
create a NDArray with specified shape
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 MXNDArrayGetGrad(NDArrayHandle handle, NDArrayHandle *out)
return gradient buffer attached to this NDArray
MXNET_DLL int MXNDArrayGetGradState(NDArrayHandle handle, int *out)
set the flag for gradient array state.
MXNET_DLL int MXRecordIOWriterFree(RecordIOHandle handle)
Delete a RecordIO writer object.
MXNET_DLL int MXExecutorSimpleBindEx64(SymbolHandle symbol_handle, int dev_type, int dev_id, const uint32_t num_g2c_keys, const char **g2c_keys, const int *g2c_dev_types, const int *g2c_dev_ids, const uint32_t provided_grad_req_list_len, const char **provided_grad_req_names, const char **provided_grad_req_types, const uint32_t num_provided_arg_shapes, const char **provided_arg_shape_names, const int64_t *provided_arg_shape_data, const uint32_t *provided_arg_shape_idx, const uint32_t num_provided_arg_dtypes, const char **provided_arg_dtype_names, const int *provided_arg_dtypes, const uint32_t num_provided_arg_stypes, const char **provided_arg_stype_names, const int *provided_arg_stypes, const uint32_t 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, uint32_t *num_in_args, NDArrayHandle **in_args, NDArrayHandle **arg_grads, uint32_t *num_aux_states, NDArrayHandle **aux_states, ExecutorHandle shared_exec_handle, ExecutorHandle *out)
void * p_declare_backward_dependency
Definition: c_api.h:148
MXNET_DLL int MXNDArrayGetData(NDArrayHandle handle, void **out_pdata)
get the content of the data in NDArray
int(* CustomOpInferTypeFunc)(int, int *, void *)
Definition: c_api.h:196
MXNET_DLL int MXKVStoreSendCommmandToServers(KVStoreHandle handle, int cmd_id, const char *cmd_body)
Send a command to all server nodes.
MXNET_DLL int MXFuncInvoke(FunctionHandle fun, NDArrayHandle *use_vars, 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 MXLoadLib(const char *path)
Load library dynamically.
Definition: c_api.h:174
MXNET_DLL int MXExecutorReshapeEx(int partial_shaping, int allow_up_sizing, int dev_type, int dev_id, uint32_t num_map_keys, const char **map_keys, const int *map_dev_types, const int *map_dev_ids, const uint32_t num_provided_arg_shapes, const char **provided_arg_shape_names, const int *provided_arg_shape_data, const uint32_t *provided_arg_shape_idx, uint32_t *num_in_args, NDArrayHandle **in_args, NDArrayHandle **arg_grads, uint32_t *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...
void * CudaKernelHandle
handle to rtc cuda kernel
Definition: c_api.h:93
MXNET_DLL int MXRandomSeedContext(int seed, int dev_type, int dev_id)
Seed the global random number generator of the given device.
void * p_list_arguments
Definition: c_api.h:147
MXNET_DLL int MXSymbolGetChildren(SymbolHandle symbol, SymbolHandle *out)
Get a symbol that contains only direct children.
MXNET_DLL int MXKVStoreRunServer(KVStoreHandle handle, MXKVStoreServerController controller, void *controller_handle)
Run as server (or scheduler)
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 MXGenAtomicSymbolFromSymbol(SymbolHandle sym_handle, SymbolHandle *ret_sym_handle)
Generate atomic symbol (able to be composed) from a source symbol.
MXNET_DLL int MXAutogradIsRecording(bool *curr)
get whether autograd recording is on
MXNET_DLL int MXReducePrecisionSymbol(SymbolHandle sym_handle, SymbolHandle *ret_sym_handle, uint32_t num_args, const int *arg_type_data, uint32_t num_ind_ptr, const int *ind_ptr, const int *target_dtype, const int cast_optional_params, const uint32_t num_target_dtype_op_names, const uint32_t num_fp32_op_names, const uint32_t num_widest_dtype_op_names, const uint32_t num_conditional_fp32_op_names, const uint32_t num_excluded_symbols, const uint32_t num_model_params, const char **target_dtype_op_names, const char **fp32_op_names, const char **widest_dtype_op_names, const char **conditional_fp32_op_names, const char **excluded_symbols, const char **conditional_param_names, const char **conditional_param_vals, const char **model_param_names, const char **arg_names)
Convert a symbol into a mixed precision symbol with cast operators for target dtype casting...
MXNET_DLL int MXNDArrayToDLPack(NDArrayHandle handle, DLManagedTensorHandle *out_dlpack)
Create a reference view of NDArray that represents as DLManagedTensor Notice: MXNet uses asynchronous...
int(* CustomOpPropCreator)(const char *, const int, const char **, const char **, struct MXCallbackList *)
Definition: c_api.h:204
MXNET_DLL int MXFuncInvokeEx(FunctionHandle fun, NDArrayHandle *use_vars, 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 MXExecutorSimpleBind(SymbolHandle symbol_handle, int dev_type, int dev_id, const uint32_t num_g2c_keys, const char **g2c_keys, const int *g2c_dev_types, const int *g2c_dev_ids, const uint32_t provided_grad_req_list_len, const char **provided_grad_req_names, const char **provided_grad_req_types, const uint32_t num_provided_arg_shapes, const char **provided_arg_shape_names, const uint32_t *provided_arg_shape_data, const uint32_t *provided_arg_shape_idx, const uint32_t num_provided_arg_dtypes, const char **provided_arg_dtype_names, const int *provided_arg_dtypes, const uint32_t num_provided_arg_stypes, const char **provided_arg_stype_names, const int *provided_arg_stypes, const uint32_t 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, uint32_t *num_in_args, NDArrayHandle **in_args, NDArrayHandle **arg_grads, uint32_t *num_aux_states, NDArrayHandle **aux_states, ExecutorHandle shared_exec_handle, ExecutorHandle *out)
DEPRECATED. Use MXExecutorSimpleBindEx instead.
MXNET_DLL int MXSymbolCreateFromFile(const char *fname, SymbolHandle *out)
Load a symbol from a json file.
MXNET_DLL int MXDataIterGetData(DataIterHandle handle, NDArrayHandle *out)
Get the handle to the NDArray of underlying data.
MXNET_DLL int MXSymbolCreateGroup(uint32_t num_symbols, SymbolHandle *symbols, SymbolHandle *out)
Create a Symbol by grouping list of symbols together.
int num_callbacks
Definition: c_api.h:154
MXNET_DLL int MXGetGPUCount(int *out)
Get the number of GPUs.
MXNET_DLL int MXListAllOpNames(uint32_t *out_size, const char ***out_array)
list all the available operator names, include entries.
MXNET_DLL int MXFreeCachedOp(CachedOpHandle handle)
free cached operator
MXNET_DLL int MXRecordIOReaderFree(RecordIOHandle handle)
Delete a RecordIO reader object.
MXNET_DLL int MXNotifyShutdown()
Notify the engine about a shutdown, This can help engine to print less messages into display...
void(* forward)(int, float **, int *, unsigned **, int *, void *)
Definition: c_api.h:121
MXNET_DLL int MXSymbolInferTypePartial(SymbolHandle sym, uint32_t num_args, const char **keys, const int *arg_type_data, uint32_t *in_type_size, const int **in_type_data, uint32_t *out_type_size, const int **out_type_data, uint32_t *aux_type_size, const int **aux_type_data, int *complete)
partially infer type of unknown input types given the known one.
MXNET_DLL int MXKVStorePushEx(KVStoreHandle handle, uint32_t num, const char **keys, NDArrayHandle *vals, int priority)
Push a list of (key,value) pairs to kvstore, where each key is a string.
MXNET_DLL int MXExecutorSetMonitorCallback(ExecutorHandle handle, ExecutorMonitorCallback callback, void *callback_handle)
set a call back to notify the completion of operation
MXNET_DLL int MXSymbolGetAtomicSymbolInfo(AtomicSymbolCreator creator, const char **name, const char **description, uint32_t *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.
MXNET_DLL int MXEnginePushAsyncND(EngineAsyncFunc async_func, void *func_param, EngineFuncParamDeleter deleter, ContextHandle ctx_handle, NDArrayHandle *const_nds_handle, int num_const_nds, NDArrayHandle *mutable_nds_handle, int num_mutable_nds, EngineFnPropertyHandle prop_handle DEFAULT(NULL), int priority DEFAULT(0), const char *opr_name DEFAULT(NULL), bool wait DEFAULT(false))
Push an asynchronous operation to the engine.
Definition: c_api.h:171
int(* CustomOpDelFunc)(void *)
Definition: c_api.h:187
MXNET_DLL int MXProfileCreateTask(ProfileHandle domain, const char *task_name, ProfileHandle *out)
Create profile task.
const char * name
Definition: c_api.h:160
MXNET_DLL int MXAutogradSetIsRecording(int is_recording, int *prev)
set whether to record operator for autograd
MXNET_DLL int MXNDArrayLoad(const char *fname, uint32_t *out_size, NDArrayHandle **out_arr, uint32_t *out_name_size, const char ***out_names)
Load list of narray from the file.
MXNET_DLL int MXSymbolGetInternals(SymbolHandle symbol, SymbolHandle *out)
Get a symbol that contains all the internals.
Definition: c_api.h:179
MXNET_DLL int MXFuncGetInfo(FunctionHandle fun, const char **name, const char **description, uint32_t *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 MXNDArrayGetAuxNDArray(NDArrayHandle handle, uint32_t i, NDArrayHandle *out)
Get a deep copy of the ith aux data blob in the form of an NDArray of default storage type...
Definition: c_api.h:211
MXNET_DLL int MXKVStoreGetType(KVStoreHandle handle, const char **type)
get the type of the kvstore
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
void(* EngineSyncFunc)(void *, void *)
Engine synchronous operation.
Definition: c_api.h:108
Definition: c_api.h:178
MXNET_DLL int MXSymbolInferShapePartialEx(SymbolHandle sym, uint32_t num_args, const char **keys, const uint32_t *arg_ind_ptr, const int *arg_shape_data, uint32_t *in_shape_size, const int **in_shape_ndim, const int ***in_shape_data, uint32_t *out_shape_size, const int **out_shape_ndim, const int ***out_shape_data, uint32_t *aux_shape_size, const int **aux_shape_ndim, const int ***aux_shape_data, int *complete)
partially infer shape of unknown input shapes given the known one.
MXNET_DLL int MXNDArrayGetStorageType(NDArrayHandle handle, int *out_storage_type)
get the storage type of the array
MXNET_DLL int MXListFunctions(uint32_t *out_size, FunctionHandle **out_array)
list all the available functions handles most user can use it to list all the needed functions ...
MXNET_DLL int MXGetVersion(int *out)
get the MXNet library version as an integer
MXNET_DLL int MXNDArrayCreateSparseEx(int storage_type, const uint32_t *shape, uint32_t ndim, int dev_type, int dev_id, int delay_alloc, int dtype, uint32_t num_aux, int *aux_type, uint32_t *aux_ndims, const uint32_t *aux_shape, NDArrayHandle *out)
create an empty sparse NDArray with specified shape and data type
int(* MXGenericCallback)(void)
Definition: c_api.h:151
void(* EngineFuncParamDeleter)(void *)
Callback to free the param for EngineAsyncFunc/EngineSyncFunc.
Definition: c_api.h:110
MXNET_DLL int MXAutogradIsTraining(bool *curr)
get whether training mode is on
MXNET_DLL int MXProcessProfilePause(int paused, int profile_process, KVStoreHandle kvStoreHandle)
Pause profiler tuning collection.
const void * ContextHandle
handle to Context
Definition: c_api.h:99
MXNET_DLL int MXRtcCudaKernelFree(CudaKernelHandle handle)
MXNET_DLL int MXKVStorePullWithSparse(KVStoreHandle handle, uint32_t num, const int *keys, NDArrayHandle *vals, int priority, bool ignore_sparse)
pull a list of (key, value) pairs from the kvstore
void * p_list_outputs
Definition: c_api.h:146
void(* EngineAsyncFunc)(void *, void *, void *)
Engine asynchronous operation.
Definition: c_api.h:106
MXNET_DLL int MXCreateCachedOp(SymbolHandle handle, CachedOpHandle *out)
create cached operator
MXNET_DLL int MXNDArrayReshape64(NDArrayHandle handle, int ndim, dim_t *dims, bool reverse, NDArrayHandle *out)
Reshape the NDArray.
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 MXProfileDurationStart(ProfileHandle duration_handle)
Start timing the duration of a profile duration object such as an event, task or frame.
MXNET_DLL int MXOptimizeForBackend(SymbolHandle sym_handle, const char *backend_name, const int dev_type, SymbolHandle *ret_sym_handle, const mx_uint len, NDArrayHandle *in_args_handle, const mx_uint num_options, const char **keys, const char **vals)
Partitions symbol for given backend, potentially creating subgraphs.
MXNET_DLL int MXEnginePushSyncND(EngineSyncFunc sync_func, void *func_param, EngineFuncParamDeleter deleter, ContextHandle ctx_handle, NDArrayHandle *const_nds_handle, int num_const_nds, NDArrayHandle *mutable_nds_handle, int num_mutable_nds, EngineFnPropertyHandle prop_handle DEFAULT(NULL), int priority DEFAULT(0), const char *opr_name DEFAULT(NULL))
Push a synchronous operation to the engine.
MXNET_DLL int MXSymbolListArguments(SymbolHandle symbol, uint32_t *out_size, const char ***out_str_array)
List arguments in the symbol.
void * RtcHandle
handle to MXRtc
Definition: c_api.h:89
MXNET_DLL int MXKVStorePushPull(KVStoreHandle handle, mx_uint vnum, const int *vkeys, mx_uint onum, const int *okeys, NDArrayHandle *vals, NDArrayHandle *outs, int priority)
push and pull a list of (key, value) pairs from the kvstore
MXNET_DLL int MXNDArraySlice64(NDArrayHandle handle, int64_t slice_begin, int64_t slice_end, NDArrayHandle *out)
MXNET_DLL int MXSymbolInferType(SymbolHandle sym, uint32_t num_args, const char **keys, const int *arg_type_data, uint32_t *in_type_size, const int **in_type_data, uint32_t *out_type_size, const int **out_type_data, uint32_t *aux_type_size, const int **aux_type_data, int *complete)
infer type of unknown input types given the known one. The types are packed into a CSR matrix represe...
MXNET_DLL int 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
#define DEFAULT(x)
Inhibit C++ name-mangling for MXNet functions.
Definition: c_api.h:37
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 MXRtcCudaKernelCreate(CudaModuleHandle handle, const char *name, int num_args, int *is_ndarray, int *is_const, int *arg_types, CudaKernelHandle *out)
void * RecordIOHandle
handle to RecordIO
Definition: c_api.h:87
MXNET_DLL int MXKVStoreSetBarrierBeforeExit(KVStoreHandle handle, const int barrier_before_exit)
whether to do barrier when finalize
MXNET_DLL int MXSetProcessProfilerConfig(int num_params, const char *const *keys, const char *const *vals, KVStoreHandle kvstoreHandle)
Set up configuration of profiler for the process passed as profile_process in keys.
MXNET_DLL int MXEnginePushAsync(EngineAsyncFunc async_func, void *func_param, EngineFuncParamDeleter deleter, ContextHandle ctx_handle, EngineVarHandle const_vars_handle, int num_const_vars, EngineVarHandle mutable_vars_handle, int num_mutable_vars, EngineFnPropertyHandle prop_handle DEFAULT(NULL), int priority DEFAULT(0), const char *opr_name DEFAULT(NULL), bool wait DEFAULT(false))
Push an asynchronous operation to the engine.
MXNET_DLL int MXExecutorFree(ExecutorHandle handle)
Delete the executor.
MXNET_DLL int MXSymbolSaveToFile(SymbolHandle symbol, const char *fname)
Save a symbol into a json file.
MXNET_DLL int MXRtcCudaModuleCreate(const char *source, int num_options, const char **options, int num_exports, const char **exports, CudaModuleHandle *out)
void * p_infer_shape
Definition: c_api.h:129
void * AtomicSymbolHandle
handle to a AtomicSymbol
Definition: c_api.h:77
const void * EngineFnPropertyHandle
handle to Engine FnProperty
Definition: c_api.h:101
MXNET_DLL int MXSymbolCreateAtomicSymbol(AtomicSymbolCreator creator, uint32_t num_param, const char **keys, const char **vals, SymbolHandle *out)
Create an AtomicSymbol.
MXNET_DLL int MXNDArrayGetShape64(NDArrayHandle handle, int *out_dim, const int64_t **out_pdata)
MXNET_DLL int MXProfileSetCounter(ProfileHandle counter_handle, uint64_t value)
Set a counter, given its handle.
MXNET_DLL int MXNDArrayCreateNone(NDArrayHandle *out)
Load TVM operator from the binary library.
MXNET_DLL int MXKVStorePullWithSparseEx(KVStoreHandle handle, uint32_t 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
Definition: c_api.h:165
MXNET_DLL int MXDumpProcessProfile(int finished, int profile_process, KVStoreHandle kvStoreHandle)
Save profile and stop profiler.
MXNET_DLL int MXSetProcessProfilerState(int state, int profile_process, KVStoreHandle kvStoreHandle)
Set up state of profiler for either worker or server process.
CustomOpCallbacks
Definition: c_api.h:164
MXNET_DLL int MXNDArrayCreateFromSharedMemEx(int shared_pid, int shared_id, const int *shape, int ndim, int dtype, NDArrayHandle *out)
Reconstruct NDArray from shared memory handle.
void * p_backward
Definition: c_api.h:144
MXNET_DLL int MXNDArrayGetAuxType64(NDArrayHandle handle, int64_t i, int *out_type)
void * NDArrayHandle
handle to NDArray
Definition: c_api.h:67
Definition: c_api.h:159
void * KVStoreHandle
handle to KVStore
Definition: c_api.h:85
void * CudaModuleHandle
handle to rtc cuda module
Definition: c_api.h:91
MXNET_DLL int MXSymbolGetName(SymbolHandle symbol, const char **out, int *success)
Get string name from symbol.
MXNET_DLL int MXNDArraySave(const char *fname, uint32_t num_args, NDArrayHandle *args, const char **keys)
Save list of narray into the file.
MXNET_DLL int MXKVStorePullRowSparseEx(KVStoreHandle handle, uint32_t 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 MXSymbolSaveToJSON(SymbolHandle symbol, const char **out_json)
Save a symbol into a json string.
MXNET_DLL int MXLibInfoFeatures(const struct LibFeature **libFeature, size_t *size)
Get list of features supported on the runtime.
MXNET_DLL int MXKVStoreInit(KVStoreHandle handle, uint32_t num, const int *keys, NDArrayHandle *vals)
Init a list of (key,value) pairs in kvstore.
MXNET_DLL int MXKVStoreSetUpdater(KVStoreHandle handle, MXKVStoreUpdater updater, void *updater_handle)
register a push updater
MXNET_DLL int MXNDArrayWaitToWrite(NDArrayHandle handle)
Wait until all the pending read/write with respect NDArray are finished. Always call this before writ...
CustomOpPropCallbacks
Definition: c_api.h:170
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 MXQuantizeSymbol(SymbolHandle sym_handle, SymbolHandle *ret_sym_handle, const int *dev_type, const uint32_t num_excluded_sym_names, const char **excluded_sym_names, const uint32_t num_excluded_op_names, const char **excluded_op_names, const uint32_t num_offline, const char **offline_params, const char *quantized_dtype, const bool calib_quantize, const char *quantize_mode, uint32_t *out_num_calib_names, const char ***out_calib_names)
Convert a symbol into a quantized symbol where FP32 operators are replaced with INT8.
MXNET_DLL int MXSymbolGetAtomicSymbolName(AtomicSymbolCreator creator, const char **name)
Get the name of an atomic symbol.
MXNET_DLL int MXAutogradGetSymbol(NDArrayHandle handle, SymbolHandle *out)
MXNET_DLL int MXCustomFunctionRecord(int num_inputs, NDArrayHandle *inputs, int num_outputs, NDArrayHandle *outputs, struct MXCallbackList *callbacks)
Definition: c_api.h:173
void * CachedOpHandle
handle to cached operator
Definition: c_api.h:73
MXNET_DLL int MXSymbolCompose(SymbolHandle sym, const char *name, uint32_t num_args, const char **keys, SymbolHandle *args)
Compose the symbol on other symbols.
MXNET_DLL int MXNDArrayFromDLPack(DLManagedTensorHandle dlpack, NDArrayHandle *out_handle)
DEPRECATED. Use MXNDArrayFromDLPackEx instead.
MXNET_DLL int MXSymbolListOutputs(SymbolHandle symbol, uint32_t *out_size, const char ***out_str_array)
List returns in the symbol.
MXNET_DLL int MXNDArrayWaitAll()
wait until all delayed operations in the system is completed
MXNET_DLL int MXSymbolInferShapeEx(SymbolHandle sym, uint32_t num_args, const char **keys, const uint32_t *arg_ind_ptr, const int *arg_shape_data, uint32_t *in_shape_size, const int **in_shape_ndim, const int ***in_shape_data, uint32_t *out_shape_size, const int **out_shape_ndim, const int ***out_shape_data, uint32_t *aux_shape_size, const int **aux_shape_ndim, const int ***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 MXDataIterGetIterInfo(DataIterCreator creator, const char **name, const char **description, uint32_t *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 MXInvokeCachedOp(CachedOpHandle handle, int num_inputs, NDArrayHandle *inputs, int *num_outputs, NDArrayHandle **outputs)
invoke cached operator
MXNET_DLL int MXRecordIOWriterTell(RecordIOHandle handle, size_t *pos)
Get the current writer pointer position.
#define MXNET_DLL
MXNET_DLL prefix for windows.
Definition: c_api.h:54
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 MXEnginePushSync(EngineSyncFunc sync_func, void *func_param, EngineFuncParamDeleter deleter, ContextHandle ctx_handle, EngineVarHandle const_vars_handle, int num_const_vars, EngineVarHandle mutable_vars_handle, int num_mutable_vars, EngineFnPropertyHandle prop_handle DEFAULT(NULL), int priority DEFAULT(0), const char *opr_name DEFAULT(NULL))
Push a synchronous operation to the engine.
MXNET_DLL int MXRtcCreate(char *name, uint32_t num_input, uint32_t num_output, char **input_names, char **output_names, NDArrayHandle *inputs, NDArrayHandle *outputs, char *kernel, RtcHandle *out)
Create a MXRtc object.
MXNET_DLL int MXNDArrayGetContext(NDArrayHandle handle, int *out_dev_type, int *out_dev_id)
get the context of the NDArray
MXNET_DLL int MXSymbolGrad(SymbolHandle sym, uint32_t num_wrt, const char **wrt, SymbolHandle *out)
Get the gradient graph of the symbol.
MXNET_DLL int MXKVStoreSetGradientCompression(KVStoreHandle handle, uint32_t num_params, const char **keys, const char **vals)
Set parameters to use low-bit compressed gradients.
MXNET_DLL int MXRecordIOWriterCreate(const char *uri, RecordIOHandle *out)
Create a RecordIO writer object.
MXNET_DLL int MXKVStoreIsSchedulerNode(int *ret)
return whether or not this process is a scheduler node.
MXNET_DLL int MXKVStorePush(KVStoreHandle handle, uint32_t num, const int *keys, NDArrayHandle *vals, int priority)
Push a list of (key,value) pairs to kvstore.
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:2778
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 MXSymbolCreateFromJSON(const char *json, SymbolHandle *out)
Load a symbol from a json string.
void * DLManagedTensorHandle
handle to DLManagedTensor
Definition: c_api.h:97
MXNET_DLL int MXDataIterCreateIter(DataIterCreator handle, uint32_t 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 MXExecutorForward(ExecutorHandle handle, int is_train)
Executor forward method.
MXNET_DLL int MXExecutorBackwardEx(ExecutorHandle handle, uint32_t len, NDArrayHandle *head_grads, int is_train)
Excecutor run backward.
MXNET_DLL int MXSymbolGetOutput(SymbolHandle symbol, uint32_t index, SymbolHandle *out)
Get index-th outputs of the symbol.
MXNET_DLL int MXNDArrayReshape(NDArrayHandle handle, int ndim, int *dims, NDArrayHandle *out)
Reshape the NDArray.
MXNET_DLL int MXNDArrayGetSharedMemHandle(NDArrayHandle handle, int *shared_pid, int *shared_id)
Get shared memory handle from NDArray.
void( MXKVStoreServerController)(int head, const char *body, void *controller_handle)
the prototype of a server controller
Definition: c_api.h:2885
void ** contexts
Definition: c_api.h:156
MXNET_DLL int MXCustomOpRegister(const char *op_type, CustomOpPropCreator creator)
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 MXNDArrayFromDLPackEx(DLManagedTensorHandle dlpack, const bool transient_handle, NDArrayHandle *out_handle)
Create a NDArray backed by a dlpack tensor.
MXNET_DLL int MXNDArrayCreateFromSharedMem(int shared_pid, int shared_id, const uint32_t *shape, uint32_t ndim, int dtype, NDArrayHandle *out)
DEPRECATED. Use MXNDArrayCreateFromSharedMemEx instead. Reconstruct NDArray from shared memory handle...
MXNET_DLL int MXExecutorGetOptimizedSymbol(ExecutorHandle handle, SymbolHandle *out)
get optimized graph from graph executor
MXNET_DLL int MXSetProfilerConfig(int num_params, const char *const *keys, const char *const *vals)
Set up configuration of profiler for worker/current process.
MXNET_DLL int MXDumpProfile(int finished)
Save profile and stop profiler for worker/current process.
MXNET_DLL int MXSymbolListAtomicSymbolCreators(uint32_t *out_size, AtomicSymbolCreator **out_array)
list all the available AtomicSymbolEntry
MXNET_DLL int MXDataIterNext(DataIterHandle handle, int *out)
Move iterator to next position.
MXNET_DLL int MXKVStoreIsWorkerNode(int *ret)
return whether or not this process is a worker node.
MXNET_DLL int MXSymbolInferShapePartial(SymbolHandle sym, uint32_t num_args, const char **keys, const uint32_t *arg_ind_ptr, const uint32_t *arg_shape_data, uint32_t *in_shape_size, const uint32_t **in_shape_ndim, const uint32_t ***in_shape_data, uint32_t *out_shape_size, const uint32_t **out_shape_ndim, const uint32_t ***out_shape_data, uint32_t *aux_shape_size, const uint32_t **aux_shape_ndim, const uint32_t ***aux_shape_data, int *complete)
DEPRECATED. Use MXSymbolInferShapePartialEx instead. partially infer shape of unknown input shapes gi...
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:2766
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...
void(* infer_shape)(int, int *, unsigned **, void *)
Definition: c_api.h:123
int(* CustomOpListFunc)(char ***, void *)
Definition: c_api.h:188
MXNET_DLL int MXExecutorBindX(SymbolHandle symbol_handle, int dev_type, int dev_id, uint32_t num_map_keys, const char **map_keys, const int *map_dev_types, const int *map_dev_ids, uint32_t len, NDArrayHandle *in_args, NDArrayHandle *arg_grad_store, uint32_t *grad_req_type, uint32_t aux_states_len, NDArrayHandle *aux_states, ExecutorHandle *out)
Generate Executor from symbol, This is advanced function, allow specify group2ctx map...
MXNET_DLL int MXRecordIOReaderTell(RecordIOHandle handle, size_t *pos)
Get the current writer pointer position.
MXNET_DLL int MXSymbolInferShapePartial64(SymbolHandle sym, uint32_t num_args, const char **keys, const int64_t *arg_ind_ptr, const int64_t *arg_shape_data, size_t *in_shape_size, const int **in_shape_ndim, const int64_t ***in_shape_data, size_t *out_shape_size, const int **out_shape_ndim, const int64_t ***out_shape_data, size_t *aux_shape_size, const int **aux_shape_ndim, const int64_t ***aux_shape_data, int *complete)
MXNET_DLL int MXRecordIOReaderCreate(const char *uri, RecordIOHandle *out)
Create a RecordIO reader object.
MXNET_DLL int MXRecordIOReaderReadRecord(RecordIOHandle handle, char const **buf, size_t *size)
Write a record to a RecordIO object.
void * p_list_outputs
Definition: c_api.h:130
MXNET_DLL int MXExecutorBind(SymbolHandle symbol_handle, int dev_type, int dev_id, uint32_t len, NDArrayHandle *in_args, NDArrayHandle *arg_grad_store, uint32_t *grad_req_type, uint32_t aux_states_len, NDArrayHandle *aux_states, ExecutorHandle *out)
Generate Executor from symbol.
MXNET_DLL int MXExecutorPrint(ExecutorHandle handle, const char **out_str)
Print the content of execution plan, used for debug.
void * EngineVarHandle
handle to Engine VarHandle
Definition: c_api.h:103
int64_t dim_t
data type to store dim size
Definition: c_api.h:62
MXNET_DLL int MXAutogradSetIsTraining(int is_training, int *prev)
set whether to record operator for autograd
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 MXListDataIters(uint32_t *out_size, DataIterCreator **out_array)
List all the available iterator entries.
MXNET_DLL int MXAutogradBackwardEx(uint32_t num_output, NDArrayHandle *output_handles, NDArrayHandle *ograd_handles, uint32_t 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
const void * FunctionHandle
handle to a mxnet narray function that changes NDArray
Definition: c_api.h:69
MXNET_DLL int MXNDArrayGetShapeEx64(NDArrayHandle handle, int *out_dim, const int64_t **out_pdata)
void(* backward)(int, float **, int *, unsigned **, int *, void *)
Definition: c_api.h:122
Definition: c_api.h:153
void * DataIterHandle
handle to a DataIterator
Definition: c_api.h:83
MXNET_DLL int MXProfileCreateCounter(ProfileHandle domain, const char *counter_name, ProfileHandle *out)
Create profile counter.
MXNET_DLL int MXGetGPUMemoryInformation(int dev, int *free_mem, int *total_mem)
get the free and total available memory on a GPU Note: Deprecated, use MXGetGPUMemoryInformation64 in...
int(* CustomOpInferStorageTypeFunc)(int, int *, void *)
Definition: c_api.h:191
MXNET_DLL int MXRecordIOWriterWriteRecord(RecordIOHandle handle, const char *buf, size_t size)
Write a record to a RecordIO object.
Definition: c_api.h:175
MXNET_DLL int MXKVStorePushPullEx(KVStoreHandle handle, mx_uint vnum, const char **vkeys, mx_uint onum, const char **okeys, NDArrayHandle *vals, NDArrayHandle *outs, int priority)
push and pull a list of (key, value) pairs from the kvstore, where each key is a string ...
Definition: c_api.h:120
MXNET_DLL int MXNDArrayCreateSparseEx64(int storage_type, const int64_t *shape, int ndim, int dev_type, int dev_id, int delay_alloc, int dtype, uint32_t num_aux, int *aux_type, int *aux_ndims, const int64_t *aux_shape, NDArrayHandle *out)
MXNET_DLL int MXDataIterFree(DataIterHandle handle)
Free the handle to the IO module.
MXNET_DLL int MXSymbolCopy(SymbolHandle symbol, SymbolHandle *out)
Copy the symbol to another handle.
MXNET_DLL int MXExecutorReshape(int partial_shaping, int allow_up_sizing, int dev_type, int dev_id, uint32_t num_map_keys, const char **map_keys, const int *map_dev_types, const int *map_dev_ids, const uint32_t num_provided_arg_shapes, const char **provided_arg_shape_names, const uint32_t *provided_arg_shape_data, const uint32_t *provided_arg_shape_idx, uint32_t *num_in_args, NDArrayHandle **in_args, NDArrayHandle **arg_grads, uint32_t *num_aux_states, NDArrayHandle **aux_states, ExecutorHandle shared_exec, ExecutorHandle *out)
DEPRECATED. Use MXExecutorReshapeEx instead. Return a new executor with the same symbol and shared me...
MXNET_DLL int MXNDArrayLoadFromBuffer(const void *ndarray_buffer, size_t size, uint32_t *out_size, NDArrayHandle **out_arr, uint32_t *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 MXDataIterGetPadNum(DataIterHandle handle, int *pad)
Get the padding number in current data batch.
void(* list_outputs)(char ***, void *)
Definition: c_api.h:124
MXNET_DLL int MXNDArraySyncCopyToCPU(NDArrayHandle handle, void *data, size_t size)
Perform a synchronize copyto a continugous CPU memory region.
MXNET_DLL int MXInitPSEnv(uint32_t num_vars, const char **keys, const char **vals)
Initialized ps-lite environment variables.
MXNET_DLL int MXSymbolCreateVariable(const char *name, SymbolHandle *out)
Create a Variable Symbol.
MXNET_DLL int MXGetFunction(const char *name, FunctionHandle *out)
get the function handle by name
int(* CustomOpCreateFunc)(const char *, int, unsigned **, const int *, const int *, struct MXCallbackList *, void *)
Definition: c_api.h:200
MXNET_DLL int MXSymbolInferShapeEx64(SymbolHandle sym, uint32_t num_args, const char **keys, const int64_t *arg_ind_ptr, const int64_t *arg_shape_data, size_t *in_shape_size, const int **in_shape_ndim, const int64_t ***in_shape_data, size_t *out_shape_size, const int **out_shape_ndim, const int64_t ***out_shape_data, size_t *aux_shape_size, const int **aux_shape_ndim, const int64_t ***aux_shape_data, int *complete)
int(* CustomOpBackwardInferStorageTypeFunc)(int, int *, int *, void *)
Definition: c_api.h:192
MXNET_DLL int MXSymbolInferShape(SymbolHandle sym, uint32_t num_args, const char **keys, const uint32_t *arg_ind_ptr, const uint32_t *arg_shape_data, uint32_t *in_shape_size, const uint32_t **in_shape_ndim, const uint32_t ***in_shape_data, uint32_t *out_shape_size, const uint32_t **out_shape_ndim, const uint32_t ***out_shape_data, uint32_t *aux_shape_size, const uint32_t **aux_shape_ndim, const uint32_t ***aux_shape_data, int *complete)
DEPRECATED. Use MXSymbolInferShapeEx instead. infer shape of unknown input shapes given the known one...
uint32_t mx_uint
manually define unsigned int
Definition: c_api.h:58