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

APIs to interact with libraries This API specifies function prototypes to register custom ops, partitioner, and passes for library authors See example/extension/lib_custom_op/README.md See example/extension/lib_subgraph/README.md See example/extension/lib_pass/README.md. More...

#include <stdint.h>
#include <stdlib.h>
#include <string.h>
#include <vector>
#include <map>
#include <unordered_map>
#include <string>
#include <iostream>
#include <utility>
#include <stdexcept>
#include <random>
#include <stddef.h>
Include dependency graph for lib_api.h:

Go to the source code of this file.

Classes

struct  DLContext
 A Device context for Tensor and operator. More...
 
struct  DLDataType
 The data type the tensor can hold. More...
 
struct  DLTensor
 Plain C Tensor object, does not manage memory. More...
 
struct  MXContext
 Context info passing from MXNet OpContext dev_type is string repr of supported context, currently only "cpu" and "gpu" dev_id is the device index where the tensor locates. More...
 
struct  MXSparse
 
struct  MXTensor
 Tensor data structure used by custom operator. More...
 
class  PassResource
 
class  OpResource
 provide resource APIs memory allocation mechanism to Forward/Backward functions More...
 
struct  JsonVal
 definition of JSON objects More...
 
struct  JsonParser
 functions used for parsing JSON More...
 
class  CustomOpSelector
 
class  CustomStatefulOp
 An abstract class for library authors creating stateful op custom library should override Forward and destructor, and has an option to implement Backward. More...
 
class  CustomStatefulOpWrapper
 StatefulOp wrapper class to pass to backend OpState. More...
 
class  CustomOp
 Class to hold custom operator registration. More...
 
class  CustomPass
 An abstract class for graph passes. More...
 
class  CustomPartitioner
 An abstract class for subgraph property. More...
 
class  Registry< T >
 Registry class to registers things (ops, properties) Singleton class. More...
 

Macros

#define MX_LIBRARY_VERSION   7
 
#define PRIVATE_SYMBOL   __attribute__ ((visibility ("hidden")))
 For loading multiple custom op libraries in Linux, exporting same symbol multiple times may lead to undefined behaviour, so we need to set symbol visibility to hidden see https://labjack.com/news/simple-cpp-symbol-visibility-demo for details. More...
 
#define DLPACK_EXTERN_C
 
#define DLPACK_VERSION   020
 The current version of dlpack. More...
 
#define DLPACK_DLL
 DLPACK_DLL prefix for windows. More...
 
#define MX_NUM_CPU_RANDOM_STATES   1024
 MXNet initialized random states for each device, used for parallelism. More...
 
#define MX_NUM_GPU_RANDOM_STATES   32768
 
#define MX_STR_SUBGRAPH_SYM_JSON   "subgraph_sym_json"
 Macro to help passing serialized subgraph through attribute dict. More...
 
#define MX_STR_DTYPE   "__ext_dtype__"
 
#define MX_STR_SHAPE   "__ext_shape__"
 
#define MX_STR_CONCAT_(__a, __b)   __a ## __b
 Macros to help with string concat Annoyingly, the concat_ and concat macros are necessary to be able to use COUNTER in an identifier name. More...
 
#define MX_STR_CONCAT(__a, __b)   MX_STR_CONCAT_(__a, __b)
 
#define MX_STRINGIFY(x)   #x
 convert a token to a string More...
 
#define MX_TOSTRING(x)   MX_STRINGIFY(x)
 
#define MX_REGISTER_NAME_(Name)   MXNet ## _CustomOp ## _
 declare a variable with custom name More...
 
#define MX_REGISTER_DEF_(Name)   CustomOp MX_REGISTER_NAME_(Name)
 
#define MX_REGISTER_PROP_NAME_(Name)   MXNet ## _CustomSubProp ## _
 
#define MX_REGISTER_PROP_DEF_(Name)   CustomPartitioner MX_REGISTER_PROP_NAME_(Name)
 
#define MX_REGISTER_PASS_NAME_(Name)   MXNet ## _CustomPass ## _
 
#define MX_REGISTER_PASS_DEF_(Name)   CustomPass MX_REGISTER_PASS_NAME_(Name)
 
#define REGISTER_OP(Name)
 assign a var to a value More...
 
#define REGISTER_PARTITIONER(Name)
 
#define REGISTER_PASS(Name)
 
#define MXLIB_OPREGSIZE_STR   "_opRegSize"
 Following are the C type APIs implemented in the external library Each API has a #define string that is used to lookup the function in the library Followed by the function declaration. More...
 
#define MXLIB_OPREGGET_STR   "_opRegGet"
 
#define MXLIB_OPCALLFREE_STR   "_opCallFree"
 
#define MXLIB_OPCALLPARSEATTRS_STR   "_opCallParseAttrs"
 
#define MXLIB_OPCALLINFERSHAPE_STR   "_opCallInferShape"
 
#define MXLIB_OPCALLINFERTYPE_STR   "_opCallInferType"
 
#define MXLIB_OPCALLINFERSTYPE_STR   "_opCallInferSType"
 
#define MXLIB_OPCALLFCOMP_STR   "_opCallFCompute"
 
#define MXLIB_OPCALLMUTATEINPUTS_STR   "_opCallMutateInputs"
 
#define MXLIB_OPCALLCREATEOPSTATE_STR   "_opCallCreateOpState"
 
#define MXLIB_OPCALLFSTATEFULCOMP_STR   "_opCallFStatefulCompute"
 
#define MXLIB_PARTREGSIZE_STR   "_partRegSize"
 
#define MXLIB_PARTREGGETCOUNT_STR   "_partRegGetCount"
 
#define MXLIB_PARTREGGET_STR   "_partRegGet"
 
#define MXLIB_PARTCALLSUPPORTEDOPS_STR   "_partCallSupportedOps"
 
#define MXLIB_PARTCALLCREATESELECTOR_STR   "_partCallCreateSelector"
 
#define MXLIB_PARTCALLSELECT_STR   "_partCallSelect"
 
#define MXLIB_PARTCALLSELECTINPUT_STR   "_partCallSelectInput"
 
#define MXLIB_PARTCALLSELECTOUTPUT_STR   "_partCallSelectOutput"
 
#define MXLIB_PARTCALLFILTER_STR   "_partCallFilter"
 
#define MXLIB_PARTCALLRESET_STR   "_partCallReset"
 
#define MXLIB_PARTCALLREVIEWSUBGRAPH_STR   "_partCallReviewSubgraph"
 
#define MXLIB_PASSREGSIZE_STR   "_passRegSize"
 
#define MXLIB_PASSREGGET_STR   "_passRegGet"
 
#define MXLIB_PASSCALLGRAPHPASS_STR   "_passCallGraphPass"
 
#define MXLIB_INITIALIZE_STR   "initialize"
 
#define MXLIB_OPVERSION_STR   "_opVersion"
 
#define MX_INT_RET   int
 
#define MX_VOID_RET   void
 

Typedefs

typedef void *(* xpu_malloc_t) (void *, int)
 resource malloc function to allocate memory inside Forward/Backward functions More...
 
typedef void(* sparse_malloc_t) (void *, int, int, int, void **, int64_t **, int64_t **)
 sparse alloc function to allocate memory inside Forward/Backward functions More...
 
typedef void(* nd_malloc_t) (const void *_ndarray_alloc, const int64_t *shapes, int num_shapes, const char *dev_str, int dev_id, int dtype, const char *name, int isArg, void **data)
 resource malloc function to allocate ndarrays for graph passes More...
 
typedef void * mx_stream_t
 GPU stream pointer, is void* when not compiled with CUDA. More...
 
typedef void * mx_gpu_rand_t
 
typedef std::mt19937 mx_cpu_rand_t
 
typedef MXReturnValue(* fcomp_t) (const std::unordered_map< std::string, std::string > &attributes, std::vector< MXTensor > *inputs, std::vector< MXTensor > *outputs, const OpResource &res)
 Custom Operator function templates. More...
 
typedef MXReturnValue(* parseAttrs_t) (const std::unordered_map< std::string, std::string > &attributes, int *num_inputs, int *num_outputs)
 
typedef MXReturnValue(* inferType_t) (const std::unordered_map< std::string, std::string > &attributes, std::vector< int > *in_types, std::vector< int > *out_types)
 
typedef MXReturnValue(* inferSType_t) (const std::unordered_map< std::string, std::string > &attributes, std::vector< int > *in_storage_types, std::vector< int > *out_storage_types)
 
typedef MXReturnValue(* inferShape_t) (const std::unordered_map< std::string, std::string > &attributes, std::vector< std::vector< unsigned int > > *in_shapes, std::vector< std::vector< unsigned int > > *out_shapes)
 
typedef MXReturnValue(* mutateInputs_t) (const std::unordered_map< std::string, std::string > &attributes, std::vector< int > *input_indices)
 
typedef MXReturnValue(* createOpState_t) (const std::unordered_map< std::string, std::string > &attributes, CustomStatefulOp **)
 
typedef MXReturnValue(* graphPass_t) (const std::string &in_graph, const std::string **out_graph, const std::unordered_map< std::string, std::string > &options, const std::unordered_map< std::string, MXTensor > &args, const std::unordered_map< std::string, MXTensor > &aux, const PassResource &res)
 Custom Pass Create function template. More...
 
typedef MXReturnValue(* supportedOps_t) (const std::string &json, std::vector< int > *ids, const std::unordered_map< std::string, std::string > &options)
 Custom Subgraph Create function template. More...
 
typedef MXReturnValue(* createSelector_t) (const std::string &json, CustomOpSelector **sel_inst, const std::unordered_map< std::string, std::string > &options)
 
typedef MXReturnValue(* reviewSubgraph_t) (const std::string &json, int subgraph_id, bool *accept, const std::unordered_map< std::string, std::string > &options, std::unordered_map< std::string, std::string > *attrs, const std::unordered_map< std::string, MXTensor > &args, const std::unordered_map< std::string, MXTensor > &aux)
 
typedef int(* opRegSize_t) (void)
 
typedef int(* opRegGet_t) (int idx, const char **name, int *isSGop, const char ***forward_ctx, fcomp_t **forward_fp, int *forward_count, const char ***backward_ctx, fcomp_t **backward_fp, int *backward_count, const char ***create_op_ctx, createOpState_t **create_op_fp, int *create_op_count, parseAttrs_t *parse, inferType_t *type, inferSType_t *stype, inferShape_t *shape, mutateInputs_t *mutate)
 
typedef int(* opCallFree_t) (void *ptr)
 
typedef int(* opCallParseAttrs_t) (parseAttrs_t parseAttrs, const char *const *keys, const char *const *vals, int num, int *num_in, int *num_out)
 
typedef int(* opCallInferShape_t) (inferShape_t inferShape, const char *const *keys, const char *const *vals, int num, unsigned int **inshapes, int *indims, int num_in, unsigned int ***mod_inshapes, int **mod_indims, unsigned int ***outshapes, int **outdims, int num_out)
 
typedef int(* opCallInferType_t) (inferType_t inferType, const char *const *keys, const char *const *vals, int num, int *intypes, int num_in, int *outtypes, int num_out)
 
typedef int(* opCallInferSType_t) (inferSType_t inferSType, const char *const *keys, const char *const *vals, int num, int *intypes, int num_in, int *outtypes, int num_out)
 
typedef int(* opCallFComp_t) (fcomp_t fcomp, const char *const *keys, const char *const *vals, int num, const int64_t **inshapes, int *indims, void **indata, int *intypes, size_t *inIDs, const char **indev_type, int *indev_id, int num_in, const int64_t **outshapes, int *outdims, void **outdata, int *outtypes, size_t *outIDs, const char **outdev_type, int *outdev_id, int num_out, xpu_malloc_t cpu_malloc, void *cpu_alloc, xpu_malloc_t gpu_malloc, void *gpu_alloc, void *cuda_stream, sparse_malloc_t sparse_malloc, void *sparse_alloc, int *instypes, int *outstypes, void **in_indices, void **out_indices, void **in_indptr, void **out_indptr, int64_t *in_indices_shapes, int64_t *out_indices_shapes, int64_t *in_indptr_shapes, int64_t *out_indptr_shapes, void *rng_cpu_states, void *rng_gpu_states)
 
typedef int(* opCallMutateInputs_t) (mutateInputs_t mutate, const char *const *keys, const char *const *vals, int num, int **mutate_indices, int *indices_size)
 
typedef int(* opCallCreateOpState_t) (createOpState_t create_op, const char *const *keys, const char *const *vals, int num, void **state_op)
 
typedef int(* opCallFStatefulComp_t) (int is_forward, void *state_op, const int64_t **inshapes, int *indims, void **indata, int *intypes, size_t *inIDs, const char **indev_type, int *indev_id, int num_in, const int64_t **outshapes, int *outdims, void **outdata, int *outtypes, size_t *outIDs, const char **outdev_type, int *outdev_id, int num_out, xpu_malloc_t cpu_malloc, void *cpu_alloc, xpu_malloc_t gpu_malloc, void *gpu_alloc, void *stream, sparse_malloc_t sparse_malloc, void *sparse_alloc, int *instypes, int *outstypes, void **in_indices, void **out_indices, void **in_indptr, void **out_indptr, int64_t *in_indices_shapes, int64_t *out_indices_shapes, int64_t *in_indptr_shapes, int64_t *out_indptr_shapes, void *rng_cpu_states, void *rng_gpu_states)
 
typedef int(* partRegSize_t) (void)
 
typedef int(* partRegGetCount_t) (int idx, const char **name)
 
typedef void(* partRegGet_t) (int part_idx, int stg_idx, const char **strategy, supportedOps_t *supportedOps, createSelector_t *createSelector, reviewSubgraph_t *reviewSubgraph, const char **op_name)
 
typedef int(* partCallSupportedOps_t) (supportedOps_t supportedOps, const char *json, int num_ids, int *ids, const char *const *opt_keys, const char *const *opt_vals, int num_opts)
 
typedef int(* partCallCreateSelector_t) (createSelector_t createSelector, const char *json, void **selector, const char *const *opt_keys, const char *const *opt_vals, int num_opts)
 
typedef void(* partCallSelect_t) (void *sel_inst, int nodeID, int *selected)
 
typedef void(* partCallSelectInput_t) (void *sel_inst, int nodeID, int input_nodeID, int *selected)
 
typedef void(* partCallSelectOutput_t) (void *sel_inst, int nodeID, int output_nodeID, int *selected)
 
typedef void(* partCallFilter_t) (void *sel_inst, int *candidates, int num_candidates, int **keep, int *num_keep)
 
typedef void(* partCallReset_t) (void *sel_inst)
 
typedef int(* partCallReviewSubgraph_t) (reviewSubgraph_t reviewSubgraph, const char *json, int subgraph_id, int *accept, const char *const *opt_keys, const char *const *opt_vals, int num_opts, char ***attr_keys, char ***attr_vals, int *num_attrs, const char *const *arg_names, int num_args, void *const *arg_data, const int64_t *const *arg_shapes, const int *arg_dims, const int *arg_types, const size_t *arg_IDs, const char *const *arg_dev_type, const int *arg_dev_id, const char *const *aux_names, int num_aux, void *const *aux_data, const int64_t *const *aux_shapes, const int *aux_dims, const int *aux_types, const size_t *aux_IDs, const char *const *aux_dev_type, const int *aux_dev_id)
 
typedef int(* passRegSize_t) (void)
 
typedef void(* passRegGet_t) (int pass_idx, graphPass_t *graphPass, const char **pass_name)
 
typedef int(* passCallGraphPass_t) (graphPass_t graphPass, const char *in_graph, char **out_graph, const char *const *opt_keys, const char *const *opt_vals, int num_opts, const char *pass_name, const char *const *arg_names, int num_args, void *const *arg_data, const int64_t *const *arg_shapes, const int *arg_dims, const int *arg_types, const size_t *arg_IDs, const char *const *arg_dev_type, const int *arg_dev_id, const char *const *aux_names, int num_aux, void *const *aux_data, const int64_t *const *aux_shapes, const int *aux_dims, const int *aux_types, const size_t *aux_IDs, const char *const *aux_dev_type, const int *aux_dev_id, nd_malloc_t nd_malloc, const void *nd_alloc)
 
typedef int(* initialize_t) (int version)
 
typedef int(* opVersion_t) ()
 

Enumerations

enum  DLDeviceType {
  kDLCPU = 1, kDLGPU = 2, kDLCPUPinned = 3, kDLOpenCL = 4,
  kDLVulkan = 7, kDLMetal = 8, kDLVPI = 9, kDLROCM = 10,
  kDLExtDev = 12, kDLCPU = 1, kDLGPU = 2, kDLCPUPinned = 3,
  kDLOpenCL = 4, kDLVulkan = 7, kDLMetal = 8, kDLVPI = 9,
  kDLROCM = 10, kDLExtDev = 12
}
 The device type in DLContext. More...
 
enum  DLDataTypeCode {
  kDLInt = 0U, kDLUInt = 1U, kDLFloat = 2U, kDLBfloat = 4U,
  kDLInt = 0U, kDLUInt = 1U, kDLFloat = 2U
}
 The type code options DLDataType. More...
 
enum  MXDType {
  kFloat32 = 0, kFloat64 = 1, kFloat16 = 2, kUint8 = 3,
  kInt32 = 4, kInt8 = 5, kInt64 = 6, kUNSET = 100
}
 Tensor data type, consistent with mshadow data type. More...
 
enum  MXStorageType { kDefaultStorage = 0, kRowSparseStorage = 1, kCSRStorage = 2 }
 
enum  MXReturnValue { MX_FAIL = 0, MX_SUCCESS = 1 }
 
enum  JsonType {
  ERR, STR, NUM, LIST,
  MAP
}
 Json utility to parse serialized subgraph symbol. More...
 

Functions

std::string getShapeAt (const std::string &shape, unsigned index)
 
std::string getDtypeAt (const std::string &dtype, unsigned index)
 
MX_INT_RET _opVersion ()
 returns MXNet library version More...
 
MX_INT_RET _opRegSize ()
 returns number of ops registered in this library More...
 
MX_VOID_RET _opRegGet (int idx, const char **name, int *isSGop, const char ***forward_ctx, fcomp_t **forward_fp, int *forward_count, const char ***backward_ctx, fcomp_t **backward_fp, int *backward_count, const char ***create_op_ctx, createOpState_t **create_op_fp, int *create_op_count, parseAttrs_t *parse, inferType_t *type, inferSType_t *stype, inferShape_t *shape, mutateInputs_t *mutate)
 returns operator registration at specified index More...
 
MX_VOID_RET _opCallFree (void *ptr)
 calls free from the external library for library allocated arrays More...
 
MX_INT_RET _opCallParseAttrs (parseAttrs_t parseAttrs, const char *const *keys, const char *const *vals, int num, int *num_in, int *num_out)
 returns status of calling parse attributes function for operator from library More...
 
MX_INT_RET _opCallInferShape (inferShape_t inferShape, const char *const *keys, const char *const *vals, int num, unsigned int **inshapes, int *indims, int num_in, unsigned int ***mod_inshapes, int **mod_indims, unsigned int ***outshapes, int **outdims, int num_out)
 returns status of calling inferShape function for operator from library More...
 
MX_INT_RET _opCallInferType (inferType_t inferType, const char *const *keys, const char *const *vals, int num, int *intypes, int num_in, int *outtypes, int num_out)
 returns status of calling inferType function for operator from library More...
 
MX_INT_RET _opCallInferSType (inferSType_t inferSType, const char *const *keys, const char *const *vals, int num, int *instypes, int num_in, int *outstypes, int num_out)
 returns status of calling inferSType function for operator from library More...
 
MX_INT_RET _opCallFCompute (fcomp_t fcomp, const char *const *keys, const char *const *vals, int num, const int64_t **inshapes, int *indims, void **indata, int *intypes, size_t *inIDs, const char **indev_type, int *indev_id, int num_in, const int64_t **outshapes, int *outdims, void **outdata, int *outtypes, size_t *outIDs, const char **outdev_type, int *outdev_id, int num_out, xpu_malloc_t cpu_malloc, void *cpu_alloc, xpu_malloc_t gpu_malloc, void *gpu_alloc, void *cuda_stream, sparse_malloc_t sparse_malloc, void *sparse_alloc, int *instypes, int *outstypes, void **in_indices, void **out_indices, void **in_indptr, void **out_indptr, int64_t *in_indices_shapes, int64_t *out_indices_shapes, int64_t *in_indptr_shapes, int64_t *out_indptr_shapes, void *rng_cpu_states, void *rng_gpu_states)
 returns status of calling Forward/Backward function for operator from library More...
 
MX_INT_RET _opCallMutateInputs (mutateInputs_t mutate, const char *const *keys, const char *const *vals, int num, int **mutate_indices, int *indices_size)
 returns status of calling mutateInputs function for operator from library More...
 
MX_INT_RET _opCallCreateOpState (createOpState_t create_op, const char *const *keys, const char *const *vals, int num, void **state_op)
 returns status of calling createStatefulOp function for operator from library More...
 
MX_INT_RET _opCallFStatefulCompute (int is_forward, void *state_op, const int64_t **inshapes, int *indims, void **indata, int *intypes, size_t *inIDs, const char **indev_type, int *indev_id, int num_in, const int64_t **outshapes, int *outdims, void **outdata, int *outtypes, size_t *outIDs, const char **outdev_type, int *outdev_id, int num_out, xpu_malloc_t cpu_malloc, void *cpu_alloc, xpu_malloc_t gpu_malloc, void *gpu_alloc, void *stream, sparse_malloc_t sparse_malloc, void *sparse_alloc, int *instypes, int *outstypes, void **in_indices, void **out_indices, void **in_indptr, void **out_indptr, int64_t *in_indices_shapes, int64_t *out_indices_shapes, int64_t *in_indptr_shapes, int64_t *out_indptr_shapes, void *rng_cpu_states, void *rng_gpu_states)
 returns status of calling Stateful Forward/Backward for operator from library More...
 
MX_INT_RET _partRegSize ()
 returns number of partitioners registered in this library More...
 
MX_INT_RET _partRegGetCount (int idx, const char **name)
 
MX_VOID_RET _partRegGet (int part_idx, int stg_idx, const char **strategy, supportedOps_t *supportedOps, createSelector_t *createSelector, reviewSubgraph_t *reviewSubgraph, const char **op_name)
 returns partitioner registration at specified index More...
 
MX_INT_RET _partCallSupportedOps (supportedOps_t supportedOps, const char *json, int num_ids, int *ids, const char *const *opt_keys, const char *const *opt_vals, int num_opts)
 returns status of calling supported ops function from library More...
 
MX_INT_RET _partCallCreateSelector (createSelector_t createSelector, const char *json, void **selector, const char *const *opt_keys, const char *const *opt_vals, int num_opts)
 returns status of calling create selector function from library More...
 
MX_VOID_RET _partCallSelect (void *sel_inst, int nodeID, int *selected)
 returns status of calling select function from library More...
 
MX_VOID_RET _partCallSelectInput (void *sel_inst, int nodeID, int input_nodeID, int *selected)
 returns status of calling select input function from library More...
 
MX_VOID_RET _partCallSelectOutput (void *sel_inst, int nodeID, int output_nodeID, int *selected)
 returns status of calling select output function from library More...
 
MX_VOID_RET _partCallFilter (void *sel_inst, int *candidates, int num_candidates, int **keep, int *num_keep)
 returns status of calling filter function from library More...
 
MX_VOID_RET _partCallReset (void *sel_inst)
 returns status of calling reset selector function from library More...
 
MX_INT_RET _partCallReviewSubgraph (reviewSubgraph_t reviewSubgraph, const char *json, int subgraph_id, int *accept, const char *const *opt_keys, const char *const *opt_vals, int num_opts, char ***attr_keys, char ***attr_vals, int *num_attrs, const char *const *arg_names, int num_args, void *const *arg_data, const int64_t *const *arg_shapes, const int *arg_dims, const int *arg_types, const size_t *arg_IDs, const char *const *arg_dev_type, const int *arg_dev_id, const char *const *aux_names, int num_aux, void *const *aux_data, const int64_t *const *aux_shapes, const int *aux_dims, const int *aux_types, const size_t *aux_IDs, const char *const *aux_dev_type, const int *aux_dev_id)
 returns status of calling review subgraph function from library More...
 
MX_INT_RET _passRegSize ()
 returns number of graph passes registered in this library More...
 
MX_VOID_RET _passRegGet (int pass_idx, graphPass_t *graphPass, const char **pass_name)
 returns pass registration at specified index More...
 
MX_INT_RET _passCallGraphPass (graphPass_t graphPass, const char *json, char **graph, const char *const *opt_keys, const char *const *opt_vals, int num_opts, const char *pass_name, const char *const *arg_names, int num_args, void *const *arg_data, const int64_t *const *arg_shapes, const int *arg_dims, const int *arg_types, const size_t *arg_IDs, const char *const *arg_dev_type, const int *arg_dev_id, const char *const *aux_names, int num_aux, void *const *aux_data, const int64_t *const *aux_shapes, const int *aux_dims, const int *aux_types, const size_t *aux_IDs, const char *const *aux_dev_type, const int *aux_dev_id, nd_malloc_t nd_malloc, const void *nd_alloc)
 returns status of calling graph pass function from library More...
 
MXReturnValue initialize (int version)
 Checks if the MXNet version is supported by the library. If supported, initializes the library. More...
 

Detailed Description

APIs to interact with libraries This API specifies function prototypes to register custom ops, partitioner, and passes for library authors See example/extension/lib_custom_op/README.md See example/extension/lib_subgraph/README.md See example/extension/lib_pass/README.md.

Copyright (c) 2019 by Contributors

Macro Definition Documentation

#define DLPACK_DLL

DLPACK_DLL prefix for windows.

#define DLPACK_EXTERN_C
#define DLPACK_VERSION   020

The current version of dlpack.

#define MX_INT_RET   int
#define MX_LIBRARY_VERSION   7
#define MX_NUM_CPU_RANDOM_STATES   1024

MXNet initialized random states for each device, used for parallelism.

#define MX_NUM_GPU_RANDOM_STATES   32768
#define MX_REGISTER_DEF_ (   Name)    CustomOp MX_REGISTER_NAME_(Name)
#define MX_REGISTER_NAME_ (   Name)    MXNet ## _CustomOp ## _

declare a variable with custom name

#define MX_REGISTER_PASS_DEF_ (   Name)    CustomPass MX_REGISTER_PASS_NAME_(Name)
#define MX_REGISTER_PASS_NAME_ (   Name)    MXNet ## _CustomPass ## _
#define MX_REGISTER_PROP_DEF_ (   Name)    CustomPartitioner MX_REGISTER_PROP_NAME_(Name)
#define MX_REGISTER_PROP_NAME_ (   Name)    MXNet ## _CustomSubProp ## _
#define MX_STR_CONCAT (   __a,
  __b 
)    MX_STR_CONCAT_(__a, __b)
#define MX_STR_CONCAT_ (   __a,
  __b 
)    __a ## __b

Macros to help with string concat Annoyingly, the concat_ and concat macros are necessary to be able to use COUNTER in an identifier name.

#define MX_STR_DTYPE   "__ext_dtype__"
#define MX_STR_SHAPE   "__ext_shape__"
#define MX_STR_SUBGRAPH_SYM_JSON   "subgraph_sym_json"

Macro to help passing serialized subgraph through attribute dict.

#define MX_STRINGIFY (   x)    #x

convert a token to a string

#define MX_TOSTRING (   x)    MX_STRINGIFY(x)
#define MX_VOID_RET   void
#define MXLIB_INITIALIZE_STR   "initialize"
#define MXLIB_OPCALLCREATEOPSTATE_STR   "_opCallCreateOpState"
#define MXLIB_OPCALLFCOMP_STR   "_opCallFCompute"
#define MXLIB_OPCALLFREE_STR   "_opCallFree"
#define MXLIB_OPCALLFSTATEFULCOMP_STR   "_opCallFStatefulCompute"
#define MXLIB_OPCALLINFERSHAPE_STR   "_opCallInferShape"
#define MXLIB_OPCALLINFERSTYPE_STR   "_opCallInferSType"
#define MXLIB_OPCALLINFERTYPE_STR   "_opCallInferType"
#define MXLIB_OPCALLMUTATEINPUTS_STR   "_opCallMutateInputs"
#define MXLIB_OPCALLPARSEATTRS_STR   "_opCallParseAttrs"
#define MXLIB_OPREGGET_STR   "_opRegGet"
#define MXLIB_OPREGSIZE_STR   "_opRegSize"

Following are the C type APIs implemented in the external library Each API has a #define string that is used to lookup the function in the library Followed by the function declaration.

#define MXLIB_OPVERSION_STR   "_opVersion"
#define MXLIB_PARTCALLCREATESELECTOR_STR   "_partCallCreateSelector"
#define MXLIB_PARTCALLFILTER_STR   "_partCallFilter"
#define MXLIB_PARTCALLRESET_STR   "_partCallReset"
#define MXLIB_PARTCALLREVIEWSUBGRAPH_STR   "_partCallReviewSubgraph"
#define MXLIB_PARTCALLSELECT_STR   "_partCallSelect"
#define MXLIB_PARTCALLSELECTINPUT_STR   "_partCallSelectInput"
#define MXLIB_PARTCALLSELECTOUTPUT_STR   "_partCallSelectOutput"
#define MXLIB_PARTCALLSUPPORTEDOPS_STR   "_partCallSupportedOps"
#define MXLIB_PARTREGGET_STR   "_partRegGet"
#define MXLIB_PARTREGGETCOUNT_STR   "_partRegGetCount"
#define MXLIB_PARTREGSIZE_STR   "_partRegSize"
#define MXLIB_PASSCALLGRAPHPASS_STR   "_passCallGraphPass"
#define MXLIB_PASSREGGET_STR   "_passRegGet"
#define MXLIB_PASSREGSIZE_STR   "_passRegSize"
#define PRIVATE_SYMBOL   __attribute__ ((visibility ("hidden")))

For loading multiple custom op libraries in Linux, exporting same symbol multiple times may lead to undefined behaviour, so we need to set symbol visibility to hidden see https://labjack.com/news/simple-cpp-symbol-visibility-demo for details.

#define REGISTER_OP (   Name)
Value:
MX_STR_CONCAT(MX_REGISTER_DEF_(Name), __COUNTER__) = \
#define MX_REGISTER_DEF_(Name)
Definition: lib_api.h:1148
T & add(const char *name)
add a new entry
Definition: lib_api.h:1113
#define MX_TOSTRING(x)
Definition: lib_api.h:1144
static Registry * get() PRIVATE_SYMBOL
get singleton pointer to class
Definition: lib_api.h:1105
#define MX_STR_CONCAT(__a, __b)
Definition: lib_api.h:1140

assign a var to a value

#define REGISTER_PARTITIONER (   Name)
Value:
MX_STR_CONCAT(MX_REGISTER_PROP_DEF_(Name), __COUNTER__) = \
T & add(const char *name)
add a new entry
Definition: lib_api.h:1113
#define MX_TOSTRING(x)
Definition: lib_api.h:1144
static Registry * get() PRIVATE_SYMBOL
get singleton pointer to class
Definition: lib_api.h:1105
#define MX_STR_CONCAT(__a, __b)
Definition: lib_api.h:1140
#define MX_REGISTER_PROP_DEF_(Name)
Definition: lib_api.h:1151
#define REGISTER_PASS (   Name)
Value:
MX_STR_CONCAT(MX_REGISTER_PASS_DEF_(Name), __COUNTER__) = \
T & add(const char *name)
add a new entry
Definition: lib_api.h:1113
#define MX_TOSTRING(x)
Definition: lib_api.h:1144
#define MX_REGISTER_PASS_DEF_(Name)
Definition: lib_api.h:1154
static Registry * get() PRIVATE_SYMBOL
get singleton pointer to class
Definition: lib_api.h:1105
#define MX_STR_CONCAT(__a, __b)
Definition: lib_api.h:1140

Typedef Documentation

typedef MXReturnValue(* createOpState_t) (const std::unordered_map< std::string, std::string > &attributes, CustomStatefulOp **)
typedef MXReturnValue(* createSelector_t) (const std::string &json, CustomOpSelector **sel_inst, const std::unordered_map< std::string, std::string > &options)
typedef MXReturnValue(* fcomp_t) (const std::unordered_map< std::string, std::string > &attributes, std::vector< MXTensor > *inputs, std::vector< MXTensor > *outputs, const OpResource &res)

Custom Operator function templates.

typedef MXReturnValue(* graphPass_t) (const std::string &in_graph, const std::string **out_graph, const std::unordered_map< std::string, std::string > &options, const std::unordered_map< std::string, MXTensor > &args, const std::unordered_map< std::string, MXTensor > &aux, const PassResource &res)

Custom Pass Create function template.

typedef MXReturnValue(* inferShape_t) (const std::unordered_map< std::string, std::string > &attributes, std::vector< std::vector< unsigned int > > *in_shapes, std::vector< std::vector< unsigned int > > *out_shapes)
typedef MXReturnValue(* inferSType_t) (const std::unordered_map< std::string, std::string > &attributes, std::vector< int > *in_storage_types, std::vector< int > *out_storage_types)
typedef MXReturnValue(* inferType_t) (const std::unordered_map< std::string, std::string > &attributes, std::vector< int > *in_types, std::vector< int > *out_types)
typedef int(* initialize_t) (int version)
typedef MXReturnValue(* mutateInputs_t) (const std::unordered_map< std::string, std::string > &attributes, std::vector< int > *input_indices)
typedef std::mt19937 mx_cpu_rand_t
typedef void* mx_gpu_rand_t
typedef void* mx_stream_t

GPU stream pointer, is void* when not compiled with CUDA.

typedef void(* nd_malloc_t) (const void *_ndarray_alloc, const int64_t *shapes, int num_shapes, const char *dev_str, int dev_id, int dtype, const char *name, int isArg, void **data)

resource malloc function to allocate ndarrays for graph passes

typedef int(* opCallCreateOpState_t) (createOpState_t create_op, const char *const *keys, const char *const *vals, int num, void **state_op)
typedef int(* opCallFComp_t) (fcomp_t fcomp, const char *const *keys, const char *const *vals, int num, const int64_t **inshapes, int *indims, void **indata, int *intypes, size_t *inIDs, const char **indev_type, int *indev_id, int num_in, const int64_t **outshapes, int *outdims, void **outdata, int *outtypes, size_t *outIDs, const char **outdev_type, int *outdev_id, int num_out, xpu_malloc_t cpu_malloc, void *cpu_alloc, xpu_malloc_t gpu_malloc, void *gpu_alloc, void *cuda_stream, sparse_malloc_t sparse_malloc, void *sparse_alloc, int *instypes, int *outstypes, void **in_indices, void **out_indices, void **in_indptr, void **out_indptr, int64_t *in_indices_shapes, int64_t *out_indices_shapes, int64_t *in_indptr_shapes, int64_t *out_indptr_shapes, void *rng_cpu_states, void *rng_gpu_states)
typedef int(* opCallFree_t) (void *ptr)
typedef int(* opCallFStatefulComp_t) (int is_forward, void *state_op, const int64_t **inshapes, int *indims, void **indata, int *intypes, size_t *inIDs, const char **indev_type, int *indev_id, int num_in, const int64_t **outshapes, int *outdims, void **outdata, int *outtypes, size_t *outIDs, const char **outdev_type, int *outdev_id, int num_out, xpu_malloc_t cpu_malloc, void *cpu_alloc, xpu_malloc_t gpu_malloc, void *gpu_alloc, void *stream, sparse_malloc_t sparse_malloc, void *sparse_alloc, int *instypes, int *outstypes, void **in_indices, void **out_indices, void **in_indptr, void **out_indptr, int64_t *in_indices_shapes, int64_t *out_indices_shapes, int64_t *in_indptr_shapes, int64_t *out_indptr_shapes, void *rng_cpu_states, void *rng_gpu_states)
typedef int(* opCallInferShape_t) (inferShape_t inferShape, const char *const *keys, const char *const *vals, int num, unsigned int **inshapes, int *indims, int num_in, unsigned int ***mod_inshapes, int **mod_indims, unsigned int ***outshapes, int **outdims, int num_out)
typedef int(* opCallInferSType_t) (inferSType_t inferSType, const char *const *keys, const char *const *vals, int num, int *intypes, int num_in, int *outtypes, int num_out)
typedef int(* opCallInferType_t) (inferType_t inferType, const char *const *keys, const char *const *vals, int num, int *intypes, int num_in, int *outtypes, int num_out)
typedef int(* opCallMutateInputs_t) (mutateInputs_t mutate, const char *const *keys, const char *const *vals, int num, int **mutate_indices, int *indices_size)
typedef int(* opCallParseAttrs_t) (parseAttrs_t parseAttrs, const char *const *keys, const char *const *vals, int num, int *num_in, int *num_out)
typedef int(* opRegGet_t) (int idx, const char **name, int *isSGop, const char ***forward_ctx, fcomp_t **forward_fp, int *forward_count, const char ***backward_ctx, fcomp_t **backward_fp, int *backward_count, const char ***create_op_ctx, createOpState_t **create_op_fp, int *create_op_count, parseAttrs_t *parse, inferType_t *type, inferSType_t *stype, inferShape_t *shape, mutateInputs_t *mutate)
typedef int(* opRegSize_t) (void)
typedef int(* opVersion_t) ()
typedef MXReturnValue(* parseAttrs_t) (const std::unordered_map< std::string, std::string > &attributes, int *num_inputs, int *num_outputs)
typedef int(* partCallCreateSelector_t) (createSelector_t createSelector, const char *json, void **selector, const char *const *opt_keys, const char *const *opt_vals, int num_opts)
typedef void(* partCallFilter_t) (void *sel_inst, int *candidates, int num_candidates, int **keep, int *num_keep)
typedef void(* partCallReset_t) (void *sel_inst)
typedef int(* partCallReviewSubgraph_t) (reviewSubgraph_t reviewSubgraph, const char *json, int subgraph_id, int *accept, const char *const *opt_keys, const char *const *opt_vals, int num_opts, char ***attr_keys, char ***attr_vals, int *num_attrs, const char *const *arg_names, int num_args, void *const *arg_data, const int64_t *const *arg_shapes, const int *arg_dims, const int *arg_types, const size_t *arg_IDs, const char *const *arg_dev_type, const int *arg_dev_id, const char *const *aux_names, int num_aux, void *const *aux_data, const int64_t *const *aux_shapes, const int *aux_dims, const int *aux_types, const size_t *aux_IDs, const char *const *aux_dev_type, const int *aux_dev_id)
typedef void(* partCallSelect_t) (void *sel_inst, int nodeID, int *selected)
typedef void(* partCallSelectInput_t) (void *sel_inst, int nodeID, int input_nodeID, int *selected)
typedef void(* partCallSelectOutput_t) (void *sel_inst, int nodeID, int output_nodeID, int *selected)
typedef int(* partCallSupportedOps_t) (supportedOps_t supportedOps, const char *json, int num_ids, int *ids, const char *const *opt_keys, const char *const *opt_vals, int num_opts)
typedef void(* partRegGet_t) (int part_idx, int stg_idx, const char **strategy, supportedOps_t *supportedOps, createSelector_t *createSelector, reviewSubgraph_t *reviewSubgraph, const char **op_name)
typedef int(* partRegGetCount_t) (int idx, const char **name)
typedef int(* partRegSize_t) (void)
typedef int(* passCallGraphPass_t) (graphPass_t graphPass, const char *in_graph, char **out_graph, const char *const *opt_keys, const char *const *opt_vals, int num_opts, const char *pass_name, const char *const *arg_names, int num_args, void *const *arg_data, const int64_t *const *arg_shapes, const int *arg_dims, const int *arg_types, const size_t *arg_IDs, const char *const *arg_dev_type, const int *arg_dev_id, const char *const *aux_names, int num_aux, void *const *aux_data, const int64_t *const *aux_shapes, const int *aux_dims, const int *aux_types, const size_t *aux_IDs, const char *const *aux_dev_type, const int *aux_dev_id, nd_malloc_t nd_malloc, const void *nd_alloc)
typedef void(* passRegGet_t) (int pass_idx, graphPass_t *graphPass, const char **pass_name)
typedef int(* passRegSize_t) (void)
typedef MXReturnValue(* reviewSubgraph_t) (const std::string &json, int subgraph_id, bool *accept, const std::unordered_map< std::string, std::string > &options, std::unordered_map< std::string, std::string > *attrs, const std::unordered_map< std::string, MXTensor > &args, const std::unordered_map< std::string, MXTensor > &aux)
typedef void(* sparse_malloc_t) (void *, int, int, int, void **, int64_t **, int64_t **)

sparse alloc function to allocate memory inside Forward/Backward functions

typedef MXReturnValue(* supportedOps_t) (const std::string &json, std::vector< int > *ids, const std::unordered_map< std::string, std::string > &options)

Custom Subgraph Create function template.

typedef void*(* xpu_malloc_t) (void *, int)

resource malloc function to allocate memory inside Forward/Backward functions

Enumeration Type Documentation

The type code options DLDataType.

Enumerator
kDLInt 
kDLUInt 
kDLFloat 
kDLBfloat 
kDLInt 
kDLUInt 
kDLFloat 

The device type in DLContext.

Enumerator
kDLCPU 

CPU device.

kDLGPU 

CUDA GPU device.

kDLCPUPinned 

Pinned CUDA GPU device by cudaMallocHost.

Note
kDLCPUPinned = kDLCPU | kDLGPU
kDLOpenCL 

OpenCL devices.

kDLVulkan 

Vulkan buffer for next generation graphics.

kDLMetal 

Metal for Apple GPU.

kDLVPI 

Verilog simulator buffer.

kDLROCM 

ROCm GPUs for AMD GPUs.

kDLExtDev 

Reserved extension device type, used for quickly test extension device The semantics can differ depending on the implementation.

kDLCPU 

CPU device.

kDLGPU 

CUDA GPU device.

kDLCPUPinned 

Pinned CUDA GPU device by cudaMallocHost.

Note
kDLCPUPinned = kDLCPU | kDLGPU
kDLOpenCL 

OpenCL devices.

kDLVulkan 

Vulkan buffer for next generation graphics.

kDLMetal 

Metal for Apple GPU.

kDLVPI 

Verilog simulator buffer.

kDLROCM 

ROCm GPUs for AMD GPUs.

kDLExtDev 

Reserved extension device type, used for quickly test extension device The semantics can differ depending on the implementation.

enum JsonType

Json utility to parse serialized subgraph symbol.

Types of JSON objects

Enumerator
ERR 
STR 
NUM 
LIST 
MAP 
enum MXDType

Tensor data type, consistent with mshadow data type.

Enumerator
kFloat32 
kFloat64 
kFloat16 
kUint8 
kInt32 
kInt8 
kInt64 
kUNSET 
Enumerator
MX_FAIL 
MX_SUCCESS 
Enumerator
kDefaultStorage 
kRowSparseStorage 
kCSRStorage 

Function Documentation

MX_INT_RET _opCallCreateOpState ( createOpState_t  create_op,
const char *const *  keys,
const char *const *  vals,
int  num,
void **  state_op 
)

returns status of calling createStatefulOp function for operator from library

MX_INT_RET _opCallFCompute ( fcomp_t  fcomp,
const char *const *  keys,
const char *const *  vals,
int  num,
const int64_t **  inshapes,
int *  indims,
void **  indata,
int *  intypes,
size_t *  inIDs,
const char **  indev_type,
int *  indev_id,
int  num_in,
const int64_t **  outshapes,
int *  outdims,
void **  outdata,
int *  outtypes,
size_t *  outIDs,
const char **  outdev_type,
int *  outdev_id,
int  num_out,
xpu_malloc_t  cpu_malloc,
void *  cpu_alloc,
xpu_malloc_t  gpu_malloc,
void *  gpu_alloc,
void *  cuda_stream,
sparse_malloc_t  sparse_malloc,
void *  sparse_alloc,
int *  instypes,
int *  outstypes,
void **  in_indices,
void **  out_indices,
void **  in_indptr,
void **  out_indptr,
int64_t *  in_indices_shapes,
int64_t *  out_indices_shapes,
int64_t *  in_indptr_shapes,
int64_t *  out_indptr_shapes,
void *  rng_cpu_states,
void *  rng_gpu_states 
)

returns status of calling Forward/Backward function for operator from library

MX_VOID_RET _opCallFree ( void *  ptr)

calls free from the external library for library allocated arrays

MX_INT_RET _opCallFStatefulCompute ( int  is_forward,
void *  state_op,
const int64_t **  inshapes,
int *  indims,
void **  indata,
int *  intypes,
size_t *  inIDs,
const char **  indev_type,
int *  indev_id,
int  num_in,
const int64_t **  outshapes,
int *  outdims,
void **  outdata,
int *  outtypes,
size_t *  outIDs,
const char **  outdev_type,
int *  outdev_id,
int  num_out,
xpu_malloc_t  cpu_malloc,
void *  cpu_alloc,
xpu_malloc_t  gpu_malloc,
void *  gpu_alloc,
void *  stream,
sparse_malloc_t  sparse_malloc,
void *  sparse_alloc,
int *  instypes,
int *  outstypes,
void **  in_indices,
void **  out_indices,
void **  in_indptr,
void **  out_indptr,
int64_t *  in_indices_shapes,
int64_t *  out_indices_shapes,
int64_t *  in_indptr_shapes,
int64_t *  out_indptr_shapes,
void *  rng_cpu_states,
void *  rng_gpu_states 
)

returns status of calling Stateful Forward/Backward for operator from library

MX_INT_RET _opCallInferShape ( inferShape_t  inferShape,
const char *const *  keys,
const char *const *  vals,
int  num,
unsigned int **  inshapes,
int *  indims,
int  num_in,
unsigned int ***  mod_inshapes,
int **  mod_indims,
unsigned int ***  outshapes,
int **  outdims,
int  num_out 
)

returns status of calling inferShape function for operator from library

MX_INT_RET _opCallInferSType ( inferSType_t  inferSType,
const char *const *  keys,
const char *const *  vals,
int  num,
int *  instypes,
int  num_in,
int *  outstypes,
int  num_out 
)

returns status of calling inferSType function for operator from library

MX_INT_RET _opCallInferType ( inferType_t  inferType,
const char *const *  keys,
const char *const *  vals,
int  num,
int *  intypes,
int  num_in,
int *  outtypes,
int  num_out 
)

returns status of calling inferType function for operator from library

MX_INT_RET _opCallMutateInputs ( mutateInputs_t  mutate,
const char *const *  keys,
const char *const *  vals,
int  num,
int **  mutate_indices,
int *  indices_size 
)

returns status of calling mutateInputs function for operator from library

MX_INT_RET _opCallParseAttrs ( parseAttrs_t  parseAttrs,
const char *const *  keys,
const char *const *  vals,
int  num,
int *  num_in,
int *  num_out 
)

returns status of calling parse attributes function for operator from library

MX_VOID_RET _opRegGet ( int  idx,
const char **  name,
int *  isSGop,
const char ***  forward_ctx,
fcomp_t **  forward_fp,
int *  forward_count,
const char ***  backward_ctx,
fcomp_t **  backward_fp,
int *  backward_count,
const char ***  create_op_ctx,
createOpState_t **  create_op_fp,
int *  create_op_count,
parseAttrs_t parse,
inferType_t type,
inferSType_t stype,
inferShape_t shape,
mutateInputs_t mutate 
)

returns operator registration at specified index

MX_INT_RET _opRegSize ( )

returns number of ops registered in this library

MX_INT_RET _opVersion ( )

returns MXNet library version

MX_INT_RET _partCallCreateSelector ( createSelector_t  createSelector,
const char *  json,
void **  selector,
const char *const *  opt_keys,
const char *const *  opt_vals,
int  num_opts 
)

returns status of calling create selector function from library

MX_VOID_RET _partCallFilter ( void *  sel_inst,
int *  candidates,
int  num_candidates,
int **  keep,
int *  num_keep 
)

returns status of calling filter function from library

MX_VOID_RET _partCallReset ( void *  sel_inst)

returns status of calling reset selector function from library

MX_INT_RET _partCallReviewSubgraph ( reviewSubgraph_t  reviewSubgraph,
const char *  json,
int  subgraph_id,
int *  accept,
const char *const *  opt_keys,
const char *const *  opt_vals,
int  num_opts,
char ***  attr_keys,
char ***  attr_vals,
int *  num_attrs,
const char *const *  arg_names,
int  num_args,
void *const *  arg_data,
const int64_t *const *  arg_shapes,
const int *  arg_dims,
const int *  arg_types,
const size_t *  arg_IDs,
const char *const *  arg_dev_type,
const int *  arg_dev_id,
const char *const *  aux_names,
int  num_aux,
void *const *  aux_data,
const int64_t *const *  aux_shapes,
const int *  aux_dims,
const int *  aux_types,
const size_t *  aux_IDs,
const char *const *  aux_dev_type,
const int *  aux_dev_id 
)

returns status of calling review subgraph function from library

MX_VOID_RET _partCallSelect ( void *  sel_inst,
int  nodeID,
int *  selected 
)

returns status of calling select function from library

MX_VOID_RET _partCallSelectInput ( void *  sel_inst,
int  nodeID,
int  input_nodeID,
int *  selected 
)

returns status of calling select input function from library

MX_VOID_RET _partCallSelectOutput ( void *  sel_inst,
int  nodeID,
int  output_nodeID,
int *  selected 
)

returns status of calling select output function from library

MX_INT_RET _partCallSupportedOps ( supportedOps_t  supportedOps,
const char *  json,
int  num_ids,
int *  ids,
const char *const *  opt_keys,
const char *const *  opt_vals,
int  num_opts 
)

returns status of calling supported ops function from library

MX_VOID_RET _partRegGet ( int  part_idx,
int  stg_idx,
const char **  strategy,
supportedOps_t supportedOps,
createSelector_t createSelector,
reviewSubgraph_t reviewSubgraph,
const char **  op_name 
)

returns partitioner registration at specified index

MX_INT_RET _partRegGetCount ( int  idx,
const char **  name 
)
MX_INT_RET _partRegSize ( )

returns number of partitioners registered in this library

MX_INT_RET _passCallGraphPass ( graphPass_t  graphPass,
const char *  json,
char **  graph,
const char *const *  opt_keys,
const char *const *  opt_vals,
int  num_opts,
const char *  pass_name,
const char *const *  arg_names,
int  num_args,
void *const *  arg_data,
const int64_t *const *  arg_shapes,
const int *  arg_dims,
const int *  arg_types,
const size_t *  arg_IDs,
const char *const *  arg_dev_type,
const int *  arg_dev_id,
const char *const *  aux_names,
int  num_aux,
void *const *  aux_data,
const int64_t *const *  aux_shapes,
const int *  aux_dims,
const int *  aux_types,
const size_t *  aux_IDs,
const char *const *  aux_dev_type,
const int *  aux_dev_id,
nd_malloc_t  nd_malloc,
const void *  nd_alloc 
)

returns status of calling graph pass function from library

MX_VOID_RET _passRegGet ( int  pass_idx,
graphPass_t graphPass,
const char **  pass_name 
)

returns pass registration at specified index

MX_INT_RET _passRegSize ( )

returns number of graph passes registered in this library

std::string getDtypeAt ( const std::string &  dtype,
unsigned  index 
)
std::string getShapeAt ( const std::string &  shape,
unsigned  index 
)
MXReturnValue initialize ( int  version)

Checks if the MXNet version is supported by the library. If supported, initializes the library.

Parameters
versionMXNet version number passed to library and defined as: MXNET_VERSION = (MXNET_MAJOR*10000 + MXNET_MINOR*100 + MXNET_PATCH)
Returns
Non-zero value on error i.e. library incompatible with passed MXNet version