PacktPublishing / TinyML-Cookbook

TinyML Cookbook, published by Packt
MIT License
241 stars 68 forks source link

Unable to build tflite-micro apps in zephyr #7

Open jdsalmonson opened 1 year ago

jdsalmonson commented 1 year ago

I've worked thru the Chapter 07 Zephyr OS project, but found that I can't build zephyr tflist-micro projects.

I have installed the zephyr sdk, zephyr-sdk-0.16.3_macos-aarch64.tar.xz, for my Mac as per the getting started guide: https://docs.zephyrproject.org/latest/develop/getting_started/index.html and was able to successfully build and run the blinky example.

However, when I try to build the cifar10 project as per page 272:

cd ~/zephyrproject/zephyr/samples/modules/tflite-micro/cifar10
west build -b qemu_cortex_m3 .

I get an error that tensorflow isn't found. Further, when I try to run the tflite-micro hello_world example: https://docs.zephyrproject.org/latest/samples/modules/tflite-micro/hello_world/README.html I get errors that tensorflow is not found. e.g.:

zephyrproject/zephyr/samples/modules/tflite-micro/hello_world/src/output_handler.hpp:20:10: fatal error: tensorflow/lite/c/common.h: No such file or directory
   20 | #include <tensorflow/lite/c/common.h>
      |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.

Has something changed wrt to the zephyr SDK installation since this edition of TinyML-Cookbook was published? I.e. was tensorflow removed from the SDK? Or is this an issue with my being on a Mac?

Many thanks.

jdsalmonson commented 1 year ago

Update: Benjamin Cabé responded to my inquiry on the Zephyr mailing list. tflite-micro is no longer installed in zephyr by default -- a change not currently reflected in the documentation. The following lines will add it, and then tflite is available for compilation as expected:

west config manifest.project-filter -- +tflite-micro
west update

(I will mention that I need to add the align(8) const unsigned char type to the model.h and input.h model arrays in order for this build to fit into RAM on the qemu_cortex_m3. This is the alteration that was employed to the model in Chapter 5.)