mxnet
|
C predict API of mxnet, contains a minimum API to run prediction. This file is self-contained, and do not dependent on any other files. More...
Go to the source code of this file.
Macros | |
#define | MXNET_DLL |
Inhibit C++ name-mangling for MXNet functions. More... | |
Typedefs | |
typedef unsigned int | mx_uint |
manually define unsigned int More... | |
typedef float | mx_float |
manually define float More... | |
typedef void * | PredictorHandle |
handle to Predictor More... | |
typedef void * | NDListHandle |
handle to NDArray list More... | |
Functions | |
MXNET_DLL const char * | MXGetLastError () |
Get the last error happeneed. More... | |
MXNET_DLL int | MXPredCreate (const char *symbol_json_str, const void *param_bytes, int param_size, int dev_type, int dev_id, mx_uint num_input_nodes, const char **input_keys, const mx_uint *input_shape_indptr, const mx_uint *input_shape_data, PredictorHandle *out) |
create a predictor More... | |
MXNET_DLL int | MXPredCreatePartialOut (const char *symbol_json_str, const void *param_bytes, int param_size, int dev_type, int dev_id, mx_uint num_input_nodes, const char **input_keys, const mx_uint *input_shape_indptr, const mx_uint *input_shape_data, mx_uint num_output_nodes, const char **output_keys, PredictorHandle *out) |
create a predictor wich customized outputs More... | |
MXNET_DLL int | MXPredReshape (mx_uint num_input_nodes, const char **input_keys, const mx_uint *input_shape_indptr, const mx_uint *input_shape_data, PredictorHandle handle, PredictorHandle *out) |
Change the input shape of an existing predictor. More... | |
MXNET_DLL int | MXPredGetOutputShape (PredictorHandle handle, mx_uint index, mx_uint **shape_data, mx_uint *shape_ndim) |
Get the shape of output node. The returned shape_data and shape_ndim is only valid before next call to MXPred function. More... | |
MXNET_DLL int | MXPredSetInput (PredictorHandle handle, const char *key, const mx_float *data, mx_uint size) |
Set the input data of predictor. More... | |
MXNET_DLL int | MXPredForward (PredictorHandle handle) |
Run a forward pass to get the output. More... | |
MXNET_DLL int | MXPredPartialForward (PredictorHandle handle, int step, int *step_left) |
Run a interactive forward pass to get the output. This is helpful for displaying progress of prediction which can be slow. User must call PartialForward from step=0, keep increasing it until step_left=0. More... | |
MXNET_DLL int | MXPredGetOutput (PredictorHandle handle, mx_uint index, mx_float *data, mx_uint size) |
Get the output value of prediction. More... | |
MXNET_DLL int | MXPredFree (PredictorHandle handle) |
Free a predictor handle. More... | |
MXNET_DLL int | MXNDListCreate (const char *nd_file_bytes, int nd_file_size, NDListHandle *out, mx_uint *out_length) |
Create a NDArray List by loading from ndarray file. This can be used to load mean image file. More... | |
MXNET_DLL int | MXNDListGet (NDListHandle handle, mx_uint index, const char **out_key, const mx_float **out_data, const mx_uint **out_shape, mx_uint *out_ndim) |
Get an element from list. More... | |
MXNET_DLL int | MXNDListFree (NDListHandle handle) |
Free a MXAPINDList. More... | |
C predict API of mxnet, contains a minimum API to run prediction. This file is self-contained, and do not dependent on any other files.
Copyright (c) 2015 by Contributors
#define MXNET_DLL |
Inhibit C++ name-mangling for MXNet functions.
typedef float mx_float |
manually define float
typedef unsigned int mx_uint |
manually define unsigned int
typedef void* NDListHandle |
handle to NDArray list
typedef void* PredictorHandle |
handle to Predictor
MXNET_DLL const char* MXGetLastError | ( | ) |
Get the last error happeneed.
MXNET_DLL int MXNDListCreate | ( | const char * | nd_file_bytes, |
int | nd_file_size, | ||
NDListHandle * | out, | ||
mx_uint * | out_length | ||
) |
Create a NDArray List by loading from ndarray file. This can be used to load mean image file.
nd_file_bytes | The byte contents of nd file to be loaded. |
nd_file_size | The size of the nd file to be loaded. |
out | The out put NDListHandle |
out_length | Length of the list. |
MXNET_DLL int MXNDListFree | ( | NDListHandle | handle | ) |
Free a MXAPINDList.
handle | The handle of the MXAPINDList. |
MXNET_DLL int MXNDListGet | ( | NDListHandle | handle, |
mx_uint | index, | ||
const char ** | out_key, | ||
const mx_float ** | out_data, | ||
const mx_uint ** | out_shape, | ||
mx_uint * | out_ndim | ||
) |
Get an element from list.
handle | The handle to the NDArray |
index | The index in the list |
out_key | The output key of the item |
out_data | The data region of the item |
out_shape | The shape of the item. |
out_ndim | The number of dimension in the shape. |
MXNET_DLL int MXPredCreate | ( | const char * | symbol_json_str, |
const void * | param_bytes, | ||
int | param_size, | ||
int | dev_type, | ||
int | dev_id, | ||
mx_uint | num_input_nodes, | ||
const char ** | input_keys, | ||
const mx_uint * | input_shape_indptr, | ||
const mx_uint * | input_shape_data, | ||
PredictorHandle * | out | ||
) |
create a predictor
symbol_json_str | The JSON string of the symbol. |
param_bytes | The in-memory raw bytes of parameter ndarray file. |
param_size | The size of parameter ndarray file. |
dev_type | The device type, 1: cpu, 2:gpu |
dev_id | The device id of the predictor. |
num_input_nodes | Number of input nodes to the net, For feedforward net, this is 1. |
input_keys | The name of input argument. For feedforward net, this is {"data"} |
input_shape_indptr | Index pointer of shapes of each input node. The length of this array = num_input_nodes + 1. For feedforward net that takes 4 dimensional input, this is {0, 4}. |
input_shape_data | A flatted data of shapes of each input node. For feedforward net that takes 4 dimensional input, this is the shape data. |
out | The created predictor handle. |
MXNET_DLL int MXPredCreatePartialOut | ( | const char * | symbol_json_str, |
const void * | param_bytes, | ||
int | param_size, | ||
int | dev_type, | ||
int | dev_id, | ||
mx_uint | num_input_nodes, | ||
const char ** | input_keys, | ||
const mx_uint * | input_shape_indptr, | ||
const mx_uint * | input_shape_data, | ||
mx_uint | num_output_nodes, | ||
const char ** | output_keys, | ||
PredictorHandle * | out | ||
) |
create a predictor wich customized outputs
symbol_json_str | The JSON string of the symbol. |
param_bytes | The in-memory raw bytes of parameter ndarray file. |
param_size | The size of parameter ndarray file. |
dev_type | The device type, 1: cpu, 2:gpu |
dev_id | The device id of the predictor. |
num_input_nodes | Number of input nodes to the net, For feedforward net, this is 1. |
input_keys | The name of input argument. For feedforward net, this is {"data"} |
input_shape_indptr | Index pointer of shapes of each input node. The length of this array = num_input_nodes + 1. For feedforward net that takes 4 dimensional input, this is {0, 4}. |
input_shape_data | A flatted data of shapes of each input node. For feedforward net that takes 4 dimensional input, this is the shape data. |
num_output_nodes | Number of output nodes to the net, |
output_keys | The name of output argument. For example {"global_pool"} |
out | The created predictor handle. |
MXNET_DLL int MXPredForward | ( | PredictorHandle | handle | ) |
Run a forward pass to get the output.
handle | The handle of the predictor. |
MXNET_DLL int MXPredFree | ( | PredictorHandle | handle | ) |
Free a predictor handle.
handle | The handle of the predictor. |
MXNET_DLL int MXPredGetOutput | ( | PredictorHandle | handle, |
mx_uint | index, | ||
mx_float * | data, | ||
mx_uint | size | ||
) |
Get the output value of prediction.
handle | The handle of the predictor. |
index | The index of output node, set to 0 if there is only one output. |
data | User allocated data to hold the output. |
size | The size of data array, used for safe checking. |
MXNET_DLL int MXPredGetOutputShape | ( | PredictorHandle | handle, |
mx_uint | index, | ||
mx_uint ** | shape_data, | ||
mx_uint * | shape_ndim | ||
) |
Get the shape of output node. The returned shape_data and shape_ndim is only valid before next call to MXPred function.
handle | The handle of the predictor. |
index | The index of output node, set to 0 if there is only one output. |
shape_data | Used to hold pointer to the shape data |
shape_ndim | Used to hold shape dimension. |
MXNET_DLL int MXPredPartialForward | ( | PredictorHandle | handle, |
int | step, | ||
int * | step_left | ||
) |
Run a interactive forward pass to get the output. This is helpful for displaying progress of prediction which can be slow. User must call PartialForward from step=0, keep increasing it until step_left=0.
handle | The handle of the predictor. |
step | The current step to run forward on. |
step_left | The number of steps left |
MXNET_DLL int MXPredReshape | ( | mx_uint | num_input_nodes, |
const char ** | input_keys, | ||
const mx_uint * | input_shape_indptr, | ||
const mx_uint * | input_shape_data, | ||
PredictorHandle | handle, | ||
PredictorHandle * | out | ||
) |
Change the input shape of an existing predictor.
num_input_nodes | Number of input nodes to the net, For feedforward net, this is 1. |
input_keys | The name of input argument. For feedforward net, this is {"data"} |
input_shape_indptr | Index pointer of shapes of each input node. The length of this array = num_input_nodes + 1. For feedforward net that takes 4 dimensional input, this is {0, 4}. |
input_shape_data | A flatted data of shapes of each input node. For feedforward net that takes 4 dimensional input, this is the shape data. |
handle | The original predictor handle. |
out | The reshaped predictor handle. |
MXNET_DLL int MXPredSetInput | ( | PredictorHandle | handle, |
const char * | key, | ||
const mx_float * | data, | ||
mx_uint | size | ||
) |
Set the input data of predictor.
handle | The predictor handle. |
key | The name of input node to set. For feedforward net, this is "data". |
data | The pointer to the data to be set, with the shape specified in MXPredCreate. |
size | The size of data array, used for safety check. |