API
The ElcoreNN API consists of the following parts:
elcorenn/elcorenn.h
: ElcoreNN CPU library API.
ElcoreNN CPU library API
elcorenn/elcorenn.h
defines the ElcoreNN CPU library API functions.
-
void InitBackend()
Initializes internal DSPs resources.
-
void ReleaseDevice()
Releases internal DSPs resources.
-
typedef unsigned int ENNModelId
Model ID.
ENNModelId
is a model descriptor.
That descriptor refers to the model loaded into DSP (Elcore50) memory.
Use LoadModel function to easily load model into DSP memory.
-
ENNModelId LoadModel(const char *model_json, const char *model_weights)
Loads model from files.
- Parameters
model_json – [in] The description of the model saved in json format
model_weights – [in] The binary file of model’s weights
- Returns
Model ID
-
void InvokeModel(ENNModelId model_id, float *input_data, float *output_data, uint32_t batch_size)
Runs model inference.
- Parameters
model_id – [in] Model ID
input_data – [in] Input data
output_data – [out] Output data
batch_size – [in] Batch size dimension in input data
The function takes model input as a float array and puts network’s result into a float array.
Note
ElcoreNN uses the data parallelization paradigm. Input data distributes between DSP cores by batch dimension.
-
void SaveModelStatisticToCSV(ENNModelId model_id, const char *file_path)
Saves model time statistic to a CSV file.
- Parameters
model_id – [in] Model ID
file_path – [in] Path to CSV file
During inference, ElcoreNN collects number of cores cycles instructions for each layer. This can be useful for performance analysis.