Skip to content
This repository was archived by the owner on Jul 17, 2024. It is now read-only.

Building an ELL model for ARM Cortex M4

Chris Lovett edited this page Aug 13, 2018 · 4 revisions

The Azure IOT DevKit from MXCHIP is a popular board for developing low power IOT solutions. It contains an ARM Cortex M4 chip from ST Microelectronics. This board has a nice microphone and can run Audio models that perform keyword spotting or wake word detection, where the board is always listening for a small set of known keywords.

When you build the ELL git repo on your PC, you will find a compile tool in the build/bin output folder. You can use this "compiler" to compile your ELL model to run on this chip using the following command line options:

compile -imap classifier.ell -cfn Predict -cmn model --bitcode -od . --fuseLinearOps True --header --blas false --optimize true --target custom --numBits 32 --cpu cortex-m4 --triple armv6m-gnueabi --features +vfp4,+d16,+soft-float

This will generate a C header containing the "model_Predict" function that you can call from your app. It will also produce LLVM bitcode which can then be optimized and turned into assembler code that you can include in your Arduino Sketch.

LLVM provides a tool called opt which is a bitcode optimizer. If you are on windows, you can add this location to your PATH environment:

%ELL_ROOT%\external\LLVMNativeWindowsLibs.x64.3.9.1.2\build\native\tools\ 

Then you can run the following:

opt classifier.bc -o classifier.opt.bc -O3

Lastly, you can generate assembler code from this using the llc bitcode compiler:

llc classifier.opt.bc -o classifier.S -O3 -filetype=asm -mtriple=armv6m-gnueabi -mcpu=cortex-m4 -relocation-model=pic -float-abi=soft -mattr=+vfp4,+d16

The file name extension of capital S is an extension that the arduino build system will recognize as assembler code and it will then do the right thing to compile that into your application.

Clone this wiki locally