Package: mlonmcu
ML on MCUThis project contains research code related to the deployment of inference or learning applications on tiny micro-controllers.Free software: Apache License, Version 2.0Python Package:https://pypi.org/project/mlonmcu/Documentation:https://mlonmcu.readthedocs.ioorhttps://tum-ei-eda.github.io/mlonmcu/FeaturesHighly configurable python packageAutomatic resolution and installation of dependenciesSupporting a large combination of frameworks/backends/targets/featuresBuild-in parallel processing of large number of benchmarksIsolated enironments (not interfering with other installations)Command Line and Python Development InterfacesDocker images to get started quicklyExtensive documentation on usage and code detailsCI/CD integration and high PyTest coverageGetting startedPrerequisitesUbuntu/DebianFirst, a set of APT packages needs to be installed:# Python related
sudo apt install python3-pip python3-venv

# MLonMCU related
sudo apt install libboost-all-dev graphviz doxygen libtinfo-dev zlib1g-dev texinfo unzip device-tree-compiler tree g++

# Optional (depending on configuration)
sudo apt install ninja-buildAlso make sure that your default Python is at least v3.7. If thepythoncommand is not available in your shell or points Python v2.7 check outpython-is-python3.Warning:It seems like the ETISS tool fails to compile if if find a version of LLVM 11 on your system which does not include Clang 11. The best workaround for now is to (if possible) remove those tools from your system:sudo apt remove llvm-11* clang-11*(See issue #1)Make sure to use a fresh virtual Python environment in the following steps.Install Release from PyPIWarning:As the PyPI package is not always up to date, it is currently recommented to use a self-build version of the package (as explained in the next section)To use the PIP package, run the following:pip install mlonmcu(Add--userif you are not using a virtual environment)Build Package manuallyFirst, install all relevant dependencies:python -m venv .venv  # Feel free to choose a different directory or use a conda environment

# Run this whenever your have updated the repository
source .venv/bin/activate

# Environment-specific dependencies are installed later

**Warning:** It is recommended to have at least version 3.20 of CMake installed for full compatibility!

# Install ptional dependecies (only for development)
pip install -r requirements_dev.txt
pip install -r docs/requirements.txt

# Only if you want to use the provided python notebooks, as explained in  ./ipynb/README.md
pip install -r ipynb/requirements.txtThen you should be able to install themlonmcupython package like this# Optionally remove an older version first: pip uninstall mlonmcu

make install  # Alternative: python setup.py installDocker (Any other OS)See./docker/README.mdfor more details.This repository ships three different types of docker images based on Debian:A minimal one with preinstalled software dependencies and python packagesFeel free to use this one if you do not want to install anything (except Docker) on your main sytem to work with mlonmcuA medium one which already has themlonmcupython package installedRecommended and the easiest to use. (Especially when usingdocker-composeto mount shared directories etc.)A very large one with an already initialized and installedMainly used for triggering automated benchmarks without spending too much time on downloading/compiling heavy dependencies over and over again.UsageIs is recommended to checkout the providedDemo Jupyter Notebookas it contains a end-to-end example which should help to understand the main concepts and methodology of the tool. The following paragraphs can be seen as a TL;DL version of the information in that Demo notebook.While some tools and features of this project work out of the box, some of them require setting up an environment where additional dependencies are installed. This can be achived by creating a MLonMCU environment as follows:mlonmcuinitMake sure to point theMLONMCU_HOMEenvironment variable to the location of the previously initialied environment. (Alternative: use thedefaultenvironment or--homeargument on the command line)Next, generate arequirements_addition.txtfile inside the environment directory usingmlonmcu setup -gwhich now be installed by runningpip install -r $MLONMCU_HOME/requirements_addition.txtinside the virtual Python environment.To use the created environment in a python program, aMlonMcuContextneeds to be created as follows:import mlonmcu.context

with mlonmcu.context.MlonMcuContext() as context:
    passDevelopmentMake sure to first install the additonal set of development Python packages into your virtual environment:pip install -r requirements_all.txt  # Install packages for every component (instead of using mlonmcu setup -g)
pip install -r requirements_dev.txt  # Building distributions and running tests
pip install -r docs/requirements.txt  # For working with the documentationUnit test and integration test are defined in thetests/directory and can be triggered usingmake testorpytest tests/Coverage can be determined by runningmake coverage. The latest coverage report (HTML) for the default branch can also be found as an artifact of the CI/CD workflow.Documentation is mainly generated automatically from doctrings (triggered viamake html). It is also possible to include markdown files from the repo into the.rstfiles found in thedocs/directory. There is a GitHub workflow which publishes the documentation for the default branch to ourGitHub Pages.Regarding coding style, it is recommended to runblackbefore every commit. The default line length should be given in thesetup.cfgfile.CreditsThis is a research project proposed by the Chair of Design Automation of the Technical University of Munich.DevelopersRafael Stahl (TUM) [@rafzi]Wrote initial version of the MLonMCU projectPhilipp van Kempen (TUM) [@PhilippvK]Came up with MLonMCU Python packageOtherThis package was created with Cookiecutter_ and theaudreyr/cookiecutter-pypackage_ project template. However most of the templates was manually changed to be in Markdown instead of reStructuredText.Cookiecutter:https://github.com/audreyr/cookiecutteraudreyr/cookiecutter-pypackage:https://github.com/audreyr/cookiecutter-pypackageHistory0.1.0 (2021-11-12)First closed-source release.