Skip to content
/ AIonMCU Public

Inference simple AI model on MCU (Cortex M - RA8M1)

Notifications You must be signed in to change notification settings

tinhnn/AIonMCU

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 

Repository files navigation

AIonMCU

Inference simple AI model on MCU (Cortex M)

Training model

Reference from here

Generate predict model to C++

  1. Write an entry-point function in MATLAB that:
function out = my_predict(in)

persistent mynet;
if isempty(mynet)
    mynet = coder.loadDeepLearningNetwork('Net.mat');
end

out = predict(mynet,in,'MiniBatchSize',2); 
  1. Create a dlconfig that is configured for generating generic C/C++ code by using the coder.DeepLearningConfig function.
dlconfig = coder.DeepLearningConfig(TargetLibrary='none');

Create a code generation configuration object for MEX, executable, or static or dynamically linked library:

cfg = coder.config('lib');
cfg.TargetLang = 'C++';
cfg.DeepLearningConfig = dlconfig;
  1. Run the codegen command
codegen -config cfg my_predict -args {testNormal} -report

Porting for RA8M1

  1. copy all file *.cpp and *.h in generate folder to folder src of e2studio project:

    source

    copy tmwtypes.h to src folder

  2. Config project:

    Stack size is 32kB:

    Stack

    Enable Data Cache:

    Cache

Result

TestCase Time [ms]
w/ Data Cache 6.374
wo/ Data Cache 19.363

Reference

https://www.mathworks.com/help/predmaint/ug/anomaly-detection-using-3-axis-vibration-data.html https://www.mathworks.com/help/coder/ug/generate-generic-cc-code-for-deep-learning-networks.html

About

Inference simple AI model on MCU (Cortex M - RA8M1)

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages