ncnn logo

ncnn

Tencent/ncnn

High-performance neural network inference framework optimized for mobile platforms

GraphCanon updated 2w · GitHub synced 2w

24k stars4.5k forksLast push 2w C++ Other

Decision brief

ncnn is a high-performance framework for deep learning inference on mobile platforms written in C++, supporting conversion from multiple DL frameworks via pnnx.

Good fit when

  • For users requiring fast inference speeds optimized for mobile devices such as Android and iOS.
  • When integration with existing C++ or Python codebases is necessary without the need for a bulky runtime environment.

Avoid when

  • If working in an environment where GPU acceleration on desktop or server is more beneficial than CPU efficiency.
  • For tasks that demand extensive training within the framework itself, as ncnn focuses on inference rather than training capabilities.
Pricing:
unknown
Requirements:
Requires pnnx for exporting PyTorch models to ncnn.

Observed Jul 17, 2026 · Source: enrich:decision_facts

Verify the decision

Maintenance and security

Full trust report
Maintenance
Very active (0d since push)
As of 2w
Provenance
Not a fork · Organization account
As of 2w
Security (OSV)
No lockfile
As of 1mo

Public GitHub metadata and optional OSV scans. Signals, not a guarantee. Trust methodology.

Install

git clone https://github.com/Tencent/ncnn

Similar tools

Same-category neighbours. No typed graph edges are catalogued for this tool yet.

Evidence and technical details

Sourced facts, taxonomy, compatibility claims, README excerpt, and machine-readable endpoints.

Overview

ncnn is developed primarily in C++ and supports multiple deep learning frameworks conversion including PyTorch, ONNX, Keras, MXNet, TensorFlow, Darknet, and Caffe. It provides a means to export models from these frameworks into ncnn's format through pnnx and offers an easy integration path with C++ or Python for performing inference.

Capability facts

Languages
c++, python

Source: github.language+pyproject.toml · Aug 4, 2026

Categories

Compatibility

Sourced claims from the README excerpt - not unsourced marketing copy.

Python runtimePython

Source: README excerpt (regex_v1, Aug 4, 2026)

```python import torch
Source link

Tags

README

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.


For agents

This page has a .md twin and JSON over the API.

Was this helpful?

Anonymous feedback helps us improve pages and translations.