# github: https://github.com/Tencent/ncnn.git
ncnn
ncnn 是一个为手机端极致优化的高性能神经网络前向计算框架。ncnn 从设计之初深刻考虑手机端的部署和使用。无第三方依赖,跨平台,手机端 cpu 的速度快于目前所有已知的开源框架。基于 ncnn,开发者能够将深度学习算法轻松移植到手机端高效执行,开发出人工智能 APP,将 AI 带到你的指尖。ncnn 目前已在腾讯多款应用中使用,如 QQ,Qzone,微信,天天P图等。
Current building status matrix
System | CPU (32bit) | CPU (64bit) | GPU (32bit) | GPU (64bit) |
---|
Linux (GCC) | [外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-EaspeQrk-1654607332977)(https://img.shields.io/github/workflow/status/Tencent/ncnn/linux-x86-cpu-gcc)] | [外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-k4AyDqDb-1654607332978)(https://img.shields.io/github/workflow/status/Tencent/ncnn/linux-x64-cpu-gcc)] | — | [外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-PpnIcRPb-1654607332978)(https://img.shields.io/github/workflow/status/Tencent/ncnn/linux-x64-gpu-gcc)] |
Linux (Clang) | [外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-3MqIOpAB-1654607332978)(https://img.shields.io/github/workflow/status/Tencent/ncnn/linux-x86-cpu-clang)] | [外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-LctzvXNs-1654607332979)(https://img.shields.io/github/workflow/status/Tencent/ncnn/linux-x64-cpu-clang)] | — | [外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-Aa2JLboj-1654607332979)(https://img.shields.io/github/workflow/status/Tencent/ncnn/linux-x64-gpu-clang)] |
Linux (ARM) | [外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-CGJodpQS-1654607332980)(https://img.shields.io/github/workflow/status/Tencent/ncnn/linux-arm-cpu-gcc)] | [外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-kepWFb5B-1654607332980)(https://img.shields.io/github/workflow/status/Tencent/ncnn/linux-aarch64-cpu-gcc)] | — | — |
Linux (MIPS) | [外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-EmFZuXiF-1654607332980)(https://img.shields.io/github/workflow/status/Tencent/ncnn/linux-mips-cpu-gcc)] | [外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-TUisOkhf-1654607332981)(https://img.shields.io/github/workflow/status/Tencent/ncnn/linux-mips64-cpu-gcc)] | — | — |
Linux (RISC-V) | — | [外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-Kx39pO47-1654607332981)(https://img.shields.io/github/workflow/status/Tencent/ncnn/linux-riscv64-cpu-gcc)] | — | — |
Linux (LoongArch) | — | [外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-smJQSqe0-1654607332981)(https://img.shields.io/github/workflow/status/Tencent/ncnn/linux-loongarch64-cpu-gcc)] | — | — |
Windows (VS2015) | [外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-06gjtYVB-1654607332982)(https://img.shields.io/github/workflow/status/Tencent/ncnn/windows-x86-cpu-vs2015)] | [外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-ml79EyPz-1654607332982)(https://img.shields.io/github/workflow/status/Tencent/ncnn/windows-x64-cpu-vs2015)] | — | — |
Windows (VS2017) | [外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-5CFpttjZ-1654607332982)(https://img.shields.io/github/workflow/status/Tencent/ncnn/windows-x86-cpu-vs2017)] | [外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-a5Wdyplf-1654607332982)(https://img.shields.io/github/workflow/status/Tencent/ncnn/windows-x64-cpu-vs2017)] | — | [外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-UTDtHI0c-1654607332983)(https://img.shields.io/github/workflow/status/Tencent/ncnn/windows-x64-gpu-vs2017)] |
Windows (VS2019) | [外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-yGChffAO-1654607332983)(https://img.shields.io/github/workflow/status/Tencent/ncnn/windows-x86-cpu-vs2019)] | [外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-0bzWgViE-1654607332983)(https://img.shields.io/github/workflow/status/Tencent/ncnn/windows-x64-cpu-vs2019)] | — | [外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-5AesZo4M-1654607332983)(https://img.shields.io/github/workflow/status/Tencent/ncnn/windows-x64-gpu-vs2019)] |
macOS | — | [外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-ixGhHbbO-1654607332984)(https://img.shields.io/github/workflow/status/Tencent/ncnn/macos-x64-cpu)] | — | [外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-zaGnZRRM-1654607332984)(https://img.shields.io/github/workflow/status/Tencent/ncnn/macos-x64-gpu)] |
macOS (ARM) | — | [外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-kjZryOiT-1654607332984)(https://img.shields.io/github/workflow/status/Tencent/ncnn/macos-arm64-cpu)] | — | [外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-b7jFTQLd-1654607332985)(https://img.shields.io/github/workflow/status/Tencent/ncnn/macos-arm64-gpu)] |
Android | [外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-nzyia3ZV-1654607332985)(https://img.shields.io/github/workflow/status/Tencent/ncnn/android-armv7-cpu)] | [外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-c42c6ya2-1654607332985)(https://img.shields.io/github/workflow/status/Tencent/ncnn/android-armv8-cpu)] | [外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-0xAQGTz1-1654607332985)(https://img.shields.io/github/workflow/status/Tencent/ncnn/android-armv7-gpu)] | [外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-Ezzg2MyR-1654607332986)(https://img.shields.io/github/workflow/status/Tencent/ncnn/android-armv8-gpu)] |
Android-x86 | [外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-zsQwS23I-1654607332986)(https://img.shields.io/github/workflow/status/Tencent/ncnn/android-x86-cpu)] | [外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-A2UA5B5P-1654607332986)(https://img.shields.io/github/workflow/status/Tencent/ncnn/android-x64-cpu)] | [外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-ZCGsnLBf-1654607332986)(https://img.shields.io/github/workflow/status/Tencent/ncnn/android-x86-gpu)] | [外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-W5kQA3Fd-1654607332987)(https://img.shields.io/github/workflow/status/Tencent/ncnn/android-x64-gpu)] |
iOS | [外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-0iNlXGfl-1654607332987)(https://img.shields.io/github/workflow/status/Tencent/ncnn/ios-cpu)] | [外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-RXO9ScWE-1654607332987)(https://img.shields.io/github/workflow/status/Tencent/ncnn/ios-cpu)] | — | [外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-HQGHnMiT-1654607332988)(https://img.shields.io/github/workflow/status/Tencent/ncnn/ios-arm64-gpu)] |
iOS Simulator | [外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-zPJ11FtH-1654607332988)(https://img.shields.io/github/workflow/status/Tencent/ncnn/ios-simulator)] | [外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-fRNvHoup-1654607332988)(https://img.shields.io/github/workflow/status/Tencent/ncnn/ios-simulator)] | — | — |
WebAssembly | [外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-877yKQTk-1654607332988)(https://img.shields.io/github/workflow/status/Tencent/ncnn/web-assembly)] | — | — | — |
RISC-V GCC/Newlib | [外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-tWp49icT-1654607332989)(https://img.shields.io/github/workflow/status/Tencent/ncnn/elf-riscv32-cpu-gcc)] | [外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-3vDGXHti-1654607332989)(https://img.shields.io/github/workflow/status/Tencent/ncnn/elf-riscv64-cpu-gcc)] | — | — |
Support most commonly used CNN network
支持大部分常用的 CNN 网络
HowTo
how to build ncnn library on Linux / Windows / macOS / Raspberry Pi3 / Android / NVIDIA Jetson / iOS / WebAssembly / AllWinner D1 / Loongson 2K1000
download prebuild binary package for android and ios
use ncnn with alexnet with detailed steps, recommended for beginners
ncnn 组件使用指北 alexnet 附带详细步骤,新人强烈推荐
use netron for ncnn model visualization
out-of-the-box web model conversion
ncnn low-level operation api
ncnn param and model file spec
ncnn operation param weight table
how to implement custom layer step by step
FAQ
ncnn throw error
ncnn produce wrong result
ncnn vulkan
Features
- Supports convolutional neural networks, supports multiple input and multi-branch structure, can calculate part of the branch
- No third-party library dependencies, does not rely on BLAS / NNPACK or any other computing framework
- Pure C++ implementation, cross-platform, supports android, ios and so on
- ARM NEON assembly level of careful optimization, calculation speed is extremely high
- Sophisticated memory management and data structure design, very low memory footprint
- Supports multi-core parallel computing acceleration, ARM big.LITTLE cpu scheduling optimization
- Supports GPU acceleration via the next-generation low-overhead vulkan api
- Extensible model design, supports 8bit quantization and half-precision floating point storage, can import caffe/pytorch/mxnet/onnx/darknet/keras/tensorflow(mlir) models
- Support direct memory zero copy reference load network model
- Can be registered with custom layer implementation and extended
- Well, it is strong, not afraid of being stuffed with 卷 QvQ
功能概述
- 支持卷积神经网络,支持多输入和多分支结构,可计算部分分支
- 无任何第三方库依赖,不依赖 BLAS/NNPACK 等计算框架
- 纯 C++ 实现,跨平台,支持 android ios 等
- ARM NEON 汇编级良心优化,计算速度极快
- 精细的内存管理和数据结构设计,内存占用极低
- 支持多核并行计算加速,ARM big.LITTLE cpu 调度优化
- 支持基于全新低消耗的 vulkan api GPU 加速
- 可扩展的模型设计,支持 8bit 量化 和半精度浮点存储,可导入 caffe/pytorch/mxnet/onnx/darknet/keras/tensorflow(mlir) 模型
- 支持直接内存零拷贝引用加载网络模型
- 可注册自定义层实现并扩展
- 恩,很强就是了,不怕被塞卷 QvQ
supported platform matrix
- ✅ = known work and runs fast with good optimization
- ✔️ = known work, but speed may not be fast enough
- ❔ = shall work, not confirmed
- / = not applied
| Windows | Linux | Android | macOS | iOS |
---|
intel-cpu | ✔️ | ✔️ | ❔ | ✔️ | / |
intel-gpu | ✔️ | ✔️ | ❔ | ❔ | / |
amd-cpu | ✔️ | ✔️ | ❔ | ✔️ | / |
amd-gpu | ✔️ | ✔️ | ❔ | ❔ | / |
nvidia-gpu | ✔️ | ✔️ | ❔ | ❔ | / |
qcom-cpu | ❔ | ✔️ | ✅ | / | / |
qcom-gpu | ❔ | ✔️ | ✔️ | / | / |
arm-cpu | ❔ | ❔ | ✅ | / | / |
arm-gpu | ❔ | ❔ | ✔️ | / | / |
apple-cpu | / | / | / | ✔️ | ✅ |
apple-gpu | / | / | / | ✔️ | ✔️ |
Example project
- https://github.com/nihui/ncnn-android-squeezenet
- https://github.com/nihui/ncnn-android-styletransfer
- https://github.com/nihui/ncnn-android-mobilenetssd
- https://github.com/moli232777144/mtcnn_ncnn
- https://github.com/nihui/ncnn-android-yolov5
- https://github.com/nihui/ncnn-android-scrfd 朗