The engineering behind inference.Contact ↗
Batch & Release/Edge AI

ExecuTorch Cortex-M Backend Runs PyTorch Models on Arm MCUs

PyTorch's ExecuTorch now supports Arm Cortex-M CPUs with CMSIS-NN acceleration, eliminating cross-framework conversion. Benchmarks on the Alif Ensemble E8 show four MLPerf Tiny models running in under 21.5 ms with less than 90 KiB of RAM.

ExecuTorch Cortex-M Backend Runs PyTorch Models on Arm MCUs — Original editorial illustration. Not a product screenshot or measured result.
Original editorial illustration. Not a product screenshot or measured result.

PyTorch's ExecuTorch now runs models directly on Arm Cortex-M CPUs, with CMSIS-NN acceleration, removing the need to convert models to other framework formats. The Cortex-M backend supports all capability tiers, from Scalar cores like M0 and M3 to DSP cores like M4 and M7, and MVE/Helium cores like M55 and M85, from a single workflow.

Benchmarks on Alif Ensemble E8

PyTorch measured four of the five MLPerf Tiny suite models on the Alif Ensemble E8, using a single Cortex-M55 core at 400 MHz with the Ethos-U NPUs unused. All models ran in 21.5 ms or less and used under 90 KiB of RAM. The DS-CNN keyword spotting model ran in 5.825 ms with 26 KiB peak RAM, MobileNet v1 0.25 for visual wake words took 21.45 ms with 85.15 KiB, ResNet-8 for image classification took 15.29 ms with 55.14 KiB, and the anomaly detection autoencoder ran in 1.208 ms with 5.2 KiB. Flash footprint ranged from 14.97 KiB for the autoencoder to 36.03 KiB for the CNNs, thanks to operator selective build that links only the operators each model needs. These are PyTorch's own measurements, not official MLPerf Tiny submissions.

The backend replaces standard PyTorch operators with CMSIS-NN-backed custom operators through ahead-of-time compiler passes. Quantized operations like linear, conv, add, mul, softmax, and activations call directly into Arm's CMSIS-NN library. Target-aware compilation selects the correct CMSIS-NN backend at compile time based on the CPU variant and ISA tier, eliminating runtime dispatch overhead. A purpose-built quantizer produces INT8 quantized graphs matching CMSIS-NN data layout requirements, using PyTorch's PT2E quantization framework.

Embedded-Friendly Design

ExecuTorch makes target-specific decisions at compile time, exploiting the fixed hardware profile of microcontroller deployments. Graph-level optimizations remove redundant dtype conversions, quantize/dequantize pairs, and memory format transposes. Quantization parameters are folded into integer multiplier/shift form at export, keeping inference entirely in fixed-point. Convolution weights are transposed from PyTorch's OIHW layout to CMSIS-NN's OHWI format at export time, so the permute cost is paid once. Static memory planning allocates all tensor and scratch buffers ahead of time, with support for spanning multiple memory regions like TCM and SRAM, and no heap allocator or runtime memory management.

The core ExecuTorch runtime is under 20 KiB of flash, and operator selective build ensures total code size scales with the model rather than the framework. The developer workflow involves exporting the model, quantizing and calibrating with the CortexMQuantizer, re-exporting, lowering to the edge dialect with Cortex-M passes, and serializing to a .pte binary for firmware integration.

Mixed CPU and NPU Execution

For heterogeneous SoCs, the Cortex-M backend provides the CPU execution path alongside Ethos-U NPU delegation. The EthosUPartitioner delegates supported operations to the NPU via the Vela compiler, and operations left outside the partition run on the Cortex-M CPU within the same graph. The Cortex-M passes run after Ethos-U partitioning and reuse existing quantization parameters, so a model quantized with EthosUQuantizer can use CMSIS-NN for CPU operations that meet the backend's constraints. Operations that don't meet the constraints fall back to ExecuTorch's portable kernels, which are functional but not accelerated. This means NPU operator coverage is not an all-or-nothing gate; models with a few undelegated operations can ship today on mixed execution.

Real-Time Person Detector Demo

PyTorch deployed a µYOLO person detection model on a Renesas EK-RA8D1 board with an Arm Cortex-M85. The model, a pruned depthwise separable CNN with a linear predictor head, is 452 KiB as an INT8 .pte file. Total flash usage is 640 KiB, peak RAM is 254 KiB, and inference latency is 24 ms per frame at 480 MHz, achieving 12.7 FPS with a 128x128 RGB camera input. The deployment demonstrates the workflow: model definition, training, export, and embedded deployment all stay within the PyTorch ecosystem, with intermediate representations remaining executable for output comparison throughout the process.

Sources & references

PyTorch: Bringing ExecuTorch to Arm Cortex-M CPUs ↗Source consulted: 2026-10-15

Privacy choices

We remember your answer in this browser for 180 days. Come back here whenever you want to change it.

EssentialSaves your answer in this browser. No cookies, no third parties.Always active