MATLAB Coder Support Package for PyTorch and LiteRT Models

Generate C/C++ code from PyTorch and LiteRT

You are now following this Submission

With MATLAB Coder or Simulink Coder, the MATLAB Coder Support Package for PyTorch® and LiteRT™ Models enables you to generate readable and portable, target-independent C/C++ source code for PyTorch and LiteRT models. Deploy a variety of pretrained deep learning networks including Whisper, DINOv2, Depth Anything, SAM2, and YOLOv11. Deploy the complete AI application from MATLAB and Simulink including the pre- and post-processing along with the trained AI models. Optimize the generated code with SIMD, OpenMP, and processor-specific intrinsics for target hardware (e.g., ARM Cortex-A/M, x86 architectures).
Use with GPU Coder to generate optimized CUDA code from PyTorch and LiteRT models along with your MATLAB code and Simulink models. Deploy to NVIDIA Jetson platforms using the MATLAB Coder Support Package for NVIDIA Jetson and NVIDIA DRIVE Platforms.
This support package is available for R2026a and later.
Key Features
  • Generate readable and portable, target-dependent C/C++ code from pretrained PyTorch and LiteRT models
  • Generate optimized CUDA code with GPU Coder
  • Optimize generated code with SIMD, OpenMP, and processor-specific intrinsics for target hardware (e.g., ARM Cortex-A/M, x86 architectures)
  • Integrate pretrained PyTorch & LiteRT models into larger engineered systems in MATLAB and Simulink and run system-level simulations
  • Target CPUs, GPUs, and embedded processors using a single workflow
  • Automate deployment to select hardware like the Raspberry Pi and NVIDIA Jetson platforms
Typical Applications
  • Edge AI and embedded deployment
  • Robotics and autonomous systems
  • Industrial inspection and automation
  • Audio, vision, and signal processing pipelines
  • GPU‑accelerated inference systems
Documentation
Example Applications
Simulate and generate deployable code for the zero-shot Depth Anything V2 PyTorch ExportedProgram model for relative and metric depth estimation. This workflow targets applications such as autonomous driving and navigation.
Simulate and generate optimized CUDA® code for a real-time object detector using a pretrained YOLO v11 LiteRT model, without relying on NVIDIA® cuDNN or TensorRT™ libraries. The model identifies and outlines objects to enable image segmentation and detection.
Generate deployable code for an AI model that predicts the battery state of charge (SOC), a key metric for energy management systems in electric vehicles and other battery-powered devices.
Generate code for an LSTM-based network that uses accelerometer data from a smartphone to classify human activities, and deploy the model to an STM32 microcontroller.
Generate C/C++ code for a lightweight CNN image classification application based on a RepViT PyTorch model. The model is optimized for low latency and high performance on mobile devices using vision-transformer-inspired design principles. Run inference on a host machine and deploy the application to Raspberry Pi® hardware.
Feedback and Support
  • This support package is functional for R2026a and beyond
  • For any issues with this support package, please contact MathWorks Technical Support

MATLAB Release Compatibility

  • Compatible with R2026a

Platform Compatibility

  • Windows
  • macOS (Apple Silicon)
  • macOS (Intel)
  • Linux