Tencent/ncnn
HIGH-PERFORMANCE NEURAL NETWORK INFERENCE FRAMEWORK FOR MOBILE
ncnn is a neural network inference framework with no third-party dependencies for mobile, embedded, and desktop platforms. Supports CPU and Vulkan GPU backends, includes pnnx tool for converting models from PyTorch and ONNX.
// KEY FEATURES
- No third-party runtime dependencies
- CPU and Vulkan GPU backends
- pnnx converter from PyTorch and ONNX
- Builds for Android, iOS, WASM, HarmonyOS
// DEEP DIVE: HOW IT WORKS
ncnn operates as a standalone inference engine: loads model parameters and weights, creates an extractor, runs forward pass on CPU or via Vulkan shaders. Architecture targets minimal overhead — no heavy runtimes, only C++ core and optional Python bindings.
Differs from alternatives (TFLite, MNN, NCNN) by combining zero dependencies, native Vulkan support for mobile GPU acceleration, and built-in pnnx converter that translates PyTorch/ONNX graphs to ncnn format without intermediate formats. Internally — handwritten SIMD kernels for ARM NEON and x86 SSE/AVX, plus SPIR-V generation for Vulkan.
Requires CMake and C++11-compatible compiler for build. Prebuilt artifacts exist for Linux (x86_64, arm, aarch64, riscv64, loongarch64), Windows (MSVC, MinGW), macOS, iOS, Android, HarmonyOS, WebAssembly, Jetson, Raspberry Pi, AllWinner D1, Loongson 2K1000, QNX. Model conversion needs Python environment with PyTorch and installed pnnx (pip install pnnx).
// USE CASES
Best for: Mobile and embedded developers deploying models to devices
- Deploy image classification in Android app via JNI
- Run object detection on Raspberry Pi with Vulkan acceleration
- Port PyTorch model to browser via WebAssembly build
// QUICK START
pip3 install pnnx
import torch
import pnnx
pnnx.export(model, "model.pt", (x,))
git clone --recursive https://github.com/Tencent/ncnn.gitCommands are taken from the repository README — check the current version on GitHub before running.
New repositories every 30 minutes
REDDYX AI scans GitHub 24/7 and ships the best AI/ML/Web3 projects to Telegram.
Join on Telegram