Skip to content

Commit

Permalink
fixup! tests/pkg/emlearn: add model.h to repo
Browse files Browse the repository at this point in the history
  • Loading branch information
maribu committed Aug 28, 2024
1 parent 70b2de5 commit 7552343
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 17 deletions.
3 changes: 3 additions & 0 deletions tests/pkg/emlearn/.gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
tmp/
/model_head.h
/model_tail.h
/tmp.h
19 changes: 17 additions & 2 deletions tests/pkg/emlearn/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,21 @@ BUILDDEPS += model.h

include $(RIOTBASE)/Makefile.include

model.h: $(CURDIR)/model
model_head.h:
$(Q)echo "#ifndef MODEL_H" > model_head.h
$(Q)echo "#define MODEL_H" >> model_head.h
$(Q)echo "#ifdef __cplusplus" >> model_head.h
$(Q)echo "extern \"C\" {" >> model_head.h
$(Q)echo "#endif" >> model_head.h

model_tail.h:
$(Q)echo "#ifdef __cplusplus" > model_tail.h
$(Q)echo "}" >> model_tail.h
$(Q)echo "#endif" >> model_tail.h
$(Q)echo "#endif /* MODEL_H */" >> model_tail.h

model.h: $(CURDIR)/model model_head.h model_tail.h
$(Q)$(CURDIR)/generate_model.py
$(Q)echo "/* fix for no newline at eof */" >> model.h
$(Q)sed -i model.h -e 's/[\t ]*$$//g'
$(Q)cat model_head.h model.h model_tail.h > tmp.h
$(Q)mv tmp.h model.h
38 changes: 23 additions & 15 deletions tests/pkg/emlearn/model.h
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
#ifndef MODEL_H

Check warning on line 1 in tests/pkg/emlearn/model.h

View workflow job for this annotation

GitHub Actions / static-tests

no copyright notice found
#define MODEL_H
#ifdef __cplusplus
extern "C" {
#endif

// !!! This file is generated using emlearn !!!

#include <eml_trees.h>


Check warning on line 11 in tests/pkg/emlearn/model.h

View workflow job for this annotation

GitHub Actions / static-tests

too many consecutive empty lines
EmlTreesNode model_nodes[1433] = {
{ 34, 3.5, 1, 79 },
Expand Down Expand Up @@ -1437,14 +1442,14 @@ EmlTreesNode model_nodes[1433] = {
{ 19, 2.5, 25, 1430 },
{ 10, 12.0, 31, 25 },
{ 37, 11.5, 31, 27 },
{ 17, 6.0, 119, 27 }
{ 17, 6.0, 119, 27 }
};

int32_t model_tree_roots[10] = { 0, 168, 304, 448, 589, 719, 866, 1001, 1152, 1307 };

EmlTrees model = {
1433,
model_nodes,
model_nodes,
10,
model_tree_roots,
};
Expand Down Expand Up @@ -2084,7 +2089,7 @@ static inline int32_t model_predict_tree_0(const float *features, int32_t featur
}
}
}


Check warning on line 2093 in tests/pkg/emlearn/model.h

View workflow job for this annotation

GitHub Actions / static-tests

too many consecutive empty lines
static inline int32_t model_predict_tree_1(const float *features, int32_t features_length) {
if (features[42] < 7.5) {
Expand Down Expand Up @@ -2633,7 +2638,7 @@ static inline int32_t model_predict_tree_1(const float *features, int32_t featur
}
}
}


Check warning on line 2642 in tests/pkg/emlearn/model.h

View workflow job for this annotation

GitHub Actions / static-tests

too many consecutive empty lines
static inline int32_t model_predict_tree_2(const float *features, int32_t features_length) {
if (features[10] < 7.5) {
Expand Down Expand Up @@ -3214,7 +3219,7 @@ static inline int32_t model_predict_tree_2(const float *features, int32_t featur
}
}
}


Check warning on line 3223 in tests/pkg/emlearn/model.h

View workflow job for this annotation

GitHub Actions / static-tests

too many consecutive empty lines
static inline int32_t model_predict_tree_3(const float *features, int32_t features_length) {
if (features[30] < 1.5) {
Expand Down Expand Up @@ -3783,7 +3788,7 @@ static inline int32_t model_predict_tree_3(const float *features, int32_t featur
}
}
}


Check warning on line 3792 in tests/pkg/emlearn/model.h

View workflow job for this annotation

GitHub Actions / static-tests

too many consecutive empty lines
static inline int32_t model_predict_tree_4(const float *features, int32_t features_length) {
if (features[36] < 0.5) {
Expand Down Expand Up @@ -4308,7 +4313,7 @@ static inline int32_t model_predict_tree_4(const float *features, int32_t featur
}
}
}


Check warning on line 4317 in tests/pkg/emlearn/model.h

View workflow job for this annotation

GitHub Actions / static-tests

too many consecutive empty lines
static inline int32_t model_predict_tree_5(const float *features, int32_t features_length) {
if (features[30] < 0.5) {
Expand Down Expand Up @@ -4901,7 +4906,7 @@ static inline int32_t model_predict_tree_5(const float *features, int32_t featur
}
}
}


Check warning on line 4910 in tests/pkg/emlearn/model.h

View workflow job for this annotation

GitHub Actions / static-tests

too many consecutive empty lines
static inline int32_t model_predict_tree_6(const float *features, int32_t features_length) {
if (features[21] < 0.5) {
Expand Down Expand Up @@ -5446,7 +5451,7 @@ static inline int32_t model_predict_tree_6(const float *features, int32_t featur
}
}
}


Check warning on line 5455 in tests/pkg/emlearn/model.h

View workflow job for this annotation

GitHub Actions / static-tests

too many consecutive empty lines
static inline int32_t model_predict_tree_7(const float *features, int32_t features_length) {
if (features[41] < 0.5) {
Expand Down Expand Up @@ -6055,7 +6060,7 @@ static inline int32_t model_predict_tree_7(const float *features, int32_t featur
}
}
}


Check warning on line 6064 in tests/pkg/emlearn/model.h

View workflow job for this annotation

GitHub Actions / static-tests

too many consecutive empty lines
static inline int32_t model_predict_tree_8(const float *features, int32_t features_length) {
if (features[58] < 5.5) {
Expand Down Expand Up @@ -6680,7 +6685,7 @@ static inline int32_t model_predict_tree_8(const float *features, int32_t featur
}
}
}


static inline int32_t model_predict_tree_9(const float *features, int32_t features_length) {
if (features[34] < 3.5) {
Expand Down Expand Up @@ -7189,7 +7194,7 @@ static inline int32_t model_predict_tree_9(const float *features, int32_t featur
}
}
}


int32_t model_predict(const float *features, int32_t features_length) {

Expand All @@ -7206,7 +7211,7 @@ int32_t model_predict(const float *features, int32_t features_length) {
_class = model_predict_tree_7(features, features_length); votes[_class] += 1;
_class = model_predict_tree_8(features, features_length); votes[_class] += 1;
_class = model_predict_tree_9(features, features_length); votes[_class] += 1;

int32_t most_voted_class = -1;
int32_t most_voted_votes = 0;
for (int32_t i=0; i<10; i++) {
Expand All @@ -7218,4 +7223,7 @@ int32_t model_predict(const float *features, int32_t features_length) {
}
return most_voted_class;
}
/* fix for no newline at eof */
#ifdef __cplusplus
}
#endif
#endif /* MODEL_H */

0 comments on commit 7552343

Please sign in to comment.