emlearn / emlearn-micropython

Efficient Machine Learning engine for MicroPython
72 stars 13 forks source link

Support usage as external C modules #18

Open jonnor opened 1 day ago

jonnor commented 1 day ago

Right now emlearn is distributed as dynamic native modules. This is excellent for getting started, as one can just drop in a .mpy file on a standard MicroPython build and have things working. However, native modules always execute out of RAM, which tends to be more limited than FLASH space. In addition, for dynamic modules, some library code like for softfloat etc must be duplicated. Additionally, the tooling for including .mpy files automatically in a firmware image is a bit missing right now.

For these reasons, it would be nice to optionally be able to include the modules, as "external C modules" during a MicroPython build.

jonnor commented 1 day ago

There was a proof of concept of this done here, https://github.com/emlearn/emlearn-micropython/pull/2 However, it needs to be revisited, as many things have changed since then.

Right now there are some natmod hacks in the module code. So that should be fixed first, to reduce the amount of #ifdefs we need to support both ways of building. Via something like https://github.com/emlearn/emlearn-micropython/pull/15

jonnor commented 1 day ago

This might also enable to include in ports that only/primarily support external C modules, like "embed" and "webassembly".