Environment:Alibaba MNN ARM Mobile Environment
| Knowledge Sources | |
|---|---|
| Domains | Infrastructure, Mobile_Deployment |
| Last Updated | 2026-02-10 00:00 GMT |
Overview
ARM-based mobile deployment environment for MNN on Android and iOS, supporting ARMv7 and ARMv8.2 with optional FP16 and BF16 acceleration.
Description
This environment defines the target hardware and build-time configuration for deploying MNN inference on ARM mobile processors. It covers Android (via NDK cross-compilation) and iOS (via Xcode) platforms. The CMake build system exposes several ARM-specific options that enable half-precision (FP16) and bfloat16 (BF16) compute paths, as well as newer ARM extensions like SME2 and KleidiAI kernels. ARMv8.2+ devices gain significant performance from FP16 native instructions, while ARMv7 devices require an explicit opt-in flag (MNN_SUPPORT_FP16_ARMV7) due to limited hardware support. On ARMv8.6+ devices, the smmla instruction provides 3x or greater speedup for quantized inference workloads.
Usage
Use this environment for all ARM mobile inference deployments of MNN, including Android NDK builds, iOS Xcode builds, and Raspberry Pi cross-compilation. Select appropriate CMake flags based on the target ARM architecture to enable hardware-specific acceleration paths.
System Requirements
| Category | Requirement | Notes |
|---|---|---|
| OS | Android (API level per NDK) or iOS (via Xcode) | Raspberry Pi (Linux ARM) also supported |
| Toolchain | Android NDK (latest stable) or Xcode | NDK for Android cross-compilation; Xcode for iOS |
| Processor | ARM (ARMv7, ARMv8, ARMv8.2+) | ARMv8.2+ recommended for FP16 acceleration |
| Build System | CMake >= 3.0 | Used for cross-compilation configuration |
Dependencies
Build Tools
- Android NDK (latest stable release) for Android targets
- Xcode (latest stable release) for iOS targets
- CMake >= 3.0
Optional Backend Libraries
- KleidiAI kernels (enabled via MNN_KLEIDIAI flag)
- ARM SME2 runtime support (enabled via MNN_SME2 flag)
Credentials
No credentials are required for this environment. Build configuration is controlled entirely through CMake options.
Quick Install
# Android ARMv8.2 build with FP16 (recommended)
mkdir build_arm64 && cd build_arm64
cmake .. \
-DCMAKE_TOOLCHAIN_FILE=$ANDROID_NDK/build/cmake/android.toolchain.cmake \
-DANDROID_ABI=arm64-v8a \
-DMNN_ARM82=ON \
-DMNN_SUPPORT_BF16=ON
make -j$(nproc)
# Android ARMv7 build (basic, no FP16)
mkdir build_armv7 && cd build_armv7
cmake .. \
-DCMAKE_TOOLCHAIN_FILE=$ANDROID_NDK/build/cmake/android.toolchain.cmake \
-DANDROID_ABI=armeabi-v7a
make -j$(nproc)
# Raspberry Pi ARMv7 build
mkdir build_rpi && cd build_rpi
cmake .. -DMNN_ARM82=OFF
make -j$(nproc)
Code Evidence
MNN_ARM82 default ON and MNN_SUPPORT_FP16_ARMV7 default OFF from CMakeLists.txt:259-260:
option(MNN_ARM82 "Enable ARM82 features (FP16 on ARMv8.2+)" ON)
option(MNN_SUPPORT_FP16_ARMV7 "Enable FP16 support on ARMv7" OFF)
ARMv7 forces MNN_ARM82 OFF unless FP16_ARMV7 explicitly enabled from CMakeLists.txt:292-298:
if(ANDROID_ABI STREQUAL "armeabi-v7a")
set(MNN_ARM82 OFF)
if(MNN_SUPPORT_FP16_ARMV7)
# Allow FP16 on ARMv7 only when explicitly requested
add_definitions(-DMNN_SUPPORT_FP16_ARMV7)
endif()
endif()
Raspberry Pi ARMv7 fix with NEON VFPv4 from CMakeLists.txt:340-341:
# Raspberry Pi armv7 fix
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -march=armv7-a -mfpu=neon-vfpv4")
Android defines and softfp float ABI from CMakeLists.txt:344-348:
if(ANDROID)
add_definitions(-D__ANDROID__)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mfloat-abi=softfp")
endif()
Common Errors
| Error Message | Cause | Solution |
|---|---|---|
| ARMv7 library crash on 32-bit CPU | MNN_SUPPORT_FP16_ARMV7 enabled on hardware that does not support FP16 half-precision instructions | Disable MNN_SUPPORT_FP16_ARMV7 (leave it OFF, the default) for devices without FP16 hardware support |
| Illegal instruction on ARMv7 | Build includes ARMv8.2 instructions (MNN_ARM82) targeting ARMv7 device | Ensure MNN_ARM82 is OFF for ARMv7 targets; the CMake build should do this automatically for armeabi-v7a |
| NEON instruction not found | Missing NEON FPU flag on Raspberry Pi | Add -march=armv7-a -mfpu=neon-vfpv4 to compiler flags (applied automatically by CMakeLists.txt for RPi builds) |
Compatibility Notes
- ARMv7: Cannot use FP16 by default. MNN_ARM82 is automatically forced OFF for armeabi-v7a ABI. Only enable MNN_SUPPORT_FP16_ARMV7 if the target hardware is confirmed to support half-precision.
- ARMv8.2+: MNN_ARM82 is ON by default, enabling FP16 native compute for significant performance gains.
- ARMv8.6+: Supports the smmla instruction, providing 3x or greater speedup for quantized (INT8) inference workloads.
- BF16: Enabled via MNN_SUPPORT_BF16. Requires ARMv8.2+ hardware with BF16 extension support.
- SME2: ARM Scalable Matrix Extension 2, enabled via MNN_SME2. Available on the latest ARM cores (e.g., Cortex-X4).
- KleidiAI: Optimized ARM kernels enabled via MNN_KLEIDIAI. Provides performance improvements for specific ARM platforms.
- Raspberry Pi: ARMv7 builds automatically add -march=armv7-a -mfpu=neon-vfpv4 flags.
- Android softfp: Android builds use soft-float ABI (-mfloat-abi=softfp) for compatibility.