Is code generation from a trained LSTM network supported, and if so, how? There appear to be different approaches to generate code from a trained LSTM network while working without/with Simulink.
MATLAB: How to generate code from a trained LSTM network using MATLAB/Simulink
bidirectionalcc codeEmbedded CoderGPU Codermatlab codersimulinkstateful
Related Solutions
This is a known bug in release 18.1.0 of the Embedded Coder Support Package for ARM Cortex-A Processors. The following workaround is available until a bug-fix is released:
1. Delete the runQemu.p file:
<SUPPORT_PACKAGE_INSTALL_FOLDER>/toolbox/target/supportpackages/arm_cortex_a/+codertarget/+arm_cortex_a/runQemu.p
2. Open the MATLAB file:
<SUPPORT_PACKAGE_INSTALL_FOLDER>/toolbox/target/supportpackages/arm_cortex_a/+codertarget/+arm_cortex_a/runQemu.m
3. In line 61~62 of file runQemu.m, the variable zImage and rootfsImage assignments should be changed as below:
zImage = fullfile(busyboxLocation,'armcortexa9_busybox', 'zImage');rootfsImage = fullfile(busyboxLocation ,'armcortexa9_busybox', 'rootfs.img.gz');
4. Deploy the edited MATLAB file into a P file.
Background
To build and run generated C++ code for Deep Learning on an ARM hardware target, you must have the ARM Compute Library installed on the ARM target.
The following describes instructions for building the ARM Compute library on an ARM target, such as the Raspberry Pi, Hikey960, and so on. You must use the ARM Compute Library version appropriate for your MATLAB Coder release:
- For the MATLAB Coder R2018b release, use ARM Compute version 18.03.
- For the MATLAB Coder R2019a release, you can use ARM Compute version 18.03 or 18.05.
- For other MATLAB Coder releases, use the ARM Compute version specific for the release, as described in the release documentation: https://www.mathworks.com/help/coder/ug/prerequisites-for-deep-learning-with-matlab-coder.html
If you need to set up environment variables on your ARM target to point to the ARM Compute Library, see:
ARM Compute Library Build Instructions on Linux based hardware
These instructions assume that the operating system is already present on the hardware. For example, Raspbian Stretch on the Raspberry Pi. On the target hardware, open a command terminal and perform these steps.
1. Install git. Enter:
sudo apt-get install git
2. As noted above, you must use the ARM Compute Library appropriate for your MATLAB Coder release. To download the latest version of the ARM Compute library from https://github.com/ARM-software/ComputeLibrary, enter:
git clone https://github.com/Arm-software/ComputeLibrary.git
To use older libraries:
a. Download source code zip or tar file from https://github.com/ARM-software/ComputeLibrary/releases and unzip downloaded source code. (OR)
b. Use git commands to download a specific version. For example, to download version 18.05, use below commands:
git clone https://github.com/Arm-software/ComputeLibrary.gitcd ComputeLibrarygit tag -lgit checkout v18.05
3. Install scons:
sudo apt-get install sconscd ComputeLibrary
4. Build the library by running the scons command with the relevant build options. For information on library build options, see https://arm-software.github.io/ComputeLibrary/latest/index.xhtml#S3_how_to_build. The ARM Compute libraries are generated under the folder 'build'.
For example, to build the ARM Compute Library for Raspberry Pi, enter:
scons Werror=0 -j2 debug=0 neon=1 opencl=0 os=linux arch=armv7a openmp=1 examples=0 asserts=0 build=native
To build ARM Compute Library for Hikey960 with opencl, enter:
scons Werror=0 -j2 debug=0 neon=0 opencl=1 os=linux arch=arm64-v8a openmp=1 examples=0 asserts=0 build=native
5. Rename the folder ‘build’ to ‘lib’.
Best Answer