cpetig / tflite_micro_compiler

generate tflite micro code which bypasses the interpreter (directly calls into kernels)
Apache License 2.0
76 stars 26 forks source link

Update for upstream tflm #63

Open yair-ehrenwald opened 2 years ago

yair-ehrenwald commented 2 years ago

Hi,

Note: Used branch bugfix/failing_fallback_opdata_parsing as a starting point as it seemed to be the most up to date code.

Made some updates in order to be able to use (sort of) the latest TFLM build. Rewrote the node/registration scanning loops to support the new subgraph API requirements.

Had some issues with data structures being defined as private in TFLM and the #define private public trick didn't work when used on compiler.cc, so for this to work I had to add a getter to the micro_interpreter for the new MicroGraph type:

MicroGraph *getGraph() {return &graph_;}

Pretty sure this can be worked around, but I couldn't find a decent solution.

Other than that, seems to work on the tests I tried.

andrewstevens-infineon commented 2 years ago

Hi Yair,

Thanks for the PR! FYI: the ifx branches (pushing bugfix was actually sloppiness on my part - it should really have been pushed as ifx/bugifx/....) reference a (currently) Infineon-internal version of tflite(u) with some extended APIs and kernel suite plus associated in-house-CI scripts etc. I'm currently wrapping updating these for tflite(u) from tensorflow v2.5.0 when that's done switching to support tflite(u) from the "new" standalone repo is "next on the list". Your PR is obvisouly very helpful in that regard.

What would be super-helpful would to fix up the PR so that checks pass again for stock tflite(u). Pressure on "other fronts" has meant this has repeatedly postpone for ifx/ branches which is blocking a proper merge back into Christoph's main code branch.

If you feel it would help your efforts I can push the current state of the v.2.5.0 update

yair-ehrenwald commented 2 years ago

I'd be glad to see the current state of what you have for v2.5.0 Just as a clarification, since I'm pretty clueless about git workflows - On my side at least, this PR pulls in the latest stock tflm version (from the new separate repo) and builds with it. I got around the MicroGraph access issue with the gcc compiler flag -fno-access-control so it requires no change to stock tflm.

In general - I would be very happy to collaborate on this project. In addition to code size savings, I think it can also serve as a platform for model modification/optimization.