Skip to content

Commit 059448f

Browse files
initial working commit
1 parent 166658f commit 059448f

File tree

6 files changed

+22
-21
lines changed

6 files changed

+22
-21
lines changed

src/embedded_ml_sdk/classifiers/nnom_middleware/nnom_middleware.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ License along with SensiML Piccolo AI. If not, see <https://www.gnu.org/licenses
2525

2626
float results[NNOM_MAX_NUMBER_REULTS];
2727

28-
nnom_classifier_rows_t nnom_classifier_rows;
28+
nnom_classifier_rows_t *nnom_classifier_rows;
2929
float probability;
3030
int32_t label;
3131

@@ -77,15 +77,15 @@ uint8_t nnom_simple_submit(uint8_t classifier_id, feature_vector_t *feature_vect
7777
*/
7878
model_results->result = (float)label;
7979

80-
return float(label);
80+
return (float)label;
8181
}
8282

8383
void nnom_init(nnom_classifier_rows_t *classifier_table, const uint8_t num_classifiers)
8484
{
8585
model = nnom_model_create();
8686
nnom_classifier_rows = classifier_table;
87-
nnom_classifier_rows[0].model=model
88-
last_nnom_initialized=0
87+
nnom_classifier_rows[0].model=model;
88+
last_nnom_initialized=0;
8989

9090
}
9191

src/server/codegen/knowledgepack_codegen_mixin.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -264,13 +264,18 @@ def create_classifier_structures(self, classifier_types, kb_models):
264264
formated_classifier_types = [
265265
x.lower().replace(" ", "_") for x in classifier_types
266266
]
267+
268+
def is_neural_netwrok(classifier_type):
269+
return (classifier_type == "tensorflow_lite_for_microcontrollers" or classifier_type == 'neural_network')
267270

268271
formated_classifier_types = [
269-
x if x != "tensorflow_lite_for_microcontrollers" else "tf_micro"
272+
x if not is_neural_netwrok(x) else self.nn_inference_engine
270273
for x in formated_classifier_types
271274
]
275+
276+
272277

273-
logger.debug(
278+
logger.info(
274279
{
275280
"message": "CLASSIFIER TYPE INFORMATION",
276281
"data": formated_classifier_types,
@@ -349,8 +354,8 @@ def create_kb_classifier_headers(self, classifier_types):
349354
output.append('#include "bonsai_trained_models.h"')
350355

351356
if self.is_tensorflow(classifier_types):
352-
if self.nn_inference_engine == "nnom":
353-
output.append('#include "nnom.h"')
357+
if self.nn_inference_engine == "nnom":
358+
output.append('#include "nnom_trained_models.h"')
354359
output.append('#include "nnom_middleware.h"')
355360

356361
if self.nn_inference_engine == "tf_micro":
@@ -419,7 +424,7 @@ def create_kb_classifier_init(self, classifier_types):
419424

420425
if self.is_tensorflow(classifier_types):
421426
if self.nn_inference_engine == "nnom":
422-
output.append(c_line(1, "nnom_init(tf_micro_classifier_rows, 0);"))
427+
output.append(c_line(1, "nnom_init(nnom_classifier_rows, 0);"))
423428

424429
if self.nn_inference_engine == "tf_micro":
425430
output.append(c_line(1, "tf_micro_init(tf_micro_classifier_rows, 0);"))

src/server/codegen/model_gen/nnom.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ def create_classifier_structures(models):
113113

114114

115115
def create_max_tmp_parameters(kb_models):
116-
pass
116+
return []
117117

118118
def validate_model_parameters(data):
119119
pass

src/server/codegen/templates/compilers/x86gcc_generic/libsensiml/sml_profile_utils.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@ License along with SensiML Piccolo AI. If not, see <https://www.gnu.org/licenses
2727
#include <string.h>
2828
#include <time.h>
2929

30+
#ifdef __cplusplus // Only compile this when c++
31+
32+
3033
static struct timespec ts_end;
3134
static struct timespec ts_begin;
3235
static long total_time_ms;
@@ -66,4 +69,6 @@ float sml_profile_get_avg_iteration_time(uint32_t iterations)
6669
return (sml_profile_get_total_time())/(iterations * 1.0f);
6770
}
6871

72+
#endif
73+
6974
#endif // __SML_PROFILE_UTILS_H__
Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,4 @@
11

22
#include "nnom_trained_models.h"
33

4-
nnom_classifier_rows_t nnom_classifier_rows[1] = {
5-
{
6-
.num_inputs=9,
7-
.num_outputs=2,
8-
.threshold=0.5,
9-
.estimator_type=0,
10-
.model = null.
11-
12-
}
13-
}
4+
// FILL_NNOM_CLASSIFIER_STRUCTS

src/server/codegen/templates/trained_classifiers/nnom/nnom_trained_models.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ extern "C"
2727
{
2828
#endif
2929

30-
extern nnom_classifier_rows_t NNOMClassifierTable[];
30+
extern nnom_classifier_rows_t nnom_classifier_rows[];
3131

3232

3333
#ifdef __cplusplus

0 commit comments

Comments
 (0)