Tencent/ncnn

▲ 1 stars today★ 23,936⑂ 4,523

ncnn is a high-performance neural network inference framework optimized for the mobile platform

About Tencent/ncnn

Tencent/ncnn is an open-source project on GitHub, mainly written in C++. ncnn is a high-performance neural network inference framework optimized for the mobile platform It currently holds 23,936 stars and 4,523 forks with 0 open issues, and was last pushed on an unknown date (repository created unknown).

Project Overview

AI Homed tracks it on the Today's Trending board, currently at rank #68 with 1 new stars today.

GitHub Repository Details

Repository Tencent/ncnn · default branch - · size 0 KB · watchers 0 · source: GitHub REST API and repository README

README

ncnn

ncnn

License Download Total Count codecov

ncnn is a high-performance neural network inference framework optimized for mobile, embedded, and desktop deployment. It has no third-party runtime dependencies, runs across CPU and Vulkan GPU backends, and provides tools such as pnnx for converting PyTorch and ONNX models to ncnn. Developers can deploy deep learning models efficiently on phones, PCs, browsers, and edge devices. ncnn is currently being used in many Tencent applications, such as QQ, Qzone, WeChat, Pitu, and so on.

ncnn 是一个面向移动端、嵌入式和桌面端部署优化的高性能神经网络推理框架。 ncnn 无第三方运行时依赖,支持 CPU 和 Vulkan GPU 后端,并提供 pnnx 等工具将 PyTorch 和 ONNX 模型转换为 ncnn 模型。 基于 ncnn,开发者可以将深度学习模型高效部署到手机、PC、浏览器和边缘设备上。 ncnn 目前已在腾讯多款应用中使用,如:QQ,Qzone,微信,天天 P 图等。

---

Quick Start

The recommended beginner path is PyTorch -> pnnx -> ncnn.

Install pnnx in a PyTorch environment

pip3 install pnnx

Export a PyTorch model to ncnn

import torch
import torch.nn as nn
import pnnx

class Model(nn.Module): def __init__(self): super().__init__() self.conv = nn.Conv2d(3, 8, 1) self.relu = nn.ReLU() self.fc = nn.Linear(8, 4)

def forward(self, x): x = self.conv(x) x = self.relu(x) x = x.mean((2, 3)) return self.fc(x)

model = Model().eval()

x = torch.rand(1, 3, 224, 224) pnnx.export(model, "model.pt", (x,))

This generates model.ncnn.param and model.ncnn.bin.

Run with ncnn C++ API

#include "net.h"

ncnn::Net net; net.load_param("model.ncnn.param"); net.load_model("model.ncnn.bin");

ncnn::Mat in(224, 224, 3);

auto ex = net.create_extractor(); ex.input("in0", in);

ncnn::Mat out; ex.extract("out0", out);

Or use Python

import numpy as np
import ncnn

net = ncnn.Net() net.load_param("model.ncnn.param") net.load_model("model.ncnn.bin")

x = np.zeros((3, 224, 224), np.float32) mat = ncnn.Mat(x)

ex = net.create_extractor() ex.input("in0", mat)

ret, out = ex.extract("out0") print(np.array(out).shape)

See pnnx, use ncnn with PyTorch or ONNX, Python API, and examples for complete workflows.

---

Community

技术交流 QQ 群
637093648 (超多大佬)
答案:卷卷卷卷卷(已满)
Telegram Group

Discord Channel

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

---

Download & Build status

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

Image from the project README

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

Source

Image from the project README

Image from the project README
Android

Image from the project README Image from the project README

Image from the project README

Android shared

Image from the project README Image from the project README

Image from the project README
HarmonyOS

Image from the project README Image from the project README

Image from the project README

HarmonyOS shared

Image from the project README Image from the project README

Image from the project README
iOS

Image from the project README Image from the project README

Image from the project README

iOS-Simulator

Image from the project README Image from the project README

Image from the project README
macOS

Image from the project README Image from the project README

Image from the project README

Mac-Catalyst

Image from the project README Image from the project README

Image from the project README

watchOS

Image from the project README

Image from the project README

watchOS-Simulator

Image from the project README

tvOS

Image from the project README Image from the project README

Image from the project README

tvOS-Simulator

Image from the project README Image from the project README

visionOS

Image from the project README Image from the project README

Image from the project README

visionOS-Simulator

Image from the project README Image from the project README

Apple xcframework

Image from the project README Image from the project README

Image from the project README
Ubuntu 22.04

Image from the project README Image from the project README

Image from the project README

Ubuntu 24.04

Image from the project README Image from the project README

https://github.com/Tencent/ncnn/blob/HEAD/windows
VS2015

Image from the project README Image from the project README

Image from the project README

VS2017

Image from the project README Image from the project README

VS2019

Image from the project README Image from the project README

VS2022

Image from the project README Image from the project README

Image from the project README
WebAssembly

Image from the project README

Image from the project README

Image from the project README
Linux (arm)

Image from the project README

Linux (aarch64)

Image from the project README

Linux (mips)

Image from the project README

Linux (mips64)

Image from the project README

Linux (ppc64)

Image from the project README

Linux (riscv64)

Image from the project README

Linux (loongarch64)

Image from the project README

---

Build

Use the prebuilt packages above when possible. To build from source, see the full how to build ncnn library guide for Linux, Windows, macOS, Android, iOS, WebAssembly, HarmonyOS, Raspberry Pi, Jetson, and embedded targets.

Common Linux build:

git clone --recursive https://github.com/Tencent/ncnn.git
cd ncnn
mkdir build && cd build
cmake -DCMAKE_BUILD_TYPE=Release -DNCNN_VULKAN=ON -DNCNN_BUILD_EXAMPLES=ON ..
cmake --build . -j$(nproc)

---

Model Conversion

| Source model | Recommended path | Docs | | --- | --- | --- | | PyTorch | pnnx.export(model, "model.pt", (input_tensor,)) or pnnx model.pt inputshape=[...] | pnnx, PyTorch / ONNX guide | | ONNX | pnnx model.onnx | pnnx, onnx tools | | ncnn model optimization | ncnnoptimize model.param model.bin new.param new.bin flag | quantization, model file spec | | Legacy Caffe / MXNet / Darknet | Use compatibility converters when maintaining older models | caffe, mxnet, darknet, AlexNet legacy tutorial |

Use Netron to inspect .param, .onnx, and .pnnx.param graphs.

---

Features

---

Model and Workload Coverage

ncnn is still strong for classic and mobile CNN workloads, but current usage is broader than CNN-only deployment.

For operator-level detail, see supported PyTorch operator status, supported ONNX operator status, and operation param weight table.

---

Project Examples

| Area | Project | | --- | --- | | Image generation | zimage-ncnn-vulkan - Z-Image g

GitHub Stars & Activity

23,936Stars
4,523Forks
0Open issues
C++Language

GitHub Popularity

GitHub stars23,936
Forks4,523
Open issues0
Primary languageC++
License-
Stars gained today1
Created-
Last pushed-

Trending History

Daily boardrank #68 · ▲ 1 stars

Related AI Projects

1

tensorflow / tensorflow

C++★ 200,869⑂ 79,102▲ 346 stars
→
2

microsoft / BitNet

C++★ 40,683⑂ 3,789▲ 208 stars
→
3

78 / xiaozhi-esp32

C++★ 30,645⑂ 7,185▲ 42 stars
→
4

leejet / stable-diffusion.cpp

C++★ 7,637⑂ 866▲ 24 stars
→
5

LingCore / WinShun

C++★ 184⑂ 18
→
6

openclaw / openclaw

TypeScript★ 391,685⑂ 82,361▲ 150 stars
→
7

mattpocock / skills

Shell★ 285,993⑂ 23,987▲ 1,768 stars
→
8

affaan-m / ECC

JavaScript★ 277,076⑂ 0
→

More AI Rankings