blob: 1af2503f88957c9bbcfe647c94e9254611b273ed [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
30@section S4_caffe_parser ArmNN Caffe Parser
31
32`armnnCaffeParser` is a library for loading neural networks defined in Caffe protobuf files into the Arm NN runtime.
33
34##Caffe layers supported by the Arm NN SDK
35This reference guide provides a list of Caffe layers the Arm NN SDK currently supports.
36
37## Although some other neural networks might work, Arm tests the Arm NN SDK with Caffe implementations of the following neural networks:
38
39- AlexNet.
Ryan OShea2bbfaa72020-02-12 16:15:27 +000040- Cifar10.
Ryan OSheaf3a43232020-02-12 16:15:27 +000041- Inception-BN.
42- Resnet_50, Resnet_101 and Resnet_152.
43- VGG_CNN_S, VGG_16 and VGG_19.
44- Yolov1_tiny.
45- Lenet.
46- MobileNetv1.
James Ward590f3f72020-12-02 10:20:48 +000047- SqueezeNet v1.0 and SqueezeNet v1.1
Ryan OSheaf3a43232020-02-12 16:15:27 +000048
Ryan OSheaf3a43232020-02-12 16:15:27 +000049## The Arm NN SDK supports the following machine learning layers for Caffe networks:
50
51- BatchNorm, in inference mode.
52- Convolution, excluding the Dilation Size, Weight Filler, Bias Filler, Engine, Force nd_im2col, and Axis parameters.
53 Caffe doesn't support depthwise convolution, the equivalent layer is implemented through the notion of groups. ArmNN supports groups this way:
54 - when group=1, it is a normal conv2d
55 - when group=#input_channels, we can replace it by a depthwise convolution
56 - 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
57- Concat, along the channel dimension only.
58- Dropout, in inference mode.
59- Element wise, excluding the coefficient parameter.
60- Inner Product, excluding the Weight Filler, Bias Filler, Engine, and Axis parameters.
61- Input.
62- Local Response Normalisation (LRN), excluding the Engine parameter.
63- Pooling, excluding the Stochastic Pooling and Engine parameters.
64- ReLU.
65- Scale.
66- Softmax, excluding the Axis and Engine parameters.
67- Split.
68
69More machine learning layers will be supported in future releases.
70
71Please 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`.
72<br/><br/><br/><br/>
73
74@section S5_onnx_parser ArmNN Onnx Parser
75
76`armnnOnnxParser` is a library for loading neural networks defined in ONNX protobuf files into the Arm NN runtime.
77
78## ONNX operators that the Arm NN SDK supports
79
80This reference guide provides a list of ONNX operators the Arm NN SDK currently supports.
81
82The Arm NN SDK ONNX parser currently only supports fp32 operators.
83
84## Fully supported
85
86- Add
87 - 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 +010088
Ryan OShea2bbfaa72020-02-12 16:15:27 +000089- AveragePool
Ryan OSheaf3a43232020-02-12 16:15:27 +000090 - 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 +010091
Ryan OSheaf3a43232020-02-12 16:15:27 +000092- Constant
93 - 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 +010094
95- Clip
96 - See the ONNX [Clip documentation](https://github.com/onnx/onnx/blob/master/docs/Operators.md#Clip) for more information.
97
98- Flatten
99 - See the ONNX [Flatten documentation](https://github.com/onnx/onnx/blob/master/docs/Operators.md#Flatten) for more information.
100
Ryan OSheaf3a43232020-02-12 16:15:27 +0000101- GlobalAveragePool
102 - 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 +0100103
104- LeakyRelu
105 - See the ONNX [LeakyRelu documentation](https://github.com/onnx/onnx/blob/master/docs/Operators.md#LeakyRelu) for more information.
106
Ryan OSheaf3a43232020-02-12 16:15:27 +0000107- MaxPool
108 - 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 +0100109
Ryan OSheaf3a43232020-02-12 16:15:27 +0000110- Relu
111 - 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 +0100112
Ryan OSheaf3a43232020-02-12 16:15:27 +0000113- Reshape
114 - See the ONNX [Reshape documentation](https://github.com/onnx/onnx/blob/master/docs/Operators.md#Reshape) for more information.
115
Ryan OSheab23b9992020-04-23 15:45:04 +0100116- Sigmoid
117 - See the ONNX [Sigmoid documentation](https://github.com/onnx/onnx/blob/master/docs/Operators.md#Sigmoid) for more information.
118
119- Tanh
120 - See the ONNX [Tanh documentation](https://github.com/onnx/onnx/blob/master/docs/Operators.md#Tanh) for more information.
121
122
Ryan OSheaf3a43232020-02-12 16:15:27 +0000123## Partially supported
124
125- Conv
126 - The parser only supports 2D convolutions with a dilation rate of [1, 1] and group = 1 or group = #Nb_of_channel (depthwise convolution)
127 See the ONNX [Conv documentation](https://github.com/onnx/onnx/blob/master/docs/Operators.md#Conv) for more information.
128- BatchNormalization
129 - 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.
130- MatMul
131 - The parser only supports constant weights in a fully connected layer.
132
133## Tested networks
134
135Arm tested these operators with the following ONNX fp32 neural networks:
136- Simple MNIST. See the ONNX [MNIST documentation](https://github.com/onnx/models/tree/master/mnist) for more information.
137- Mobilenet_v2. See the ONNX [MobileNet documentation](https://github.com/onnx/models/tree/master/models/image_classification/mobilenet) for more information.
138
139More machine learning operators will be supported in future releases.
140<br/><br/><br/><br/>
141
142@section S6_tf_lite_parser ArmNN Tf Lite Parser
143
144`armnnTfLiteParser` is a library for loading neural networks defined by TensorFlow Lite FlatBuffers files
145into the Arm NN runtime.
146
147## TensorFlow Lite operators that the Arm NN SDK supports
148
149This reference guide provides a list of TensorFlow Lite operators the Arm NN SDK currently supports.
150
151## Fully supported
152
153The Arm NN SDK TensorFlow Lite parser currently supports the following operators:
154
155- ADD
156- AVERAGE_POOL_2D, Supported Fused Activation: RELU , RELU6 , TANH, NONE
157- BATCH_TO_SPACE
158- CONCATENATION, Supported Fused Activation: RELU , RELU6 , TANH, NONE
159- CONV_2D, Supported Fused Activation: RELU , RELU6 , TANH, NONE
160- DEPTHWISE_CONV_2D, Supported Fused Activation: RELU , RELU6 , TANH, NONE
James Ward590f3f72020-12-02 10:20:48 +0000161- DEQUANTIZE
Darshan Patel42b3d7d2020-05-25 22:30:07 +0530162- DIV
Ryan OSheaeb1f9cf2020-05-21 17:07:40 +0100163- EXP
Ryan OSheaf3a43232020-02-12 16:15:27 +0000164- FULLY_CONNECTED, Supported Fused Activation: RELU , RELU6 , TANH, NONE
165- LOGISTIC
166- L2_NORMALIZATION
Sadik Armagan12239e72020-05-27 11:06:17 +0100167- LEAKY_RELU
Ryan OSheaf3a43232020-02-12 16:15:27 +0000168- MAX_POOL_2D, Supported Fused Activation: RELU , RELU6 , TANH, NONE
169- MAXIMUM
170- MEAN
171- MINIMUM
172- MUL
Darshan Patel83fcf982020-05-26 22:22:42 +0530173- NEG
Ryan OSheaf3a43232020-02-12 16:15:27 +0000174- PACK
175- PAD
James Ward590f3f72020-12-02 10:20:48 +0000176- QUANTIZE
Ryan OSheaf3a43232020-02-12 16:15:27 +0000177- RELU
178- RELU6
179- RESHAPE
180- RESIZE_BILINEAR
James Ward590f3f72020-12-02 10:20:48 +0000181- RESIZE_NEAREST_NEIGHBOR
Ryan OSheaf3a43232020-02-12 16:15:27 +0000182- SLICE
183- SOFTMAX
184- SPACE_TO_BATCH
185- SPLIT
Ryan OShea86704732020-05-26 11:41:04 +0100186- SPLIT_V
Ryan OSheaf3a43232020-02-12 16:15:27 +0000187- SQUEEZE
188- STRIDED_SLICE
189- SUB
190- TANH
191- TRANSPOSE
192- TRANSPOSE_CONV
193- UNPACK
194
195## Custom Operator
196
197- TFLite_Detection_PostProcess
198
199## Tested networks
200
201Arm tested these operators with the following TensorFlow Lite neural network:
202- [Quantized MobileNet](http://download.tensorflow.org/models/mobilenet_v1_2018_02_22/mobilenet_v1_1.0_224_quant.tgz)
203- [Quantized SSD MobileNet](http://download.tensorflow.org/models/object_detection/ssd_mobilenet_v1_quantized_300x300_coco14_sync_2018_07_18.tar.gz)
204- DeepSpeech v1 converted from [TensorFlow model](https://github.com/mozilla/DeepSpeech/releases/tag/v0.4.1)
205- DeepSpeaker
James Ward590f3f72020-12-02 10:20:48 +0000206- [DeepLab v3+](https://www.tensorflow.org/lite/models/segmentation/overview)
207- FSRCNN
208- EfficientNet-lite
209- RDN converted from [TensorFlow model](https://github.com/hengchuan/RDN-TensorFlow)
210- Quantized RDN (CpuRef)
211- [Quantized Inception v3](http://download.tensorflow.org/models/tflite_11_05_08/inception_v3_quant.tgz)
212- [Quantized Inception v4](http://download.tensorflow.org/models/inception_v4_299_quant_20181026.tgz) (CpuRef)
213- Quantized ResNet v2 50 (CpuRef)
214- Quantized Yolo v3 (CpuRef)
Ryan OSheaf3a43232020-02-12 16:15:27 +0000215
216More machine learning operators will be supported in future releases.
217<br/><br/><br/><br/>
218
219@section S7_tf_parser ArmNN Tensorflow Parser
220
221`armnnTfParser` is a library for loading neural networks defined by TensorFlow protobuf files into the Arm NN runtime.
222
223## TensorFlow operators that the Arm NN SDK supports
224
225This reference guide provides a list of TensorFlow operators the Arm NN SDK currently supports.
226
227The Arm NN SDK TensorFlow parser currently only supports fp32 operators.
228
229## Fully supported
230
231- avg_pool
232 - See the TensorFlow [avg_pool documentation](https://www.tensorflow.org/api_docs/python/tf/nn/avg_pool) for more information.
233- bias_add
234 - See the TensorFlow [bias_add documentation](https://www.tensorflow.org/api_docs/python/tf/nn/bias_add) for more information.
235- conv2d
236 - See the TensorFlow [conv2d documentation](https://www.tensorflow.org/api_docs/python/tf/nn/conv2d) for more information.
237- expand_dims
238 - See the TensorFlow [expand_dims documentation](https://www.tensorflow.org/api_docs/python/tf/expand_dims) for more information.
239- gather
240 - See the TensorFlow [gather documentation](https://www.tensorflow.org/api_docs/python/tf/gather) for more information.
241- identity
242 - See the TensorFlow [identity documentation](https://www.tensorflow.org/api_docs/python/tf/identity) for more information.
243- local_response_normalization
244 - See the TensorFlow [local_response_normalization documentation](https://www.tensorflow.org/api_docs/python/tf/nn/local_response_normalization) for more information.
245- max_pool
246 - See the TensorFlow [max_pool documentation](https://www.tensorflow.org/api_docs/python/tf/nn/max_pool) for more information.
247- placeholder
248 - See the TensorFlow [placeholder documentation](https://www.tensorflow.org/api_docs/python/tf/placeholder) for more information.
249- reduce_mean
Ryan OShea2bbfaa72020-02-12 16:15:27 +0000250 - 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 +0000251- relu
252 - See the TensorFlow [relu documentation](https://www.tensorflow.org/api_docs/python/tf/nn/relu) for more information.
253- relu6
254 - See the TensorFlow [relu6 documentation](https://www.tensorflow.org/api_docs/python/tf/nn/relu6) for more information.
255- rsqrt
256 - See the TensorFlow [rsqrt documentation](https://www.tensorflow.org/api_docs/python/tf/math/rsqrt) for more information.
257- shape
258 - See the TensorFlow [shape documentation](https://www.tensorflow.org/api_docs/python/tf/shape) for more information.
259- sigmoid
260 - See the TensorFlow [sigmoid documentation](https://www.tensorflow.org/api_docs/python/tf/sigmoid) for more information.
261- softplus
262 - See the TensorFlow [softplus documentation](https://www.tensorflow.org/api_docs/python/tf/nn/softplus) for more information.
263- squeeze
264 - See the TensorFlow [squeeze documentation](https://www.tensorflow.org/api_docs/python/tf/squeeze) for more information.
265- tanh
266 - See the TensorFlow [tanh documentation](https://www.tensorflow.org/api_docs/python/tf/tanh) for more information.
James Ward590f3f72020-12-02 10:20:48 +0000267- transpose
268 - See the TensorFlow [transpose documentation](https://www.tensorflow.org/api_docs/python/tf/transpose) for more information.
Ryan OSheaf3a43232020-02-12 16:15:27 +0000269
270## Partially supported
271
272- add
273 - 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.
274- add_n
275 - 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.
276- concat
277 - Arm NN supports concatenation along the channel dimension for data formats NHWC and NCHW.
278- constant
279 - 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.
280- depthwise_conv2d_native
281 - 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.
282- equal
283 - 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.
284- fused_batch_norm
285 - 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.
286- greater
287 - 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.
288- matmul
289 - 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.
290- maximum
291 where maximum is used in one of the following ways
292 - max(mul(a, x), x)
293 - max(mul(x, a), x)
294 - max(x, mul(a, x))
295 - max(x, mul(x, a)
296 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.
297- minimum
298 - 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.
299- multiply
300 - 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 +0000301- pack/stack
302 - See the TensorFlow [stack documentation](https://www.tensorflow.org/api_docs/python/tf/stack) for more information.
Ryan OSheaf3a43232020-02-12 16:15:27 +0000303- pad
304 - 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.
305- realdiv
306 - 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.
307- reshape
308 - 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.
309- resize_images
310 - 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.
311- softmax
312 - 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.
313- split
314 - Arm NN supports split along the channel dimension for data formats NHWC and NCHW.
James Ward590f3f72020-12-02 10:20:48 +0000315- strided_slice
316 - 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 +0000317- subtract
318 - 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.
319
James Ward590f3f72020-12-02 10:20:48 +0000320
Ryan OSheaf3a43232020-02-12 16:15:27 +0000321## Tested networks
322
323Arm tests these operators with the following TensorFlow fp32 neural networks:
324- Lenet
325- 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.
326- 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.
327
328Using these datasets:
329- Cifar10
330- 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.
331
332More machine learning operators will be supported in future releases.
333
334**/
335}
Ryan OShea2bbfaa72020-02-12 16:15:27 +0000336