• Home
  • History
  • Annotate
Name Date Size #Lines LOC

..--

bench/23-Nov-2023-24,09519,529

cmake/23-Nov-2023-169141

eval/23-Nov-2023-14,41613,183

include/23-Nov-2023-2,2751,419

models/23-Nov-2023-36,35234,018

scripts/23-Nov-2023-4,5053,231

src/23-Nov-2023-809,286635,400

test/23-Nov-2023-587,333537,874

third_party/23-Nov-2023-999917

tools/23-Nov-2023-10,3669,027

.bazelrcD23-Nov-20231.3 KiB5239

.gitignoreD23-Nov-2023485 3532

Android.bpD23-Nov-2023155.1 KiB3,8913,785

BUILD.bazelD23-Nov-2023273 KiB7,6267,225

CMakeLists.txtD23-Nov-2023227 KiB5,1314,843

CONTRIBUTING.mdD23-Nov-20231.1 KiB2920

LICENSED23-Nov-20231.5 KiB3224

METADATAD23-Nov-2023738 2019

MODULE_LICENSE_BSDD23-Nov-20230

OWNERSD23-Nov-2023219 1211

README.mdD23-Nov-20236.2 KiB11589

TEST_MAPPINGD23-Nov-20231.9 KiB107106

WORKSPACED23-Nov-20233.2 KiB9278

build_defs.bzlD23-Nov-202316.6 KiB442411

emscripten.bzlD23-Nov-20231.1 KiB3833

preamble.js.ldsD23-Nov-2023393 108

README.md

1# XNNPACK
2
3XNNPACK is a highly optimized library of floating-point neural network inference operators for ARM, WebAssembly, and x86 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](https://www.tensorflow.org/lite), [TensorFlow.js](https://www.tensorflow.org/js), [PyTorch](https://pytorch.org/), and [MediaPipe](https://mediapipe.dev).
4
5## Supported Architectures
6
7- ARM64 on Android, Linux, macOS, and iOS (including WatchOS and tvOS)
8- ARMv7 (with NEON) on Android, Linux, and iOS (including WatchOS)
9- x86 and x86-64 (up to AVX512) on Windows, Linux, macOS, Android, and iOS simulator
10- WebAssembly MVP
11- WebAssembly SIMD (experimental)
12
13## Operator Coverage
14
15XNNPACK implements the following neural network operators:
16
17- 2D Convolution (including grouped and depthwise)
18- 2D Deconvolution (AKA Transposed Convolution)
19- 2D Average Pooling
20- 2D Max Pooling
21- 2D ArgMax Pooling (Max Pooling + indices)
22- 2D Unpooling
23- 2D Bilinear Resize
24- 2D Depth-to-Space (AKA Pixel Shuffle)
25- Add (including broadcasting, two inputs only)
26- Subtract (including broadcasting)
27- Divide (including broadcasting)
28- Maximum (including broadcasting)
29- Minimum (including broadcasting)
30- Multiply (including broadcasting)
31- Squared Difference (including broadcasting)
32- Global Average Pooling
33- Channel Shuffle
34- Fully Connected
35- Abs (absolute value)
36- Bankers' Rounding (rounding to nearest, ties to even)
37- Ceiling (rounding to integer above)
38- Clamp (includes ReLU and ReLU6)
39- Copy
40- ELU
41- Floor (rounding to integer below)
42- HardSwish
43- Leaky ReLU
44- Negate
45- Sigmoid
46- Softmax
47- Square
48- Truncation (rounding to integer towards zero)
49- PReLU
50
51All operators in XNNPACK support NHWC layout, but additionally allow custom stride along the **C**hannel 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.
52
53## Performance
54
55### Mobile phones
56
57The table below presents **single-threaded** performance of XNNPACK library on three generations of MobileNet models and three generations of Pixel phones.
58
59| Model              | Pixel, ms | Pixel 2, ms | Pixel 3a, ms |
60| ------------------ | :-------: | :---------: | :----------: |
61| MobileNet v1 1.0X  |    82     |      86     |      88      |
62| MobileNet v2 1.0X  |    49     |      53     |      55      |
63| MobileNet v3 Large |    39     |      42     |      44      |
64| MobileNet v3 Small |    12     |      14     |      14      |
65
66The 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.
67
68| Model              | Pixel, ms | Pixel 2, ms | Pixel 3a, ms |
69| ------------------ | :-------: | :---------: | :----------: |
70| MobileNet v1 1.0X  |    43     |      27     |      46      |
71| MobileNet v2 1.0X  |    26     |      18     |      28      |
72| MobileNet v3 Large |    22     |      16     |      24      |
73| MobileNet v3 Small |     7     |       6     |       8      |
74
75Benchmarked 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.
76
77### Raspberry Pi
78
79The table below presents **multi-threaded** performance of XNNPACK library on three generations of MobileNet models and three generations of Raspberry Pi boards.
80
81| Model              | RPi Zero W (BCM2835), ms | RPi 2 (BCM2836), ms | RPi 3+ (BCM2837B0), ms | RPi 4 (BCM2711), ms |
82| ------------------ | :----------------------: | :-----------------: | :--------------------: | :-----------------: |
83| MobileNet v1 1.0X  |          4004            |         337         |          116           |          72         |
84| MobileNet v2 1.0X  |          2011            |         195         |           83           |          41         |
85| MobileNet v3 Large |          1694            |         163         |           70           |          38         |
86| MobileNet v3 Small |           482            |          52         |           23           |          13         |
87
88Benchmarked on May 22, 2020 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.
89
90## Publications
91
92- Marat Dukhan "The Indirect Convolution Algorithm". Presented on [Efficient Deep Learning for Compute Vision (ECV) 2019](https://sites.google.com/corp/view/ecv2019/) workshop ([slides](https://drive.google.com/file/d/1ZayB3By5ZxxQIRtN7UDq_JvPg1IYd3Ac/view), [paper on ArXiv](https://arxiv.org/abs/1907.02129)).
93- Erich Elsen, Marat Dukhan, Trevor Gale, Karen Simonyan "Fast Sparse ConvNets".
94  [Paper on ArXiv](https://arxiv.org/abs/1911.09723), [pre-trained sparse
95  models](https://github.com/google-research/google-research/tree/master/fastconvnets).
96- Marat Dukhan, Artsiom Ablavatski "The Two-Pass Softmax Algorithm".
97  [Paper on ArXiv](https://arxiv.org/abs/2001.04438).
98- Yury Pisarchyk, Juhyun Lee "Efficient Memory Management for Deep Neural Net Inference".
99  [Paper on ArXiv](https://arxiv.org/abs/2001.03288).
100
101## Ecosystem
102
103### Machine Learning Frameworks
104
105- [TensorFlow Lite](https://blog.tensorflow.org/2020/07/accelerating-tensorflow-lite-xnnpack-integration.html).
106- [TensorFlow.js WebAssembly backend](https://blog.tensorflow.org/2020/03/introducing-webassembly-backend-for-tensorflow-js.html).
107- [PyTorch Mobile](https://pytorch.org/mobile).
108- [MediaPipe for the Web](https://developers.googleblog.com/2020/01/mediapipe-on-web.html).
109- [Alibaba HALO (Heterogeneity-Aware Lowering and Optimization)](https://github.com/alibaba/heterogeneity-aware-lowering-and-optimization)
110- [Samsung ONE (On-device Neural Engine)](https://github.com/Samsung/ONE)
111
112## Acknowledgements
113
114XNNPACK is a based on [QNNPACK](https://github.com/pytorch/QNNPACK) library. Over time its codebase diverged a lot, and XNNPACK API is no longer compatible with QNNPACK.
115