matlab-deploy-embedded-ai

Generate C/C++ code from neural networks for embedded hardware targets using MATLAB and Simulink.

995|122|Updated Apr 3, 2026
One-click install
npx skills add https://github.com/matlab/matlab-agentic-toolkit --skill matlab-deploy-embedded-ai
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: matlab-deploy-embedded-ai
Source: https://github.com/matlab/matlab-agentic-toolkit/tree/main/skills-catalog/ai-and-statistics/matlab-deploy-embedded-ai
Command: npx skills add https://github.com/matlab/matlab-agentic-toolkit --skill matlab-deploy-embedded-ai

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

Deploying trained AI models to resource-constrained embedded hardware requires navigating model import, compression, quantization, Simulink integration, and code generation across multiple MathWorks toolchains, and choosing the wrong path wastes effort or produces suboptimal code.

Core Features & Use Cases

  • Two deployment patterns: Pattern 1 imports or builds a dlnetwork, optionally compresses it (pruning, projection, INT8 quantization), then generates C/C++ via MATLAB Coder or exports to Simulink; Pattern 2 generates C/C++ directly from PyTorch (.pt2) or LiteRT (.tflite) models without conversion.
  • Target-aware code generation: Configures MATLAB Coder and Embedded Coder for ARM Cortex-M/A/R, x86, and NVIDIA GPU targets, including CMSIS-NN/CMSIS-DSP acceleration, MKL-DNN, cuDNN, and TensorRT library selection.
  • Verification workflow: Validates numerical equivalence across the original model, compressed MATLAB model, Simulink simulation, MEX, and generated code, with optional OOD detection and robustness checks.
  • Use Case: A user has a PyTorch LSTM model and wants it running on an ARM Cortex-M7. The skill walks them through environment discovery, picks the right pattern via a decision tree, compresses the model, and generates verified C code step by step.

Quick Start

Ask the agent to deploy your trained neural network to an embedded target such as ARM Cortex-M and let it guide you through the workflow step by step.

Frequently Asked Questions about matlab-deploy-embedded-ai

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I deploy a neural network to embedded hardware with MATLAB?

Build or import a dlnetwork, optionally compress it with pruning, projection, or quantization, then generate C/C++ code using MATLAB Coder or export it to Simulink with exportNetworkToSimulink and build with Embedded Coder. The skill guides each phase with verification at every step.

How do I generate C code from a PyTorch model in MATLAB?

Load the exported PyTorch model with loadPyTorchExportedProgram, wrap inference in a codegen entry-point function, and run codegen with coder.DeepLearningConfig set to 'none' for portable C. This direct path skips dlnetwork conversion but does not support quantization or pruning.

Should I quantize an LSTM model for ARM Cortex-M deployment?

Quantizing an LSTM reduces flash usage but does not speed up inference on Cortex-M, because CMSIS-NN in R2026a provides INT8 kernels only for Conv2D and fully connected layers. For latency, keep recurrent layers in float32 and use the CMSIS-DSP matrix-multiply replacement via the Simulink path.

Can I generate code from a quantized dlnetwork with MATLAB Coder?

No, coder.loadDeepLearningNetwork does not accept the output of quantize(). Pass the quantized network to exportNetworkToSimulink and build with slbuild to generate fixed-point C, or use the uncompressed network for the direct MATLAB Coder path.

What MATLAB version and toolboxes are required for embedded AI deployment?

This workflow requires MATLAB R2026a or newer with Deep Learning Toolbox, Statistics and Machine Learning Toolbox, MATLAB Coder, Embedded Coder, Simulink, and Fixed-Point Designer. Target-specific support packages, such as the Embedded Coder Support Package for ARM Cortex-M, are installed separately via Add-On Explorer.

When should I not use this embedded AI deployment workflow?

Avoid it for cloud or server deployment (use MATLAB Production Server), FPGA or PLC targets (use HDL Coder or Simulink PLC Coder), and classical machine learning models that are not neural networks. It also does not cover training models purely for research without a deployment target.