Code Generation for Matrix Multiplication in Deep Learning Layers with CMSIS Library for ARM Cortex-M Processors
Embedded Coder® Support Package for ARM® Cortex®-M Processors provides a code replacement library (CRL) for common microcontroller software interface standard (CMSIS) functions. This library provides optimized code for matrix multiplication operation essential for deep learning. By using CMSIS CRL, you can increase the speed and efficiency of deep learning neural networks on ARM Cortex-M processors.
CMSIS CRL supports these processors:
Cortex-M0
Cortex-M0+
Cortex-M3
Cortex-M4
Cortex-M7
Cortex-M33
The CMSIS CRL provides code replacement for matrix multiplication only for these supported deep learning layers:
Fully connected layer
Gated recurrent unit (GRU) layer
Long short-term memory (LSTM) layer
Bidirectional long short-term memory (BiLSTM) layer
Operation | Wrappers Calling CMSIS Function | Supported Data Types |
---|---|---|
Matrix Multiplication | mw_arm_mat_mult_f32 | single |
You can generate the code for matrix multiplication in supported deep learning layers using the Simulink® Coder™ workflow.
Generate Optimized Code Using Simulink Coder
Use the MATLAB Function to write an entry-point function that loads a pretrained deep learning network and calls the
predict
function. Add the input and output block to the model.You can also use the Predict (Deep Learning Toolbox), Image Classifier (Deep Learning Toolbox), Stateful Classify (Deep Learning Toolbox), and Stateful Predict (Deep Learning Toolbox) blocks with the pretrained network. Make sure that the pretrained network includes the supported deep learning layers to get the code replacement for matrix multiplication.
Click the Modeling tab on the Simulink toolstrip and select Model Settings to open the Configuration Parameters window.
Set the Hardware board to one of the supported boards and Code generation system target file to
ert.tlc
. Under Hardware board settings, navigate to Target hardware resources and enter the serial port number to which your ARM Cortex-M hardware is connected. To find the serial port number on a Windows® computer, open Device Manager and go to Ports (COM & LPT). Locate the entry of your hardware board. UseCOMx
as the serial port number.To generate optimized code for the selected ARM Cortex-M hardware, set the CRL to
ARM Cortex-M
.Click Build or press Ctrl+B to generate the optimized code for the model.
See Also
codegen
| coder.config
| coder.loadDeepLearningNetwork