43 #ifndef __CY_ML_INFERENCE_H 44 #define __CY_ML_INFERENCE_H 58 #if defined(COMPONENT_ML_FLOAT32) 59 typedef float CY_ML_DATA_TYPE_T;
60 #elif defined(COMPONENT_ML_INT16x16) || defined(COMPONENT_ML_INT16x8) 61 typedef int16_t CY_ML_DATA_TYPE_T;
62 #elif defined(COMPONENT_ML_INT8x8) 63 typedef int8_t CY_ML_DATA_TYPE_T;
65 #error Unsupported data type 71 #define CY_ML_INFERENCE_VERSION_MAJOR 2 72 #define CY_ML_INFERENCE_VERSION_MINOR 0 73 #define CY_ML_INFERENCE_VERSION_PATCH 0 74 #define CY_ML_INFERENCE_VERSION 200 76 #define CY_ML_SUCCESS (0) 78 #define CY_ML_LINE_SHIFT (16u) 79 #define CY_ML_LINE_MASK (0xFFFF0000) 81 #define CY_ML_LAYER_ID_SHIFT (8u) 82 #define CY_ML_LAYER_ID_MASK (0x0000FF00) 83 #define CY_ML_LAYER_ID_INVALID (255u) 85 #define CY_ML_ERR_CODE_MASK (0x000000FF) 86 #define CY_ML_ERR_CORE_TOOL_VERSION (0x01) 87 #define CY_ML_ERR_EXCEED_MAX_SCRATCH_MEM (0x02) 88 #define CY_ML_ERR_LAYER_NOT_SUPPORTED (0x03) 89 #define CY_ML_ERR_ACT_NOT_SUPPORTED (0x04) 90 #define CY_ML_ERR_INPUT_DIMENTION (0x05) 91 #define CY_ML_ERR_CONNECTION (0x06) 92 #define CY_ML_ERR_OTHER_INPUT_MISSING (0x07) 93 #define CY_ML_ERR_INVALID_ARGUMENT (0x08) 94 #define CY_ML_ERR_MISMATCH_DATA_TYPE (0x09) 95 #define CY_ML_ERR_MISMATCH_PARM_CHECKSUM (0x0A) 96 #define CY_ML_ERR_INVALID_SCRATCH_MEM_OPT (0x0B) 98 #define CY_ML_ERROR(x, y) ((__LINE__ << CY_ML_LINE_SHIFT) | \ 99 (((x) << CY_ML_LAYER_ID_SHIFT) & CY_ML_LAYER_ID_MASK) | \ 100 ((y) & CY_ML_ERR_CODE_MASK)) 101 #define CY_ML_ERR_CODE(x) (uint8_t)((x) & CY_ML_ERR_CODE_MASK) 102 #define CY_ML_ERR_LAYER_INDEX(x) (uint8_t)(((x) & CY_ML_LAYER_ID_MASK) >> CY_ML_LAYER_ID_SHIFT) 103 #define CY_ML_ERR_LINE_NUMBER(x) (uint16_t)(((x) & CY_ML_LINE_MASK) >> CY_ML_LINE_SHIFT) 105 #define CY_ML_PROFILE_FRAME (0x01) 106 #define CY_ML_PROFILE_LAYER (0x02) 107 #define CY_ML_PROFILE_MODEL (0x04) 108 #define CY_ML_LOG_MODEL_OUTPUT (0x10) 110 #define CY_ML_MODEL_OBJECT_SIZE (360) 111 #define CY_ML_RES_CONN_OBJECT_SIZE (8) 112 #if defined(COMPONENT_ML_FLOAT32) 113 #define CY_ML_LAYER_OBJECT_SIZE (80) 115 #define CY_ML_LAYER_OBJECT_SIZE (88) 123 CY_ML_DATA_UNKNOWN = 0u,
124 CY_ML_DATA_INT8 = 1u,
125 CY_ML_DATA_INT16 = 2u,
126 CY_ML_DATA_FLOAT = 3u,
127 } cy_en_ml_data_type_t;
132 CY_ML_PROFILE_DISABLE = 0,
133 CY_ML_PROFILE_ENABLE_MODEL = CY_ML_PROFILE_MODEL,
134 CY_ML_PROFILE_ENABLE_LAYER = CY_ML_PROFILE_LAYER,
135 CY_ML_PROFILE_ENABLE_MODEL_PER_FRAME = (CY_ML_PROFILE_MODEL | CY_ML_PROFILE_FRAME),
136 CY_ML_PROFILE_ENABLE_LAYER_PER_FRAME = (CY_ML_PROFILE_LAYER | CY_ML_PROFILE_FRAME),
137 CY_ML_LOG_ENABLE_MODEL_LOG = CY_ML_LOG_MODEL_OUTPUT
138 } cy_en_ml_profile_config_t;
164 typedef int (*cy_ml_cb_fun) (
void* arg,
char* buf, cy_en_ml_profile_config_t type);
248 ,
char *fn_prms,
char *fn_ptr
296 int Cy_ML_Profile_Init(
void *modelPt, cy_en_ml_profile_config_t config, cy_ml_cb_fun cb_func,
void *cb_arg);
int Cy_ML_Profile_Print(void *modelPt)
: Print profile log.
int libml_version
Definition: cy_ml_inference.h:153
cy_en_ml_data_type_t libml_input_type
Definition: cy_ml_inference.h:155
int num_of_res_conns
Definition: cy_ml_inference.h:151
int Cy_ML_Profile_Control(void *modelPt, cy_en_ml_profile_config_t config)
: Update profile configuration.
int Cy_ML_Profile_Get_Tsc(uint32_t *val)
: Cy_ML_Profile_Get_Tsc() is an API function to read time stamp counter (TSC) .
uint32_t ml_coretool_version
Definition: cy_ml_inference.h:154
int Cy_ML_Model_Inference(void *modelPt, void *input, void *output, int *in_out_q)
: Cy_ML_Model_Inference() is the API function to perform NN inference.
int Cy_ML_Profile_Init(void *modelPt, cy_en_ml_profile_config_t config, cy_ml_cb_fun cb_func, void *cb_arg)
: Initialize profile configuration.
int scratch_mem
Definition: cy_ml_inference.h:147
Definition: cy_ml_inference.h:143
int input_size
Definition: cy_ml_inference.h:149
int Cy_ML_Rnn_State_Control(void *modelPt, int rnn_status, int window_size)
: Cy_ML_Rnn_State_Control() is the API function to rest recurrent NN state, inference engine will res...
int persistent_mem
Definition: cy_ml_inference.h:148
cy_en_ml_data_type_t libml_weight_type
Definition: cy_ml_inference.h:156
int output_size
Definition: cy_ml_inference.h:146
int Cy_ML_Model_Parse(char *fn_prms, cy_stc_ml_model_info_t *mdl_infoPt)
: Cy_ML_Model_Parse() is the API function to parse NN model parameters to get basic info...
int num_of_layers
Definition: cy_ml_inference.h:150
int Cy_ML_Model_Init(void **dPt_container, char *fn_prms, char *fn_ptr, char *persistent_mem, char *scratch_mem, cy_stc_ml_model_info_t *mdl_infoPt)
: Cy_ML_Model_Init() is the API function to parse NN model and initialize CY data container before st...
int recurrent_ts_size
Definition: cy_ml_inference.h:152