Zum Hauptinhalt springen

NPU & AI SDK

Read this before you quote a TOPS number

NPU TOPS is a peak number for one datatype under ideal conditions. Real models get 20–60 % of peak. Always benchmark your model before promising a frame rate to a customer.

Toolchain​

StepToolRuns on
Train / exportPyTorch, TensorFlow, ONNXx86 host
ConvertRKNN-Toolkit2x86 Linux host
Runlibrknnrt + Python/C APIthe board

Convert a model​

from rknn.api import RKNN

rknn = RKNN(verbose=True)
rknn.config(
mean_values=[[0, 0, 0]],
std_values=[[255, 255, 255]],
target_platform='rk3576',
quantized_dtype='w8a8',
)
rknn.load_onnx(model='model.onnx')
rknn.build(do_quantization=True, dataset='./calib.txt')
rknn.export_rknn('model.rknn')
rknn.release()

calib.txt must list 100–300 images that look like real deployment data. Calibrating on stock photos and deploying on industrial camera frames is the most common cause of a 20-point accuracy drop.

Run on the board​

# Python
python3 rknn_demo.py --model model.rknn --image test.jpg

# Benchmark (use this, not the datasheet)
python3 benchmark.py --model model.rknn --repeat 200

Performance expectations​

ModelInputExpectedNote
YOLOv8n640 × 640TODO fpsINT8
ResNet-50224 × 224TODO fpsINT8
MobileNetV2224 × 224TODO fpsINT8

Conditions: TODO °C ambient, TODO W power cap, single-core CPU governor performance. Publish the conditions with the number or the number is meaningless.

Accuracy checklist​

  • Quantization calibration set matches the deployment domain
  • Per-layer cosine similarity ≥ 0.98 between FP32 and INT8 (accuracy_analysis)
  • Post-processing identical between host and board (same NMS thresholds, same letterbox)
  • Colour order checked (RGB vs BGR) — this alone explains most "the model is broken" reports