blob: 40ee7a5e45b3aae6ef8c4a8b923c7f587d37a244 [file] [log] [blame]
Nattapat Chaimanowong969eea32019-01-30 13:33:11 +00001//
2// Copyright © 2017 Arm Ltd. All rights reserved.
3// SPDX-License-Identifier: MIT
4//
5
Derek Lamberti0028d1b2019-02-20 13:57:42 +00006namespace armnnSerializer;
Nattapat Chaimanowong969eea32019-01-30 13:33:11 +00007
8file_identifier "ARMN";
9
10file_extension "armnn";
11
Mike Kellyaf484012019-02-20 16:53:11 +000012enum ActivationFunction : byte {
13 Sigmoid = 0,
14 TanH = 1,
15 Linear = 2,
16 ReLu = 3,
17 BoundedReLu = 4,
18 SoftReLu = 5,
19 LeakyReLu = 6,
20 Abs = 7,
21 Sqrt = 8,
22 Square = 9
23}
24
Nattapat Chaimanowong969eea32019-01-30 13:33:11 +000025enum DataType : byte {
26 Float16 = 0,
27 Float32 = 1,
28 QuantisedAsymm8 = 2,
29 Signed32 = 3,
30 Boolean = 4
31}
32
Saoirse Stewart3166c3e2019-02-18 15:24:53 +000033enum DataLayout : byte {
34 NHWC = 0,
35 NCHW = 1
36}
37
Nattapat Chaimanowong969eea32019-01-30 13:33:11 +000038table TensorInfo {
39 dimensions:[uint];
40 dataType:DataType;
41 quantizationScale:float = 1.0;
42 quantizationOffset:int = 0;
43}
44
45struct Connection {
46 sourceLayerIndex:uint;
47 outputSlotIndex:uint;
48}
49
50table ByteData {
51 data:[byte];
52}
53
54table ShortData {
55 data:[short];
56}
57
58table IntData {
59 data:[int];
60}
61
62table LongData {
63 data:[long];
64}
65
66union ConstTensorData { ByteData, ShortData, IntData, LongData }
67
68table ConstTensor {
69 info:TensorInfo;
70 data:ConstTensorData;
71}
72
73table InputSlot {
74 index:uint;
75 connection:Connection;
76}
77
78table OutputSlot {
79 index:uint;
80 tensorInfo:TensorInfo;
81}
82
83enum LayerType : uint {
84 Addition = 0,
85 Input = 1,
Sadik Armagan5f450272019-02-12 14:31:45 +000086 Multiplication = 2,
Aron Virginas-Tarfc413c02019-02-13 15:41:52 +000087 Output = 3,
Saoirse Stewart3166c3e2019-02-18 15:24:53 +000088 Pooling2d = 4,
Saoirse Stewart263829c2019-02-19 15:54:14 +000089 Reshape = 5,
Mike Kellya0766c32019-02-19 17:22:07 +000090 Softmax = 6,
Aron Virginas-Tarc04125f2019-02-19 16:31:08 +000091 Convolution2d = 7,
Mike Kellyaf484012019-02-20 16:53:11 +000092 DepthwiseConvolution2d = 8,
Nattapat Chaimanowong30b00202019-02-20 17:31:34 +000093 Activation = 9,
Sadik Armagandbb0c0c2019-02-21 09:01:41 +000094 Permute = 10,
Conor Kennedy76277882019-02-26 08:29:54 +000095 FullyConnected = 11,
Nattapat Chaimanowong45286992019-02-26 15:53:02 +000096 Constant = 12,
Nattapat Chaimanowong6b4ed982019-02-26 17:24:13 +000097 SpaceToBatchNd = 13,
Éanna Ó Catháin58885892019-02-27 16:16:39 +000098 BatchToSpaceNd = 14,
Aron Virginas-Tar0fe32452019-02-28 13:12:47 +000099 Division = 15,
Nattapat Chaimanowong235cea52019-02-28 16:27:30 +0000100 Minimum = 16,
Aron Virginas-Tar377351e2019-02-27 14:42:31 +0000101 Equal = 17,
Nina Drozd57728782019-02-27 10:53:27 +0000102 Maximum = 18,
Nattapat Chaimanowongebb0f9c2019-03-01 12:14:06 +0000103 Normalization = 19,
Sadik Armagan8b42a382019-03-01 14:24:49 +0000104 Pad = 20,
Finn Williamsdd2ba7e2019-03-01 11:51:52 +0000105 Rsqrt = 21,
ruoyan018e7fa232019-02-28 15:09:07 +0000106 Floor = 22,
Conor Kennedy79ffdf52019-03-01 14:24:54 +0000107 BatchNormalization = 23,
Nattapat Chaimanowong6522cdc2019-03-01 16:14:13 +0000108 Greater = 24,
Conor Kennedyda1f9752019-03-01 14:37:12 +0000109 ResizeBilinear = 25,
Nattapat Chaimanowongb3485212019-03-04 12:35:39 +0000110 Subtraction = 26,
Saoirse Stewarta1ed73a2019-03-04 13:40:12 +0000111 StridedSlice = 27,
Sadik Armaganac97c8c2019-03-04 17:44:21 +0000112 Gather = 28,
Jim Flynnac25a1b2019-02-28 10:40:49 +0000113 Mean = 29,
Narumol Prangnawarat495701f2019-03-07 17:31:34 +0000114 Merger = 30,
Jim Flynn18ce3382019-03-08 11:08:30 +0000115 L2Normalization = 31,
116 Splitter = 32
Nattapat Chaimanowong969eea32019-01-30 13:33:11 +0000117}
118
119// Base layer table to be used as part of other layers
120table LayerBase {
121 index:uint;
122 layerName:string;
123 layerType:LayerType;
124 inputSlots:[InputSlot];
125 outputSlots:[OutputSlot];
126}
127
128table BindableLayerBase {
129 base:LayerBase;
130 layerBindingId:int;
131}
132
133// Table for each layer defined below
Mike Kellyaf484012019-02-20 16:53:11 +0000134table ActivationLayer {
135 base:LayerBase;
136 descriptor:ActivationDescriptor;
137}
138
139table ActivationDescriptor {
140 function:ActivationFunction = Sigmoid;
141 a:float;
142 b:float;
143}
144
Nattapat Chaimanowong969eea32019-01-30 13:33:11 +0000145table AdditionLayer {
146 base:LayerBase;
147}
148
Conor Kennedy76277882019-02-26 08:29:54 +0000149table ConstantLayer {
150 base:LayerBase;
151 input:ConstTensor;
152}
153
Mike Kellya0766c32019-02-19 17:22:07 +0000154table Convolution2dLayer {
155 base:LayerBase;
156 descriptor:Convolution2dDescriptor;
157 weights:ConstTensor;
158 biases:ConstTensor;
159}
160
161table Convolution2dDescriptor {
162 padLeft:uint;
163 padRight:uint;
164 padTop:uint;
165 padBottom:uint;
166 strideX:uint;
167 strideY:uint;
168 biasEnabled:bool = false;
169 dataLayout:DataLayout = NCHW;
170}
171
Éanna Ó Catháin58885892019-02-27 16:16:39 +0000172table DivisionLayer {
173 base:LayerBase;
174}
175
Nattapat Chaimanowong235cea52019-02-28 16:27:30 +0000176table EqualLayer {
177 base:LayerBase;
178}
179
Finn Williamsdd2ba7e2019-03-01 11:51:52 +0000180table FloorLayer{
181 base:LayerBase;
182}
183
Sadik Armagandbb0c0c2019-02-21 09:01:41 +0000184table FullyConnectedLayer {
185 base:LayerBase;
186 descriptor:FullyConnectedDescriptor;
187 weights:ConstTensor;
188 biases:ConstTensor;
189}
190
191table FullyConnectedDescriptor {
192 biasEnabled:bool = false;
193 transposeWeightsMatrix:bool = false;
194}
195
Saoirse Stewarta1ed73a2019-03-04 13:40:12 +0000196table GatherLayer {
197 base:LayerBase;
198}
199
Conor Kennedy79ffdf52019-03-01 14:24:54 +0000200table GreaterLayer {
201 base:LayerBase;
202}
203
Nattapat Chaimanowong969eea32019-01-30 13:33:11 +0000204table InputLayer {
205 base:BindableLayerBase;
206}
207
Narumol Prangnawarat495701f2019-03-07 17:31:34 +0000208table L2NormalizationLayer {
209 base:LayerBase;
210 descriptor:L2NormalizationDescriptor;
211}
212
213table L2NormalizationDescriptor {
214 dataLayout:DataLayout = NCHW;
215}
216
Aron Virginas-Tar0fe32452019-02-28 13:12:47 +0000217table MinimumLayer {
218 base:LayerBase;
219}
220
Aron Virginas-Tar377351e2019-02-27 14:42:31 +0000221table MaximumLayer {
222 base:LayerBase;
223}
224
Sadik Armagan5f450272019-02-12 14:31:45 +0000225table MultiplicationLayer {
226 base:LayerBase;
227}
228
Saoirse Stewart3166c3e2019-02-18 15:24:53 +0000229table Pooling2dLayer {
230 base:LayerBase;
231 descriptor:Pooling2dDescriptor;
232}
233
234enum PoolingAlgorithm : byte {
235 Max = 0,
236 Average = 1,
237 L2 = 2
238}
239
240enum OutputShapeRounding : byte {
241 Floor = 0,
242 Ceiling = 1
243}
244
245enum PaddingMethod : byte {
246 IgnoreValue = 0,
247 Exclude = 1
248}
249
250table Pooling2dDescriptor {
251 poolType:PoolingAlgorithm;
252 padLeft:uint;
253 padRight:uint;
254 padTop:uint;
255 padBottom:uint;
256 poolWidth:uint;
257 poolHeight:uint;
258 strideX:uint;
259 strideY:uint;
260 outputShapeRounding:OutputShapeRounding;
261 paddingMethod:PaddingMethod;
262 dataLayout:DataLayout;
263}
264
Aron Virginas-Tarfc413c02019-02-13 15:41:52 +0000265table SoftmaxLayer {
266 base:LayerBase;
267 descriptor:SoftmaxDescriptor;
268}
269
270table SoftmaxDescriptor {
271 beta:float;
272}
273
Aron Virginas-Tarc04125f2019-02-19 16:31:08 +0000274table DepthwiseConvolution2dLayer {
275 base:LayerBase;
276 descriptor:DepthwiseConvolution2dDescriptor;
277 weights:ConstTensor;
278 biases:ConstTensor;
279}
280
281table DepthwiseConvolution2dDescriptor {
282 padLeft:uint;
283 padRight:uint;
284 padTop:uint;
285 padBottom:uint;
286 strideX:uint;
287 strideY:uint;
288 biasEnabled:bool = false;
289 dataLayout:DataLayout = NCHW;
290}
291
Nattapat Chaimanowong969eea32019-01-30 13:33:11 +0000292table OutputLayer {
293 base:BindableLayerBase;
294}
295
Saoirse Stewart263829c2019-02-19 15:54:14 +0000296table ReshapeLayer {
297 base:LayerBase;
298 descriptor:ReshapeDescriptor;
299}
300
301table ReshapeDescriptor {
302 targetShape:[uint];
303}
304
Nattapat Chaimanowong30b00202019-02-20 17:31:34 +0000305table PermuteLayer {
306 base:LayerBase;
307 descriptor:PermuteDescriptor;
308}
309
310table PermuteDescriptor {
311 dimMappings:[uint];
312}
313
Nattapat Chaimanowong45286992019-02-26 15:53:02 +0000314table SpaceToBatchNdLayer {
315 base:LayerBase;
316 descriptor:SpaceToBatchNdDescriptor;
317}
318
319table SpaceToBatchNdDescriptor {
320 blockShape:[uint];
321 padList:[uint];
322 dataLayout:DataLayout;
323}
324
Conor Kennedyda1f9752019-03-01 14:37:12 +0000325table SubtractionLayer {
326 base:LayerBase;
327}
328
Nattapat Chaimanowong6b4ed982019-02-26 17:24:13 +0000329table BatchToSpaceNdLayer {
330 base:LayerBase;
331 descriptor:BatchToSpaceNdDescriptor;
332}
333
334table BatchToSpaceNdDescriptor {
335 blockShape:[uint];
336 crops:[uint];
337 dataLayout:DataLayout;
338}
339
Nina Drozd57728782019-02-27 10:53:27 +0000340enum NormalizationAlgorithmChannel : byte {
341 Across = 0,
342 Within = 1
343}
344
345enum NormalizationAlgorithmMethod : byte {
346 LocalBrightness = 0,
347 LocalContrast = 1
348}
349
350table NormalizationLayer {
351 base:LayerBase;
352 descriptor:NormalizationDescriptor;
353}
354
355table NormalizationDescriptor {
356 normChannelType:NormalizationAlgorithmChannel = Across;
357 normMethodType:NormalizationAlgorithmMethod = LocalBrightness;
358 normSize:uint;
359 alpha:float;
360 beta:float;
361 k:float;
362 dataLayout:DataLayout = NCHW;
363}
364
Sadik Armaganac97c8c2019-03-04 17:44:21 +0000365table MeanLayer {
366 base:LayerBase;
367 descriptor:MeanDescriptor;
368}
369
370table MeanDescriptor {
371 axis:[uint];
372 keepDims:bool = false;
373}
374
Nattapat Chaimanowongebb0f9c2019-03-01 12:14:06 +0000375table PadLayer {
376 base:LayerBase;
377 descriptor:PadDescriptor;
378}
379
380table PadDescriptor {
381 padList:[uint];
382}
383
Sadik Armagan8b42a382019-03-01 14:24:49 +0000384table RsqrtLayer {
385 base:LayerBase;
386}
387
ruoyan018e7fa232019-02-28 15:09:07 +0000388table BatchNormalizationLayer {
389 base:LayerBase;
390 descriptor:BatchNormalizationDescriptor;
391 mean:ConstTensor;
392 variance:ConstTensor;
393 beta:ConstTensor;
394 gamma:ConstTensor;
395}
396
397table BatchNormalizationDescriptor {
398 eps:float;
399 dataLayout:DataLayout;
400}
401
Nattapat Chaimanowong6522cdc2019-03-01 16:14:13 +0000402table ResizeBilinearLayer {
403 base:LayerBase;
404 descriptor:ResizeBilinearDescriptor;
405}
406
407table ResizeBilinearDescriptor {
408 targetWidth:uint;
409 targetHeight:uint;
410 dataLayout:DataLayout;
411}
412
Nattapat Chaimanowongb3485212019-03-04 12:35:39 +0000413table StridedSliceLayer {
414 base:LayerBase;
415 descriptor:StridedSliceDescriptor;
416}
417
418table StridedSliceDescriptor {
419 begin:[int];
420 end:[int];
421 stride:[int];
422 beginMask:int;
423 endMask:int;
424 shrinkAxisMask:int;
425 ellipsisMask:int;
426 newAxisMask:int;
427 dataLayout:DataLayout;
428}
429
Jim Flynnac25a1b2019-02-28 10:40:49 +0000430table MergerLayer {
431 base:LayerBase;
432 descriptor:OriginsDescriptor;
433}
434
435table UintVector {
436 data:[uint];
437}
438
439table OriginsDescriptor {
440 concatAxis:uint;
441 numViews:uint;
442 numDimensions:uint;
443 viewOrigins:[UintVector];
444}
445
Jim Flynn18ce3382019-03-08 11:08:30 +0000446table ViewsDescriptor {
447 origins:OriginsDescriptor;
448 viewSizes:[UintVector];
449}
450
451table SplitterLayer {
452 base:LayerBase;
453 descriptor:ViewsDescriptor;
454}
455
Nattapat Chaimanowong969eea32019-01-30 13:33:11 +0000456union Layer {
Mike Kellyaf484012019-02-20 16:53:11 +0000457 ActivationLayer,
Nattapat Chaimanowong969eea32019-01-30 13:33:11 +0000458 AdditionLayer,
Nattapat Chaimanowong6b4ed982019-02-26 17:24:13 +0000459 BatchToSpaceNdLayer,
ruoyan018e7fa232019-02-28 15:09:07 +0000460 BatchNormalizationLayer,
Conor Kennedy76277882019-02-26 08:29:54 +0000461 ConstantLayer,
Mike Kellya0766c32019-02-19 17:22:07 +0000462 Convolution2dLayer,
Aron Virginas-Tarc04125f2019-02-19 16:31:08 +0000463 DepthwiseConvolution2dLayer,
Sadik Armagandbb0c0c2019-02-21 09:01:41 +0000464 FullyConnectedLayer,
Nattapat Chaimanowong969eea32019-01-30 13:33:11 +0000465 InputLayer,
Sadik Armagan5f450272019-02-12 14:31:45 +0000466 MultiplicationLayer,
Aron Virginas-Tarfc413c02019-02-13 15:41:52 +0000467 OutputLayer,
Nattapat Chaimanowong30b00202019-02-20 17:31:34 +0000468 PermuteLayer,
Saoirse Stewart3166c3e2019-02-18 15:24:53 +0000469 Pooling2dLayer,
Saoirse Stewart263829c2019-02-19 15:54:14 +0000470 ReshapeLayer,
Nattapat Chaimanowong45286992019-02-26 15:53:02 +0000471 SoftmaxLayer,
Éanna Ó Catháin58885892019-02-27 16:16:39 +0000472 SpaceToBatchNdLayer,
Aron Virginas-Tar0fe32452019-02-28 13:12:47 +0000473 DivisionLayer,
Nattapat Chaimanowong235cea52019-02-28 16:27:30 +0000474 MinimumLayer,
Aron Virginas-Tar377351e2019-02-27 14:42:31 +0000475 EqualLayer,
Nina Drozd57728782019-02-27 10:53:27 +0000476 MaximumLayer,
Nattapat Chaimanowongebb0f9c2019-03-01 12:14:06 +0000477 NormalizationLayer,
Sadik Armagan8b42a382019-03-01 14:24:49 +0000478 PadLayer,
Finn Williamsdd2ba7e2019-03-01 11:51:52 +0000479 RsqrtLayer,
Conor Kennedy79ffdf52019-03-01 14:24:54 +0000480 FloorLayer,
Nattapat Chaimanowong6522cdc2019-03-01 16:14:13 +0000481 GreaterLayer,
Conor Kennedyda1f9752019-03-01 14:37:12 +0000482 ResizeBilinearLayer,
Nattapat Chaimanowongb3485212019-03-04 12:35:39 +0000483 SubtractionLayer,
Saoirse Stewarta1ed73a2019-03-04 13:40:12 +0000484 StridedSliceLayer,
Sadik Armaganac97c8c2019-03-04 17:44:21 +0000485 GatherLayer,
Jim Flynnac25a1b2019-02-28 10:40:49 +0000486 MeanLayer,
Narumol Prangnawarat495701f2019-03-07 17:31:34 +0000487 MergerLayer,
Jim Flynn18ce3382019-03-08 11:08:30 +0000488 L2NormalizationLayer,
489 SplitterLayer
Nattapat Chaimanowong969eea32019-01-30 13:33:11 +0000490}
491
Saoirse Stewart49dbe0e2019-02-05 17:27:06 +0000492table AnyLayer {
493 layer:Layer;
494}
495
Nattapat Chaimanowong969eea32019-01-30 13:33:11 +0000496// Root type for serialized data is the graph of the network
497table SerializedGraph {
Saoirse Stewart49dbe0e2019-02-05 17:27:06 +0000498 layers:[AnyLayer];
Mike Kelly8c1701a2019-02-11 17:01:27 +0000499 inputIds:[uint];
500 outputIds:[uint];
Nattapat Chaimanowong969eea32019-01-30 13:33:11 +0000501}
502
503root_type SerializedGraph;