blob: 80d616f5e718908a64d600cd7af9852f4ed694ca [file] [log] [blame]
Ryan OShea2bbfaa72020-02-12 16:15:27 +00001/// Copyright (c) 2020 ARM Limited.
Ryan OSheaf3a43232020-02-12 16:15:27 +00002///
3/// SPDX-License-Identifier: MIT
4///
5/// Permission is hereby granted, free of charge, to any person obtaining a copy
6/// of this software and associated documentation files (the "Software"), to deal
7/// in the Software without restriction, including without limitation the rights
8/// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9/// copies of the Software, and to permit persons to whom the Software is
10/// furnished to do so, subject to the following conditions:
11///
12/// The above copyright notice and this permission notice shall be included in all
13/// copies or substantial portions of the Software.
14///
15/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17/// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18/// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21/// SOFTWARE.
22///
23
24namespace armnn
25{
26/**
27@page parsers Parsers
28
29@tableofcontents
Jan Eilersb6578192021-01-28 09:13:24 +000030Execute models from different machine learning platforms efficiently with our parsers. Simply choose a parser according
31to the model you want to run e.g. If you've got a model in tensorflow format (<model_name>.pb) use our tensorflow-parser.
32
Ryan OSheaf3a43232020-02-12 16:15:27 +000033@section S4_caffe_parser ArmNN Caffe Parser
34
35`armnnCaffeParser` is a library for loading neural networks defined in Caffe protobuf files into the Arm NN runtime.
36
Jan Eilersb6578192021-01-28 09:13:24 +000037## Caffe layers supported by the Arm NN SDK
Ryan OSheaf3a43232020-02-12 16:15:27 +000038This reference guide provides a list of Caffe layers the Arm NN SDK currently supports.
39
40## Although some other neural networks might work, Arm tests the Arm NN SDK with Caffe implementations of the following neural networks:
41
42- AlexNet.
Ryan OShea2bbfaa72020-02-12 16:15:27 +000043- Cifar10.
Ryan OSheaf3a43232020-02-12 16:15:27 +000044- Inception-BN.
45- Resnet_50, Resnet_101 and Resnet_152.
46- VGG_CNN_S, VGG_16 and VGG_19.
47- Yolov1_tiny.
48- Lenet.
49- MobileNetv1.
James Ward590f3f72020-12-02 10:20:48 +000050- SqueezeNet v1.0 and SqueezeNet v1.1
Ryan OSheaf3a43232020-02-12 16:15:27 +000051
Ryan OSheaf3a43232020-02-12 16:15:27 +000052## The Arm NN SDK supports the following machine learning layers for Caffe networks:
53
54- BatchNorm, in inference mode.
55- Convolution, excluding the Dilation Size, Weight Filler, Bias Filler, Engine, Force nd_im2col, and Axis parameters.
56 Caffe doesn't support depthwise convolution, the equivalent layer is implemented through the notion of groups. ArmNN supports groups this way:
57 - when group=1, it is a normal conv2d
58 - when group=#input_channels, we can replace it by a depthwise convolution
59 - 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
60- Concat, along the channel dimension only.
61- Dropout, in inference mode.
62- Element wise, excluding the coefficient parameter.
63- Inner Product, excluding the Weight Filler, Bias Filler, Engine, and Axis parameters.
64- Input.
65- Local Response Normalisation (LRN), excluding the Engine parameter.
66- Pooling, excluding the Stochastic Pooling and Engine parameters.
67- ReLU.
68- Scale.
69- Softmax, excluding the Axis and Engine parameters.
70- Split.
71
72More machine learning layers will be supported in future releases.
73
74Please 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`.
75<br/><br/><br/><br/>
76
77@section S5_onnx_parser ArmNN Onnx Parser
78
79`armnnOnnxParser` is a library for loading neural networks defined in ONNX protobuf files into the Arm NN runtime.
80
81## ONNX operators that the Arm NN SDK supports
82
83This reference guide provides a list of ONNX operators the Arm NN SDK currently supports.
84
85The Arm NN SDK ONNX parser currently only supports fp32 operators.
86
87## Fully supported
88
89- Add
90 - 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 +010091
Ryan OShea2bbfaa72020-02-12 16:15:27 +000092- AveragePool
Ryan OSheaf3a43232020-02-12 16:15:27 +000093 - 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 +010094
Ryan OSheaf3a43232020-02-12 16:15:27 +000095- Constant
96 - 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 +010097
98- Clip
99 - See the ONNX [Clip documentation](https://github.com/onnx/onnx/blob/master/docs/Operators.md#Clip) for more information.
100
101- Flatten
102 - See the ONNX [Flatten documentation](https://github.com/onnx/onnx/blob/master/docs/Operators.md#Flatten) for more information.
103
Ryan OSheaf3a43232020-02-12 16:15:27 +0000104- GlobalAveragePool
105 - 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 +0100106
107- LeakyRelu
108 - See the ONNX [LeakyRelu documentation](https://github.com/onnx/onnx/blob/master/docs/Operators.md#LeakyRelu) for more information.
109
Ryan OSheaf3a43232020-02-12 16:15:27 +0000110- MaxPool
111 - 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 +0100112
Ryan OSheaf3a43232020-02-12 16:15:27 +0000113- Relu
114 - 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 +0100115
Ryan OSheaf3a43232020-02-12 16:15:27 +0000116- Reshape
117 - See the ONNX [Reshape documentation](https://github.com/onnx/onnx/blob/master/docs/Operators.md#Reshape) for more information.
118
Ryan OSheab23b9992020-04-23 15:45:04 +0100119- Sigmoid
120 - See the ONNX [Sigmoid documentation](https://github.com/onnx/onnx/blob/master/docs/Operators.md#Sigmoid) for more information.
121
122- Tanh
123 - See the ONNX [Tanh documentation](https://github.com/onnx/onnx/blob/master/docs/Operators.md#Tanh) for more information.
124
125
Ryan OSheaf3a43232020-02-12 16:15:27 +0000126## Partially supported
127
128- Conv
129 - The parser only supports 2D convolutions with a dilation rate of [1, 1] and group = 1 or group = #Nb_of_channel (depthwise convolution)
130 See the ONNX [Conv documentation](https://github.com/onnx/onnx/blob/master/docs/Operators.md#Conv) for more information.
131- BatchNormalization
132 - 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.
133- MatMul
134 - The parser only supports constant weights in a fully connected layer.
135
136## Tested networks
137
138Arm tested these operators with the following ONNX fp32 neural networks:
139- Simple MNIST. See the ONNX [MNIST documentation](https://github.com/onnx/models/tree/master/mnist) for more information.
140- Mobilenet_v2. See the ONNX [MobileNet documentation](https://github.com/onnx/models/tree/master/models/image_classification/mobilenet) for more information.
141
142More machine learning operators will be supported in future releases.
143<br/><br/><br/><br/>
144
145@section S6_tf_lite_parser ArmNN Tf Lite Parser
146
147`armnnTfLiteParser` is a library for loading neural networks defined by TensorFlow Lite FlatBuffers files
148into the Arm NN runtime.
149
150## TensorFlow Lite operators that the Arm NN SDK supports
151
152This reference guide provides a list of TensorFlow Lite operators the Arm NN SDK currently supports.
153
154## Fully supported
155
156The Arm NN SDK TensorFlow Lite parser currently supports the following operators:
157
158- ADD
159- AVERAGE_POOL_2D, Supported Fused Activation: RELU , RELU6 , TANH, NONE
160- BATCH_TO_SPACE
161- CONCATENATION, Supported Fused Activation: RELU , RELU6 , TANH, NONE
162- CONV_2D, Supported Fused Activation: RELU , RELU6 , TANH, NONE
163- DEPTHWISE_CONV_2D, Supported Fused Activation: RELU , RELU6 , TANH, NONE
James Ward590f3f72020-12-02 10:20:48 +0000164- DEQUANTIZE
Darshan Patel42b3d7d2020-05-25 22:30:07 +0530165- DIV
Ryan OSheaeb1f9cf2020-05-21 17:07:40 +0100166- EXP
Ryan OSheaf3a43232020-02-12 16:15:27 +0000167- FULLY_CONNECTED, Supported Fused Activation: RELU , RELU6 , TANH, NONE
168- LOGISTIC
169- L2_NORMALIZATION
Sadik Armagan12239e72020-05-27 11:06:17 +0100170- LEAKY_RELU
Ryan OSheaf3a43232020-02-12 16:15:27 +0000171- MAX_POOL_2D, Supported Fused Activation: RELU , RELU6 , TANH, NONE
172- MAXIMUM
173- MEAN
174- MINIMUM
175- MUL
Darshan Patel83fcf982020-05-26 22:22:42 +0530176- NEG
Ryan OSheaf3a43232020-02-12 16:15:27 +0000177- PACK
178- PAD
James Ward590f3f72020-12-02 10:20:48 +0000179- QUANTIZE
Ryan OSheaf3a43232020-02-12 16:15:27 +0000180- RELU
181- RELU6
182- RESHAPE
183- RESIZE_BILINEAR
James Ward590f3f72020-12-02 10:20:48 +0000184- RESIZE_NEAREST_NEIGHBOR
Ryan OSheaf3a43232020-02-12 16:15:27 +0000185- SLICE
186- SOFTMAX
187- SPACE_TO_BATCH
188- SPLIT
Ryan OShea86704732020-05-26 11:41:04 +0100189- SPLIT_V
Ryan OSheaf3a43232020-02-12 16:15:27 +0000190- SQUEEZE
191- STRIDED_SLICE
192- SUB
193- TANH
194- TRANSPOSE
195- TRANSPOSE_CONV
196- UNPACK
197
198## Custom Operator
199
200- TFLite_Detection_PostProcess
201
202## Tested networks
203
204Arm tested these operators with the following TensorFlow Lite neural network:
205- [Quantized MobileNet](http://download.tensorflow.org/models/mobilenet_v1_2018_02_22/mobilenet_v1_1.0_224_quant.tgz)
206- [Quantized SSD MobileNet](http://download.tensorflow.org/models/object_detection/ssd_mobilenet_v1_quantized_300x300_coco14_sync_2018_07_18.tar.gz)
207- DeepSpeech v1 converted from [TensorFlow model](https://github.com/mozilla/DeepSpeech/releases/tag/v0.4.1)
208- DeepSpeaker
James Ward590f3f72020-12-02 10:20:48 +0000209- [DeepLab v3+](https://www.tensorflow.org/lite/models/segmentation/overview)
210- FSRCNN
211- EfficientNet-lite
212- RDN converted from [TensorFlow model](https://github.com/hengchuan/RDN-TensorFlow)
213- Quantized RDN (CpuRef)
214- [Quantized Inception v3](http://download.tensorflow.org/models/tflite_11_05_08/inception_v3_quant.tgz)
215- [Quantized Inception v4](http://download.tensorflow.org/models/inception_v4_299_quant_20181026.tgz) (CpuRef)
216- Quantized ResNet v2 50 (CpuRef)
217- Quantized Yolo v3 (CpuRef)
Ryan OSheaf3a43232020-02-12 16:15:27 +0000218
219More machine learning operators will be supported in future releases.
220<br/><br/><br/><br/>
221
222@section S7_tf_parser ArmNN Tensorflow Parser
223
224`armnnTfParser` is a library for loading neural networks defined by TensorFlow protobuf files into the Arm NN runtime.
225
226## TensorFlow operators that the Arm NN SDK supports
227
228This reference guide provides a list of TensorFlow operators the Arm NN SDK currently supports.
229
230The Arm NN SDK TensorFlow parser currently only supports fp32 operators.
231
232## Fully supported
233
234- avg_pool
235 - See the TensorFlow [avg_pool documentation](https://www.tensorflow.org/api_docs/python/tf/nn/avg_pool) for more information.
236- bias_add
237 - See the TensorFlow [bias_add documentation](https://www.tensorflow.org/api_docs/python/tf/nn/bias_add) for more information.
238- conv2d
239 - See the TensorFlow [conv2d documentation](https://www.tensorflow.org/api_docs/python/tf/nn/conv2d) for more information.
240- expand_dims
241 - See the TensorFlow [expand_dims documentation](https://www.tensorflow.org/api_docs/python/tf/expand_dims) for more information.
242- gather
243 - See the TensorFlow [gather documentation](https://www.tensorflow.org/api_docs/python/tf/gather) for more information.
244- identity
245 - See the TensorFlow [identity documentation](https://www.tensorflow.org/api_docs/python/tf/identity) for more information.
246- local_response_normalization
247 - See the TensorFlow [local_response_normalization documentation](https://www.tensorflow.org/api_docs/python/tf/nn/local_response_normalization) for more information.
248- max_pool
249 - See the TensorFlow [max_pool documentation](https://www.tensorflow.org/api_docs/python/tf/nn/max_pool) for more information.
250- placeholder
251 - See the TensorFlow [placeholder documentation](https://www.tensorflow.org/api_docs/python/tf/placeholder) for more information.
252- reduce_mean
Ryan OShea2bbfaa72020-02-12 16:15:27 +0000253 - 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 +0000254- relu
255 - See the TensorFlow [relu documentation](https://www.tensorflow.org/api_docs/python/tf/nn/relu) for more information.
256- relu6
257 - See the TensorFlow [relu6 documentation](https://www.tensorflow.org/api_docs/python/tf/nn/relu6) for more information.
258- rsqrt
259 - See the TensorFlow [rsqrt documentation](https://www.tensorflow.org/api_docs/python/tf/math/rsqrt) for more information.
260- shape
261 - See the TensorFlow [shape documentation](https://www.tensorflow.org/api_docs/python/tf/shape) for more information.
262- sigmoid
263 - See the TensorFlow [sigmoid documentation](https://www.tensorflow.org/api_docs/python/tf/sigmoid) for more information.
264- softplus
265 - See the TensorFlow [softplus documentation](https://www.tensorflow.org/api_docs/python/tf/nn/softplus) for more information.
266- squeeze
267 - See the TensorFlow [squeeze documentation](https://www.tensorflow.org/api_docs/python/tf/squeeze) for more information.
268- tanh
269 - See the TensorFlow [tanh documentation](https://www.tensorflow.org/api_docs/python/tf/tanh) for more information.
James Ward590f3f72020-12-02 10:20:48 +0000270- transpose
271 - See the TensorFlow [transpose documentation](https://www.tensorflow.org/api_docs/python/tf/transpose) for more information.
Ryan OSheaf3a43232020-02-12 16:15:27 +0000272
273## Partially supported
274
275- add
276 - 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.
277- add_n
278 - 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.
279- concat
280 - Arm NN supports concatenation along the channel dimension for data formats NHWC and NCHW.
281- constant
282 - 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.
283- depthwise_conv2d_native
284 - 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.
285- equal
286 - 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.
287- fused_batch_norm
288 - 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.
289- greater
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 [greater operator documentation](https://www.tensorflow.org/api_docs/python/tf/math/greater) for more information.
291- matmul
292 - 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.
293- maximum
294 where maximum is used in one of the following ways
295 - max(mul(a, x), x)
296 - max(mul(x, a), x)
297 - max(x, mul(a, x))
298 - max(x, mul(x, a)
299 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.
300- minimum
301 - 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.
302- multiply
303 - 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 +0000304- pack/stack
305 - See the TensorFlow [stack documentation](https://www.tensorflow.org/api_docs/python/tf/stack) for more information.
Ryan OSheaf3a43232020-02-12 16:15:27 +0000306- pad
307 - 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.
308- realdiv
309 - 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.
310- reshape
311 - 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.
312- resize_images
313 - 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.
314- softmax
315 - 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.
316- split
317 - Arm NN supports split along the channel dimension for data formats NHWC and NCHW.
James Ward590f3f72020-12-02 10:20:48 +0000318- strided_slice
319 - 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 +0000320- subtract
321 - 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.
322
James Ward590f3f72020-12-02 10:20:48 +0000323
Ryan OSheaf3a43232020-02-12 16:15:27 +0000324## Tested networks
325
326Arm tests these operators with the following TensorFlow fp32 neural networks:
327- Lenet
328- 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.
329- 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.
330
331Using these datasets:
332- Cifar10
333- 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.
334
335More machine learning operators will be supported in future releases.
336
337**/
338}
Ryan OShea2bbfaa72020-02-12 16:15:27 +0000339