Home

Awesome

ncnn

ncnn

License Download Total Count codecov

ncnn is a high-performance neural network inference computing framework optimized for mobile platforms. ncnn is deeply considerate about deployment and uses on mobile phones from the beginning of design. ncnn does not have third-party dependencies. It is cross-platform and runs faster than all known open-source frameworks on mobile phone cpu. Developers can easily deploy deep learning algorithm models to the mobile platform by using efficient ncnn implementation, creating intelligent APPs, and bringing artificial intelligence to your fingertips. ncnn is currently being used in many Tencent applications, such as QQ, Qzone, WeChat, Pitu, and so on.

ncnn 是一个为手机端极致优化的高性能神经网络前向计算框架。 ncnn 从设计之初深刻考虑手机端的部署和使用。 无第三方依赖,跨平台,手机端 cpu 的速度快于目前所有已知的开源框架。 基于 ncnn,开发者能够将深度学习算法轻松移植到手机端高效执行, 开发出人工智能 APP,将 AI 带到你的指尖。 ncnn 目前已在腾讯多款应用中使用,如:QQ,Qzone,微信,天天 P 图等。


<table> <tr> <td> <b>技术交流 QQ 群</b><br /> 637093648 (超多大佬)<br /> 答案:卷卷卷卷卷(已满) </td> <td rowspan=3> <b>Telegram Group</b>

https://t.me/ncnnyes

</td> <td rowspan=3> <b>Discord Channel</b>

https://discord.gg/YRsxgmF

</td> </tr> <tr> <td> <b>Pocky QQ 群(MLIR YES!)</b><br /> 677104663 (超多大佬)<br /> 答案:multi-level intermediate representation </td> </tr> <tr> <td> <b>他们都不知道 pnnx 有多好用群</b><br /> 818998520 (新群!) </td> </tr> </table>

Download & Build status

https://github.com/Tencent/ncnn/releases/latest

<table> <tr> <td rowspan=2> <img src="https://user-images.githubusercontent.com/25181517/192108372-f71d70ac-7ae6-4c0d-8395-51d8870c2ef0.png" width="120" height="auto"> </td> <td colspan=3>

how to build ncnn library on Linux / Windows / macOS / Raspberry Pi3, Pi4 / POWER / Android / NVIDIA Jetson / iOS / WebAssembly / AllWinner D1 / Loongson 2K1000

</td> </tr> <tr> <td>Source</td> <td colspan=2>

<img src="https://img.shields.io/badge/download-blue?style=for-the-badge">

</td> </tr> <tr> <td rowspan=3> <img src="https://user-images.githubusercontent.com/25181517/117269608-b7dcfb80-ae58-11eb-8e66-6cc8753553f0.png" width="120" height="auto"> </td> <td colspan=3> </td> </tr> <tr> <td>Android</td> <td>

<img src="https://img.shields.io/badge/download-blue?style=for-the-badge"> <img src="https://img.shields.io/badge/+cpuonly-blue?style=for-the-badge">

</td> <td rowspan=2>

<img src="https://img.shields.io/github/actions/workflow/status/Tencent/ncnn/android.yml?branch=master&style=for-the-badge&label=build">

</td> </tr> <tr> <td>Android shared</td> <td>

<img src="https://img.shields.io/badge/download-blue?style=for-the-badge"> <img src="https://img.shields.io/badge/+cpuonly-blue?style=for-the-badge">

</td> </tr> <tr> <td rowspan=3> <img src="https://upload.wikimedia.org/wikipedia/commons/thumb/3/37/HMOS_Logo_Icon.svg/240px-HMOS_Logo_Icon.svg.png" width="120" height="auto"> </td> <td colspan=3> </td> </tr> <tr> <td>HarmonyOS</td> <td> </td> <td rowspan=2>

<img src="https://img.shields.io/github/actions/workflow/status/Tencent/ncnn/harmonyos.yml?branch=master&style=for-the-badge&label=build">

</td> </tr> <tr> <td>HarmonyOS shared</td> <td> </td> </tr> <tr> <td rowspan=3> <img src="https://user-images.githubusercontent.com/25181517/121406611-a8246b80-c95e-11eb-9b11-b771486377f6.png" width="120" height="auto"> </td> <td colspan=3> </td> </tr> <tr> <td>iOS</td> <td>

<img src="https://img.shields.io/badge/download-blue?style=for-the-badge"> <img src="https://img.shields.io/badge/+cpuonly-blue?style=for-the-badge">

</td> <td rowspan=2>

<img src="https://img.shields.io/github/actions/workflow/status/Tencent/ncnn/ios.yml?branch=master&style=for-the-badge&label=build">

</td> </tr> <tr> <td>iOS-Simulator</td> <td>

<img src="https://img.shields.io/badge/download-blue?style=for-the-badge"> <img src="https://img.shields.io/badge/+cpuonly-blue?style=for-the-badge">

</td> </tr> <tr> <td rowspan=10> <img src="https://user-images.githubusercontent.com/25181517/186884152-ae609cca-8cf1-4175-8d60-1ce1fa078ca2.png" width="120" height="auto"> </td> <td colspan=3> </td> </tr> <tr> <td>macOS</td> <td>

<img src="https://img.shields.io/badge/download-blue?style=for-the-badge"> <img src="https://img.shields.io/badge/+cpuonly-blue?style=for-the-badge">

</td> <td rowspan=1>

<img src="https://img.shields.io/github/actions/workflow/status/Tencent/ncnn/macos.yml?branch=master&style=for-the-badge&label=build">

</td> </tr> <tr> <td>Mac-Catalyst</td> <td>

<img src="https://img.shields.io/badge/download-blue?style=for-the-badge"> <img src="https://img.shields.io/badge/+cpuonly-blue?style=for-the-badge">

</td> <td rowspan=1>

<img src="https://img.shields.io/github/actions/workflow/status/Tencent/ncnn/mac-catalyst.yml?branch=master&style=for-the-badge&label=build">

</td> </tr> <tr> <td>watchOS</td> <td>

<img src="https://img.shields.io/badge/download-blue?style=for-the-badge">

</td> <td rowspan=2>

<img src="https://img.shields.io/github/actions/workflow/status/Tencent/ncnn/watchos.yml?branch=master&style=for-the-badge&label=build">

</td> </tr> <tr> <td>watchOS-Simulator</td> <td>

<img src="https://img.shields.io/badge/download-blue?style=for-the-badge">

</td> </tr> <tr> <td>tvOS</td> <td>

<img src="https://img.shields.io/badge/download-blue?style=for-the-badge"> <img src="https://img.shields.io/badge/+cpuonly-blue?style=for-the-badge">

</td> <td rowspan=2>

<img src="https://img.shields.io/github/actions/workflow/status/Tencent/ncnn/tvos.yml?branch=master&style=for-the-badge&label=build">

</td> </tr> <tr> <td>tvOS-Simulator</td> <td>

<img src="https://img.shields.io/badge/download-blue?style=for-the-badge"> <img src="https://img.shields.io/badge/+cpuonly-blue?style=for-the-badge">

</td> </tr> <tr> <td>visionOS</td> <td>

<img src="https://img.shields.io/badge/download-blue?style=for-the-badge"> <img src="https://img.shields.io/badge/+cpuonly-blue?style=for-the-badge">

</td> <td rowspan=2>

<img src="https://img.shields.io/github/actions/workflow/status/Tencent/ncnn/visionos.yml?branch=master&style=for-the-badge&label=build">

</td> </tr> <tr> <td>visionOS-Simulator</td> <td>

<img src="https://img.shields.io/badge/download-blue?style=for-the-badge"> <img src="https://img.shields.io/badge/+cpuonly-blue?style=for-the-badge">

</td> </tr> <tr> <td>Apple xcframework</td> <td>

<img src="https://img.shields.io/badge/download-blue?style=for-the-badge"> <img src="https://img.shields.io/badge/+cpuonly-blue?style=for-the-badge">

</td> <td rowspan=1> </td> </tr> <tr> <td rowspan=4> <img src="https://user-images.githubusercontent.com/25181517/186884153-99edc188-e4aa-4c84-91b0-e2df260ebc33.png" width="120" height="auto"> </td> <td colspan=4> </td> </tr> <tr> <td>Ubuntu 20.04</td> <td>

<img src="https://img.shields.io/badge/download-blue?style=for-the-badge"> <img src="https://img.shields.io/badge/+shared-blue?style=for-the-badge">

</td> <td rowspan=3>

<img src="https://img.shields.io/github/actions/workflow/status/Tencent/ncnn/linux-x64-gpu-gcc.yml?branch=master&style=for-the-badge&label=build">

</td> </tr> <tr> <td>Ubuntu 22.04</td> <td>

<img src="https://img.shields.io/badge/download-blue?style=for-the-badge"> <img src="https://img.shields.io/badge/+shared-blue?style=for-the-badge">

</td> </tr> <tr> <td>Ubuntu 24.04</td> <td>

<img src="https://img.shields.io/badge/download-blue?style=for-the-badge"> <img src="https://img.shields.io/badge/+shared-blue?style=for-the-badge">

</td> </tr> <tr> <td rowspan=5> <img alt="windows" src="https://user-images.githubusercontent.com/25181517/186884150-05e9ff6d-340e-4802-9533-2c3f02363ee3.png" width="120" height="auto"> </td> <td colspan=3> </td> </tr> <tr> <td>VS2015</td> <td>

<img src="https://img.shields.io/badge/download-blue?style=for-the-badge"> <img src="https://img.shields.io/badge/+shared-blue?style=for-the-badge">

</td> <td rowspan=4>

<img src="https://img.shields.io/github/actions/workflow/status/Tencent/ncnn/windows.yml?branch=master&style=for-the-badge&label=build">

</td> </tr> <tr> <td>VS2017</td> <td>

<img src="https://img.shields.io/badge/download-blue?style=for-the-badge"> <img src="https://img.shields.io/badge/+shared-blue?style=for-the-badge">

</td> </tr> <tr> <td>VS2019</td> <td>

<img src="https://img.shields.io/badge/download-blue?style=for-the-badge"> <img src="https://img.shields.io/badge/+shared-blue?style=for-the-badge">

</td> </tr> <tr> <td>VS2022</td> <td>

<img src="https://img.shields.io/badge/download-blue?style=for-the-badge"> <img src="https://img.shields.io/badge/+shared-blue?style=for-the-badge">

</td> </tr> <tr> <td rowspan=2> <img src="https://user-images.githubusercontent.com/25181517/188324036-d704ac9a-6e61-4722-b978-254b25b61bed.png" width="120" height="auto"> </td> <td colspan=3> </td> </tr> <tr> <td>WebAssembly</td> <td>

<img src="https://img.shields.io/badge/download-blue?style=for-the-badge">

</td> <td>

<img src="https://img.shields.io/github/actions/workflow/status/Tencent/ncnn/web-assembly.yml?branch=master&style=for-the-badge&label=build">

</td> </tr> <tr> <td rowspan=8> <img src="https://github.com/marwin1991/profile-technology-icons/assets/76662862/2481dc48-be6b-4ebb-9e8c-3b957efe69fa" width="120" height="auto"> </td> <td colspan=3> </td> </tr> <tr> <td>Linux (arm)</td> <td></td> <td>

<img src="https://img.shields.io/github/actions/workflow/status/Tencent/ncnn/linux-arm-cpu-gcc.yml?branch=master&style=for-the-badge&label=build">

</td> </tr> <tr> <td>Linux (aarch64)</td> <td></td> <td>

<img src="https://img.shields.io/github/actions/workflow/status/Tencent/ncnn/linux-aarch64-cpu-gcc.yml?branch=master&style=for-the-badge&label=build">

</td> </tr> <tr> <td>Linux (mips)</td> <td></td> <td>

<img src="https://img.shields.io/github/actions/workflow/status/Tencent/ncnn/linux-mips-cpu-gcc.yml?branch=master&style=for-the-badge&label=build">

</td> </tr> <tr> <td>Linux (mips64)</td> <td></td> <td>

<img src="https://img.shields.io/github/actions/workflow/status/Tencent/ncnn/linux-mips64-cpu-gcc.yml?branch=master&style=for-the-badge&label=build">

</td> </tr> <tr> <td>Linux (ppc64)</td> <td></td> <td>

<img src="https://img.shields.io/github/actions/workflow/status/Tencent/ncnn/linux-ppc64-cpu-gcc.yml?branch=master&style=for-the-badge&label=build">

</td> </tr> <tr> <td>Linux (riscv64)</td> <td></td> <td>

<img src="https://img.shields.io/github/actions/workflow/status/Tencent/ncnn/linux-riscv64-cpu-gcc.yml?branch=master&style=for-the-badge&label=build">

</td> </tr> <tr> <td>Linux (loongarch64)</td> <td></td> <td>

<img src="https://img.shields.io/github/actions/workflow/status/Tencent/ncnn/linux-loongarch64-cpu-gcc.yml?branch=master&style=for-the-badge&label=build">

</td> </tr> </table>

Support most commonly used CNN network

支持大部分常用的 CNN 网络


HowTo

use ncnn with alexnet with detailed steps, recommended for beginners :)

ncnn 组件使用指北 alexnet 附带详细步骤,新人强烈推荐 :)

use netron for ncnn model visualization

use ncnn with pytorch or onnx

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

功能概述


supported platform matrix

WindowsLinuxAndroidmacOSiOS
intel-cpu✔️✔️✔️/
intel-gpu✔️✔️/
amd-cpu✔️✔️✔️/
amd-gpu✔️✔️/
nvidia-gpu✔️✔️/
qcom-cpu✔️//
qcom-gpu✔️✔️//
arm-cpu//
arm-gpu✔️//
apple-cpu///✔️
apple-gpu///✔️✔️
ibm-cpu/✔️///

Project examples

<img src="https://github.com/nihui/ncnn-assets/raw/master/20181217/ncnn-2.jpg" height ="230"/><img src="https://github.com/nihui/ncnn-assets/raw/master/20181217/4.jpg" height ="230"/><img src="https://github.com/nihui/ncnn-assets/raw/master/20181217/ncnn-33.jpg" height ="230"/><img src="https://github.com/nihui/ncnn-assets/raw/master/20181217/ncnn-m.png" height ="230"/><img src="https://github.com/nihui/ncnn-android-yolov5/raw/master/screenshot.jpg" height ="230"/><img src="https://github.com/nihui/ncnn-android-scrfd/raw/master/screenshot.jpg" height ="230"/><br>


License

BSD 3 Clause