tum-ei-eda / mlonmcu

Tool for the deployment and analysis of TinyML applications on TFLM and MicroTVM backends
Apache License 2.0
29 stars 12 forks source link

Decouple/Isolate backend definitions and their implementation #23

Closed PhilippvK closed 2 years ago

PhilippvK commented 2 years ago

I am a bit unhappy with the current approach how the backend implementations are handles in MCUonMCU.

Some examples:

For the last problem there exist multiple solutions:

  1. Use multiprocessing.Process() to invoke the TVM backends in a new process which can use a different PYTHONPATH. The two main issues of this approach are:
    • Inconsistency between frameworks: While on the TFLM side, this should not be required, both frameworks should be handled in a similar way. We could simply use the same approach on the TFLM side, but this would result in more nested processed (as tflmc internally calls tflite_micro_compiler)
    • Logging module is not multiprocessing-safe -> unable to properly control (mute, redirect) stdout of backend implementation
  2. Like 1. But using subprocess.Popen instead -> allows to decouple backend-stdout from rest of MLonMCU
  3. Only implement the wrapper generation (without TVM dependencies) in the Backend itself an define the actual script somewhere else (like other dependencies)
    • Preferable approach because isolation on the same level as on TFLM backends
    • Reuse TVMC command line utility? -> How to integrate custom features (See Issue #9)
    • Should we create a new repository for TVM-specific features or Include them in TVM codebase? (In my opinion they do not belong to mlonmcu/flow/tvm as the are useful without mlonmcu -> Make them an external dependency instead)