Bolt
|
C API Document. More...
Go to the source code of this file.
Typedefs | |
typedef void * | ModelHandle |
typedef void * | ResultHandle |
Enumerations | |
enum | AFFINITY_TYPE { CPU_HIGH_PERFORMANCE = 0, CPU_LOW_POWER = 1, GPU = 2 } |
enum | DEVICE_TYPE { CPU_SERIAL = 0, CPU_ARM_V7 = 1, CPU_ARM_V8 = 2, CPU_ARM_A55 = 3, CPU_ARM_A76 = 4, CPU_X86_AVX2 = 5, CPU_X86_AVX512 = 6, GPU_MALI = 10, GPU_QUALCOMM = 11 } |
enum | DATA_TYPE { FP_32 = 0, FP_16 = 1, INT_32 = 2, UINT_32 = 3 } |
enum | DATA_FORMAT { NCHW = 0, NHWC = 1, NCHWC8 = 2, MTK = 3, NORMAL = 4, NCHWC4 = 5 } |
Functions | |
const char *const * | GetDataTypeString () |
const char *const * | GetDataFormatString () |
ModelHandle | CreateModel (const char *modelPath, AFFINITY_TYPE affinity, const char *algorithmMapPath) |
create model from file More... | |
int | GetNumInputsFromModel (ModelHandle ih) |
get the number of model input from ModelHandle More... | |
void | GetInputDataInfoFromModel (ModelHandle ih, int num_inputs, char **name, int *n, int *c, int *h, int *w, DATA_TYPE *dt, DATA_FORMAT *df) |
get input data info set in model handle, which is read from .bolt More... | |
void | PrepareModel (ModelHandle ih, const int num_inputs, const char **name, const int *n, const int *c, const int *h, const int *w, const DATA_TYPE *dt, const DATA_FORMAT *df) |
complete model inference engine prepare More... | |
ResultHandle | AllocAllResultHandle (ModelHandle ih) |
malloc result data memory More... | |
void | RunModel (ModelHandle ih, ResultHandle ir, int num_inputs, const char **name, void **data) |
inference result from input More... | |
int | GetNumOutputsFromResultHandle (ResultHandle ir) |
get the number of model output from ResultHandle More... | |
void | GetOutputDataInfoFromResultHandle (ResultHandle ir, int num_outputs, char **outputNames, int *n, int *c, int *h, int *w, DATA_TYPE *dt, DATA_FORMAT *df) |
get output Data info from ResultHandle More... | |
void | GetOutputDataFromResultHandle (ResultHandle ir, int num_outputs, void **data) |
get output data from ResultHandle, default to pass value of output ptr, More... | |
void | FreeResultHandle (ResultHandle ir) |
free result data memory More... | |
void | DestroyModel (ModelHandle ih) |
destroy model More... | |
void | GetGpuDeviceName (char *gpuDeviceName) |
ModelHandle | CreateModelWithFileStream (const char *modelFileStream, AFFINITY_TYPE affinity, const char *algorithmMapFileStream) |
create model from file stream Other info is the same with CreateModel | |
void | GetInputDataInfoFromModel5D (ModelHandle ih, int num_inputs, char **name, int *n, int *c, int *t, int *h, int *w, DATA_TYPE *dt, DATA_FORMAT *df) |
get input Data info set in model handle, when input data is 5d input dims (n,c,t,h,w) other info please reference GetInputDataInfoFromModel | |
void | PrepareModel5D (ModelHandle ih, int num_input, const char **name, const int *n, const int *c, const int *t, const int *h, const int *w, const DATA_TYPE *dt_input, const DATA_FORMAT *df_input) |
complete model inference engine prepare when input data dim is 5d input dims (n,c,t,h,w) other info please reference PrepareModel | |
void | ResizeModelInput (ModelHandle ih, int num_inputs, const char **name, const int *n, const int *c, const int *h, const int *w, const DATA_TYPE *dt, const DATA_FORMAT *df) |
resize model input size More... | |
ResultHandle | AllocSpecificResultHandle (ModelHandle ih, int num_outputs, const char **name) |
malloc result data memory according to user specification More... | |
ModelHandle | CloneModel (ModelHandle ih) |
clone model from a model More... | |
ResultHandle | CloneResultHandle (ResultHandle ir) |
clone result handle More... | |
void | SetRuntimeDevice (ModelHandle ih, int cpu_id, DEVICE_TYPE device) |
set process to run on specified CPU core More... | |
void | SetRuntimeDeviceDynamic (ModelHandle ih) |
set process cpu affinity according cpu average occupy More... | |
void | SetNumThreads (int threads) |
set parallel threads num More... | |
C API Document.
Definition in file bolt.h.
typedef void* ModelHandle |
typedef void* ResultHandle |
enum AFFINITY_TYPE |
enum DATA_FORMAT |
multi-dimension data format
enum DATA_TYPE |
enum DEVICE_TYPE |
ResultHandle AllocAllResultHandle | ( | ModelHandle | ih | ) |
malloc result data memory
ih | inference pipeline handle |
Referenced by GetDataFormatString().
ResultHandle AllocSpecificResultHandle | ( | ModelHandle | ih, |
int | num_outputs, | ||
const char ** | name | ||
) |
malloc result data memory according to user specification
ih | inference pipeline handle |
num_outputs | the number of tensor that needed |
name | the array of tesor name that needed |
Referenced by GetDataFormatString().
ModelHandle CloneModel | ( | ModelHandle | ih | ) |
clone model from a model
ih | a inference pipeline handle pointer of a model |
Referenced by GetDataFormatString().
ResultHandle CloneResultHandle | ( | ResultHandle | ir | ) |
clone result handle
ir | a result data handle |
Referenced by GetDataFormatString().
ModelHandle CreateModel | ( | const char * | modelPath, |
AFFINITY_TYPE | affinity, | ||
const char * | algorithmMapPath | ||
) |
create model from file
modelPath | model file path |
affinity | CPU affinity setting |
algorithmMapPath | the file path to save and load algorithm map file |
Referenced by GetDataFormatString().
void DestroyModel | ( | ModelHandle | ih | ) |
void FreeResultHandle | ( | ResultHandle | ir | ) |
free result data memory
ir | result data memory handle |
Referenced by GetDataFormatString().
const char* const* GetDataFormatString | ( | ) |
Get DATA_FORMAT String
Definition at line 80 of file bolt.h.
References AllocAllResultHandle(), AllocSpecificResultHandle(), CloneModel(), CloneResultHandle(), CreateModel(), CreateModelWithFileStream(), DestroyModel(), FreeResultHandle(), GetGpuDeviceName(), GetInputDataInfoFromModel(), GetInputDataInfoFromModel5D(), GetNumInputsFromModel(), GetNumOutputsFromResultHandle(), GetOutputDataFromResultHandle(), GetOutputDataInfoFromResultHandle(), PrepareModel(), PrepareModel5D(), ResizeModelInput(), RunModel(), SetNumThreads(), SetRuntimeDevice(), and SetRuntimeDeviceDynamic().
void GetGpuDeviceName | ( | char * | gpuDeviceName | ) |
Copy current GPU device name to gpuDeviceName User need to alloc memory of gpuDeviceName used with CreateModelWithFileStream to help user choose algoFile
Referenced by GetDataFormatString().
void GetInputDataInfoFromModel | ( | ModelHandle | ih, |
int | num_inputs, | ||
char ** | name, | ||
int * | n, | ||
int * | c, | ||
int * | h, | ||
int * | w, | ||
DATA_TYPE * | dt, | ||
DATA_FORMAT * | df | ||
) |
get input data info set in model handle, which is read from .bolt
ih | inference pipeline handle |
num_inputs | the number of input |
name | the array of all input data's name |
n | the array of all input data's n dimension |
c | the array of all input data's c dimension |
h | the array of all input data's h dimension |
w | the array of all input data's w dimension |
dt | the array of all input data's data type |
df | the array of all input data's data format |
Referenced by GetDataFormatString().
int GetNumInputsFromModel | ( | ModelHandle | ih | ) |
get the number of model input from ModelHandle
ih | inference pipeline handle |
Referenced by GetDataFormatString().
int GetNumOutputsFromResultHandle | ( | ResultHandle | ir | ) |
get the number of model output from ResultHandle
ir | result data memory handle |
Referenced by GetDataFormatString().
void GetOutputDataFromResultHandle | ( | ResultHandle | ir, |
int | num_outputs, | ||
void ** | data | ||
) |
get output data from ResultHandle, default to pass value of output ptr,
ir | result data memory handle |
num_outputs | the number of output data |
data | the array of all output data's content |
Referenced by GetDataFormatString().
void GetOutputDataInfoFromResultHandle | ( | ResultHandle | ir, |
int | num_outputs, | ||
char ** | outputNames, | ||
int * | n, | ||
int * | c, | ||
int * | h, | ||
int * | w, | ||
DATA_TYPE * | dt, | ||
DATA_FORMAT * | df | ||
) |
get output Data info from ResultHandle
ir | result data memory handle |
num_outputs | the number of output data |
outputNames | the array of all output data's name |
n | the array of all output data's n dimension |
c | the array of all output data's c dimension |
h | the array of all output data's h dimension |
w | the array of all output data's w dimension |
dt | the array of all output data's data type |
df | the array of all output data's data format |
Referenced by GetDataFormatString().
void PrepareModel | ( | ModelHandle | ih, |
const int | num_inputs, | ||
const char ** | name, | ||
const int * | n, | ||
const int * | c, | ||
const int * | h, | ||
const int * | w, | ||
const DATA_TYPE * | dt, | ||
const DATA_FORMAT * | df | ||
) |
complete model inference engine prepare
ih | model inference handle |
num_inputs | the number of input data |
name | the array of all input data's name in string format |
n | the array of all input data's n dimension |
c | the array of all input data's c dimension |
h | the array of all input data's h dimension |
w | the array of all input data's w dimension |
dt | the array of all input data's data type |
df | the array of all input data's data format |
Referenced by GetDataFormatString().
void ResizeModelInput | ( | ModelHandle | ih, |
int | num_inputs, | ||
const char ** | name, | ||
const int * | n, | ||
const int * | c, | ||
const int * | h, | ||
const int * | w, | ||
const DATA_TYPE * | dt, | ||
const DATA_FORMAT * | df | ||
) |
resize model input size
ih | model inference handle |
num_inputs | the number of input data |
name | the array of all input data's name in string format |
n | the array of all input data's n dimension |
c | the array of all input data's c dimension |
h | the array of all input data's h dimension |
w | the array of all input data's w dimension |
dt | the array of all input data's data type |
df | the array of all input data's data format |
Referenced by GetDataFormatString().
void RunModel | ( | ModelHandle | ih, |
ResultHandle | ir, | ||
int | num_inputs, | ||
const char ** | name, | ||
void ** | data | ||
) |
inference result from input
ih | inference pipeline handle |
ir | result data memory handle |
num_inputs | the number of input data |
name | the array of all input data's name |
data | the array of all input data |
Referenced by GetDataFormatString().
void SetNumThreads | ( | int | threads | ) |
set parallel threads num
threads | number of threads |
Referenced by GetDataFormatString().
void SetRuntimeDevice | ( | ModelHandle | ih, |
int | cpu_id, | ||
DEVICE_TYPE | device | ||
) |
set process to run on specified CPU core
ih | inference pipeline handle |
cpu_id | cpu core id(0, 1, 2...) |
device | cpu core architecture(ARM_A76) |
Referenced by GetDataFormatString().
void SetRuntimeDeviceDynamic | ( | ModelHandle | ih | ) |
set process cpu affinity according cpu average occupy
ih | inference pipeline handle |
Referenced by GetDataFormatString().