Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pkg/tflite-micro: Update tflite-micro to latest version. requires update of pkg/flatbuffers as well. #20683

Merged
merged 8 commits into from
May 27, 2024

Conversation

FlapKap
Copy link
Contributor

@FlapKap FlapKap commented May 22, 2024

Contribution description

This PR updates tflite-micro to the the latest version. Since the current version in Riot OS is quite old, this has mandated some other changes and updates:
The included flatbuffers pkg and dist/tools have been updated to v23.5.26 as thats the one tflite-micro uses.
The patch files to fix cast-align errors have been updated
The mnist example have been updated with new locations for headers and i've replaced the AllOpsResolver with mutable_ops_resolver, since the former has been deprecated. This requires the user to specify the exact operators needed, with an added bonus of a much smaller binary size.

Testing procedure

run the tests/pkg/tflite-micro test

Issues/PRs references

@github-actions github-actions bot added Area: tests Area: tests and testing framework Area: build system Area: Build system Area: pkg Area: External package ports Area: tools Area: Supplementary tools labels May 22, 2024
@benpicco benpicco added the CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR label May 22, 2024
@aabadie
Copy link
Contributor

aabadie commented May 22, 2024

I tried to build locally and got this error:

"make" -C /work/riot/RIOT/build/pkg/tflite-micro/tensorflow/lite/micro -f /work/riot/RIOT/pkg/tflite-micro/tflite-micro.mk
In file included from /work/riot/RIOT/build/pkg/tflite-micro/tensorflow/lite/micro/micro_interpreter.cc:33:
/work/riot/RIOT/build/pkg/tflite-micro/tensorflow/lite/schema/schema_utils.h:29:38: error: 'OperatorCodeT' does not name a type; did you mean 'OperatorCode'?
   29 | BuiltinOperator GetBuiltinCode(const OperatorCodeT *op_code);
      |                                      ^~~~~~~~~~~~~
      |                                      OperatorCode

Any idea what it could be?

@aabadie
Copy link
Contributor

aabadie commented May 22, 2024

Using make clean all fixes the problem.

@aabadie
Copy link
Contributor

aabadie commented May 22, 2024

Tested on native and nrf52840dk and it works! Good job!

@aabadie
Copy link
Contributor

aabadie commented May 22, 2024

Can you prepend your 4 last commit messages with the right context ("pkg/tflite-micro: ", "pkg/flatbuffers: ") ?

@FlapKap
Copy link
Contributor Author

FlapKap commented May 22, 2024

Can you prepend your 4 last commit messages with the right context ("pkg/tflite-micro: ", "pkg/flatbuffers: ") ?

done!

I tried to build locally and got this error:

"make" -C /work/riot/RIOT/build/pkg/tflite-micro/tensorflow/lite/micro -f /work/riot/RIOT/pkg/tflite-micro/tflite-micro.mk
In file included from /work/riot/RIOT/build/pkg/tflite-micro/tensorflow/lite/micro/micro_interpreter.cc:33:
/work/riot/RIOT/build/pkg/tflite-micro/tensorflow/lite/schema/schema_utils.h:29:38: error: 'OperatorCodeT' does not name a type; did you mean 'OperatorCode'?
   29 | BuiltinOperator GetBuiltinCode(const OperatorCodeT *op_code);
      |                                      ^~~~~~~~~~~~~
      |                                      OperatorCode

Any idea what it could be?

I encountered the same issue when i had generated the schema using a different version of flatc than required. Just using the schema_generated already in the repo fixed it.

@riot-ci
Copy link

riot-ci commented May 22, 2024

Murdock results

✔️ PASSED

6d51de0 pkg/tflite-micro: remove trailing spaces

Success Failures Total Runtime
10104 0 10105 17m:35s

Artifacts

@aabadie
Copy link
Contributor

aabadie commented May 23, 2024

Can you fix the check-commits check? https://github.com/RIOT-OS/RIOT/actions/runs/9207542826/job/25327831907?pr=20683#step:4:5.
A multi line commit message should make it:

pkg/flatbuffers: downgrade to v23.5.26

because that's what tflite-micro depends on

@aabadie
Copy link
Contributor

aabadie commented May 24, 2024

Sorry to bother you again with 57abe1c
The commit message should be:

pkg/flatbuffers: downgrade to v23.5.26

because that's what tflite-micro depends on

format is: short description on the first line, blank line, extended description.

@FlapKap
Copy link
Contributor Author

FlapKap commented May 24, 2024

Sorry to bother you again with 57abe1c The commit message should be:

pkg/flatbuffers: downgrade to v23.5.26

because that's what tflite-micro depends on

format is: short description on the first line, blank line, extended description.

Done. No worries. Maybe I just shouldn't have done this past midnight :)

pkg/tflite-micro/Makefile Outdated Show resolved Hide resolved
@@ -1,109 +1,29 @@
BOARD_INSUFFICIENT_MEMORY := \
airfy-beacon \
Copy link
Contributor

@aabadie aabadie May 24, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is removing too many boards to be right. I doubt all those removed boards have enough memory. nrf51dk has only 8kB of RAM.

Copy link
Contributor Author

@FlapKap FlapKap May 24, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I generated it through the RIOT/dist/tools/insufficient_memory/create_makefile.ci.sh script, but i must admit i don't have that board to test it on. Running BOARD=nrf51dk make -C tests/pkg/tflite-micro/ it builds fine, but I can't actually run it. The closest i have access to is a microbit, and this compiles and works on that

Co-authored-by: Alexandre Abadie <alexandre.abadie@inria.fr>
@aabadie aabadie enabled auto-merge May 24, 2024 19:09
@aabadie aabadie added this pull request to the merge queue May 24, 2024
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks May 24, 2024
@FlapKap
Copy link
Contributor Author

FlapKap commented May 26, 2024

Murdock timed out on compiling the test for arduino-mkrwan1300 after 300 seconds. It does compile on my machine, but it takes 6,5 minutes

@aabadie aabadie added this pull request to the merge queue May 27, 2024
Merged via the queue into RIOT-OS:master with commit 2f3c262 May 27, 2024
26 checks passed
@maribu
Copy link
Member

maribu commented May 28, 2024

I tried to build locally and got this error:

"make" -C /work/riot/RIOT/build/pkg/tflite-micro/tensorflow/lite/micro -f /work/riot/RIOT/pkg/tflite-micro/tflite-micro.mk
In file included from /work/riot/RIOT/build/pkg/tflite-micro/tensorflow/lite/micro/micro_interpreter.cc:33:
/work/riot/RIOT/build/pkg/tflite-micro/tensorflow/lite/schema/schema_utils.h:29:38: error: 'OperatorCodeT' does not name a type; did you mean 'OperatorCode'?
   29 | BuiltinOperator GetBuiltinCode(const OperatorCodeT *op_code);
      |                                      ^~~~~~~~~~~~~
      |                                      OperatorCode

Any idea what it could be?

This is now also popping up in the CI every now and then. There seems to be a race condition.

@FlapKap
Copy link
Contributor Author

FlapKap commented May 28, 2024

I tried to build locally and got this error:

"make" -C /work/riot/RIOT/build/pkg/tflite-micro/tensorflow/lite/micro -f /work/riot/RIOT/pkg/tflite-micro/tflite-micro.mk
In file included from /work/riot/RIOT/build/pkg/tflite-micro/tensorflow/lite/micro/micro_interpreter.cc:33:
/work/riot/RIOT/build/pkg/tflite-micro/tensorflow/lite/schema/schema_utils.h:29:38: error: 'OperatorCodeT' does not name a type; did you mean 'OperatorCode'?
   29 | BuiltinOperator GetBuiltinCode(const OperatorCodeT *op_code);
      |                                      ^~~~~~~~~~~~~
      |                                      OperatorCode

Any idea what it could be?

This is now also popping up in the CI every now and then. There seems to be a race condition.

The cause is that schema_generated.h is not using the proper flatc flags to generate the appropriate types. However, the tflite-micro repo already has the correct schema_generated.h so there is probably some funny stuff going on when make decide to regenerate it. I'll create a new PR with the fix.

EDIT: PR #20703

@mguetschow mguetschow added this to the Release 2024.07 milestone Jun 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: build system Area: Build system Area: pkg Area: External package ports Area: tests Area: tests and testing framework Area: tools Area: Supplementary tools CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants