ML Middleware
ModusToolbox Machine Learning Middleware Library
All Data Structures Functions Variables Modules
Model_API

Functions

cy_rslt_t mtb_ml_model_init (const mtb_ml_model_bin_t *bin, const mtb_ml_model_buffer_t *buffer, mtb_ml_model_t **object)
 : Allocate and initialize NN model runtime object based on model data. Only intended to be called once. More...
 
cy_rslt_t mtb_ml_model_deinit (mtb_ml_model_t *object)
 : Delete NN model runtime object and free all dynamically allocated memory. Only intended to be called once. More...
 
cy_rslt_t mtb_ml_model_run (mtb_ml_model_t *object, MTB_ML_DATA_T *input)
 : Perform NN model inference More...
 
int mtb_ml_model_get_input_size (const mtb_ml_model_t *object)
 : Get NN model input data size More...
 
cy_rslt_t mtb_ml_model_get_output (const mtb_ml_model_t *object, MTB_ML_DATA_T **out_pptr, int *size_ptr)
 : Get NN model output buffer and size More...
 
cy_rslt_t mtb_ml_model_rnn_reset_all_parameters (mtb_ml_model_t *object)
 : Reset model parameters More...
 
void * mtb_ml_model_get_inference_object (const mtb_ml_model_t *object)
 : Get MTB ML inference runtime object More...
 
int mtb_ml_model_profile_get_tsc (uint64_t *val)
 : Read time stamp counter (TSC) . More...
 
cy_rslt_t mtb_ml_model_profile_config (mtb_ml_model_t *object, mtb_ml_profile_config_t config)
 : Update MTB ML inference profiling setting More...
 
cy_rslt_t mtb_ml_model_profile_log (mtb_ml_model_t *object)
 : Generate MTB ML profiling log More...
 

Detailed Description

Function Documentation

◆ mtb_ml_model_deinit()

cy_rslt_t mtb_ml_model_deinit ( mtb_ml_model_t object)

: Delete NN model runtime object and free all dynamically allocated memory. Only intended to be called once.

Parameters
[in]object: Pointer of model object.
Returns
: MTB_ML_RESULT_SUCCESS - success : MTB_ML_RESULT_BAD_ARG - if input parameter is invalid.

◆ mtb_ml_model_get_inference_object()

void* mtb_ml_model_get_inference_object ( const mtb_ml_model_t object)

: Get MTB ML inference runtime object

Parameters
[in]object: Pointer of model object.
Returns
: Pointer of inference object : NULL - if input parameter is invalid.

◆ mtb_ml_model_get_input_size()

int mtb_ml_model_get_input_size ( const mtb_ml_model_t object)

: Get NN model input data size

Parameters
[in]object: Pointer of model object.
Returns
: Input data size : 0 - if input parameter is invalid.

◆ mtb_ml_model_get_output()

cy_rslt_t mtb_ml_model_get_output ( const mtb_ml_model_t object,
MTB_ML_DATA_T **  out_pptr,
int *  size_ptr 
)

: Get NN model output buffer and size

Parameters
[in]object: Pointer of model object.
[out]out_pptr: Pointer of output buffer pointer
[out]size_ptr: Pointer of output size
Returns
: Output data size : 0 - if input parameter is invalid.

◆ mtb_ml_model_init()

cy_rslt_t mtb_ml_model_init ( const mtb_ml_model_bin_t bin,
const mtb_ml_model_buffer_t buffer,
mtb_ml_model_t **  object 
)

: Allocate and initialize NN model runtime object based on model data. Only intended to be called once.

Parameters
[in]bin: Pointer of model binary data.
[in]buffer: Pointer of buffer data structure for statically allocated persistent and scratch buffer. This is optional, if no passed-in buffer, the API will allocate memory as persistent and scratch buffer.
[out]object: Pointer of model object.
Returns
: MTB_ML_RESULT_SUCCESS - success : MTB_ML_RESULT_BAD_ARG - if input parameter is invalid. : MTB_ML_RESULT_ALLOC_ERR - if memory allocation failure. : MTB_ML_RESULT_BAD_MODEL - if model parsing or initialization error.

◆ mtb_ml_model_profile_config()

cy_rslt_t mtb_ml_model_profile_config ( mtb_ml_model_t object,
mtb_ml_profile_config_t  config 
)

: Update MTB ML inference profiling setting

Parameters
[in]object: Pointer of model object's pointer.
[in]config: Profiling setting
Returns
: MTB_ML_RESULT_SUCCESS - success : MTB_ML_RESULT_BAD_ARG - if input parameter is invalid.

◆ mtb_ml_model_profile_get_tsc()

int mtb_ml_model_profile_get_tsc ( uint64_t *  val)

: Read time stamp counter (TSC) .

Platform specific function to read HW time stamp counter or OS tick timer counter for profiling. The application program developer should provide this function if profiling is enabled.

Parameters
[out]val: Pointer to time stamp counter return value
Returns
: Return 0 when success, otherwise return error code

◆ mtb_ml_model_profile_log()

cy_rslt_t mtb_ml_model_profile_log ( mtb_ml_model_t object)

: Generate MTB ML profiling log

Parameters
[in]object: Pointer of model object.
Returns
: MTB_ML_RESULT_SUCCESS - success : MTB_ML_RESULT_BAD_ARG - if input parameter is invalid.

◆ mtb_ml_model_rnn_reset_all_parameters()

cy_rslt_t mtb_ml_model_rnn_reset_all_parameters ( mtb_ml_model_t object)

: Reset model parameters

Parameters
[in]object: Pointer of model object.
Returns
: MTB_ML_RESULT_SUCCESS - success : MTB_ML_RESULT_BAD_ARG - if input parameter is invalid.

◆ mtb_ml_model_run()

cy_rslt_t mtb_ml_model_run ( mtb_ml_model_t object,
MTB_ML_DATA_T *  input 
)

: Perform NN model inference

Parameters
[in]object: Pointer of model object.
[in]input: Pointer of input data buffer
Returns
: MTB_ML_RESULT_SUCCESS - success : MTB_ML_RESULT_BAD_ARG - if input parameter is invalid. : MTB_ML_RESULT_INFERENCE_ERROR - if inference failure