mxnet
Classes | Macros | Typedefs | Enumerations | Functions
c_api.h File Reference

C API of mxnet. More...

#include <stdint.h>
#include <stddef.h>
#include <stdbool.h>
Include dependency graph for c_api.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  NativeOpInfo
 
struct  NDArrayOpInfo
 
struct  MXCallbackList
 

Macros

#define DEFAULT(x)
 Inhibit C++ name-mangling for MXNet functions. More...
 
#define MXNET_DLL
 MXNET_DLL prefix for windows. More...
 

Typedefs

typedef unsigned int mx_uint
 manually define unsigned int More...
 
typedef float mx_float
 manually define float More...
 
typedef void * NDArrayHandle
 handle to NDArray More...
 
typedef const void * FunctionHandle
 handle to a mxnet narray function that changes NDArray More...
 
typedef void * AtomicSymbolCreator
 handle to a function that takes param and creates symbol More...
 
typedef void * CachedOpHandle
 handle to cached operator More...
 
typedef void * SymbolHandle
 handle to a symbol that can be bind as operator More...
 
typedef void * AtomicSymbolHandle
 handle to a AtomicSymbol More...
 
typedef void * ExecutorHandle
 handle to an Executor More...
 
typedef void * DataIterCreator
 handle a dataiter creator More...
 
typedef void * DataIterHandle
 handle to a DataIterator More...
 
typedef void * KVStoreHandle
 handle to KVStore More...
 
typedef void * RecordIOHandle
 handle to RecordIO More...
 
typedef void * RtcHandle
 handle to MXRtc More...
 
typedef void * CudaModuleHandle
 handle to rtc cuda module More...
 
typedef void * CudaKernelHandle
 handle to rtc cuda kernel More...
 
typedef void(* ExecutorMonitorCallback) (const char *, NDArrayHandle, void *)
 
typedef int(* MXGenericCallback) (void)
 
typedef int(* CustomOpFBFunc) (int, void **, int *, const int *, const int, void *)
 
typedef int(* CustomOpDelFunc) (void *)
 
typedef int(* CustomOpListFunc) (char ***, void *)
 
typedef int(* CustomOpInferShapeFunc) (int, int *, unsigned **, void *)
 
typedef int(* CustomOpInferTypeFunc) (int, int *, void *)
 
typedef int(* CustomOpBwdDepFunc) (const int *, const int *, const int *, int *, int **, void *)
 
typedef int(* CustomOpCreateFunc) (const char *, int, unsigned **, const int *, const int *, struct MXCallbackList *, void *)
 
typedef int(* CustomOpPropCreator) (const char *, const int, const char **, const char **, struct MXCallbackList *)
 
typedef int(* CustomFunctionBwdFunc) (int, int, void **, const int *, const int, void *)
 
typedef int(* CustomFunctionDelFunc) (void *)
 
typedef void( MXKVStoreUpdater) (int key, NDArrayHandle recv, NDArrayHandle local, void *handle)
 user-defined updater for the kvstore It's this updater's responsibility to delete recv and local More...
 
typedef void( MXKVStoreStrUpdater) (const char *key, NDArrayHandle recv, NDArrayHandle local, void *handle)
 user-defined updater for the kvstore with string keys It's this updater's responsibility to delete recv and local More...
 
typedef void( MXKVStoreServerController) (int head, const char *body, void *controller_handle)
 the prototype of a server controller More...
 

Enumerations

enum  CustomOpCallbacks { kCustomOpDelete, kCustomOpForward, kCustomOpBackward }
 
enum  CustomOpPropCallbacks {
  kCustomOpPropDelete, kCustomOpPropListArguments, kCustomOpPropListOutputs, kCustomOpPropListAuxiliaryStates,
  kCustomOpPropInferShape, kCustomOpPropDeclareBackwardDependency, kCustomOpPropCreateOperator, kCustomOpPropInferType
}
 
enum  CustomFunctionCallbacks { kCustomFunctionBackward, kCustomFunctionDelete }
 

Functions

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 an error occured, MXGetLastError can be called to retrieve the error More...
 
MXNET_DLL int MXRandomSeed (int seed)
 Seed the global random number generators in mxnet. More...
 
MXNET_DLL int MXNotifyShutdown ()
 Notify the engine about a shutdown, This can help engine to print less messages into display. More...
 
MXNET_DLL int MXSetProfilerConfig (int mode, const char *filename)
 Set up configuration of profiler. More...
 
MXNET_DLL int MXSetProfilerState (int state)
 Set up state of profiler. More...
 
MXNET_DLL int MXDumpProfile ()
 Save profile and stop profiler. More...
 
MXNET_DLL int MXSetNumOMPThreads (int thread_num)
 Set the number of OMP threads to use. More...
 
MXNET_DLL int MXGetVersion (int *out)
 get the MXNet library version as an integer More...
 
MXNET_DLL int MXNDArrayCreateNone (NDArrayHandle *out)
 create a NDArray handle that is not initialized can be used to pass in as mutate variables to hold the result of NDArray More...
 
MXNET_DLL int MXNDArrayCreate (const mx_uint *shape, mx_uint ndim, int dev_type, int dev_id, int delay_alloc, NDArrayHandle *out)
 create a NDArray with specified shape More...
 
MXNET_DLL int MXNDArrayCreateEx (const mx_uint *shape, mx_uint ndim, int dev_type, int dev_id, int delay_alloc, int dtype, NDArrayHandle *out)
 create a NDArray with specified shape and data type More...
 
MXNET_DLL int MXNDArrayCreateSparseEx (int storage_type, const mx_uint *shape, mx_uint ndim, int dev_type, int dev_id, int delay_alloc, int dtype, mx_uint num_aux, int *aux_type, mx_uint *aux_ndims, const mx_uint *aux_shape, NDArrayHandle *out)
 create an empty sparse NDArray with specified shape and data type More...
 
MXNET_DLL int MXNDArrayLoadFromRawBytes (const void *buf, size_t size, NDArrayHandle *out)
 create a NDArray handle that is loaded from raw bytes. More...
 
MXNET_DLL int MXNDArraySaveRawBytes (NDArrayHandle handle, size_t *out_size, const char **out_buf)
 save the NDArray into raw bytes. More...
 
MXNET_DLL int MXNDArraySave (const char *fname, mx_uint num_args, NDArrayHandle *args, const char **keys)
 Save list of narray into the file. More...
 
MXNET_DLL int MXNDArrayLoad (const char *fname, mx_uint *out_size, NDArrayHandle **out_arr, mx_uint *out_name_size, const char ***out_names)
 Load list of narray from the file. More...
 
MXNET_DLL int MXNDArraySyncCopyFromCPU (NDArrayHandle handle, const void *data, size_t size)
 Perform a synchronize copy from a continugous CPU memory region. More...
 
MXNET_DLL int MXNDArraySyncCopyToCPU (NDArrayHandle handle, void *data, size_t size)
 Perform a synchronize copyto a continugous CPU memory region. More...
 
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. Do not use it in performance critical code. More...
 
MXNET_DLL int MXNDArrayWaitToRead (NDArrayHandle handle)
 Wait until all the pending writes with respect NDArray are finished. Always call this before read data out synchronizely. More...
 
MXNET_DLL int MXNDArrayWaitToWrite (NDArrayHandle handle)
 Wait until all the pending read/write with respect NDArray are finished. Always call this before write data into NDArray synchronizely. More...
 
MXNET_DLL int MXNDArrayWaitAll ()
 wait until all delayed operations in the system is completed More...
 
MXNET_DLL int MXNDArrayFree (NDArrayHandle handle)
 free the narray handle More...
 
MXNET_DLL int MXNDArraySlice (NDArrayHandle handle, mx_uint slice_begin, mx_uint slice_end, NDArrayHandle *out)
 Slice the NDArray along axis 0. More...
 
MXNET_DLL int MXNDArrayAt (NDArrayHandle handle, mx_uint idx, NDArrayHandle *out)
 Index the NDArray along axis 0. More...
 
MXNET_DLL int MXNDArrayGetStorageType (NDArrayHandle handle, int *out_storage_type)
 get the storage type of the array More...
 
MXNET_DLL int MXNDArrayReshape (NDArrayHandle handle, int ndim, int *dims, NDArrayHandle *out)
 Reshape the NDArray. More...
 
MXNET_DLL int MXNDArrayGetShape (NDArrayHandle handle, mx_uint *out_dim, const mx_uint **out_pdata)
 get the shape of the array More...
 
MXNET_DLL int MXNDArrayGetData (NDArrayHandle handle, void **out_pdata)
 get the content of the data in NDArray More...
 
MXNET_DLL int MXNDArrayGetDType (NDArrayHandle handle, int *out_dtype)
 get the type of the data in NDArray More...
 
MXNET_DLL int MXNDArrayGetAuxType (NDArrayHandle handle, mx_uint i, int *out_type)
 get the type of the ith aux data in NDArray More...
 
MXNET_DLL int MXNDArrayGetAuxNDArray (NDArrayHandle handle, mx_uint i, NDArrayHandle *out)
 Get a deep copy of the ith aux data blob in the form of an NDArray of default storage type. This function blocks. Do not use it in performance critical code. More...
 
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. More...
 
MXNET_DLL int MXNDArrayGetContext (NDArrayHandle handle, int *out_dev_type, int *out_dev_id)
 get the context of the NDArray More...
 
MXNET_DLL int MXNDArrayGetGrad (NDArrayHandle handle, NDArrayHandle *out)
 return gradient buffer attached to this NDArray More...
 
MXNET_DLL int MXNDArrayDetach (NDArrayHandle handle, NDArrayHandle *out)
 detach and ndarray from computation graph by clearing entry_ More...
 
MXNET_DLL int MXNDArraySetGradState (NDArrayHandle handle, int state)
 set the flag for gradient array state. More...
 
MXNET_DLL int MXNDArrayGetGradState (NDArrayHandle handle, int *out)
 set the flag for gradient array state. More...
 
MXNET_DLL int MXListFunctions (mx_uint *out_size, FunctionHandle **out_array)
 list all the available functions handles most user can use it to list all the needed functions More...
 
MXNET_DLL int MXGetFunction (const char *name, FunctionHandle *out)
 get the function handle by name More...
 
MXNET_DLL int MXFuncGetInfo (FunctionHandle fun, const char **name, const char **description, mx_uint *num_args, const char ***arg_names, const char ***arg_type_infos, const char ***arg_descriptions, const char **return_type DEFAULT(NULL))
 Get the information of the function handle. More...
 
MXNET_DLL int MXFuncDescribe (FunctionHandle fun, mx_uint *num_use_vars, mx_uint *num_scalars, mx_uint *num_mutate_vars, int *type_mask)
 get the argument requirements of the function More...
 
MXNET_DLL int MXFuncInvoke (FunctionHandle fun, NDArrayHandle *use_vars, mx_float *scalar_args, NDArrayHandle *mutate_vars)
 invoke a function, the array size of passed in arguments must match the values in the More...
 
MXNET_DLL int MXFuncInvokeEx (FunctionHandle fun, NDArrayHandle *use_vars, mx_float *scalar_args, NDArrayHandle *mutate_vars, int num_params, char **param_keys, char **param_vals)
 invoke a function, the array size of passed in arguments must match the values in the More...
 
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 More...
 
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 More...
 
MXNET_DLL int MXAutogradSetIsRecording (int is_recording, int *prev)
 set whether to record operator for autograd More...
 
MXNET_DLL int MXAutogradSetIsTraining (int is_training, int *prev)
 set whether to record operator for autograd More...
 
MXNET_DLL int MXAutogradIsRecording (bool *curr)
 get whether autograd recording is on More...
 
MXNET_DLL int MXAutogradIsTraining (bool *curr)
 get whether training mode is on More...
 
MXNET_DLL int MXAutogradMarkVariables (mx_uint num_var, NDArrayHandle *var_handles, mx_uint *reqs_array, NDArrayHandle *grad_handles)
 mark NDArrays as variables to compute gradient for autograd More...
 
MXNET_DLL int MXAutogradComputeGradient (mx_uint num_output, NDArrayHandle *output_handles)
 compute the gradient of outputs w.r.t variabels More...
 
MXNET_DLL int MXAutogradBackward (mx_uint num_output, NDArrayHandle *output_handles, NDArrayHandle *ograd_handles, int retain_graph)
 compute the gradient of outputs w.r.t variabels More...
 
MXNET_DLL int MXAutogradBackwardEx (mx_uint num_output, NDArrayHandle *output_handles, NDArrayHandle *ograd_handles, mx_uint num_variables, NDArrayHandle *var_handles, int retain_graph, int create_graph, int is_train, NDArrayHandle **grad_handles, int **grad_stypes)
 compute the gradient of outputs w.r.t variabels More...
 
MXNET_DLL int MXAutogradGetSymbol (NDArrayHandle handle, SymbolHandle *out)
 
MXNET_DLL int MXCreateCachedOp (SymbolHandle handle, CachedOpHandle *out)
 create cached operator More...
 
MXNET_DLL int MXFreeCachedOp (CachedOpHandle handle)
 free cached operator More...
 
MXNET_DLL int MXInvokeCachedOp (CachedOpHandle handle, int num_inputs, NDArrayHandle *inputs, int *num_outputs, NDArrayHandle **outputs)
 invoke cached operator More...
 
MXNET_DLL int MXInvokeCachedOpEx (CachedOpHandle handle, int num_inputs, NDArrayHandle *inputs, int *num_outputs, NDArrayHandle **outputs, const int **out_stypes)
 invoke a cached op More...
 
MXNET_DLL int MXListAllOpNames (mx_uint *out_size, const char ***out_array)
 list all the available operator names, include entries. More...
 
MXNET_DLL int MXSymbolListAtomicSymbolCreators (mx_uint *out_size, AtomicSymbolCreator **out_array)
 list all the available AtomicSymbolEntry More...
 
MXNET_DLL int MXSymbolGetAtomicSymbolName (AtomicSymbolCreator creator, const char **name)
 Get the name of an atomic symbol. More...
 
MXNET_DLL int MXSymbolGetAtomicSymbolInfo (AtomicSymbolCreator creator, const char **name, const char **description, mx_uint *num_args, const char ***arg_names, const char ***arg_type_infos, const char ***arg_descriptions, const char **key_var_num_args, const char **return_type DEFAULT(NULL))
 Get the detailed information about atomic symbol. More...
 
MXNET_DLL int MXSymbolCreateAtomicSymbol (AtomicSymbolCreator creator, mx_uint num_param, const char **keys, const char **vals, SymbolHandle *out)
 Create an AtomicSymbol. More...
 
MXNET_DLL int MXSymbolCreateVariable (const char *name, SymbolHandle *out)
 Create a Variable Symbol. More...
 
MXNET_DLL int MXSymbolCreateGroup (mx_uint num_symbols, SymbolHandle *symbols, SymbolHandle *out)
 Create a Symbol by grouping list of symbols together. More...
 
MXNET_DLL int MXSymbolCreateFromFile (const char *fname, SymbolHandle *out)
 Load a symbol from a json file. More...
 
MXNET_DLL int MXSymbolCreateFromJSON (const char *json, SymbolHandle *out)
 Load a symbol from a json string. More...
 
MXNET_DLL int MXSymbolSaveToFile (SymbolHandle symbol, const char *fname)
 Save a symbol into a json file. More...
 
MXNET_DLL int MXSymbolSaveToJSON (SymbolHandle symbol, const char **out_json)
 Save a symbol into a json string. More...
 
MXNET_DLL int MXSymbolFree (SymbolHandle symbol)
 Free the symbol handle. More...
 
MXNET_DLL int MXSymbolCopy (SymbolHandle symbol, SymbolHandle *out)
 Copy the symbol to another handle. More...
 
MXNET_DLL int MXSymbolPrint (SymbolHandle symbol, const char **out_str)
 Print the content of symbol, used for debug. More...
 
MXNET_DLL int MXSymbolGetName (SymbolHandle symbol, const char **out, int *success)
 Get string name from symbol. More...
 
MXNET_DLL int MXSymbolGetAttr (SymbolHandle symbol, const char *key, const char **out, int *success)
 Get string attribute from symbol. More...
 
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(mutable/immutable) of symbolic graph. More...
 
MXNET_DLL int MXSymbolListAttr (SymbolHandle symbol, mx_uint *out_size, const char ***out)
 Get all attributes from symbol, including all descendents. More...
 
MXNET_DLL int MXSymbolListAttrShallow (SymbolHandle symbol, mx_uint *out_size, const char ***out)
 Get all attributes from symbol, excluding descendents. More...
 
MXNET_DLL int MXSymbolListArguments (SymbolHandle symbol, mx_uint *out_size, const char ***out_str_array)
 List arguments in the symbol. More...
 
MXNET_DLL int MXSymbolListOutputs (SymbolHandle symbol, mx_uint *out_size, const char ***out_str_array)
 List returns in the symbol. More...
 
MXNET_DLL int MXSymbolGetInternals (SymbolHandle symbol, SymbolHandle *out)
 Get a symbol that contains all the internals. More...
 
MXNET_DLL int MXSymbolGetChildren (SymbolHandle symbol, SymbolHandle *out)
 Get a symbol that contains only direct children. More...
 
MXNET_DLL int MXSymbolGetOutput (SymbolHandle symbol, mx_uint index, SymbolHandle *out)
 Get index-th outputs of the symbol. More...
 
MXNET_DLL int MXSymbolListAuxiliaryStates (SymbolHandle symbol, mx_uint *out_size, const char ***out_str_array)
 List auxiliary states in the symbol. More...
 
MXNET_DLL int MXSymbolCompose (SymbolHandle sym, const char *name, mx_uint num_args, const char **keys, SymbolHandle *args)
 Compose the symbol on other symbols. More...
 
MXNET_DLL int MXSymbolGrad (SymbolHandle sym, mx_uint num_wrt, const char **wrt, SymbolHandle *out)
 Get the gradient graph of the symbol. More...
 
MXNET_DLL int MXSymbolInferShape (SymbolHandle sym, mx_uint num_args, const char **keys, const mx_uint *arg_ind_ptr, const mx_uint *arg_shape_data, mx_uint *in_shape_size, const mx_uint **in_shape_ndim, const mx_uint ***in_shape_data, mx_uint *out_shape_size, const mx_uint **out_shape_ndim, const mx_uint ***out_shape_data, mx_uint *aux_shape_size, const mx_uint **aux_shape_ndim, const mx_uint ***aux_shape_data, int *complete)
 infer shape of unknown input shapes given the known one. The shapes are packed into a CSR matrix represented by arg_ind_ptr and arg_shape_data The call will be treated as a kwargs call if key != nullptr or num_args==0, otherwise it is positional. More...
 
MXNET_DLL int MXSymbolInferShapePartial (SymbolHandle sym, mx_uint num_args, const char **keys, const mx_uint *arg_ind_ptr, const mx_uint *arg_shape_data, mx_uint *in_shape_size, const mx_uint **in_shape_ndim, const mx_uint ***in_shape_data, mx_uint *out_shape_size, const mx_uint **out_shape_ndim, const mx_uint ***out_shape_data, mx_uint *aux_shape_size, const mx_uint **aux_shape_ndim, const mx_uint ***aux_shape_data, int *complete)
 partially infer shape of unknown input shapes given the known one. More...
 
MXNET_DLL int MXSymbolInferType (SymbolHandle sym, mx_uint num_args, const char **keys, const int *arg_type_data, mx_uint *in_type_size, const int **in_type_data, mx_uint *out_type_size, const int **out_type_data, mx_uint *aux_type_size, const int **aux_type_data, int *complete)
 infer type of unknown input types given the known one. The types are packed into a CSR matrix represented by arg_ind_ptr and arg_type_data The call will be treated as a kwargs call if key != nullptr or num_args==0, otherwise it is positional. More...
 
MXNET_DLL int MXExecutorFree (ExecutorHandle handle)
 Delete the executor. More...
 
MXNET_DLL int MXExecutorPrint (ExecutorHandle handle, const char **out_str)
 Print the content of execution plan, used for debug. More...
 
MXNET_DLL int MXExecutorForward (ExecutorHandle handle, int is_train)
 Executor forward method. More...
 
MXNET_DLL int MXExecutorBackward (ExecutorHandle handle, mx_uint len, NDArrayHandle *head_grads)
 Excecutor run backward. More...
 
MXNET_DLL int MXExecutorBackwardEx (ExecutorHandle handle, mx_uint len, NDArrayHandle *head_grads, int is_train)
 Excecutor run backward. More...
 
MXNET_DLL int MXExecutorOutputs (ExecutorHandle handle, mx_uint *out_size, NDArrayHandle **out)
 Get executor's head NDArray. More...
 
MXNET_DLL int MXExecutorBind (SymbolHandle symbol_handle, int dev_type, int dev_id, mx_uint len, NDArrayHandle *in_args, NDArrayHandle *arg_grad_store, mx_uint *grad_req_type, mx_uint aux_states_len, NDArrayHandle *aux_states, ExecutorHandle *out)
 Generate Executor from symbol. More...
 
MXNET_DLL int MXExecutorBindX (SymbolHandle symbol_handle, int dev_type, int dev_id, mx_uint num_map_keys, const char **map_keys, const int *map_dev_types, const int *map_dev_ids, mx_uint len, NDArrayHandle *in_args, NDArrayHandle *arg_grad_store, mx_uint *grad_req_type, mx_uint aux_states_len, NDArrayHandle *aux_states, ExecutorHandle *out)
 Generate Executor from symbol, This is advanced function, allow specify group2ctx map. The user can annotate "ctx_group" attribute to name each group. More...
 
MXNET_DLL int MXExecutorBindEX (SymbolHandle symbol_handle, int dev_type, int dev_id, mx_uint num_map_keys, const char **map_keys, const int *map_dev_types, const int *map_dev_ids, mx_uint len, NDArrayHandle *in_args, NDArrayHandle *arg_grad_store, mx_uint *grad_req_type, mx_uint aux_states_len, NDArrayHandle *aux_states, ExecutorHandle shared_exec, ExecutorHandle *out)
 Generate Executor from symbol, This is advanced function, allow specify group2ctx map. The user can annotate "ctx_group" attribute to name each group. More...
 
MXNET_DLL int MXExecutorSimpleBind (SymbolHandle symbol_handle, int dev_type, int dev_id, const mx_uint num_g2c_keys, const char **g2c_keys, const int *g2c_dev_types, const int *g2c_dev_ids, const mx_uint provided_grad_req_list_len, const char **provided_grad_req_names, const char **provided_grad_req_types, const mx_uint num_provided_arg_shapes, const char **provided_arg_shape_names, const mx_uint *provided_arg_shape_data, const mx_uint *provided_arg_shape_idx, const mx_uint num_provided_arg_dtypes, const char **provided_arg_dtype_names, const int *provided_arg_dtypes, const mx_uint num_provided_arg_stypes, const char **provided_arg_stype_names, const int *provided_arg_stypes, const mx_uint num_shared_arg_names, const char **shared_arg_name_list, int *shared_buffer_len, const char **shared_buffer_name_list, NDArrayHandle *shared_buffer_handle_list, const char ***updated_shared_buffer_name_list, NDArrayHandle **updated_shared_buffer_handle_list, mx_uint *num_in_args, NDArrayHandle **in_args, NDArrayHandle **arg_grads, mx_uint *num_aux_states, NDArrayHandle **aux_states, ExecutorHandle shared_exec_handle, ExecutorHandle *out)
 
MXNET_DLL int MXExecutorSetMonitorCallback (ExecutorHandle handle, ExecutorMonitorCallback callback, void *callback_handle)
 set a call back to notify the completion of operation More...
 
MXNET_DLL int MXListDataIters (mx_uint *out_size, DataIterCreator **out_array)
 List all the available iterator entries. More...
 
MXNET_DLL int MXDataIterCreateIter (DataIterCreator handle, mx_uint num_param, const char **keys, const char **vals, DataIterHandle *out)
 Init an iterator, init with parameters the array size of passed in arguments. More...
 
MXNET_DLL int MXDataIterGetIterInfo (DataIterCreator creator, const char **name, const char **description, mx_uint *num_args, const char ***arg_names, const char ***arg_type_infos, const char ***arg_descriptions)
 Get the detailed information about data iterator. More...
 
MXNET_DLL int MXDataIterFree (DataIterHandle handle)
 Free the handle to the IO module. More...
 
MXNET_DLL int MXDataIterNext (DataIterHandle handle, int *out)
 Move iterator to next position. More...
 
MXNET_DLL int MXDataIterBeforeFirst (DataIterHandle handle)
 Call iterator.Reset. More...
 
MXNET_DLL int MXDataIterGetData (DataIterHandle handle, NDArrayHandle *out)
 Get the handle to the NDArray of underlying data. More...
 
MXNET_DLL int MXDataIterGetIndex (DataIterHandle handle, uint64_t **out_index, uint64_t *out_size)
 Get the image index by array. More...
 
MXNET_DLL int MXDataIterGetPadNum (DataIterHandle handle, int *pad)
 Get the padding number in current data batch. More...
 
MXNET_DLL int MXDataIterGetLabel (DataIterHandle handle, NDArrayHandle *out)
 Get the handle to the NDArray of underlying label. More...
 
MXNET_DLL int MXInitPSEnv (mx_uint num_vars, const char **keys, const char **vals)
 Initialized ps-lite environment variables. More...
 
MXNET_DLL int MXKVStoreCreate (const char *type, KVStoreHandle *out)
 Create a kvstore. More...
 
MXNET_DLL int MXKVStoreFree (KVStoreHandle handle)
 Delete a KVStore handle. More...
 
MXNET_DLL int MXKVStoreInit (KVStoreHandle handle, mx_uint num, const int *keys, NDArrayHandle *vals)
 Init a list of (key,value) pairs in kvstore. More...
 
MXNET_DLL int MXKVStoreInitEx (KVStoreHandle handle, mx_uint num, const char **keys, NDArrayHandle *vals)
 Init a list of (key,value) pairs in kvstore, where each key is a string. More...
 
MXNET_DLL int MXKVStorePush (KVStoreHandle handle, mx_uint num, const int *keys, NDArrayHandle *vals, int priority)
 Push a list of (key,value) pairs to kvstore. More...
 
MXNET_DLL int MXKVStorePushEx (KVStoreHandle handle, mx_uint num, const char **keys, NDArrayHandle *vals, int priority)
 Push a list of (key,value) pairs to kvstore, where each key is a string. More...
 
MXNET_DLL int MXKVStorePull (KVStoreHandle handle, mx_uint num, const int *keys, NDArrayHandle *vals, int priority)
 pull a list of (key, value) pairs from the kvstore More...
 
MXNET_DLL int MXKVStorePullEx (KVStoreHandle handle, mx_uint num, const char **keys, NDArrayHandle *vals, int priority)
 pull a list of (key, value) pairs from the kvstore, where each key is a string More...
 
MXNET_DLL int MXKVStorePullRowSparse (KVStoreHandle handle, mx_uint num, const int *keys, NDArrayHandle *vals, const NDArrayHandle *row_ids, int priority)
 pull a list of (key, value) pairs from the kvstore, where each key is an integer. The NDArray pulled back will be in row_sparse storage with only the specified row_ids present based row_ids (others rows are zeros). More...
 
MXNET_DLL int MXKVStorePullRowSparseEx (KVStoreHandle handle, mx_uint num, const char **keys, NDArrayHandle *vals, const NDArrayHandle *row_ids, int priority)
 pull a list of (key, value) pairs from the kvstore, where each key is a string. The NDArray pulled back will be in row_sparse storage with only the specified row_ids present based row_ids (others rows are zeros). More...
 
MXNET_DLL int MXKVStoreSetUpdater (KVStoreHandle handle, MXKVStoreUpdater updater, void *updater_handle)
 register a push updater More...
 
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 More...
 
MXNET_DLL int MXKVStoreGetType (KVStoreHandle handle, const char **type)
 get the type of the kvstore More...
 
MXNET_DLL int MXKVStoreGetRank (KVStoreHandle handle, int *ret)
 return The rank of this node in its group, which is in [0, GroupSize). More...
 
MXNET_DLL int MXKVStoreGetGroupSize (KVStoreHandle handle, int *ret)
 return The number of nodes in this group, which is More...
 
MXNET_DLL int MXKVStoreIsWorkerNode (int *ret)
 return whether or not this process is a worker node. More...
 
MXNET_DLL int MXKVStoreIsServerNode (int *ret)
 return whether or not this process is a server node. More...
 
MXNET_DLL int MXKVStoreIsSchedulerNode (int *ret)
 return whether or not this process is a scheduler node. More...
 
MXNET_DLL int MXKVStoreBarrier (KVStoreHandle handle)
 global barrier among all worker machines More...
 
MXNET_DLL int MXKVStoreSetBarrierBeforeExit (KVStoreHandle handle, const int barrier_before_exit)
 whether to do barrier when finalize More...
 
MXNET_DLL int MXKVStoreRunServer (KVStoreHandle handle, MXKVStoreServerController controller, void *controller_handle)
 
MXNET_DLL int MXKVStoreSendCommmandToServers (KVStoreHandle handle, int cmd_id, const char *cmd_body)
 
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}. More...
 
MXNET_DLL int MXRecordIOWriterCreate (const char *uri, RecordIOHandle *out)
 Create a RecordIO writer object. More...
 
MXNET_DLL int MXRecordIOWriterFree (RecordIOHandle handle)
 Delete a RecordIO writer object. More...
 
MXNET_DLL int MXRecordIOWriterWriteRecord (RecordIOHandle handle, const char *buf, size_t size)
 Write a record to a RecordIO object. More...
 
MXNET_DLL int MXRecordIOWriterTell (RecordIOHandle handle, size_t *pos)
 Get the current writer pointer position. More...
 
MXNET_DLL int MXRecordIOReaderCreate (const char *uri, RecordIOHandle *out)
 Create a RecordIO reader object. More...
 
MXNET_DLL int MXRecordIOReaderFree (RecordIOHandle handle)
 Delete a RecordIO reader object. More...
 
MXNET_DLL int MXRecordIOReaderReadRecord (RecordIOHandle handle, char const **buf, size_t *size)
 Write a record to a RecordIO object. More...
 
MXNET_DLL int MXRecordIOReaderSeek (RecordIOHandle handle, size_t pos)
 Set the current reader pointer position. More...
 
MXNET_DLL int MXRecordIOReaderTell (RecordIOHandle handle, size_t *pos)
 Get the current writer pointer position. More...
 
MXNET_DLL int MXRtcCreate (char *name, mx_uint num_input, mx_uint num_output, char **input_names, char **output_names, NDArrayHandle *inputs, NDArrayHandle *outputs, char *kernel, RtcHandle *out)
 Create a MXRtc object. More...
 
MXNET_DLL int MXRtcPush (RtcHandle handle, mx_uint num_input, mx_uint num_output, NDArrayHandle *inputs, NDArrayHandle *outputs, mx_uint gridDimX, mx_uint gridDimY, mx_uint gridDimZ, mx_uint blockDimX, mx_uint blockDimY, mx_uint blockDimZ)
 Run cuda kernel. More...
 
MXNET_DLL int MXRtcFree (RtcHandle handle)
 Delete a MXRtc object. More...
 
MXNET_DLL int MXCustomOpRegister (const char *op_type, CustomOpPropCreator creator)
 
MXNET_DLL int MXCustomFunctionRecord (int num_inputs, NDArrayHandle *inputs, int num_outputs, NDArrayHandle *outputs, struct MXCallbackList *callbacks)
 
MXNET_DLL int MXRtcCudaModuleCreate (const char *source, int num_options, const char **options, int num_exports, const char **exports, CudaModuleHandle *out)
 
MXNET_DLL int MXRtcCudaModuleFree (CudaModuleHandle handle)
 
MXNET_DLL int MXRtcCudaKernelCreate (CudaModuleHandle handle, const char *name, int num_args, int *is_ndarray, int *is_const, int *arg_types, CudaKernelHandle *out)
 
MXNET_DLL int MXRtcCudaKernelFree (CudaKernelHandle handle)
 
MXNET_DLL int MXRtcCudaKernelCall (CudaKernelHandle handle, int dev_id, void **args, mx_uint grid_dim_x, mx_uint grid_dim_y, mx_uint grid_dim_z, mx_uint block_dim_x, mx_uint block_dim_y, mx_uint block_dim_z, mx_uint shared_mem)
 

Detailed Description

C API of mxnet.

Macro Definition Documentation

#define DEFAULT (   x)

Inhibit C++ name-mangling for MXNet functions.

Keep the default value in C++

#define MXNET_DLL

MXNET_DLL prefix for windows.

Typedef Documentation

typedef void* AtomicSymbolCreator

handle to a function that takes param and creates symbol

typedef void* AtomicSymbolHandle

handle to a AtomicSymbol

typedef void* CachedOpHandle

handle to cached operator

typedef void* CudaKernelHandle

handle to rtc cuda kernel

typedef void* CudaModuleHandle

handle to rtc cuda module

typedef int(* CustomFunctionBwdFunc) (int, int, void **, const int *, const int, void *)
typedef int(* CustomFunctionDelFunc) (void *)
typedef int(* CustomOpBwdDepFunc) (const int *, const int *, const int *, int *, int **, void *)
typedef int(* CustomOpCreateFunc) (const char *, int, unsigned **, const int *, const int *, struct MXCallbackList *, void *)
typedef int(* CustomOpDelFunc) (void *)
typedef int(* CustomOpFBFunc) (int, void **, int *, const int *, const int, void *)
typedef int(* CustomOpInferShapeFunc) (int, int *, unsigned **, void *)
typedef int(* CustomOpInferTypeFunc) (int, int *, void *)
typedef int(* CustomOpListFunc) (char ***, void *)
typedef int(* CustomOpPropCreator) (const char *, const int, const char **, const char **, struct MXCallbackList *)
typedef void* DataIterCreator

handle a dataiter creator

typedef void* DataIterHandle

handle to a DataIterator

typedef void* ExecutorHandle

handle to an Executor

typedef void(* ExecutorMonitorCallback) (const char *, NDArrayHandle, void *)
typedef const void* FunctionHandle

handle to a mxnet narray function that changes NDArray

typedef void* KVStoreHandle

handle to KVStore

typedef float mx_float

manually define float

typedef unsigned int mx_uint

manually define unsigned int

typedef int(* MXGenericCallback) (void)
typedef void( MXKVStoreServerController) (int head, const char *body, void *controller_handle)

the prototype of a server controller

Parameters
headthe head of the command
bodythe body of the command
controller_handlehelper handle for implementing controller
typedef void( MXKVStoreStrUpdater) (const char *key, NDArrayHandle recv, NDArrayHandle local, void *handle)

user-defined updater for the kvstore with string keys It's this updater's responsibility to delete recv and local

Parameters
thekey
recvthe pushed value on this key
localthe value stored on local on this key
handleThe additional handle to the updater
typedef void( MXKVStoreUpdater) (int key, NDArrayHandle recv, NDArrayHandle local, void *handle)

user-defined updater for the kvstore It's this updater's responsibility to delete recv and local

Parameters
thekey
recvthe pushed value on this key
localthe value stored on local on this key
handleThe additional handle to the updater
typedef void* NDArrayHandle

handle to NDArray

typedef void* RecordIOHandle

handle to RecordIO

typedef void* RtcHandle

handle to MXRtc

typedef void* SymbolHandle

handle to a symbol that can be bind as operator

Enumeration Type Documentation

Enumerator
kCustomFunctionBackward 
kCustomFunctionDelete 
Enumerator
kCustomOpDelete 
kCustomOpForward 
kCustomOpBackward 
Enumerator
kCustomOpPropDelete 
kCustomOpPropListArguments 
kCustomOpPropListOutputs 
kCustomOpPropListAuxiliaryStates 
kCustomOpPropInferShape 
kCustomOpPropDeclareBackwardDependency 
kCustomOpPropCreateOperator 
kCustomOpPropInferType 

Function Documentation

MXNET_DLL int MXAutogradBackward ( mx_uint  num_output,
NDArrayHandle output_handles,
NDArrayHandle ograd_handles,
int  retain_graph 
)

compute the gradient of outputs w.r.t variabels

Parameters
num_outputnumber of output NDArray
output_handlesoutput NDArrays
ograd_handleshead gradient for NDArrays
retain_graphwhether to keep the graph after backward
Returns
0 when success, -1 when failure happens
MXNET_DLL int MXAutogradBackwardEx ( mx_uint  num_output,
NDArrayHandle output_handles,
NDArrayHandle ograd_handles,
mx_uint  num_variables,
NDArrayHandle var_handles,
int  retain_graph,
int  create_graph,
int  is_train,
NDArrayHandle **  grad_handles,
int **  grad_stypes 
)

compute the gradient of outputs w.r.t variabels

Parameters
num_outputnumber of output NDArray
output_handlesoutput NDArrays
ograd_handleshead gradient for NDArrays
num_variablesnumber of variables
MXNET_DLL int MXAutogradComputeGradient ( mx_uint  num_output,
NDArrayHandle output_handles 
)

compute the gradient of outputs w.r.t variabels

Parameters
num_outputnumber of output NDArray
output_handlesoutput NDArrays
Returns
0 when success, -1 when failure happens
MXNET_DLL int MXAutogradGetSymbol ( NDArrayHandle  handle,
SymbolHandle out 
)
MXNET_DLL int MXAutogradIsRecording ( bool *  curr)

get whether autograd recording is on

Parameters
currreturns the current status.
Returns
0 when success, -1 when failure happens
MXNET_DLL int MXAutogradIsTraining ( bool *  curr)

get whether training mode is on

Parameters
currreturns the current status.
Returns
0 when success, -1 when failure happens
MXNET_DLL int MXAutogradMarkVariables ( mx_uint  num_var,
NDArrayHandle var_handles,
mx_uint reqs_array,
NDArrayHandle grad_handles 
)

mark NDArrays as variables to compute gradient for autograd

Parameters
num_varnumber of variable NDArrays
var_handlesvariable NDArrays
Returns
0 when success, -1 when failure happens
MXNET_DLL int MXAutogradSetIsRecording ( int  is_recording,
int *  prev 
)

set whether to record operator for autograd

Parameters
is_recording1 when recording, 0 when not recording.
prevreturns the previous status before this set.
Returns
0 when success, -1 when failure happens
MXNET_DLL int MXAutogradSetIsTraining ( int  is_training,
int *  prev 
)

set whether to record operator for autograd

Parameters
is_training1 when training, 0 when testing
prevreturns the previous status before this set.
Returns
0 when success, -1 when failure happens
MXNET_DLL int MXCreateCachedOp ( SymbolHandle  handle,
CachedOpHandle out 
)

create cached operator

MXNET_DLL int MXCustomFunctionRecord ( int  num_inputs,
NDArrayHandle inputs,
int  num_outputs,
NDArrayHandle outputs,
struct MXCallbackList callbacks 
)
MXNET_DLL int MXCustomOpRegister ( const char *  op_type,
CustomOpPropCreator  creator 
)
MXNET_DLL int MXDataIterBeforeFirst ( DataIterHandle  handle)

Call iterator.Reset.

Parameters
handlethe handle to iterator
Returns
0 when success, -1 when failure happens
MXNET_DLL int MXDataIterCreateIter ( DataIterCreator  handle,
mx_uint  num_param,
const char **  keys,
const char **  vals,
DataIterHandle out 
)

Init an iterator, init with parameters the array size of passed in arguments.

Parameters
handleof the iterator creator
num_paramnumber of parameter
keysparameter keys
valsparameter values
outresulting iterator
Returns
0 when success, -1 when failure happens
MXNET_DLL int MXDataIterFree ( DataIterHandle  handle)

Free the handle to the IO module.

Parameters
handlethe handle pointer to the data iterator
Returns
0 when success, -1 when failure happens
MXNET_DLL int MXDataIterGetData ( DataIterHandle  handle,
NDArrayHandle out 
)

Get the handle to the NDArray of underlying data.

Parameters
handlethe handle pointer to the data iterator
outhandle to underlying data NDArray
Returns
0 when success, -1 when failure happens
MXNET_DLL int MXDataIterGetIndex ( DataIterHandle  handle,
uint64_t **  out_index,
uint64_t *  out_size 
)

Get the image index by array.

Parameters
handlethe handle pointer to the data iterator
out_indexoutput index of the array.
out_sizeoutput size of the array.
Returns
0 when success, -1 when failure happens
MXNET_DLL int MXDataIterGetIterInfo ( DataIterCreator  creator,
const char **  name,
const char **  description,
mx_uint num_args,
const char ***  arg_names,
const char ***  arg_type_infos,
const char ***  arg_descriptions 
)

Get the detailed information about data iterator.

Parameters
creatorthe DataIterCreator.
nameThe returned name of the creator.
descriptionThe returned description of the symbol.
num_argsNumber of arguments.
arg_namesName of the arguments.
arg_type_infosType informations about the arguments.
arg_descriptionsDescription information about the arguments.
Returns
0 when success, -1 when failure happens
MXNET_DLL int MXDataIterGetLabel ( DataIterHandle  handle,
NDArrayHandle out 
)

Get the handle to the NDArray of underlying label.

Parameters
handlethe handle pointer to the data iterator
outthe handle to underlying label NDArray
Returns
0 when success, -1 when failure happens
MXNET_DLL int MXDataIterGetPadNum ( DataIterHandle  handle,
int *  pad 
)

Get the padding number in current data batch.

Parameters
handlethe handle pointer to the data iterator
padpad number ptr
Returns
0 when success, -1 when failure happens
MXNET_DLL int MXDataIterNext ( DataIterHandle  handle,
int *  out 
)

Move iterator to next position.

Parameters
handlethe handle to iterator
outreturn value of next
Returns
0 when success, -1 when failure happens
MXNET_DLL int MXDumpProfile ( )

Save profile and stop profiler.

MXNET_DLL int MXExecutorBackward ( ExecutorHandle  handle,
mx_uint  len,
NDArrayHandle head_grads 
)

Excecutor run backward.

Parameters
handleexecute handle
lenlenth
head_gradsNDArray handle for heads' gradient
Returns
0 when success, -1 when failure happens
MXNET_DLL int MXExecutorBackwardEx ( ExecutorHandle  handle,
mx_uint  len,
NDArrayHandle head_grads,
int  is_train 
)

Excecutor run backward.

Parameters
handleexecute handle
lenlenth
head_gradsNDArray handle for heads' gradient
is_trainint value to indicate whether the backward pass is for evaluation
Returns
0 when success, -1 when failure happens
MXNET_DLL int MXExecutorBind ( SymbolHandle  symbol_handle,
int  dev_type,
int  dev_id,
mx_uint  len,
NDArrayHandle in_args,
NDArrayHandle arg_grad_store,
mx_uint grad_req_type,
mx_uint  aux_states_len,
NDArrayHandle aux_states,
ExecutorHandle out 
)

Generate Executor from symbol.

Parameters
symbol_handlesymbol handle
dev_typedevice type
dev_iddevice id
lenlength
in_argsin args array
arg_grad_storearg grads handle array
grad_req_typegrad req array
aux_states_lenlength of auxiliary states
aux_statesauxiliary states array
outoutput executor handle
Returns
0 when success, -1 when failure happens
MXNET_DLL int MXExecutorBindEX ( SymbolHandle  symbol_handle,
int  dev_type,
int  dev_id,
mx_uint  num_map_keys,
const char **  map_keys,
const int *  map_dev_types,
const int *  map_dev_ids,
mx_uint  len,
NDArrayHandle in_args,
NDArrayHandle arg_grad_store,
mx_uint grad_req_type,
mx_uint  aux_states_len,
NDArrayHandle aux_states,
ExecutorHandle  shared_exec,
ExecutorHandle out 
)

Generate Executor from symbol, This is advanced function, allow specify group2ctx map. The user can annotate "ctx_group" attribute to name each group.

Parameters
symbol_handlesymbol handle
dev_typedevice type of default context
dev_iddevice id of default context
num_map_keyssize of group2ctx map
map_keyskeys of group2ctx map
map_dev_typesdevice type of group2ctx map
map_dev_idsdevice id of group2ctx map
lenlength
in_argsin args array
arg_grad_storearg grads handle array
grad_req_typegrad req array
aux_states_lenlength of auxiliary states
aux_statesauxiliary states array
shared_execinput executor handle for memory sharing
outoutput executor handle
Returns
0 when success, -1 when failure happens
MXNET_DLL int MXExecutorBindX ( SymbolHandle  symbol_handle,
int  dev_type,
int  dev_id,
mx_uint  num_map_keys,
const char **  map_keys,
const int *  map_dev_types,
const int *  map_dev_ids,
mx_uint  len,
NDArrayHandle in_args,
NDArrayHandle arg_grad_store,
mx_uint grad_req_type,
mx_uint  aux_states_len,
NDArrayHandle aux_states,
ExecutorHandle out 
)

Generate Executor from symbol, This is advanced function, allow specify group2ctx map. The user can annotate "ctx_group" attribute to name each group.

Parameters
symbol_handlesymbol handle
dev_typedevice type of default context
dev_iddevice id of default context
num_map_keyssize of group2ctx map
map_keyskeys of group2ctx map
map_dev_typesdevice type of group2ctx map
map_dev_idsdevice id of group2ctx map
lenlength
in_argsin args array
arg_grad_storearg grads handle array
grad_req_typegrad req array
aux_states_lenlength of auxiliary states
aux_statesauxiliary states array
outoutput executor handle
Returns
0 when success, -1 when failure happens
MXNET_DLL int MXExecutorForward ( ExecutorHandle  handle,
int  is_train 
)

Executor forward method.

Parameters
handleexecutor handle
is_trainint value to indicate whether the forward pass is for evaluation
Returns
0 when success, -1 when failure happens
MXNET_DLL int MXExecutorFree ( ExecutorHandle  handle)

Delete the executor.

Parameters
handlethe executor.
Returns
0 when success, -1 when failure happens
MXNET_DLL int MXExecutorOutputs ( ExecutorHandle  handle,
mx_uint out_size,
NDArrayHandle **  out 
)

Get executor's head NDArray.

Parameters
handleexecutor handle
out_sizeoutput narray vector size
outout put narray handles
Returns
0 when success, -1 when failure happens
MXNET_DLL int MXExecutorPrint ( ExecutorHandle  handle,
const char **  out_str 
)

Print the content of execution plan, used for debug.

Parameters
handlethe executor.
out_strpointer to hold the output string of the printing.
Returns
0 when success, -1 when failure happens
MXNET_DLL int MXExecutorSetMonitorCallback ( ExecutorHandle  handle,
ExecutorMonitorCallback  callback,
void *  callback_handle 
)

set a call back to notify the completion of operation

MXNET_DLL int MXExecutorSimpleBind ( SymbolHandle  symbol_handle,
int  dev_type,
int  dev_id,
const mx_uint  num_g2c_keys,
const char **  g2c_keys,
const int *  g2c_dev_types,
const int *  g2c_dev_ids,
const mx_uint  provided_grad_req_list_len,
const char **  provided_grad_req_names,
const char **  provided_grad_req_types,
const mx_uint  num_provided_arg_shapes,
const char **  provided_arg_shape_names,
const mx_uint provided_arg_shape_data,
const mx_uint provided_arg_shape_idx,
const mx_uint  num_provided_arg_dtypes,
const char **  provided_arg_dtype_names,
const int *  provided_arg_dtypes,
const mx_uint  num_provided_arg_stypes,
const char **  provided_arg_stype_names,
const int *  provided_arg_stypes,
const mx_uint  num_shared_arg_names,
const char **  shared_arg_name_list,
int *  shared_buffer_len,
const char **  shared_buffer_name_list,
NDArrayHandle shared_buffer_handle_list,
const char ***  updated_shared_buffer_name_list,
NDArrayHandle **  updated_shared_buffer_handle_list,
mx_uint num_in_args,
NDArrayHandle **  in_args,
NDArrayHandle **  arg_grads,
mx_uint num_aux_states,
NDArrayHandle **  aux_states,
ExecutorHandle  shared_exec_handle,
ExecutorHandle out 
)
MXNET_DLL int MXFreeCachedOp ( CachedOpHandle  handle)

free cached operator

MXNET_DLL int MXFuncDescribe ( FunctionHandle  fun,
mx_uint num_use_vars,
mx_uint num_scalars,
mx_uint num_mutate_vars,
int *  type_mask 
)

get the argument requirements of the function

Parameters
funinput function handle
num_use_varshow many NDArrays to be passed in as used_vars
num_scalarsscalar variable is needed
num_mutate_varshow many NDArrays to be passed in as mutate_vars
type_maskthe type mask of this function
Returns
0 when success, -1 when failure happens
See also
MXFuncInvoke
MXNET_DLL int MXFuncGetInfo ( FunctionHandle  fun,
const char **  name,
const char **  description,
mx_uint num_args,
const char ***  arg_names,
const char ***  arg_type_infos,
const char ***  arg_descriptions,
const char **return_type   DEFAULTNULL 
)

Get the information of the function handle.

Parameters
funThe function handle.
nameThe returned name of the function.
descriptionThe returned description of the function.
num_argsNumber of arguments.
arg_namesName of the arguments.
arg_type_infosType information about the arguments.
arg_descriptionsDescription information about the arguments.
return_typeReturn type of the function.
Returns
0 when success, -1 when failure happens
MXNET_DLL int MXFuncInvoke ( FunctionHandle  fun,
NDArrayHandle use_vars,
mx_float scalar_args,
NDArrayHandle mutate_vars 
)

invoke a function, the array size of passed in arguments must match the values in the

Parameters
funthe function
use_varsthe normal arguments passed to function
scalar_argsthe scalar qarguments
mutate_varsthe mutate arguments
Returns
0 when success, -1 when failure happens
See also
MXFuncDescribeArgs
MXNET_DLL int MXFuncInvokeEx ( FunctionHandle  fun,
NDArrayHandle use_vars,
mx_float scalar_args,
NDArrayHandle mutate_vars,
int  num_params,
char **  param_keys,
char **  param_vals 
)

invoke a function, the array size of passed in arguments must match the values in the

Parameters
funthe function
use_varsthe normal arguments passed to function
scalar_argsthe scalar qarguments
mutate_varsthe mutate arguments
num_paramsnumber of keyword parameters
param_keyskeys for keyword parameters
param_valsvalues for keyword parameters
Returns
0 when success, -1 when failure happens
See also
MXFuncDescribeArgs
MXNET_DLL int MXGetFunction ( const char *  name,
FunctionHandle out 
)

get the function handle by name

Parameters
namethe name of the function
outthe corresponding function handle
Returns
0 when success, -1 when failure happens
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 an error occured, MXGetLastError can be called to retrieve the error

this function is threadsafe and can be called by different thread

Returns
error info
MXNET_DLL int MXGetVersion ( int *  out)

get the MXNet library version as an integer

Parameters
pointerto the integer holding the version number
Returns
0 when success, -1 when failure happens
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

Parameters
creatorthe op
num_inputsnumber of input NDArrays
inputsinput NDArrays
num_outputsnumber of output NDArrays
outputsoutput NDArrays
num_paramsnumber of keyword parameters
param_keyskeys for keyword parameters
param_valsvalues for keyword parameters
Returns
0 when success, -1 when failure happens
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

Parameters
creatorthe op
num_inputsnumber of input NDArrays
inputsinput NDArrays
num_outputsnumber of output NDArrays
outputsoutput NDArrays
num_paramsnumber of keyword parameters
param_keyskeys for keyword parameters
param_valsvalues for keyword parameters
out_stypesoutput ndarrays' stypes
Returns
0 when success, -1 when failure happens
MXNET_DLL int MXInitPSEnv ( mx_uint  num_vars,
const char **  keys,
const char **  vals 
)

Initialized ps-lite environment variables.

Parameters
num_varsnumber of variables to initialize
keysenvironment keys
valsenvironment values
MXNET_DLL int MXInvokeCachedOp ( CachedOpHandle  handle,
int  num_inputs,
NDArrayHandle inputs,
int *  num_outputs,
NDArrayHandle **  outputs 
)

invoke cached operator

MXNET_DLL int MXInvokeCachedOpEx ( CachedOpHandle  handle,
int  num_inputs,
NDArrayHandle inputs,
int *  num_outputs,
NDArrayHandle **  outputs,
const int **  out_stypes 
)

invoke a cached op

Parameters
handlethe handle to the cached op
num_inputsnumber of input NDArrays
inputsinput NDArrays
num_outputsnumber of output NDArrays
outputsoutput NDArrays
out_stypesoutput ndarrays' stypes
Returns
0 when success, -1 when failure happens
MXNET_DLL int MXKVStoreBarrier ( KVStoreHandle  handle)

global barrier among all worker machines

Parameters
handlehandle to the KVStore
Returns
0 when success, -1 when failure happens
MXNET_DLL int MXKVStoreCreate ( const char *  type,
KVStoreHandle out 
)

Create a kvstore.

Parameters
typethe type of KVStore
outThe output type of KVStore
Returns
0 when success, -1 when failure happens
MXNET_DLL int MXKVStoreFree ( KVStoreHandle  handle)

Delete a KVStore handle.

Parameters
handlehandle to the kvstore
Returns
0 when success, -1 when failure happens
MXNET_DLL int MXKVStoreGetGroupSize ( KVStoreHandle  handle,
int *  ret 
)

return The number of nodes in this group, which is

  • number of workers if if IsWorkerNode() == true,
  • number of servers if if IsServerNode() == true,
  • 1 if IsSchedulerNode() == true,
    Parameters
    handlehandle to the KVStore
    retthe group size
    Returns
    0 when success, -1 when failure happens
MXNET_DLL int MXKVStoreGetNumDeadNode ( KVStoreHandle  handle,
const int  node_id,
int *  number,
const int timeout_sec   DEFAULT60 
)

Get the number of ps dead node(s) specified by {node_id}.

Parameters
handlehandle to the KVStore
node_idCan be a node group or a single node. kScheduler = 1, kServerGroup = 2, kWorkerGroup = 4
numberOuptut number of dead nodes
timeout_secA node fails to send heartbeart in {timeout_sec} seconds will be presumed as 'dead'
MXNET_DLL int MXKVStoreGetRank ( KVStoreHandle  handle,
int *  ret 
)

return The rank of this node in its group, which is in [0, GroupSize).

Parameters
handlehandle to the KVStore
retthe node rank
Returns
0 when success, -1 when failure happens
MXNET_DLL int MXKVStoreGetType ( KVStoreHandle  handle,
const char **  type 
)

get the type of the kvstore

Parameters
handlehandle to the KVStore
typea string type
Returns
0 when success, -1 when failure happens
MXNET_DLL int MXKVStoreInit ( KVStoreHandle  handle,
mx_uint  num,
const int *  keys,
NDArrayHandle vals 
)

Init a list of (key,value) pairs in kvstore.

Parameters
handlehandle to the kvstore
numthe number of key-value pairs
keysthe list of keys
valsthe list of values
Returns
0 when success, -1 when failure happens
MXNET_DLL int MXKVStoreInitEx ( KVStoreHandle  handle,
mx_uint  num,
const char **  keys,
NDArrayHandle vals 
)

Init a list of (key,value) pairs in kvstore, where each key is a string.

Parameters
handlehandle to the kvstore
numthe number of key-value pairs
keysthe list of keys
valsthe list of values
Returns
0 when success, -1 when failure happens
MXNET_DLL int MXKVStoreIsSchedulerNode ( int *  ret)

return whether or not this process is a scheduler node.

Parameters
ret1 for yes, 0 for no
Returns
0 when success, -1 when failure happens
MXNET_DLL int MXKVStoreIsServerNode ( int *  ret)

return whether or not this process is a server node.

Parameters
ret1 for yes, 0 for no
Returns
0 when success, -1 when failure happens
MXNET_DLL int MXKVStoreIsWorkerNode ( int *  ret)

return whether or not this process is a worker node.

Parameters
ret1 for yes, 0 for no
Returns
0 when success, -1 when failure happens
MXNET_DLL int MXKVStorePull ( KVStoreHandle  handle,
mx_uint  num,
const int *  keys,
NDArrayHandle vals,
int  priority 
)

pull a list of (key, value) pairs from the kvstore

Parameters
handlehandle to the kvstore
numthe number of key-value pairs
keysthe list of keys
valsthe list of values
prioritythe priority of the action
Returns
0 when success, -1 when failure happens
MXNET_DLL int MXKVStorePullEx ( KVStoreHandle  handle,
mx_uint  num,
const char **  keys,
NDArrayHandle vals,
int  priority 
)

pull a list of (key, value) pairs from the kvstore, where each key is a string

Parameters
handlehandle to the kvstore
numthe number of key-value pairs
keysthe list of keys
valsthe list of values
prioritythe priority of the action
Returns
0 when success, -1 when failure happens
MXNET_DLL int MXKVStorePullRowSparse ( KVStoreHandle  handle,
mx_uint  num,
const int *  keys,
NDArrayHandle vals,
const NDArrayHandle row_ids,
int  priority 
)

pull a list of (key, value) pairs from the kvstore, where each key is an integer. The NDArray pulled back will be in row_sparse storage with only the specified row_ids present based row_ids (others rows are zeros).

Parameters
handlehandle to the kvstore
numthe number of key-value pairs
keysthe list of keys
valsthe list of values
row_idsthe list of row_id NDArrays
prioritythe priority of the action
Returns
0 when success, -1 when failure happens
MXNET_DLL int MXKVStorePullRowSparseEx ( KVStoreHandle  handle,
mx_uint  num,
const char **  keys,
NDArrayHandle vals,
const NDArrayHandle row_ids,
int  priority 
)

pull a list of (key, value) pairs from the kvstore, where each key is a string. The NDArray pulled back will be in row_sparse storage with only the specified row_ids present based row_ids (others rows are zeros).

Parameters
handlehandle to the kvstore
numthe number of key-value pairs
keysthe list of keys
valsthe list of values
row_idsthe list of row_id NDArrays
prioritythe priority of the action
Returns
0 when success, -1 when failure happens
MXNET_DLL int MXKVStorePush ( KVStoreHandle  handle,
mx_uint  num,
const int *  keys,
NDArrayHandle vals,
int  priority 
)

Push a list of (key,value) pairs to kvstore.

Parameters
handlehandle to the kvstore
numthe number of key-value pairs
keysthe list of keys
valsthe list of values
prioritythe priority of the action
Returns
0 when success, -1 when failure happens
MXNET_DLL int MXKVStorePushEx ( KVStoreHandle  handle,
mx_uint  num,
const char **  keys,
NDArrayHandle vals,
int  priority 
)

Push a list of (key,value) pairs to kvstore, where each key is a string.

Parameters
handlehandle to the kvstore
numthe number of key-value pairs
keysthe list of keys
valsthe list of values
prioritythe priority of the action
Returns
0 when success, -1 when failure happens
MXNET_DLL int MXKVStoreRunServer ( KVStoreHandle  handle,
MXKVStoreServerController  controller,
void *  controller_handle 
)
Returns
Run as server (or scheduler)
Parameters
handlehandle to the KVStore
controllerthe user-defined server controller
controller_handlehelper handle for implementing controller
Returns
0 when success, -1 when failure happens
MXNET_DLL int MXKVStoreSendCommmandToServers ( KVStoreHandle  handle,
int  cmd_id,
const char *  cmd_body 
)
Returns
Send a command to all server nodes
Parameters
handlehandle to the KVStore
cmd_idthe head of the command
cmd_bodythe body of the command
Returns
0 when success, -1 when failure happens
MXNET_DLL int MXKVStoreSetBarrierBeforeExit ( KVStoreHandle  handle,
const int  barrier_before_exit 
)

whether to do barrier when finalize

Parameters
handlehandle to the KVStore
barrier_before_exitwhether to do barrier when kvstore finalize
Returns
0 when success, -1 when failure happens
MXNET_DLL int MXKVStoreSetUpdater ( KVStoreHandle  handle,
MXKVStoreUpdater  updater,
void *  updater_handle 
)

register a push updater

Parameters
handlehandle to the KVStore
updaterudpater function
updater_handleThe additional handle used to invoke the updater
Returns
0 when success, -1 when failure happens
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

Parameters
handlehandle to the KVStore
updaterupdater function with int keys
str_updaterupdater function with string keys
updater_handleThe additional handle used to invoke the updater
Returns
0 when success, -1 when failure happens
MXNET_DLL int MXListAllOpNames ( mx_uint out_size,
const char ***  out_array 
)

list all the available operator names, include entries.

Parameters
out_sizethe size of returned array
out_arraythe output operator name array.
Returns
0 when success, -1 when failure happens
MXNET_DLL int MXListDataIters ( mx_uint out_size,
DataIterCreator **  out_array 
)

List all the available iterator entries.

Parameters
out_sizethe size of returned iterators
out_arraythe output iteratos entries
Returns
0 when success, -1 when failure happens
MXNET_DLL int MXListFunctions ( mx_uint out_size,
FunctionHandle **  out_array 
)

list all the available functions handles most user can use it to list all the needed functions

Parameters
out_sizethe size of returned array
out_arraythe output function array
Returns
0 when success, -1 when failure happens
MXNET_DLL int MXNDArrayAt ( NDArrayHandle  handle,
mx_uint  idx,
NDArrayHandle out 
)

Index the NDArray along axis 0.

Parameters
handlethe handle to the NDArray
idxthe index
outThe NDArrayHandle of output NDArray
Returns
0 when success, -1 when failure happens
MXNET_DLL int MXNDArrayCreate ( const mx_uint shape,
mx_uint  ndim,
int  dev_type,
int  dev_id,
int  delay_alloc,
NDArrayHandle out 
)

create a NDArray with specified shape

Parameters
shapethe pointer to the shape
ndimthe dimension of the shape
dev_typedevice type, specify device we want to take
dev_idthe device id of the specific device
delay_allocwhether to delay allocation until the narray is first mutated
outthe returning handle
Returns
0 when success, -1 when failure happens
MXNET_DLL int MXNDArrayCreateEx ( const mx_uint shape,
mx_uint  ndim,
int  dev_type,
int  dev_id,
int  delay_alloc,
int  dtype,
NDArrayHandle out 
)

create a NDArray with specified shape and data type

Parameters
shapethe pointer to the shape
ndimthe dimension of the shape
dev_typedevice type, specify device we want to take
dev_idthe device id of the specific device
delay_allocwhether to delay allocation until the narray is first mutated
dtypedata type of created array
outthe returning handle
Returns
0 when success, -1 when failure happens
MXNET_DLL int MXNDArrayCreateNone ( NDArrayHandle out)

create a NDArray handle that is not initialized can be used to pass in as mutate variables to hold the result of NDArray

Parameters
outthe returning handle
Returns
0 when success, -1 when failure happens
MXNET_DLL int MXNDArrayCreateSparseEx ( int  storage_type,
const mx_uint shape,
mx_uint  ndim,
int  dev_type,
int  dev_id,
int  delay_alloc,
int  dtype,
mx_uint  num_aux,
int *  aux_type,
mx_uint aux_ndims,
const mx_uint aux_shape,
NDArrayHandle out 
)

create an empty sparse NDArray with specified shape and data type

Parameters
storage_typethe storage type of the ndarray
shapethe pointer to the shape
ndimthe dimension of the shape
dev_typedevice type, specify device we want to take
dev_idthe device id of the specific device
delay_allocwhether to delay allocation until the narray is first mutated
dtypedata type of created array
num_auxthe number of aux data to support this ndarray
aux_typedata type of the aux data for the created array
aux_ndimsthe dimension of the shapes of aux data
aux_shapethe shapes of aux data
outthe returning handle
Returns
0 when success, -1 when failure happens
MXNET_DLL int MXNDArrayDetach ( NDArrayHandle  handle,
NDArrayHandle out 
)

detach and ndarray from computation graph by clearing entry_

Parameters
handleNDArray handle
Returns
0 when success, -1 when failure happens
MXNET_DLL int MXNDArrayFree ( NDArrayHandle  handle)

free the narray handle

Parameters
handlethe handle to be freed
Returns
0 when success, -1 when failure happens
MXNET_DLL int MXNDArrayGetAuxNDArray ( NDArrayHandle  handle,
mx_uint  i,
NDArrayHandle out 
)

Get a deep copy of the ith aux data blob in the form of an NDArray of default storage type. This function blocks. Do not use it in performance critical code.

MXNET_DLL int MXNDArrayGetAuxType ( NDArrayHandle  handle,
mx_uint  i,
int *  out_type 
)

get the type of the ith aux data in NDArray

Parameters
handlethe handle to the narray
ithe index of the aux data
out_typepointer holder to get type of aux data
Returns
0 when success, -1 when failure happens
MXNET_DLL int MXNDArrayGetContext ( NDArrayHandle  handle,
int *  out_dev_type,
int *  out_dev_id 
)

get the context of the NDArray

Parameters
handlethe handle to the narray
out_dev_typethe output device type
out_dev_idthe output device id
Returns
0 when success, -1 when failure happens
MXNET_DLL int MXNDArrayGetData ( NDArrayHandle  handle,
void **  out_pdata 
)

get the content of the data in NDArray

Parameters
handlethe handle to the ndarray
out_pdatapointer holder to get pointer of data
Returns
0 when success, -1 when failure happens
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 MXNDArrayGetDType ( NDArrayHandle  handle,
int *  out_dtype 
)

get the type of the data in NDArray

Parameters
handlethe handle to the narray
out_dtypepointer holder to get type of data
Returns
0 when success, -1 when failure happens
MXNET_DLL int MXNDArrayGetGrad ( NDArrayHandle  handle,
NDArrayHandle out 
)

return gradient buffer attached to this NDArray

Parameters
handleNDArray handle
Returns
0 when success, -1 when failure happens
MXNET_DLL int MXNDArrayGetGradState ( NDArrayHandle  handle,
int *  out 
)

set the flag for gradient array state.

Parameters
handleNDArray handle
statethe new state.
Returns
0 when success, -1 when failure happens
MXNET_DLL int MXNDArrayGetShape ( NDArrayHandle  handle,
mx_uint out_dim,
const mx_uint **  out_pdata 
)

get the shape of the array

Parameters
handlethe handle to the narray
out_dimthe output dimension
out_pdatapointer holder to get data pointer of the shape
Returns
0 when success, -1 when failure happens
MXNET_DLL int MXNDArrayGetStorageType ( NDArrayHandle  handle,
int *  out_storage_type 
)

get the storage type of the array

MXNET_DLL int MXNDArrayLoad ( const char *  fname,
mx_uint out_size,
NDArrayHandle **  out_arr,
mx_uint out_name_size,
const char ***  out_names 
)

Load list of narray from the file.

Parameters
fnamename of the file.
out_sizenumber of narray loaded.
out_arrhead of the returning narray handles.
out_name_sizesize of output name arrray.
out_namesthe names of returning NDArrays, can be NULL
Returns
0 when success, -1 when failure happens
MXNET_DLL int MXNDArrayLoadFromRawBytes ( const void *  buf,
size_t  size,
NDArrayHandle out 
)

create a NDArray handle that is loaded from raw bytes.

Parameters
bufthe head of the raw bytes
sizesize of the raw bytes
outthe returning handle
Returns
0 when success, -1 when failure happens
MXNET_DLL int MXNDArrayReshape ( NDArrayHandle  handle,
int  ndim,
int *  dims,
NDArrayHandle out 
)

Reshape the NDArray.

Parameters
handlethe handle to the narray
ndimnumber of dimensions of new shape
dimsnew shape
outthe NDArrayHandle of reshaped NDArray
Returns
0 when success, -1 when failure happens
MXNET_DLL int MXNDArraySave ( const char *  fname,
mx_uint  num_args,
NDArrayHandle args,
const char **  keys 
)

Save list of narray into the file.

Parameters
fnamename of the file.
num_argsnumber of arguments to save.
argsthe array of NDArrayHandles to be saved.
keysthe name of the NDArray, optional, can be NULL
Returns
0 when success, -1 when failure happens
MXNET_DLL int MXNDArraySaveRawBytes ( NDArrayHandle  handle,
size_t *  out_size,
const char **  out_buf 
)

save the NDArray into raw bytes.

Parameters
handlethe NDArray handle
out_sizesize of the raw bytes
out_bufthe head of returning memory bytes.
Returns
0 when success, -1 when failure happens
MXNET_DLL int MXNDArraySetGradState ( NDArrayHandle  handle,
int  state 
)

set the flag for gradient array state.

Parameters
handleNDArray handle
statethe new state.
Returns
0 when success, -1 when failure happens
MXNET_DLL int MXNDArraySlice ( NDArrayHandle  handle,
mx_uint  slice_begin,
mx_uint  slice_end,
NDArrayHandle out 
)

Slice the NDArray along axis 0.

Parameters
handlethe handle to the NDArray
slice_beginThe beginning index of slice
slice_endThe ending index of slice
outThe NDArrayHandle of sliced NDArray
Returns
0 when success, -1 when failure happens
MXNET_DLL int MXNDArraySyncCopyFromCPU ( NDArrayHandle  handle,
const void *  data,
size_t  size 
)

Perform a synchronize copy from a continugous CPU memory region.

This function will call WaitToWrite before the copy is performed. This is useful to copy data from existing memory region that are not wrapped by NDArray(thus dependency not being tracked).

Parameters
handlethe NDArray handle
datathe data source to copy from.
sizethe memory size we want to copy from.
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. Do not use it in performance critical code.

Parameters
handle_dsthandle of a dst ndarray whose data/aux_data has been allocated
handle_srchandle of a src ndarray which has default storage type
idst data blob indicator
MXNET_DLL int MXNDArraySyncCopyToCPU ( NDArrayHandle  handle,
void *  data,
size_t  size 
)

Perform a synchronize copyto a continugous CPU memory region.

This function will call WaitToRead before the copy is performed. This is useful to copy data from existing memory region that are not wrapped by NDArray(thus dependency not being tracked).

Parameters
handlethe NDArray handle
datathe data source to copy into.
sizethe memory size we want to copy into.
MXNET_DLL int MXNDArrayWaitAll ( )

wait until all delayed operations in the system is completed

Returns
0 when success, -1 when failure happens
MXNET_DLL int MXNDArrayWaitToRead ( NDArrayHandle  handle)

Wait until all the pending writes with respect NDArray are finished. Always call this before read data out synchronizely.

Parameters
handlethe NDArray handle
Returns
0 when success, -1 when failure happens
MXNET_DLL int MXNDArrayWaitToWrite ( NDArrayHandle  handle)

Wait until all the pending read/write with respect NDArray are finished. Always call this before write data into NDArray synchronizely.

Parameters
handlethe NDArray handle
Returns
0 when success, -1 when failure happens
MXNET_DLL int MXNotifyShutdown ( )

Notify the engine about a shutdown, This can help engine to print less messages into display.

User do not have to call this function.

Returns
0 when success, -1 when failure happens.
MXNET_DLL int MXRandomSeed ( int  seed)

Seed the global random number generators in mxnet.

Parameters
seedthe random number seed.
Returns
0 when success, -1 when failure happens.
MXNET_DLL int MXRecordIOReaderCreate ( const char *  uri,
RecordIOHandle out 
)

Create a RecordIO reader object.

Parameters
uripath to file
outhandle pointer to the created object
Returns
0 when success, -1 when failure happens
MXNET_DLL int MXRecordIOReaderFree ( RecordIOHandle  handle)

Delete a RecordIO reader object.

Parameters
handlehandle to RecordIO object
Returns
0 when success, -1 when failure happens
MXNET_DLL int MXRecordIOReaderReadRecord ( RecordIOHandle  handle,
char const **  buf,
size_t *  size 
)

Write a record to a RecordIO object.

Parameters
handlehandle to RecordIO object
bufpointer to return buffer
sizepoint to size of buffer
Returns
0 when success, -1 when failure happens
MXNET_DLL int MXRecordIOReaderSeek ( RecordIOHandle  handle,
size_t  pos 
)

Set the current reader pointer position.

Parameters
handlehandle to RecordIO object
postarget position
Returns
0 when success, -1 when failure happens
MXNET_DLL int MXRecordIOReaderTell ( RecordIOHandle  handle,
size_t *  pos 
)

Get the current writer pointer position.

Parameters
handlehandle to RecordIO object
poshandle to output position
Returns
0 when success, -1 when failure happens
MXNET_DLL int MXRecordIOWriterCreate ( const char *  uri,
RecordIOHandle out 
)

Create a RecordIO writer object.

Parameters
uripath to file
outhandle pointer to the created object
Returns
0 when success, -1 when failure happens
MXNET_DLL int MXRecordIOWriterFree ( RecordIOHandle  handle)

Delete a RecordIO writer object.

Parameters
handlehandle to RecordIO object
Returns
0 when success, -1 when failure happens
MXNET_DLL int MXRecordIOWriterTell ( RecordIOHandle  handle,
size_t *  pos 
)

Get the current writer pointer position.

Parameters
handlehandle to RecordIO object
poshandle to output position
Returns
0 when success, -1 when failure happens
MXNET_DLL int MXRecordIOWriterWriteRecord ( RecordIOHandle  handle,
const char *  buf,
size_t  size 
)

Write a record to a RecordIO object.

Parameters
handlehandle to RecordIO object
bufbuffer to write
sizesize of buffer
Returns
0 when success, -1 when failure happens
MXNET_DLL int MXRtcCreate ( char *  name,
mx_uint  num_input,
mx_uint  num_output,
char **  input_names,
char **  output_names,
NDArrayHandle inputs,
NDArrayHandle outputs,
char *  kernel,
RtcHandle out 
)

Create a MXRtc object.

MXNET_DLL int MXRtcCudaKernelCall ( CudaKernelHandle  handle,
int  dev_id,
void **  args,
mx_uint  grid_dim_x,
mx_uint  grid_dim_y,
mx_uint  grid_dim_z,
mx_uint  block_dim_x,
mx_uint  block_dim_y,
mx_uint  block_dim_z,
mx_uint  shared_mem 
)
MXNET_DLL int MXRtcCudaKernelCreate ( CudaModuleHandle  handle,
const char *  name,
int  num_args,
int *  is_ndarray,
int *  is_const,
int *  arg_types,
CudaKernelHandle out 
)
MXNET_DLL int MXRtcCudaKernelFree ( CudaKernelHandle  handle)
MXNET_DLL int MXRtcCudaModuleCreate ( const char *  source,
int  num_options,
const char **  options,
int  num_exports,
const char **  exports,
CudaModuleHandle out 
)
MXNET_DLL int MXRtcCudaModuleFree ( CudaModuleHandle  handle)
MXNET_DLL int MXRtcFree ( RtcHandle  handle)

Delete a MXRtc object.

MXNET_DLL int MXRtcPush ( RtcHandle  handle,
mx_uint  num_input,
mx_uint  num_output,
NDArrayHandle inputs,
NDArrayHandle outputs,
mx_uint  gridDimX,
mx_uint  gridDimY,
mx_uint  gridDimZ,
mx_uint  blockDimX,
mx_uint  blockDimY,
mx_uint  blockDimZ 
)

Run cuda kernel.

MXNET_DLL int MXSetNumOMPThreads ( int  thread_num)

Set the number of OMP threads to use.

MXNET_DLL int MXSetProfilerConfig ( int  mode,
const char *  filename 
)

Set up configuration of profiler.

Parameters
modeindicate the working mode of profiler, record anly symbolic operator when mode == 0, record all operator when mode == 1
filenamewhere to save trace file
Returns
0 when success, -1 when failure happens.
MXNET_DLL int MXSetProfilerState ( int  state)

Set up state of profiler.

Parameters
stateindicate the working state of profiler, profiler not running when state == 0, profiler running when state == 1
Returns
0 when success, -1 when failure happens.
MXNET_DLL int MXSymbolCompose ( SymbolHandle  sym,
const char *  name,
mx_uint  num_args,
const char **  keys,
SymbolHandle args 
)

Compose the symbol on other symbols.

This function will change the sym hanlde. To achieve function apply behavior, copy the symbol first before apply.

Parameters
symthe symbol to apply
namethe name of symbol
num_argsnumber of arguments
keysthe key of keyword args (optional)
argsarguments to sym
Returns
0 when success, -1 when failure happens
MXNET_DLL int MXSymbolCopy ( SymbolHandle  symbol,
SymbolHandle out 
)

Copy the symbol to another handle.

Parameters
symbolthe source symbol
outused to hold the result of copy
Returns
0 when success, -1 when failure happens
MXNET_DLL int MXSymbolCreateAtomicSymbol ( AtomicSymbolCreator  creator,
mx_uint  num_param,
const char **  keys,
const char **  vals,
SymbolHandle out 
)

Create an AtomicSymbol.

Parameters
creatorthe AtomicSymbolCreator
num_paramthe number of parameters
keysthe keys to the params
valsthe vals of the params
outpointer to the created symbol handle
Returns
0 when success, -1 when failure happens
MXNET_DLL int MXSymbolCreateFromFile ( const char *  fname,
SymbolHandle out 
)

Load a symbol from a json file.

Parameters
fnamethe file name.
outthe output symbol.
Returns
0 when success, -1 when failure happens
MXNET_DLL int MXSymbolCreateFromJSON ( const char *  json,
SymbolHandle out 
)

Load a symbol from a json string.

Parameters
jsonthe json string.
outthe output symbol.
Returns
0 when success, -1 when failure happens
MXNET_DLL int MXSymbolCreateGroup ( mx_uint  num_symbols,
SymbolHandle symbols,
SymbolHandle out 
)

Create a Symbol by grouping list of symbols together.

Parameters
num_symbolsnumber of symbols to be grouped
symbolsarray of symbol handles
outpointer to the created symbol handle
Returns
0 when success, -1 when failure happens
MXNET_DLL int MXSymbolCreateVariable ( const char *  name,
SymbolHandle out 
)

Create a Variable Symbol.

Parameters
namename of the variable
outpointer to the created symbol handle
Returns
0 when success, -1 when failure happens
MXNET_DLL int MXSymbolFree ( SymbolHandle  symbol)

Free the symbol handle.

Parameters
symbolthe symbol
Returns
0 when success, -1 when failure happens
MXNET_DLL int MXSymbolGetAtomicSymbolInfo ( AtomicSymbolCreator  creator,
const char **  name,
const char **  description,
mx_uint num_args,
const char ***  arg_names,
const char ***  arg_type_infos,
const char ***  arg_descriptions,
const char **  key_var_num_args,
const char **return_type   DEFAULTNULL 
)

Get the detailed information about atomic symbol.

Parameters
creatorthe AtomicSymbolCreator.
nameThe returned name of the creator.
descriptionThe returned description of the symbol.
num_argsNumber of arguments.
arg_namesName of the arguments.
arg_type_infosType informations about the arguments.
arg_descriptionsDescription information about the arguments.
key_var_num_argsThe keyword argument for specifying variable number of arguments. When this parameter has non-zero length, the function allows variable number of positional arguments, and will need the caller to pass it in in MXSymbolCreateAtomicSymbol, With key = key_var_num_args, and value = number of positional arguments.
return_typeReturn type of the function, can be Symbol or Symbol[]
Returns
0 when success, -1 when failure happens
MXNET_DLL int MXSymbolGetAtomicSymbolName ( AtomicSymbolCreator  creator,
const char **  name 
)

Get the name of an atomic symbol.

Parameters
creatorthe AtomicSymbolCreator.
nameThe returned name of the creator.
MXNET_DLL int MXSymbolGetAttr ( SymbolHandle  symbol,
const char *  key,
const char **  out,
int *  success 
)

Get string attribute from symbol.

Parameters
symbolthe source symbol
keyThe key of the symbol.
outThe result attribute, can be NULL if the attribute do not exist.
successWhether the result is contained in out.
Returns
0 when success, -1 when failure happens
MXNET_DLL int MXSymbolGetChildren ( SymbolHandle  symbol,
SymbolHandle out 
)

Get a symbol that contains only direct children.

Parameters
symbolThe symbol
outThe output symbol whose outputs are the direct children.
Returns
0 when success, -1 when failure happens
MXNET_DLL int MXSymbolGetInternals ( SymbolHandle  symbol,
SymbolHandle out 
)

Get a symbol that contains all the internals.

Parameters
symbolThe symbol
outThe output symbol whose outputs are all the internals.
Returns
0 when success, -1 when failure happens
MXNET_DLL int MXSymbolGetName ( SymbolHandle  symbol,
const char **  out,
int *  success 
)

Get string name from symbol.

Parameters
symbolthe source symbol
outThe result name.
successWhether the result is contained in out.
Returns
0 when success, -1 when failure happens
MXNET_DLL int MXSymbolGetOutput ( SymbolHandle  symbol,
mx_uint  index,
SymbolHandle out 
)

Get index-th outputs of the symbol.

Parameters
symbolThe symbol
indexthe Index of the output.
outThe output symbol whose outputs are the index-th symbol.
Returns
0 when success, -1 when failure happens
MXNET_DLL int MXSymbolGrad ( SymbolHandle  sym,
mx_uint  num_wrt,
const char **  wrt,
SymbolHandle out 
)

Get the gradient graph of the symbol.

Parameters
symthe symbol to get gradient
num_wrtnumber of arguments to get gradient
wrtthe name of the arguments to get gradient
outthe returned symbol that has gradient
Returns
0 when success, -1 when failure happens
MXNET_DLL int MXSymbolInferShape ( SymbolHandle  sym,
mx_uint  num_args,
const char **  keys,
const mx_uint arg_ind_ptr,
const mx_uint arg_shape_data,
mx_uint in_shape_size,
const mx_uint **  in_shape_ndim,
const mx_uint ***  in_shape_data,
mx_uint out_shape_size,
const mx_uint **  out_shape_ndim,
const mx_uint ***  out_shape_data,
mx_uint aux_shape_size,
const mx_uint **  aux_shape_ndim,
const mx_uint ***  aux_shape_data,
int *  complete 
)

infer shape of unknown input shapes given the known one. The shapes are packed into a CSR matrix represented by arg_ind_ptr and arg_shape_data The call will be treated as a kwargs call if key != nullptr or num_args==0, otherwise it is positional.

Parameters
symsymbol handle
num_argsnumbe of input arguments.
keysthe key of keyword args (optional)
arg_ind_ptrthe head pointer of the rows in CSR
arg_shape_datathe content of the CSR
in_shape_sizesizeof the returning array of in_shapes
in_shape_ndimreturning array of shape dimensions of eachs input shape.
in_shape_datareturning array of pointers to head of the input shape.
out_shape_sizesizeof the returning array of out_shapes
out_shape_ndimreturning array of shape dimensions of eachs input shape.
out_shape_datareturning array of pointers to head of the input shape.
aux_shape_sizesizeof the returning array of aux_shapes
aux_shape_ndimreturning array of shape dimensions of eachs auxiliary shape.
aux_shape_datareturning array of pointers to head of the auxiliary shape.
completewhether infer shape completes or more information is needed.
Returns
0 when success, -1 when failure happens
MXNET_DLL int MXSymbolInferShapePartial ( SymbolHandle  sym,
mx_uint  num_args,
const char **  keys,
const mx_uint arg_ind_ptr,
const mx_uint arg_shape_data,
mx_uint in_shape_size,
const mx_uint **  in_shape_ndim,
const mx_uint ***  in_shape_data,
mx_uint out_shape_size,
const mx_uint **  out_shape_ndim,
const mx_uint ***  out_shape_data,
mx_uint aux_shape_size,
const mx_uint **  aux_shape_ndim,
const mx_uint ***  aux_shape_data,
int *  complete 
)

partially infer shape of unknown input shapes given the known one.

Return partially inferred results if not all shapes could be inferred. The shapes are packed into a CSR matrix represented by arg_ind_ptr and arg_shape_data The call will be treated as a kwargs call if key != nullptr or num_args==0, otherwise it is positional.

Parameters
symsymbol handle
num_argsnumbe of input arguments.
keysthe key of keyword args (optional)
arg_ind_ptrthe head pointer of the rows in CSR
arg_shape_datathe content of the CSR
in_shape_sizesizeof the returning array of in_shapes
in_shape_ndimreturning array of shape dimensions of eachs input shape.
in_shape_datareturning array of pointers to head of the input shape.
out_shape_sizesizeof the returning array of out_shapes
out_shape_ndimreturning array of shape dimensions of eachs input shape.
out_shape_datareturning array of pointers to head of the input shape.
aux_shape_sizesizeof the returning array of aux_shapes
aux_shape_ndimreturning array of shape dimensions of eachs auxiliary shape.
aux_shape_datareturning array of pointers to head of the auxiliary shape.
completewhether infer shape completes or more information is needed.
Returns
0 when success, -1 when failure happens
MXNET_DLL int MXSymbolInferType ( SymbolHandle  sym,
mx_uint  num_args,
const char **  keys,
const int *  arg_type_data,
mx_uint in_type_size,
const int **  in_type_data,
mx_uint out_type_size,
const int **  out_type_data,
mx_uint aux_type_size,
const int **  aux_type_data,
int *  complete 
)

infer type of unknown input types given the known one. The types are packed into a CSR matrix represented by arg_ind_ptr and arg_type_data The call will be treated as a kwargs call if key != nullptr or num_args==0, otherwise it is positional.

Parameters
symsymbol handle
num_argsnumbe of input arguments.
keysthe key of keyword args (optional)
arg_type_datathe content of the CSR
in_type_sizesizeof the returning array of in_types
in_type_datareturning array of pointers to head of the input type.
out_type_sizesizeof the returning array of out_types
out_type_datareturning array of pointers to head of the input type.
aux_type_sizesizeof the returning array of aux_types
aux_type_datareturning array of pointers to head of the auxiliary type.
completewhether infer type completes or more information is needed.
Returns
0 when success, -1 when failure happens
MXNET_DLL int MXSymbolListArguments ( SymbolHandle  symbol,
mx_uint out_size,
const char ***  out_str_array 
)

List arguments in the symbol.

Parameters
symbolthe symbol
out_sizeoutput size
out_str_arraypointer to hold the output string array
Returns
0 when success, -1 when failure happens
MXNET_DLL int MXSymbolListAtomicSymbolCreators ( mx_uint out_size,
AtomicSymbolCreator **  out_array 
)

list all the available AtomicSymbolEntry

Parameters
out_sizethe size of returned array
out_arraythe output AtomicSymbolCreator array
Returns
0 when success, -1 when failure happens
MXNET_DLL int MXSymbolListAttr ( SymbolHandle  symbol,
mx_uint out_size,
const char ***  out 
)

Get all attributes from symbol, including all descendents.

Parameters
symbolthe source symbol
out_sizeThe number of output attributes
out2*out_size strings representing key value pairs.
Returns
0 when success, -1 when failure happens
MXNET_DLL int MXSymbolListAttrShallow ( SymbolHandle  symbol,
mx_uint out_size,
const char ***  out 
)

Get all attributes from symbol, excluding descendents.

Parameters
symbolthe source symbol
out_sizeThe number of output attributes
out2*out_size strings representing key value pairs.
Returns
0 when success, -1 when failure happens
MXNET_DLL int MXSymbolListAuxiliaryStates ( SymbolHandle  symbol,
mx_uint out_size,
const char ***  out_str_array 
)

List auxiliary states in the symbol.

Parameters
symbolthe symbol
out_sizeoutput size
out_str_arraypointer to hold the output string array
Returns
0 when success, -1 when failure happens
MXNET_DLL int MXSymbolListOutputs ( SymbolHandle  symbol,
mx_uint out_size,
const char ***  out_str_array 
)

List returns in the symbol.

Parameters
symbolthe symbol
out_sizeoutput size
out_str_arraypointer to hold the output string array
Returns
0 when success, -1 when failure happens
MXNET_DLL int MXSymbolPrint ( SymbolHandle  symbol,
const char **  out_str 
)

Print the content of symbol, used for debug.

Parameters
symbolthe symbol
out_strpointer to hold the output string of the printing.
Returns
0 when success, -1 when failure happens
MXNET_DLL int MXSymbolSaveToFile ( SymbolHandle  symbol,
const char *  fname 
)

Save a symbol into a json file.

Parameters
symbolthe input symbol.
fnamethe file name.
Returns
0 when success, -1 when failure happens
MXNET_DLL int MXSymbolSaveToJSON ( SymbolHandle  symbol,
const char **  out_json 
)

Save a symbol into a json string.

Parameters
symbolthe input symbol.
out_jsonoutput json string.
Returns
0 when success, -1 when failure happens
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(mutable/immutable) of symbolic graph.

Safe recommendaton: use immutable graph

  • Only allow set attributes during creation of new symbol as optional parameter

Mutable graph (be careful about the semantics):

  • Allow set attr at any point.
  • Mutating an attribute of some common node of two graphs can cause confusion from user.
Parameters
symbolthe source symbol
keyThe key of the symbol.
valueThe value to be saved.
Returns
0 when success, -1 when failure happens