
MNN
On-device deep learning inference engine by Alibaba
Replaces —

Who it's for
Teams building Android or iOS apps who need inference for image recognition, NLP, or generative AI without a server round-trip. MNN ships as an 800 KB Android .so and a 12 MB iOS static library with no external dependencies.
Your app targets only server-side inference or cloud GPUs.
Engineers deploying models on POSIX-compatible embedded devices or IoT hardware. MNN supports devices as far back as Android 4.3 and iOS 8.0 and targets Qualcomm Hexagon DSPs (added in v3.6.1) and RISC-V.
Your hardware has no supported backend (check the architecture/precision matrix first).
Researchers running LLM experiments on mobile hardware. MNN-LLM supports Qwen, LLaMA, Baichuan, Zhipu, and others, with INT4 quantized builds that fit large models in under 200 MB on a phone.
You need server-side multi-GPU training or are evaluating cloud inference throughput.
Teams who want an inference runtime with published benchmark comparisons against TensorFlow Lite, PyTorch Mobile, and TVM (available in the OSDI 2022 paper and the /benchmark path of the repo) and a track record in Alibaba's production environment.
Your evaluation requires ONNX Runtime or TensorFlow Lite compatibility without a conversion step.
The problem
Running deep learning models on mobile devices, IoT hardware, and edge environments is difficult because cloud-based inference adds latency, requires connectivity, and raises privacy concerns. Existing runtimes are either too large to embed, too slow for real-time use cases, or limited in the model formats and hardware backends they support.
How it works
The Android core shared library is about 800 KB (armv7a, c++_shared) and has no external dependencies. The iOS static library for armv7+arm64 is about 12 MB. The MNN_BUILD_MINI flag reduces package size by a further 25%.
Deploys large language models locally on phones, PCs, and IoT devices. Supports Qwen, Baichuan, Zhipu, LLaMA, and others. The team's own MNN-Pocket-0.3B model runs at 350 tok/s on iPhone 18 Pro in a 173 MB INT4 build with 32K context support.
Converts and runs models from TensorFlow (178 ops), Caffe (52 ops), ONNX (158 ops), and TorchScript (163 ops). Supports CNN, RNN, GAN, and Transformer architectures, including models with dynamic inputs and control flow.
Targets ARM v7a through v9 (SME2), x86/x64 AVX2/AVX512, and RISC-V CPUs. GPU inference uses OpenCL, Vulkan, Metal, and CUDA. NPU paths include CoreML, Qualcomm Hexagon (added in v3.6.1), HIAI, NNAPI, and QNN.
Core compute is implemented in hand-optimized assembly for ARM and x64. The Winograd algorithm accelerates symmetric convolutions (3x3 through 7x7). ARMv8.2 FP16 provides 2x speed over standard FP32; sdot on ARMv8.2 and VNNI gives 2.5x on integer paths.
An OpenCV-like image processing library built on MNN's op set, adding only about 100 KB. Supports a Python API so ML engineers can run inference, training, and image processing without writing C++ code.
Features
- Minimal footprint
- MNN-LLM runtime
- Broad model format support
- Wide hardware backend coverage
- Winograd and assembly-level optimizations
- MNN-CV lightweight image library
How to install
git clone https://github.com/alibaba/MNN.git cd MNN mkdir build && cd build cmake .. -DMNN_BUILD_QUANTOOLS=ON -DMNN_BUILD_CONVERTER=ON make -j4
Recommended for this setup
Strengths
- Proven at Alibaba scale: MNN is integrated into more than 30 Alibaba production apps across 70+ usage scenarios, and its deployment architecture was presented at OSDI 2022 as part of the Walle device-cloud ML system.
- Quantization reduces model size significantly: FP16 and INT8 quantization can shrink model sizes by 50-70%, making large models practical on memory-constrained devices. INT4 weight-only quantization (W4A16) is used in the MNN-Pocket-0.3B release.
- No runtime dependencies: MNN is designed to deploy without external library dependencies, simplifying integration into mobile and embedded environments where dependency management is constrained.
- Full model lifecycle tooling: The ecosystem includes MNN-Converter (format conversion and graph optimization), MNN-Compress (model compression), MNN-Train (on-device training), and MNN Workbench (visualized training tools and one-click deployment).
Trade-offs
- Community discussions are predominantly Chinese: The DingTalk community groups are primarily Chinese-language. English speakers are welcomed but should expect a language barrier in community support channels.
- Several backends rated B or C (not production-ready): The support matrix marks native CPU (non-optimized), RISC-V BF16/FP16, NeuroPilot, NNAPI, and QNN at B or C ratings, meaning they are either unsupported, buggy, or not optimized enough to recommend for production use.
- MNN model format required for inference: Models must be converted to MNN's own format using MNN-Converter before they can run. This adds a conversion step compared to runtimes that consume ONNX or TorchScript directly.
Tech stack
FAQ
MNN-Converter converts models from TensorFlow (178 ops), Caffe (52 ops), ONNX (158 ops), and TorchScript (163 ops) into MNN's own format, which the runtime then executes. Models must be converted before inference.
The core shared library is about 800 KB for armv7a with c++_shared. Using the MNN_BUILD_MINI build flag reduces the overall package size by about 25%, with the trade-off of requiring fixed model input sizes.
Yes. MNN-LLM is a sub-project that deploys LLMs locally on phones, PCs, and IoT devices. It supports models including Qwen, LLaMA, Baichuan, and Zhipu. The team's own MNN-Pocket-0.3B model achieves 350 tok/s on iPhone 18 Pro in a 173 MB INT4 build.
GPU backends include OpenCL, Vulkan, Metal (iOS), and CUDA (NVIDIA with TensorCore support). NPU backends include CoreML (Apple), Qualcomm Hexagon (added in MNN 3.6.1 for Hexagon DSPs), HIAI, NNAPI, and QNN. Support quality varies; check the architecture/precision matrix in the README for each backend's rating.
MNN includes MNN-Train for on-device model training and supports building and training models on both PC and mobile. However, MNN is primarily designed and optimized for inference; heavy training workloads are better suited to frameworks like PyTorch or TensorFlow.