mocleiri / tensorflow-micropython-examples

A custom micropython firmware integrating tensorflow lite for microcontrollers and ulab to implement the tensorflow micro examples.
MIT License
170 stars 79 forks source link

Create mechanism to build tensorflow ops as native modules to reduce the firmware size #7

Closed mocleiri closed 2 years ago

mocleiri commented 3 years ago

Tensorflow lite can run in very small flash sizes if only the ops needed for the problem at hand are included in the firmware.

Currently we are bundling all of the tensorflow ops in the firmware however this has a price in terms of flash memory required.

For esp32 4MB flash we changed the partition size to be 3 MB firmware data and 1 MB filesystem.

Native modules are limited for the api's that they are called. However I want to see if the reverse is true. Can we add tensorflow ops in a way that they register with the firmware based microlite module. Because the microlite module is contained within the firmware will that allow the modules loaded via the reduced function table to be called from the code that has full access to all of the code on the firmware.

If we can implement this feature it will dramatically reduce the out of the box storage space needed.

mocleiri commented 2 years ago

To support this I think we need to change how tensorflow-microlite.a is built. We should instead reach into the tensorflow lite micro repository from our microlite module to build the base interpreter but without the ops.

Next we need a way to have a native module for each op.

I think we should be able to start with the hello-world example.

The main question is to find out if we need to make any extensions to the micropython function table that is exposed to native modules.

mocleiri commented 2 years ago

I'm closing this as its not a priority anymore.