mxnet
c_predict_api.h
Go to the documentation of this file.
1 /*
2  * Licensed to the Apache Software Foundation (ASF) under one
3  * or more contributor license agreements. See the NOTICE file
4  * distributed with this work for additional information
5  * regarding copyright ownership. The ASF licenses this file
6  * to you under the Apache License, Version 2.0 (the
7  * "License"); you may not use this file except in compliance
8  * with the License. You may obtain a copy of the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing,
13  * software distributed under the License is distributed on an
14  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15  * KIND, either express or implied. See the License for the
16  * specific language governing permissions and limitations
17  * under the License.
18  */
19 
25 #ifndef MXNET_C_PREDICT_API_H_
26 #define MXNET_C_PREDICT_API_H_
27 
29 #ifdef __cplusplus
30 extern "C" {
31 #endif // __cplusplus
32 
33 #ifdef _WIN32
34 #ifdef MXNET_EXPORTS
35 #define MXNET_DLL __declspec(dllexport)
36 #else
37 #define MXNET_DLL __declspec(dllimport)
38 #endif
39 #else
40 #define MXNET_DLL
41 #endif
42 
44 typedef unsigned int mx_uint;
46 typedef float mx_float;
48 typedef void *PredictorHandle;
50 typedef void *NDListHandle;
51 
56 MXNET_DLL const char* MXGetLastError();
57 
77 MXNET_DLL int MXPredCreate(const char* symbol_json_str,
78  const void* param_bytes,
79  int param_size,
80  int dev_type, int dev_id,
81  mx_uint num_input_nodes,
82  const char** input_keys,
83  const mx_uint* input_shape_indptr,
84  const mx_uint* input_shape_data,
85  PredictorHandle* out);
86 
110 MXNET_DLL int MXPredCreatePartialOut(const char* symbol_json_str,
111  const void* param_bytes,
112  int param_size,
113  int dev_type, int dev_id,
114  mx_uint num_input_nodes,
115  const char** input_keys,
116  const mx_uint* input_shape_indptr,
117  const mx_uint* input_shape_data,
118  mx_uint num_output_nodes,
119  const char** output_keys,
120  PredictorHandle* out);
130 MXNET_DLL int MXPredGetOutputShape(PredictorHandle handle,
131  mx_uint index,
132  mx_uint** shape_data,
133  mx_uint* shape_ndim);
143 MXNET_DLL int MXPredSetInput(PredictorHandle handle,
144  const char* key,
145  const mx_float* data,
146  mx_uint size);
152 MXNET_DLL int MXPredForward(PredictorHandle handle);
169 MXNET_DLL int MXPredPartialForward(PredictorHandle handle, int step, int* step_left);
178 MXNET_DLL int MXPredGetOutput(PredictorHandle handle,
179  mx_uint index,
180  mx_float* data,
181  mx_uint size);
187 MXNET_DLL int MXPredFree(PredictorHandle handle);
197 MXNET_DLL int MXNDListCreate(const char* nd_file_bytes,
198  int nd_file_size,
199  NDListHandle *out,
200  mx_uint* out_length);
211 MXNET_DLL int MXNDListGet(NDListHandle handle,
212  mx_uint index,
213  const char** out_key,
214  const mx_float** out_data,
215  const mx_uint** out_shape,
216  mx_uint* out_ndim);
222 MXNET_DLL int MXNDListFree(NDListHandle handle);
223 
224 #ifdef __cplusplus
225 }
226 #endif // __cplusplus
227 
228 #endif // MXNET_C_PREDICT_API_H_
MXNET_DLL int MXPredForward(PredictorHandle handle)
Run a forward pass to get the output.
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...
MXNET_DLL int MXPredSetInput(PredictorHandle handle, const char *key, const mx_float *data, mx_uint size)
Set the input data of predictor.
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
MXNET_DLL int MXNDListFree(NDListHandle handle)
Free a MXAPINDList.
void * PredictorHandle
handle to Predictor
Definition: c_predict_api.h:48
MXNET_DLL int MXPredFree(PredictorHandle handle)
Free a predictor handle.
unsigned int mx_uint
manually define unsigned int
Definition: c_predict_api.h:44
float mx_float
manually define float
Definition: c_predict_api.h:46
void * NDListHandle
handle to NDArray list
Definition: c_predict_api.h:50
MXNET_DLL const char * MXGetLastError()
Get the last error happeneed.
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 t...
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
#define MXNET_DLL
Inhibit C++ name-mangling for MXNet functions.
Definition: c_predict_api.h:40
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 predicti...
MXNET_DLL int MXPredGetOutput(PredictorHandle handle, mx_uint index, mx_float *data, mx_uint size)
Get the output value of prediction.
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.