Skip to content

Commit e8a7b5d

Browse files
committed
SDK release 12 Aug 2024
1 parent 3b2f7cd commit e8a7b5d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

56 files changed

+3777
-467
lines changed

.DS_Store

8 KB
Binary file not shown.

CMSIS/.DS_Store

6 KB
Binary file not shown.

classifier/ei_classifier_config.h

-11
Original file line numberDiff line numberDiff line change
@@ -49,17 +49,6 @@
4949
#endif
5050
#endif // EI_CLASSIFIER_TFLITE_ENABLE_CMSIS_NN
5151

52-
// CMSIS-NN falls back to reference kernels when __ARM_FEATURE_DSP and __ARM_FEATURE_MVE are not defined
53-
// we should never use those... So disable CMSIS-NN in that case and throw a warning
54-
#if EI_CLASSIFIER_TFLITE_ENABLE_CMSIS_NN == 1
55-
#if !defined(__ARM_FEATURE_DSP) && !defined(__ARM_FEATURE_MVE)
56-
#pragma message( \
57-
"CMSIS-NN enabled, but neither __ARM_FEATURE_DSP nor __ARM_FEATURE_MVE defined. Falling back.")
58-
#undef EI_CLASSIFIER_TFLITE_ENABLE_CMSIS_NN
59-
#define EI_CLASSIFIER_TFLITE_ENABLE_CMSIS_NN 0
60-
#endif
61-
#endif // EI_CLASSIFIER_TFLITE_ENABLE_CMSIS_NN == 1
62-
6352
#if EI_CLASSIFIER_TFLITE_ENABLE_CMSIS_NN == 1
6453
#define CMSIS_NN 1
6554
#define EI_CLASSIFIER_TFLITE_LOAD_CMSIS_NN_SOURCES 1

classifier/ei_classifier_types.h

+41-36
Original file line numberDiff line numberDiff line change
@@ -28,32 +28,32 @@
2828

2929
/**
3030
* @defgroup ei_structs Structs
31-
*
31+
*
3232
* Public-facing structs for Edge Impulse C++ SDK.
33-
*
33+
*
3434
* @addtogroup ei_structs
3535
* @{
3636
*/
3737

3838
/**
3939
* @brief Holds the output of inference, anomaly results, and timing information.
40-
*
40+
*
4141
* `ei_impulse_result_t` holds the output of `run_classifier()`. If object detection is
4242
* enabled, then the output results is a
4343
* pointer to an array of bounding boxes of size `bounding_boxes_count`, as given by
4444
* [ei_impulse_result_bounding_box_t](https://docs.edgeimpulse.com/reference/ei_impulse_result_bounding_box_t).
4545
* Otherwise, results are stored as an array of classification scores, as given by
4646
* [ei_impulse_result_classification_t](https://docs.edgeimpulse.com/reference/ei_impulse_result_classification_t).
47-
*
47+
*
4848
* If anomaly detection is enabled (e.g. `EI_CLASSIFIER_HAS_ANOMALY == 1`), then the
4949
* anomaly score will be stored as a floating point value in `anomaly`.
50-
*
51-
* Timing information is stored in an
50+
*
51+
* Timing information is stored in an
5252
* [ei_impulse_result_timing_t](https://docs.edgeimpulse.com/reference/ei_impulse_result_timing_t)
5353
* struct.
54-
*
54+
*
5555
* **Source**: [classifier/ei_classifier_types.h](https://github.com/edgeimpulse/inferencing-sdk-cpp/blob/master/classifier/ei_classifier_types.h)
56-
*
56+
*
5757
* **Example**: [standalone inferencing main.cpp](https://github.com/edgeimpulse/example-standalone-inferencing/blob/master/source/main.cpp)
5858
*/
5959
typedef struct {
@@ -70,16 +70,16 @@ typedef struct {
7070

7171
/**
7272
* @brief Holds the output of visual anomaly detection (FOMO-AD)
73-
*
73+
*
7474
* If visual anomaly detection is enabled (e.g. `EI_CLASSIFIER_HAS_VISUAL_ANOMALY ==
75-
* 1`), then the output results will be a pointer to an array of grid cells of size
76-
* `visual_ad_count`, as given by
75+
* 1`), then the output results will be a pointer to an array of grid cells of size
76+
* `visual_ad_count`, as given by
7777
* [ei_impulse_result_bounding_box_t](https://docs.edgeimpulse.com/reference/ei_impulse_result_bounding_box_t).
78-
*
78+
*
7979
* The visual anomaly detection result is stored in `visual_ad_result`, which contains the mean and max values of the grid cells.
80-
*
80+
*
8181
* **Source**: [classifier/ei_classifier_types.h](https://github.com/edgeimpulse/inferencing-sdk-cpp/blob/master/classifier/ei_classifier_types.h)
82-
*
82+
*
8383
* **Example**: [standalone inferencing main.cpp](https://github.com/edgeimpulse/example-standalone-inferencing/blob/master/source/main.cpp)
8484
*/
8585
typedef struct {
@@ -96,7 +96,7 @@ typedef struct {
9696

9797
/**
9898
* @brief Holds information for a single bounding box.
99-
*
99+
*
100100
* If object detection is enabled (i.e. `EI_CLASSIFIER_OBJECT_DETECTION == 1`), then
101101
* inference results will be one or more bounding boxes. The bounding boxes with the
102102
* highest confidence scores (assuming those scores are equal to or greater than
@@ -105,20 +105,20 @@ typedef struct {
105105
* least `EI_CLASSIFIER_OBJECT_DETECTION_COUNT`. The exact number of bounding boxes
106106
* is stored in `bounding_boxes_count` field of [ei_impulse_result_t]/C++ Inference
107107
* SDK Library/structs/ei_impulse_result_t.md).
108-
*
109-
* A bounding box is a rectangle that ideally surrounds the identified object. The
108+
*
109+
* A bounding box is a rectangle that ideally surrounds the identified object. The
110110
* (`x`, `y`) coordinates in the struct identify the top-left corner of the box.
111111
* `label` is the predicted class with the highest confidence score. `value` is the
112112
* confidence score between [0.0..1.0] of the given `label`.
113-
*
113+
*
114114
* **Source**: [classifier/ei_classifier_types.h](https://github.com/edgeimpulse/inferencing-sdk-cpp/blob/master/classifier/ei_classifier_types.h)
115-
*
115+
*
116116
* **Example**: [standalone inferencing main.cpp](https://github.com/edgeimpulse/example-standalone-inferencing/blob/master/source/main.cpp)
117117
*/
118118
typedef struct {
119119
/**
120-
* Pointer to a character array describing the associated class of the given
121-
* bounding box. Taken from one of the elements of
120+
* Pointer to a character array describing the associated class of the given
121+
* bounding box. Taken from one of the elements of
122122
* `ei_classifier_inferencing_categories[]`.
123123
*/
124124
const char *label;
@@ -151,19 +151,19 @@ typedef struct {
151151

152152
/**
153153
* @brief Holds timing information about the processing (DSP) and inference blocks.
154-
*
154+
*
155155
* Records timing information during the execution of the preprocessing (DSP) and
156156
* inference blocks. Can be used to determine if inference will meet timing requirements
157157
* on your particular platform.
158-
*
158+
*
159159
* **Source**: [classifier/ei_classifier_types.h](https://github.com/edgeimpulse/inferencing-sdk-cpp/blob/master/classifier/ei_classifier_types.h)
160-
*
160+
*
161161
* **Example**: [standalone inferencing main.cpp](https://github.com/edgeimpulse/example-standalone-inferencing/blob/master/source/main.cpp)
162162
*/
163163
typedef struct {
164164
/**
165165
* If using `run_impulse()` to perform sampling and inference, it is the amount of
166-
* time (in milliseconds) it took to fetch raw samples. Not used for
166+
* time (in milliseconds) it took to fetch raw samples. Not used for
167167
* `run_classifier()`.
168168
*/
169169
int sampling;
@@ -185,12 +185,12 @@ typedef struct {
185185
int anomaly;
186186

187187
/**
188-
* Amount of time (in milliseconds) it took to run the post-processing block
188+
* Amount of time (in microseconds) it took to run the post-processing block
189189
*/
190190
int64_t dsp_us;
191191

192192
/**
193-
* Amount of time (in milliseconds) it took to run the inference block
193+
* Amount of time (in microseconds) it took to run the inference block
194194
*/
195195
int64_t classification_us;
196196

@@ -203,23 +203,23 @@ typedef struct {
203203

204204
/**
205205
* @brief Holds the output of inference, anomaly results, and timing information.
206-
*
206+
*
207207
* `ei_impulse_result_t` holds the output of `run_classifier()`. If object detection is
208208
* enabled (e.g. `EI_CLASSIFIER_OBJECT_DETECTION == 1`), then the output results is a
209209
* pointer to an array of bounding boxes of size `bounding_boxes_count`, as given by
210-
* [ei_impulse_result_bounding_box_t](https://docs.edgeimpulse.com/reference/ei_impulse_result_bounding_box_t).
210+
* [ei_impulse_result_bounding_box_t](https://docs.edgeimpulse.com/reference/ei_impulse_result_bounding_box_t).
211211
* Otherwise, results are stored as an array of classification scores, as given by
212212
* [ei_impulse_result_classification_t](https://docs.edgeimpulse.com/reference/ei_impulse_result_classification_t).
213-
*
213+
*
214214
* If anomaly detection is enabled (e.g. `EI_CLASSIFIER_HAS_ANOMALY == 1`), then the
215215
* anomaly score will be stored as a floating point value in `anomaly`.
216-
*
217-
* Timing information is stored in an
218-
* [ei_impulse_result_timing_t](https://docs.edgeimpulse.com/reference/ei_impulse_result_timing_t)
216+
*
217+
* Timing information is stored in an
218+
* [ei_impulse_result_timing_t](https://docs.edgeimpulse.com/reference/ei_impulse_result_timing_t)
219219
* struct.
220-
*
220+
*
221221
* **Source**: [classifier/ei_classifier_types.h](https://github.com/edgeimpulse/inferencing-sdk-cpp/blob/master/classifier/ei_classifier_types.h)
222-
*
222+
*
223223
* **Example**: [standalone inferencing main.cpp](https://github.com/edgeimpulse/example-standalone-inferencing/blob/master/source/main.cpp)
224224
*/
225225
typedef struct {
@@ -238,13 +238,18 @@ typedef struct {
238238
* Array of classification results. If object detection is enabled, this will be
239239
* empty.
240240
*/
241+
#ifdef EI_DSP_RESULT_OVERRIDE
242+
// For CI only. We will create the array to hold results
243+
ei_impulse_result_classification_t* classification;
244+
#else
241245
#if EI_CLASSIFIER_LABEL_COUNT == 0
242246
// EI_CLASSIFIER_LABEL_COUNT can be 0 for anomaly only models
243247
// to prevent compiler warnings/errors, we need to have at least one element
244248
ei_impulse_result_classification_t classification[1];
245249
#else
246250
ei_impulse_result_classification_t classification[EI_CLASSIFIER_LABEL_COUNT];
247-
#endif
251+
#endif // EI_CLASSIFIER_LABEL_COUNT == 0
252+
#endif // EI_DSP_RESULT_OVERRIDE else
248253

249254
/**
250255
* Anomaly score. If anomaly detection is not enabled, this will be 0. A higher

classifier/ei_fill_result_struct.h

+10-1
Original file line numberDiff line numberDiff line change
@@ -374,15 +374,24 @@ __attribute__((unused)) static EI_IMPULSE_ERROR fill_result_struct_f32(const ei_
374374
ei_impulse_result_t *result,
375375
float *data,
376376
bool debug) {
377-
for (uint32_t ix = 0; ix < impulse->label_count; ix++) {
377+
#ifdef EI_DSP_RESULT_OVERRIDE
378+
uint32_t stop_count = EI_DSP_RESULT_OVERRIDE;
379+
#else
380+
uint32_t stop_count = impulse->label_count;
381+
#endif
382+
for (uint32_t ix = 0; ix < stop_count; ix++) {
383+
378384
float value = data[ix];
379385

380386
if (debug) {
381387
ei_printf("%s:\t", impulse->categories[ix]);
382388
ei_printf_float(value);
383389
ei_printf("\n");
384390
}
391+
// For testing purposes, we will have more values than labels
392+
#ifndef EI_DSP_RESULT_OVERRIDE
385393
result->classification[ix].label = impulse->categories[ix];
394+
#endif
386395
result->classification[ix].value = value;
387396
}
388397

classifier/ei_model_types.h

+27-9
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
#define EI_CLASSIFIER_SYNTIANT 10
4343
#define EI_CLASSIFIER_ONNX_TIDL 11
4444
#define EI_CLASSIFIER_MEMRYX 12
45+
#define EI_CLASSIFIER_ETHOS_LINUX 13
4546

4647
#define EI_CLASSIFIER_SENSOR_UNKNOWN -1
4748
#define EI_CLASSIFIER_SENSOR_MICROPHONE 1
@@ -108,7 +109,7 @@ typedef struct {
108109
extract_fn_t extract_fn;
109110
void *config;
110111
uint8_t *axes;
111-
size_t axes_size;
112+
uint8_t axes_size;
112113
int version; // future proof, can easily add to this struct now
113114
DspHandle* (*factory)(void* config, float sampling_freq); // nullptr means no state
114115
// v1 ends here
@@ -126,7 +127,7 @@ typedef struct {
126127
void *config;
127128
int image_scaling;
128129
const uint32_t* input_block_ids;
129-
const uint32_t input_block_ids_size;
130+
const uint8_t input_block_ids_size;
130131
uint32_t output_features_count;
131132
} ei_learning_block_t;
132133

@@ -149,6 +150,21 @@ typedef struct {
149150
size_t arena_size;
150151
} ei_config_tflite_graph_t;
151152

153+
typedef struct {
154+
uint16_t implementation_version;
155+
uint8_t input_datatype;
156+
bool input_quantized;
157+
float input_scale;
158+
float input_zeropoint;
159+
uint8_t output_datatype;
160+
bool output_quantized;
161+
float output_scale;
162+
float output_zeropoint;
163+
const unsigned char *model;
164+
size_t model_size;
165+
size_t arena_size;
166+
} ei_config_ethos_graph_t;
167+
152168
typedef struct {
153169
uint16_t implementation_version;
154170
TfLiteStatus (*model_init)(void*(*alloc_fnc)(size_t, size_t));
@@ -208,7 +224,9 @@ typedef struct ei_impulse {
208224
uint32_t project_id;
209225
const char *project_owner;
210226
const char *project_name;
211-
uint32_t deploy_version;
227+
uint16_t impulse_id;
228+
const char *impulse_name;
229+
uint16_t deploy_version;
212230

213231
/* DSP details */
214232
uint32_t nn_input_frame_size;
@@ -220,7 +238,7 @@ typedef struct ei_impulse {
220238
uint32_t input_frames;
221239
float interval_ms;
222240
float frequency;
223-
size_t dsp_blocks_size;
241+
uint8_t dsp_blocks_size;
224242
ei_model_dsp_t *dsp_blocks;
225243

226244
/* object detection */
@@ -229,20 +247,20 @@ typedef struct ei_impulse {
229247
uint32_t tflite_output_features_count;
230248

231249
/* learning blocks */
232-
const size_t learning_blocks_size;
250+
const uint8_t learning_blocks_size;
233251
const ei_learning_block_t *learning_blocks;
234252

235253
/* inference parameters */
236-
uint32_t inferencing_engine;
254+
uint8_t inferencing_engine;
237255

238256
/* sensors and on-device inference */
239-
uint32_t sensor;
257+
uint8_t sensor;
240258
const char *fusion_string;
241259
uint32_t slice_size;
242-
uint32_t slices_per_model_window;
260+
uint8_t slices_per_model_window;
243261

244262
/* output details */
245-
uint16_t has_anomaly;
263+
uint8_t has_anomaly;
246264
uint16_t label_count;
247265
const ei_model_performance_calibration_t calibration;
248266
const char **categories;

0 commit comments

Comments
 (0)