Main Content

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

OperationWrappers Calling CMSIS Function Supported Data Types
Matrix Multiplicationmw_arm_mat_mult_f32single

You can generate the code for matrix multiplication in supported deep learning layers using the Simulink® Coder™ workflow.

Generate Optimized Code Using Simulink Coder

  1. 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.Simulink model showing the MATLAB function block with the input and output blocks.

    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.

  2. Click the Modeling tab on the Simulink toolstrip and select Model Settings to open the Configuration Parameters window.Simulink toolstrip with Model Settings.

  3. 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. Use COMx as the serial port number.Configuration parameters window with Hardware board and Serial port options highlighted.

  4. To generate optimized code for the selected ARM Cortex-M hardware, set the CRL to ARM Cortex-M.

  5. Configuration parameter window with Code replacement libraries highlighted.

  6. Click Build or press Ctrl+B to generate the optimized code for the model.

See Also

| |

Topics