blob: 20d0ced20900418e3b8b029561193c2e043e65c8 [file] [log] [blame]
Jan Eilers31a7c892021-01-29 14:18:13 +00001/// Copyright (c) 2021 ARM Limited and Contributors. All rights reserved.
Ryan OSheaf3a43232020-02-12 16:15:27 +00002///
3/// SPDX-License-Identifier: MIT
4///
Ryan OSheaf3a43232020-02-12 16:15:27 +00005
6namespace armnn
7{
8/**
9@page parsers Parsers
10
11@tableofcontents
Jan Eilersb6578192021-01-28 09:13:24 +000012Execute models from different machine learning platforms efficiently with our parsers. Simply choose a parser according
13to the model you want to run e.g. If you've got a model in tensorflow format (<model_name>.pb) use our tensorflow-parser.
14
Jan Eilers31a7c892021-01-29 14:18:13 +000015If you would like to run a Tensorflow Lite (TfLite) model you probably also want to take a look at our [TfLite delegate](delegate).
16
17All parsers are written in C++ but it is also possible to use them in python. For more information on our python
18bindings take a look into the [PyArmNN](pyarmnn) section.
19
20Fallback mechanism
21
Ryan OSheaf3a43232020-02-12 16:15:27 +000022@section S4_caffe_parser ArmNN Caffe Parser
23
24`armnnCaffeParser` is a library for loading neural networks defined in Caffe protobuf files into the Arm NN runtime.
25
Jan Eilersb6578192021-01-28 09:13:24 +000026## Caffe layers supported by the Arm NN SDK
Ryan OSheaf3a43232020-02-12 16:15:27 +000027This reference guide provides a list of Caffe layers the Arm NN SDK currently supports.
28
29## Although some other neural networks might work, Arm tests the Arm NN SDK with Caffe implementations of the following neural networks:
30
31- AlexNet.
Ryan OShea2bbfaa72020-02-12 16:15:27 +000032- Cifar10.
Ryan OSheaf3a43232020-02-12 16:15:27 +000033- Inception-BN.
34- Resnet_50, Resnet_101 and Resnet_152.
35- VGG_CNN_S, VGG_16 and VGG_19.
36- Yolov1_tiny.
37- Lenet.
38- MobileNetv1.
James Ward590f3f72020-12-02 10:20:48 +000039- SqueezeNet v1.0 and SqueezeNet v1.1
Ryan OSheaf3a43232020-02-12 16:15:27 +000040
Ryan OSheaf3a43232020-02-12 16:15:27 +000041## The Arm NN SDK supports the following machine learning layers for Caffe networks:
42
43- BatchNorm, in inference mode.
44- Convolution, excluding the Dilation Size, Weight Filler, Bias Filler, Engine, Force nd_im2col, and Axis parameters.
45 Caffe doesn't support depthwise convolution, the equivalent layer is implemented through the notion of groups. ArmNN supports groups this way:
46 - when group=1, it is a normal conv2d
47 - when group=#input_channels, we can replace it by a depthwise convolution
48 - when group>1 && group<#input_channels, we need to split the input into the given number of groups, apply a separate convolution and then merge the results
49- Concat, along the channel dimension only.
50- Dropout, in inference mode.
51- Element wise, excluding the coefficient parameter.
52- Inner Product, excluding the Weight Filler, Bias Filler, Engine, and Axis parameters.
53- Input.
54- Local Response Normalisation (LRN), excluding the Engine parameter.
55- Pooling, excluding the Stochastic Pooling and Engine parameters.
56- ReLU.
57- Scale.
58- Softmax, excluding the Axis and Engine parameters.
59- Split.
60
61More machine learning layers will be supported in future releases.
62
63Please note that certain deprecated Caffe features are not supported by the armnnCaffeParser. If you think that Arm NN should be able to load your model according to the list of supported layers, but you are getting strange error messages, then try upgrading your model to the latest format using Caffe, either by saving it to a new file or using the upgrade utilities in `caffe/tools`.
64<br/><br/><br/><br/>
65
66@section S5_onnx_parser ArmNN Onnx Parser
67
68`armnnOnnxParser` is a library for loading neural networks defined in ONNX protobuf files into the Arm NN runtime.
69
70## ONNX operators that the Arm NN SDK supports
71
72This reference guide provides a list of ONNX operators the Arm NN SDK currently supports.
73
74The Arm NN SDK ONNX parser currently only supports fp32 operators.
75
76## Fully supported
77
78- Add
79 - See the ONNX [Add documentation](https://github.com/onnx/onnx/blob/master/docs/Operators.md#Add) for more information
Ryan OSheab23b9992020-04-23 15:45:04 +010080
Ryan OShea2bbfaa72020-02-12 16:15:27 +000081- AveragePool
Ryan OSheaf3a43232020-02-12 16:15:27 +000082 - See the ONNX [AveragePool documentation](https://github.com/onnx/onnx/blob/master/docs/Operators.md#AveragePool) for more information.
Ryan OSheab23b9992020-04-23 15:45:04 +010083
Ryan OSheaf3a43232020-02-12 16:15:27 +000084- Constant
85 - See the ONNX [Constant documentation](https://github.com/onnx/onnx/blob/master/docs/Operators.md#Constant) for more information.
Ryan OSheab23b9992020-04-23 15:45:04 +010086
87- Clip
88 - See the ONNX [Clip documentation](https://github.com/onnx/onnx/blob/master/docs/Operators.md#Clip) for more information.
89
90- Flatten
91 - See the ONNX [Flatten documentation](https://github.com/onnx/onnx/blob/master/docs/Operators.md#Flatten) for more information.
92
Ryan OSheaf3a43232020-02-12 16:15:27 +000093- GlobalAveragePool
94 - See the ONNX [GlobalAveragePool documentation](https://github.com/onnx/onnx/blob/master/docs/Operators.md#GlobalAveragePool) for more information.
Ryan OSheab23b9992020-04-23 15:45:04 +010095
96- LeakyRelu
97 - See the ONNX [LeakyRelu documentation](https://github.com/onnx/onnx/blob/master/docs/Operators.md#LeakyRelu) for more information.
98
Ryan OSheaf3a43232020-02-12 16:15:27 +000099- MaxPool
100 - See the ONNX [max_pool documentation](https://github.com/onnx/onnx/blob/master/docs/Operators.md#MaxPool) for more information.
Ryan OSheab23b9992020-04-23 15:45:04 +0100101
Ryan OSheaf3a43232020-02-12 16:15:27 +0000102- Relu
103 - See the ONNX [Relu documentation](https://github.com/onnx/onnx/blob/master/docs/Operators.md#Relu) for more information.
Ryan OSheab23b9992020-04-23 15:45:04 +0100104
Ryan OSheaf3a43232020-02-12 16:15:27 +0000105- Reshape
106 - See the ONNX [Reshape documentation](https://github.com/onnx/onnx/blob/master/docs/Operators.md#Reshape) for more information.
107
Ryan OSheab23b9992020-04-23 15:45:04 +0100108- Sigmoid
109 - See the ONNX [Sigmoid documentation](https://github.com/onnx/onnx/blob/master/docs/Operators.md#Sigmoid) for more information.
110
111- Tanh
112 - See the ONNX [Tanh documentation](https://github.com/onnx/onnx/blob/master/docs/Operators.md#Tanh) for more information.
113
114
Ryan OSheaf3a43232020-02-12 16:15:27 +0000115## Partially supported
116
117- Conv
118 - The parser only supports 2D convolutions with a dilation rate of [1, 1] and group = 1 or group = #Nb_of_channel (depthwise convolution)
119 See the ONNX [Conv documentation](https://github.com/onnx/onnx/blob/master/docs/Operators.md#Conv) for more information.
120- BatchNormalization
121 - The parser does not support training mode. See the ONNX [BatchNormalization documentation](https://github.com/onnx/onnx/blob/master/docs/Operators.md#BatchNormalization) for more information.
122- MatMul
123 - The parser only supports constant weights in a fully connected layer.
124
125## Tested networks
126
127Arm tested these operators with the following ONNX fp32 neural networks:
128- Simple MNIST. See the ONNX [MNIST documentation](https://github.com/onnx/models/tree/master/mnist) for more information.
129- Mobilenet_v2. See the ONNX [MobileNet documentation](https://github.com/onnx/models/tree/master/models/image_classification/mobilenet) for more information.
130
131More machine learning operators will be supported in future releases.
132<br/><br/><br/><br/>
133
134@section S6_tf_lite_parser ArmNN Tf Lite Parser
135
136`armnnTfLiteParser` is a library for loading neural networks defined by TensorFlow Lite FlatBuffers files
137into the Arm NN runtime.
138
139## TensorFlow Lite operators that the Arm NN SDK supports
140
141This reference guide provides a list of TensorFlow Lite operators the Arm NN SDK currently supports.
142
143## Fully supported
144
145The Arm NN SDK TensorFlow Lite parser currently supports the following operators:
146
147- ADD
148- AVERAGE_POOL_2D, Supported Fused Activation: RELU , RELU6 , TANH, NONE
149- BATCH_TO_SPACE
150- CONCATENATION, Supported Fused Activation: RELU , RELU6 , TANH, NONE
151- CONV_2D, Supported Fused Activation: RELU , RELU6 , TANH, NONE
152- DEPTHWISE_CONV_2D, Supported Fused Activation: RELU , RELU6 , TANH, NONE
James Ward590f3f72020-12-02 10:20:48 +0000153- DEQUANTIZE
Darshan Patel42b3d7d2020-05-25 22:30:07 +0530154- DIV
Ryan OSheaeb1f9cf2020-05-21 17:07:40 +0100155- EXP
Ryan OSheaf3a43232020-02-12 16:15:27 +0000156- FULLY_CONNECTED, Supported Fused Activation: RELU , RELU6 , TANH, NONE
157- LOGISTIC
158- L2_NORMALIZATION
Sadik Armagan12239e72020-05-27 11:06:17 +0100159- LEAKY_RELU
Ryan OSheaf3a43232020-02-12 16:15:27 +0000160- MAX_POOL_2D, Supported Fused Activation: RELU , RELU6 , TANH, NONE
161- MAXIMUM
162- MEAN
163- MINIMUM
164- MUL
Darshan Patel83fcf982020-05-26 22:22:42 +0530165- NEG
Ryan OSheaf3a43232020-02-12 16:15:27 +0000166- PACK
167- PAD
James Ward590f3f72020-12-02 10:20:48 +0000168- QUANTIZE
Ryan OSheaf3a43232020-02-12 16:15:27 +0000169- RELU
170- RELU6
171- RESHAPE
172- RESIZE_BILINEAR
James Ward590f3f72020-12-02 10:20:48 +0000173- RESIZE_NEAREST_NEIGHBOR
Ryan OSheaf3a43232020-02-12 16:15:27 +0000174- SLICE
175- SOFTMAX
176- SPACE_TO_BATCH
177- SPLIT
Ryan OShea86704732020-05-26 11:41:04 +0100178- SPLIT_V
Ryan OSheaf3a43232020-02-12 16:15:27 +0000179- SQUEEZE
180- STRIDED_SLICE
181- SUB
182- TANH
183- TRANSPOSE
184- TRANSPOSE_CONV
185- UNPACK
186
187## Custom Operator
188
189- TFLite_Detection_PostProcess
190
191## Tested networks
192
193Arm tested these operators with the following TensorFlow Lite neural network:
194- [Quantized MobileNet](http://download.tensorflow.org/models/mobilenet_v1_2018_02_22/mobilenet_v1_1.0_224_quant.tgz)
195- [Quantized SSD MobileNet](http://download.tensorflow.org/models/object_detection/ssd_mobilenet_v1_quantized_300x300_coco14_sync_2018_07_18.tar.gz)
196- DeepSpeech v1 converted from [TensorFlow model](https://github.com/mozilla/DeepSpeech/releases/tag/v0.4.1)
197- DeepSpeaker
James Ward590f3f72020-12-02 10:20:48 +0000198- [DeepLab v3+](https://www.tensorflow.org/lite/models/segmentation/overview)
199- FSRCNN
200- EfficientNet-lite
201- RDN converted from [TensorFlow model](https://github.com/hengchuan/RDN-TensorFlow)
202- Quantized RDN (CpuRef)
203- [Quantized Inception v3](http://download.tensorflow.org/models/tflite_11_05_08/inception_v3_quant.tgz)
204- [Quantized Inception v4](http://download.tensorflow.org/models/inception_v4_299_quant_20181026.tgz) (CpuRef)
205- Quantized ResNet v2 50 (CpuRef)
206- Quantized Yolo v3 (CpuRef)
Ryan OSheaf3a43232020-02-12 16:15:27 +0000207
208More machine learning operators will be supported in future releases.
209<br/><br/><br/><br/>
210
211@section S7_tf_parser ArmNN Tensorflow Parser
212
213`armnnTfParser` is a library for loading neural networks defined by TensorFlow protobuf files into the Arm NN runtime.
214
215## TensorFlow operators that the Arm NN SDK supports
216
217This reference guide provides a list of TensorFlow operators the Arm NN SDK currently supports.
218
219The Arm NN SDK TensorFlow parser currently only supports fp32 operators.
220
221## Fully supported
222
223- avg_pool
224 - See the TensorFlow [avg_pool documentation](https://www.tensorflow.org/api_docs/python/tf/nn/avg_pool) for more information.
225- bias_add
226 - See the TensorFlow [bias_add documentation](https://www.tensorflow.org/api_docs/python/tf/nn/bias_add) for more information.
227- conv2d
228 - See the TensorFlow [conv2d documentation](https://www.tensorflow.org/api_docs/python/tf/nn/conv2d) for more information.
229- expand_dims
230 - See the TensorFlow [expand_dims documentation](https://www.tensorflow.org/api_docs/python/tf/expand_dims) for more information.
231- gather
232 - See the TensorFlow [gather documentation](https://www.tensorflow.org/api_docs/python/tf/gather) for more information.
233- identity
234 - See the TensorFlow [identity documentation](https://www.tensorflow.org/api_docs/python/tf/identity) for more information.
235- local_response_normalization
236 - See the TensorFlow [local_response_normalization documentation](https://www.tensorflow.org/api_docs/python/tf/nn/local_response_normalization) for more information.
237- max_pool
238 - See the TensorFlow [max_pool documentation](https://www.tensorflow.org/api_docs/python/tf/nn/max_pool) for more information.
239- placeholder
240 - See the TensorFlow [placeholder documentation](https://www.tensorflow.org/api_docs/python/tf/placeholder) for more information.
241- reduce_mean
Ryan OShea2bbfaa72020-02-12 16:15:27 +0000242 - See the TensorFlow [reduce_mean documentation](https://www.tensorflow.org/api_docs/python/tf/reduce_mean) for more information.
Ryan OSheaf3a43232020-02-12 16:15:27 +0000243- relu
244 - See the TensorFlow [relu documentation](https://www.tensorflow.org/api_docs/python/tf/nn/relu) for more information.
245- relu6
246 - See the TensorFlow [relu6 documentation](https://www.tensorflow.org/api_docs/python/tf/nn/relu6) for more information.
247- rsqrt
248 - See the TensorFlow [rsqrt documentation](https://www.tensorflow.org/api_docs/python/tf/math/rsqrt) for more information.
249- shape
250 - See the TensorFlow [shape documentation](https://www.tensorflow.org/api_docs/python/tf/shape) for more information.
251- sigmoid
252 - See the TensorFlow [sigmoid documentation](https://www.tensorflow.org/api_docs/python/tf/sigmoid) for more information.
253- softplus
254 - See the TensorFlow [softplus documentation](https://www.tensorflow.org/api_docs/python/tf/nn/softplus) for more information.
255- squeeze
256 - See the TensorFlow [squeeze documentation](https://www.tensorflow.org/api_docs/python/tf/squeeze) for more information.
257- tanh
258 - See the TensorFlow [tanh documentation](https://www.tensorflow.org/api_docs/python/tf/tanh) for more information.
James Ward590f3f72020-12-02 10:20:48 +0000259- transpose
260 - See the TensorFlow [transpose documentation](https://www.tensorflow.org/api_docs/python/tf/transpose) for more information.
Ryan OSheaf3a43232020-02-12 16:15:27 +0000261
262## Partially supported
263
264- add
265 - The parser does not support all forms of [broadcast composition](https://www.tensorflow.org/performance/xla/broadcasting), only broadcasting of scalars and 1D tensors. See the TensorFlow [add operator documentation](https://www.tensorflow.org/api_docs/python/tf/add) for more information.
266- add_n
267 - The parser does not support all forms of [broadcast composition](https://www.tensorflow.org/performance/xla/broadcasting), only broadcasting of scalars and 1D tensors. See the TensorFlow [add operator documentation](https://www.tensorflow.org/api_docs/python/tf/add_n) for more information.
268- concat
269 - Arm NN supports concatenation along the channel dimension for data formats NHWC and NCHW.
270- constant
271 - The parser does not support the optional `shape` argument. It always infers the shape of the output tensor from `value`. See the TensorFlow [constant documentation](https://www.tensorflow.org/api_docs/python/tf/constant) for further information.
272- depthwise_conv2d_native
273 - The parser only supports a dilation rate of (1,1,1,1). See the TensorFlow [depthwise_conv2d_native documentation](https://www.tensorflow.org/api_docs/python/tf/nn/depthwise_conv2d_native) for more information.
274- equal
275 - The parser does not support all forms of [broadcast composition](https://www.tensorflow.org/performance/xla/broadcasting), only broadcasting of 4D and 1D tensors. See the TensorFlow [equal operator documentation](https://www.tensorflow.org/api_docs/python/tf/math/equal) for more information.
276- fused_batch_norm
277 - The parser does not support training outputs. See the TensorFlow [fused_batch_norm documentation](https://www.tensorflow.org/api_docs/python/tf/nn/fused_batch_norm) for more information.
278- greater
279 - The parser does not support all forms of [broadcast composition](https://www.tensorflow.org/performance/xla/broadcasting), only broadcasting of 4D and 1D tensors. See the TensorFlow [greater operator documentation](https://www.tensorflow.org/api_docs/python/tf/math/greater) for more information.
280- matmul
281 - The parser only supports constant weights in a fully connected layer. See the TensorFlow [matmul documentation](https://www.tensorflow.org/api_docs/python/tf/matmul) for more information.
282- maximum
283 where maximum is used in one of the following ways
284 - max(mul(a, x), x)
285 - max(mul(x, a), x)
286 - max(x, mul(a, x))
287 - max(x, mul(x, a)
288 This is interpreted as a ActivationLayer with a LeakyRelu activation function. Any other usage of max will result in the insertion of a simple maximum layer. The parser does not support all forms of [broadcast composition](https://www.tensorflow.org/performance/xla/broadcasting). See the TensorFlow [maximum documentation](https://www.tensorflow.org/api_docs/python/tf/maximum) for more information.
289- minimum
290 - The parser does not support all forms of [broadcast composition](https://www.tensorflow.org/performance/xla/broadcasting), only broadcasting of 4D and 1D tensors. See the TensorFlow [minimum operator documentation](https://www.tensorflow.org/api_docs/python/tf/math/minimum) for more information.
291- multiply
292 - The parser does not support all forms of [broadcast composition](https://www.tensorflow.org/performance/xla/broadcasting), only broadcasting of scalars and 1D tensors. See the TensorFlow [multiply documentation](https://www.tensorflow.org/api_docs/python/tf/multiply) for more information.
James Ward590f3f72020-12-02 10:20:48 +0000293- pack/stack
294 - See the TensorFlow [stack documentation](https://www.tensorflow.org/api_docs/python/tf/stack) for more information.
Ryan OSheaf3a43232020-02-12 16:15:27 +0000295- pad
296 - Only supports tf.pad function with mode = 'CONSTANT' and constant_values = 0. See the TensorFlow [pad documentation](https://www.tensorflow.org/api_docs/python/tf/pad) for more information.
297- realdiv
298 - The parser does not support all forms of [broadcast composition](https://www.tensorflow.org/performance/xla/broadcasting), only broadcasting of scalars and 1D tensors. See the TensorFlow [realdiv documentation](https://www.tensorflow.org/api_docs/python/tf/realdiv) for more information.
299- reshape
300 - The parser does not support reshaping to or from 4D. See the TensorFlow [reshape documentation](https://www.tensorflow.org/api_docs/python/tf/reshape) for more information.
301- resize_images
302 - The parser only supports `ResizeMethod.BILINEAR` with `align_corners=False`. See the TensorFlow [resize_images documentation](https://www.tensorflow.org/api_docs/python/tf/image/resize_images) for more information.
303- softmax
304 - The parser only supports 2D inputs and does not support selecting the `softmax` dimension. See the TensorFlow [softmax documentation](https://www.tensorflow.org/api_docs/python/tf/nn/softmax) for more information.
305- split
306 - Arm NN supports split along the channel dimension for data formats NHWC and NCHW.
James Ward590f3f72020-12-02 10:20:48 +0000307- strided_slice
308 - See the TensorFlow [strided_slice documentation](https://www.tensorflow.org/api_docs/python/tf/strided_slice) for more information.
Ryan OSheaf3a43232020-02-12 16:15:27 +0000309- subtract
310 - The parser does not support all forms of broadcasting [broadcast composition](https://www.tensorflow.org/performance/xla/broadcasting), only broadcasting of scalars and 1D tensors. See the TensorFlow [subtract documentation](https://www.tensorflow.org/api_docs/python/tf/math/subtract) for more information.
311
James Ward590f3f72020-12-02 10:20:48 +0000312
Ryan OSheaf3a43232020-02-12 16:15:27 +0000313## Tested networks
314
315Arm tests these operators with the following TensorFlow fp32 neural networks:
316- Lenet
317- mobilenet_v1_1.0_224. The Arm NN SDK only supports the non-quantized version of the network. See the [MobileNet_v1 documentation](https://github.com/tensorflow/models/blob/master/research/slim/nets/mobilenet_v1.md) for more information on quantized networks.
318- inception_v3. The Arm NN SDK only supports the official inception_v3 transformed model. See the TensorFlow documentation on [preparing models for mobile deployment](https://www.tensorflow.org/mobile/prepare_models) for more information on how to transform the inception_v3 network.
319
320Using these datasets:
321- Cifar10
322- Simple MNIST. For more information check out the [tutorial](https://developer.arm.com/technologies/machine-learning-on-arm/developer-material/how-to-guides/deploying-a-tensorflow-mnist-model-on-arm-nn) on the Arm Developer portal.
323
324More machine learning operators will be supported in future releases.
325
326**/
327}
Ryan OShea2bbfaa72020-02-12 16:15:27 +0000328