Home

Awesome

XNNPACK

XNNPACK is a highly optimized solution for neural network inference on ARM, x86, WebAssembly, and RISC-V platforms. XNNPACK is not intended for direct use by deep learning practitioners and researchers; instead it provides low-level performance primitives for accelerating high-level machine learning frameworks, such as TensorFlow Lite, TensorFlow.js, PyTorch, ONNX Runtime, and MediaPipe.

Supported Architectures

Operator Coverage

XNNPACK implements the following neural network operators:

All operators in XNNPACK support NHWC layout, but additionally allow custom stride along the Channel dimension. Thus, operators can consume a subset of channels in the input tensor, and produce a subset of channels in the output tensor, providing a zero-cost Channel Split and Channel Concatenation operations.

Performance

Mobile phones

The table below presents single-threaded performance of XNNPACK library on three generations of MobileNet models and three generations of Pixel phones.

ModelPixel, msPixel 2, msPixel 3a, ms
FP32 MobileNet v1 1.0X828688
FP32 MobileNet v2 1.0X495355
FP32 MobileNet v3 Large394244
FP32 MobileNet v3 Small121414

The following table presents multi-threaded (using as many threads as there are big cores) performance of XNNPACK library on three generations of MobileNet models and three generations of Pixel phones.

ModelPixel, msPixel 2, msPixel 3a, ms
FP32 MobileNet v1 1.0X432746
FP32 MobileNet v2 1.0X261828
FP32 MobileNet v3 Large221624
FP32 MobileNet v3 Small768

Benchmarked on March 27, 2020 with end2end_bench --benchmark_min_time=5 on an Android/ARM64 build with Android NDK r21 (bazel build -c opt --config android_arm64 :end2end_bench) and neural network models with randomized weights and inputs.

Raspberry Pi

The table below presents multi-threaded performance of XNNPACK library on three generations of MobileNet models and three generations of Raspberry Pi boards.

ModelRPi Zero W (BCM2835), msRPi 2 (BCM2836), msRPi 3+ (BCM2837B0), msRPi 4 (BCM2711), msRPi 4 (BCM2711, ARM64), ms
FP32 MobileNet v1 1.0X39193021147277
FP32 MobileNet v2 1.0X1987191794146
FP32 MobileNet v3 Large1658161673840
FP32 MobileNet v3 Small47450221315
INT8 MobileNet v1 1.0X2589128462924
INT8 MobileNet v2 1.0X149582302017

Benchmarked on Feb 8, 2022 with end2end-bench --benchmark_min_time=5 on a Raspbian Buster build with CMake (./scripts/build-local.sh) and neural network models with randomized weights and inputs. INT8 inference was evaluated on per-channel quantization schema.

Minimum build requirements

Publications

Ecosystem

Machine Learning Frameworks

Acknowledgements

XNNPACK is a based on QNNPACK library. Over time its codebase diverged a lot, and XNNPACK API is no longer compatible with QNNPACK.