blob: 1204ad8f0f63d178287163a5bdb0f221c8239789 [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,
Nattapat Chaimanowongcd5ac232019-03-19 12:26:36 +000030 Boolean = 4,
31 QuantisedSymm16 = 5
Nattapat Chaimanowong969eea32019-01-30 13:33:11 +000032}
33
Saoirse Stewart3166c3e2019-02-18 15:24:53 +000034enum DataLayout : byte {
35 NHWC = 0,
36 NCHW = 1
37}
38
Nattapat Chaimanowong969eea32019-01-30 13:33:11 +000039table TensorInfo {
40 dimensions:[uint];
41 dataType:DataType;
42 quantizationScale:float = 1.0;
43 quantizationOffset:int = 0;
44}
45
46struct Connection {
47 sourceLayerIndex:uint;
48 outputSlotIndex:uint;
49}
50
51table ByteData {
52 data:[byte];
53}
54
55table ShortData {
56 data:[short];
57}
58
59table IntData {
60 data:[int];
61}
62
63table LongData {
64 data:[long];
65}
66
67union ConstTensorData { ByteData, ShortData, IntData, LongData }
68
69table ConstTensor {
70 info:TensorInfo;
71 data:ConstTensorData;
72}
73
74table InputSlot {
75 index:uint;
76 connection:Connection;
77}
78
79table OutputSlot {
80 index:uint;
81 tensorInfo:TensorInfo;
82}
83
84enum LayerType : uint {
85 Addition = 0,
86 Input = 1,
Sadik Armagan5f450272019-02-12 14:31:45 +000087 Multiplication = 2,
Aron Virginas-Tarfc413c02019-02-13 15:41:52 +000088 Output = 3,
Saoirse Stewart3166c3e2019-02-18 15:24:53 +000089 Pooling2d = 4,
Saoirse Stewart263829c2019-02-19 15:54:14 +000090 Reshape = 5,
Mike Kellya0766c32019-02-19 17:22:07 +000091 Softmax = 6,
Aron Virginas-Tarc04125f2019-02-19 16:31:08 +000092 Convolution2d = 7,
Mike Kellyaf484012019-02-20 16:53:11 +000093 DepthwiseConvolution2d = 8,
Nattapat Chaimanowong30b00202019-02-20 17:31:34 +000094 Activation = 9,
Sadik Armagandbb0c0c2019-02-21 09:01:41 +000095 Permute = 10,
Conor Kennedy76277882019-02-26 08:29:54 +000096 FullyConnected = 11,
Nattapat Chaimanowong45286992019-02-26 15:53:02 +000097 Constant = 12,
Nattapat Chaimanowong6b4ed982019-02-26 17:24:13 +000098 SpaceToBatchNd = 13,
Éanna Ó Catháin58885892019-02-27 16:16:39 +000099 BatchToSpaceNd = 14,
Aron Virginas-Tar0fe32452019-02-28 13:12:47 +0000100 Division = 15,
Nattapat Chaimanowong235cea52019-02-28 16:27:30 +0000101 Minimum = 16,
Aron Virginas-Tar377351e2019-02-27 14:42:31 +0000102 Equal = 17,
Nina Drozd57728782019-02-27 10:53:27 +0000103 Maximum = 18,
Nattapat Chaimanowongebb0f9c2019-03-01 12:14:06 +0000104 Normalization = 19,
Sadik Armagan8b42a382019-03-01 14:24:49 +0000105 Pad = 20,
Finn Williamsdd2ba7e2019-03-01 11:51:52 +0000106 Rsqrt = 21,
ruoyan018e7fa232019-02-28 15:09:07 +0000107 Floor = 22,
Conor Kennedy79ffdf52019-03-01 14:24:54 +0000108 BatchNormalization = 23,
Nattapat Chaimanowong6522cdc2019-03-01 16:14:13 +0000109 Greater = 24,
Conor Kennedyda1f9752019-03-01 14:37:12 +0000110 ResizeBilinear = 25,
Nattapat Chaimanowongb3485212019-03-04 12:35:39 +0000111 Subtraction = 26,
Saoirse Stewarta1ed73a2019-03-04 13:40:12 +0000112 StridedSlice = 27,
Sadik Armaganac97c8c2019-03-04 17:44:21 +0000113 Gather = 28,
Jim Flynnac25a1b2019-02-28 10:40:49 +0000114 Mean = 29,
Narumol Prangnawarat495701f2019-03-07 17:31:34 +0000115 Merger = 30,
Jim Flynn18ce3382019-03-08 11:08:30 +0000116 L2Normalization = 31,
Nattapat Chaimanowong3e14a9d2019-03-18 12:37:06 +0000117 Splitter = 32,
Jim Flynn11af3752019-03-19 17:22:29 +0000118 DetectionPostProcess = 33,
Derek Lamberti87acb272019-03-27 16:51:31 +0000119 Lstm = 34,
Nattapat Chaimanowonge4294fd2019-03-28 09:56:53 +0000120 Quantize = 35,
Nattapat Chaimanowong1f886302019-04-05 13:37:19 +0100121 Dequantize = 36,
Sadik Armaganeff363d2019-04-05 15:25:46 +0100122 Merge = 37,
Jim Flynne242f2d2019-05-22 14:24:13 +0100123 Switch = 38,
Aron Virginas-Taraa067142019-06-11 16:01:44 +0100124 Concat = 39,
125 SpaceToDepth = 40
Nattapat Chaimanowong969eea32019-01-30 13:33:11 +0000126}
127
128// Base layer table to be used as part of other layers
129table LayerBase {
130 index:uint;
131 layerName:string;
132 layerType:LayerType;
133 inputSlots:[InputSlot];
134 outputSlots:[OutputSlot];
135}
136
137table BindableLayerBase {
138 base:LayerBase;
139 layerBindingId:int;
140}
141
142// Table for each layer defined below
Mike Kellyaf484012019-02-20 16:53:11 +0000143table ActivationLayer {
144 base:LayerBase;
145 descriptor:ActivationDescriptor;
146}
147
148table ActivationDescriptor {
149 function:ActivationFunction = Sigmoid;
150 a:float;
151 b:float;
152}
153
Nattapat Chaimanowong969eea32019-01-30 13:33:11 +0000154table AdditionLayer {
155 base:LayerBase;
156}
157
Conor Kennedy76277882019-02-26 08:29:54 +0000158table ConstantLayer {
159 base:LayerBase;
160 input:ConstTensor;
161}
162
Mike Kellya0766c32019-02-19 17:22:07 +0000163table Convolution2dLayer {
164 base:LayerBase;
165 descriptor:Convolution2dDescriptor;
166 weights:ConstTensor;
167 biases:ConstTensor;
168}
169
170table Convolution2dDescriptor {
171 padLeft:uint;
172 padRight:uint;
173 padTop:uint;
174 padBottom:uint;
175 strideX:uint;
176 strideY:uint;
Matthew Benthamacad04e2019-05-13 10:02:45 +0100177 dilationX:uint = 1;
178 dilationY:uint = 1;
Mike Kellya0766c32019-02-19 17:22:07 +0000179 biasEnabled:bool = false;
180 dataLayout:DataLayout = NCHW;
181}
182
Éanna Ó Catháin58885892019-02-27 16:16:39 +0000183table DivisionLayer {
184 base:LayerBase;
185}
186
Nattapat Chaimanowong235cea52019-02-28 16:27:30 +0000187table EqualLayer {
188 base:LayerBase;
189}
190
Finn Williamsdd2ba7e2019-03-01 11:51:52 +0000191table FloorLayer{
192 base:LayerBase;
193}
194
Sadik Armagandbb0c0c2019-02-21 09:01:41 +0000195table FullyConnectedLayer {
196 base:LayerBase;
197 descriptor:FullyConnectedDescriptor;
198 weights:ConstTensor;
199 biases:ConstTensor;
200}
201
202table FullyConnectedDescriptor {
203 biasEnabled:bool = false;
204 transposeWeightsMatrix:bool = false;
205}
206
Saoirse Stewarta1ed73a2019-03-04 13:40:12 +0000207table GatherLayer {
208 base:LayerBase;
209}
210
Conor Kennedy79ffdf52019-03-01 14:24:54 +0000211table GreaterLayer {
212 base:LayerBase;
213}
214
Nattapat Chaimanowong969eea32019-01-30 13:33:11 +0000215table InputLayer {
216 base:BindableLayerBase;
217}
218
Narumol Prangnawarat495701f2019-03-07 17:31:34 +0000219table L2NormalizationLayer {
220 base:LayerBase;
221 descriptor:L2NormalizationDescriptor;
222}
223
224table L2NormalizationDescriptor {
225 dataLayout:DataLayout = NCHW;
226}
227
Aron Virginas-Tar0fe32452019-02-28 13:12:47 +0000228table MinimumLayer {
229 base:LayerBase;
230}
231
Aron Virginas-Tar377351e2019-02-27 14:42:31 +0000232table MaximumLayer {
233 base:LayerBase;
234}
235
Sadik Armagan5f450272019-02-12 14:31:45 +0000236table MultiplicationLayer {
237 base:LayerBase;
238}
239
Saoirse Stewart3166c3e2019-02-18 15:24:53 +0000240table Pooling2dLayer {
241 base:LayerBase;
242 descriptor:Pooling2dDescriptor;
243}
244
245enum PoolingAlgorithm : byte {
246 Max = 0,
247 Average = 1,
248 L2 = 2
249}
250
251enum OutputShapeRounding : byte {
252 Floor = 0,
253 Ceiling = 1
254}
255
256enum PaddingMethod : byte {
257 IgnoreValue = 0,
258 Exclude = 1
259}
260
261table Pooling2dDescriptor {
262 poolType:PoolingAlgorithm;
263 padLeft:uint;
264 padRight:uint;
265 padTop:uint;
266 padBottom:uint;
267 poolWidth:uint;
268 poolHeight:uint;
269 strideX:uint;
270 strideY:uint;
271 outputShapeRounding:OutputShapeRounding;
272 paddingMethod:PaddingMethod;
273 dataLayout:DataLayout;
274}
275
Derek Lamberti87acb272019-03-27 16:51:31 +0000276table QuantizeLayer {
277 base:LayerBase;
278}
279
Aron Virginas-Tarfc413c02019-02-13 15:41:52 +0000280table SoftmaxLayer {
281 base:LayerBase;
282 descriptor:SoftmaxDescriptor;
283}
284
285table SoftmaxDescriptor {
286 beta:float;
287}
288
Aron Virginas-Tarc04125f2019-02-19 16:31:08 +0000289table DepthwiseConvolution2dLayer {
290 base:LayerBase;
291 descriptor:DepthwiseConvolution2dDescriptor;
292 weights:ConstTensor;
293 biases:ConstTensor;
294}
295
296table DepthwiseConvolution2dDescriptor {
297 padLeft:uint;
298 padRight:uint;
299 padTop:uint;
300 padBottom:uint;
301 strideX:uint;
302 strideY:uint;
Matthew Benthamacad04e2019-05-13 10:02:45 +0100303 dilationX:uint = 1;
304 dilationY:uint = 1;
Aron Virginas-Tarc04125f2019-02-19 16:31:08 +0000305 biasEnabled:bool = false;
306 dataLayout:DataLayout = NCHW;
307}
308
Nattapat Chaimanowong969eea32019-01-30 13:33:11 +0000309table OutputLayer {
310 base:BindableLayerBase;
311}
312
Saoirse Stewart263829c2019-02-19 15:54:14 +0000313table ReshapeLayer {
314 base:LayerBase;
315 descriptor:ReshapeDescriptor;
316}
317
318table ReshapeDescriptor {
319 targetShape:[uint];
320}
321
Nattapat Chaimanowong30b00202019-02-20 17:31:34 +0000322table PermuteLayer {
323 base:LayerBase;
324 descriptor:PermuteDescriptor;
325}
326
327table PermuteDescriptor {
328 dimMappings:[uint];
329}
330
Nattapat Chaimanowong45286992019-02-26 15:53:02 +0000331table SpaceToBatchNdLayer {
332 base:LayerBase;
333 descriptor:SpaceToBatchNdDescriptor;
334}
335
336table SpaceToBatchNdDescriptor {
337 blockShape:[uint];
338 padList:[uint];
339 dataLayout:DataLayout;
340}
341
Aron Virginas-Taraa067142019-06-11 16:01:44 +0100342table SpaceToDepthLayer {
343 base:LayerBase;
344 descriptor:SpaceToDepthDescriptor;
345}
346
347table SpaceToDepthDescriptor {
348 blockSize:uint;
349 dataLayout:DataLayout;
350}
351
Conor Kennedyda1f9752019-03-01 14:37:12 +0000352table SubtractionLayer {
353 base:LayerBase;
354}
355
Nattapat Chaimanowong6b4ed982019-02-26 17:24:13 +0000356table BatchToSpaceNdLayer {
357 base:LayerBase;
358 descriptor:BatchToSpaceNdDescriptor;
359}
360
361table BatchToSpaceNdDescriptor {
362 blockShape:[uint];
363 crops:[uint];
364 dataLayout:DataLayout;
365}
366
Nina Drozd57728782019-02-27 10:53:27 +0000367enum NormalizationAlgorithmChannel : byte {
368 Across = 0,
369 Within = 1
370}
371
372enum NormalizationAlgorithmMethod : byte {
373 LocalBrightness = 0,
374 LocalContrast = 1
375}
376
377table NormalizationLayer {
378 base:LayerBase;
379 descriptor:NormalizationDescriptor;
380}
381
382table NormalizationDescriptor {
383 normChannelType:NormalizationAlgorithmChannel = Across;
384 normMethodType:NormalizationAlgorithmMethod = LocalBrightness;
385 normSize:uint;
386 alpha:float;
387 beta:float;
388 k:float;
389 dataLayout:DataLayout = NCHW;
390}
391
Sadik Armaganac97c8c2019-03-04 17:44:21 +0000392table MeanLayer {
393 base:LayerBase;
394 descriptor:MeanDescriptor;
395}
396
397table MeanDescriptor {
398 axis:[uint];
399 keepDims:bool = false;
400}
401
Nattapat Chaimanowongebb0f9c2019-03-01 12:14:06 +0000402table PadLayer {
403 base:LayerBase;
404 descriptor:PadDescriptor;
405}
406
407table PadDescriptor {
408 padList:[uint];
409}
410
Sadik Armagan8b42a382019-03-01 14:24:49 +0000411table RsqrtLayer {
412 base:LayerBase;
413}
414
ruoyan018e7fa232019-02-28 15:09:07 +0000415table BatchNormalizationLayer {
416 base:LayerBase;
417 descriptor:BatchNormalizationDescriptor;
418 mean:ConstTensor;
419 variance:ConstTensor;
420 beta:ConstTensor;
421 gamma:ConstTensor;
422}
423
424table BatchNormalizationDescriptor {
425 eps:float;
426 dataLayout:DataLayout;
427}
428
Nattapat Chaimanowong6522cdc2019-03-01 16:14:13 +0000429table ResizeBilinearLayer {
430 base:LayerBase;
431 descriptor:ResizeBilinearDescriptor;
432}
433
434table ResizeBilinearDescriptor {
435 targetWidth:uint;
436 targetHeight:uint;
437 dataLayout:DataLayout;
438}
439
Nattapat Chaimanowongb3485212019-03-04 12:35:39 +0000440table StridedSliceLayer {
441 base:LayerBase;
442 descriptor:StridedSliceDescriptor;
443}
444
445table StridedSliceDescriptor {
446 begin:[int];
447 end:[int];
448 stride:[int];
449 beginMask:int;
450 endMask:int;
451 shrinkAxisMask:int;
452 ellipsisMask:int;
453 newAxisMask:int;
454 dataLayout:DataLayout;
455}
456
Jim Flynne242f2d2019-05-22 14:24:13 +0100457table ConcatLayer {
458 base:LayerBase;
459 descriptor:OriginsDescriptor;
460}
461
Jim Flynnac25a1b2019-02-28 10:40:49 +0000462table MergerLayer {
463 base:LayerBase;
464 descriptor:OriginsDescriptor;
465}
466
467table UintVector {
468 data:[uint];
469}
470
471table OriginsDescriptor {
472 concatAxis:uint;
473 numViews:uint;
474 numDimensions:uint;
475 viewOrigins:[UintVector];
476}
477
Jim Flynn18ce3382019-03-08 11:08:30 +0000478table ViewsDescriptor {
479 origins:OriginsDescriptor;
480 viewSizes:[UintVector];
481}
482
483table SplitterLayer {
484 base:LayerBase;
485 descriptor:ViewsDescriptor;
486}
487
Nattapat Chaimanowong3e14a9d2019-03-18 12:37:06 +0000488table DetectionPostProcessLayer {
489 base:LayerBase;
490 descriptor:DetectionPostProcessDescriptor;
491 anchors:ConstTensor;
492}
493
494table DetectionPostProcessDescriptor {
495 maxDetections:uint;
496 maxClassesPerDetection:uint;
497 detectionsPerClass:uint;
498 nmsScoreThreshold:float;
499 nmsIouThreshold:float;
500 numClasses:uint;
501 useRegularNms:bool;
502 scaleX:float;
503 scaleY:float;
504 scaleW:float;
505 scaleH:float;
506}
507
Jim Flynn11af3752019-03-19 17:22:29 +0000508table LstmInputParams {
509 inputToForgetWeights:ConstTensor;
510 inputToCellWeights:ConstTensor;
511 inputToOutputWeights:ConstTensor;
512 recurrentToForgetWeights:ConstTensor;
513 recurrentToCellWeights:ConstTensor;
514 recurrentToOutputWeights:ConstTensor;
515 forgetGateBias:ConstTensor;
516 cellBias:ConstTensor;
517 outputGateBias:ConstTensor;
518
519 inputToInputWeights:ConstTensor;
520 recurrentToInputWeights:ConstTensor;
521 cellToInputWeights:ConstTensor;
522 inputGateBias:ConstTensor;
523
524 projectionWeights:ConstTensor;
525 projectionBias:ConstTensor;
526
527 cellToForgetWeights:ConstTensor;
528 cellToOutputWeights:ConstTensor;
529}
530
531table LstmDescriptor {
532 activationFunc:uint;
533 clippingThresCell:float;
534 clippingThresProj:float;
535 cifgEnabled:bool = true;
536 peepholeEnabled:bool = false;
537 projectionEnabled:bool = false;
538}
539
540table LstmLayer {
541 base:LayerBase;
542 descriptor:LstmDescriptor;
543 inputParams:LstmInputParams;
544}
545
Nattapat Chaimanowonge4294fd2019-03-28 09:56:53 +0000546table DequantizeLayer {
547 base:LayerBase;
548}
549
Nattapat Chaimanowong1f886302019-04-05 13:37:19 +0100550table MergeLayer {
551 base:LayerBase;
552}
553
Sadik Armaganeff363d2019-04-05 15:25:46 +0100554table SwitchLayer {
555 base:LayerBase;
556}
557
Nattapat Chaimanowong969eea32019-01-30 13:33:11 +0000558union Layer {
Mike Kellyaf484012019-02-20 16:53:11 +0000559 ActivationLayer,
Nattapat Chaimanowong969eea32019-01-30 13:33:11 +0000560 AdditionLayer,
Nattapat Chaimanowong6b4ed982019-02-26 17:24:13 +0000561 BatchToSpaceNdLayer,
ruoyan018e7fa232019-02-28 15:09:07 +0000562 BatchNormalizationLayer,
Conor Kennedy76277882019-02-26 08:29:54 +0000563 ConstantLayer,
Mike Kellya0766c32019-02-19 17:22:07 +0000564 Convolution2dLayer,
Aron Virginas-Tarc04125f2019-02-19 16:31:08 +0000565 DepthwiseConvolution2dLayer,
Sadik Armagandbb0c0c2019-02-21 09:01:41 +0000566 FullyConnectedLayer,
Nattapat Chaimanowong969eea32019-01-30 13:33:11 +0000567 InputLayer,
Sadik Armagan5f450272019-02-12 14:31:45 +0000568 MultiplicationLayer,
Aron Virginas-Tarfc413c02019-02-13 15:41:52 +0000569 OutputLayer,
Nattapat Chaimanowong30b00202019-02-20 17:31:34 +0000570 PermuteLayer,
Saoirse Stewart3166c3e2019-02-18 15:24:53 +0000571 Pooling2dLayer,
Saoirse Stewart263829c2019-02-19 15:54:14 +0000572 ReshapeLayer,
Nattapat Chaimanowong45286992019-02-26 15:53:02 +0000573 SoftmaxLayer,
Éanna Ó Catháin58885892019-02-27 16:16:39 +0000574 SpaceToBatchNdLayer,
Aron Virginas-Tar0fe32452019-02-28 13:12:47 +0000575 DivisionLayer,
Nattapat Chaimanowong235cea52019-02-28 16:27:30 +0000576 MinimumLayer,
Aron Virginas-Tar377351e2019-02-27 14:42:31 +0000577 EqualLayer,
Nina Drozd57728782019-02-27 10:53:27 +0000578 MaximumLayer,
Nattapat Chaimanowongebb0f9c2019-03-01 12:14:06 +0000579 NormalizationLayer,
Sadik Armagan8b42a382019-03-01 14:24:49 +0000580 PadLayer,
Finn Williamsdd2ba7e2019-03-01 11:51:52 +0000581 RsqrtLayer,
Conor Kennedy79ffdf52019-03-01 14:24:54 +0000582 FloorLayer,
Nattapat Chaimanowong6522cdc2019-03-01 16:14:13 +0000583 GreaterLayer,
Conor Kennedyda1f9752019-03-01 14:37:12 +0000584 ResizeBilinearLayer,
Nattapat Chaimanowongb3485212019-03-04 12:35:39 +0000585 SubtractionLayer,
Saoirse Stewarta1ed73a2019-03-04 13:40:12 +0000586 StridedSliceLayer,
Sadik Armaganac97c8c2019-03-04 17:44:21 +0000587 GatherLayer,
Jim Flynnac25a1b2019-02-28 10:40:49 +0000588 MeanLayer,
Narumol Prangnawarat495701f2019-03-07 17:31:34 +0000589 MergerLayer,
Jim Flynn18ce3382019-03-08 11:08:30 +0000590 L2NormalizationLayer,
Nattapat Chaimanowong3e14a9d2019-03-18 12:37:06 +0000591 SplitterLayer,
Jim Flynn11af3752019-03-19 17:22:29 +0000592 DetectionPostProcessLayer,
Derek Lamberti87acb272019-03-27 16:51:31 +0000593 LstmLayer,
Nattapat Chaimanowonge4294fd2019-03-28 09:56:53 +0000594 QuantizeLayer,
Nattapat Chaimanowong1f886302019-04-05 13:37:19 +0100595 DequantizeLayer,
Sadik Armaganeff363d2019-04-05 15:25:46 +0100596 MergeLayer,
Jim Flynne242f2d2019-05-22 14:24:13 +0100597 SwitchLayer,
Aron Virginas-Taraa067142019-06-11 16:01:44 +0100598 ConcatLayer,
599 SpaceToDepthLayer
Nattapat Chaimanowong969eea32019-01-30 13:33:11 +0000600}
601
Saoirse Stewart49dbe0e2019-02-05 17:27:06 +0000602table AnyLayer {
603 layer:Layer;
604}
605
Nattapat Chaimanowong969eea32019-01-30 13:33:11 +0000606// Root type for serialized data is the graph of the network
607table SerializedGraph {
Saoirse Stewart49dbe0e2019-02-05 17:27:06 +0000608 layers:[AnyLayer];
Mike Kelly8c1701a2019-02-11 17:01:27 +0000609 inputIds:[uint];
610 outputIds:[uint];
Nattapat Chaimanowong969eea32019-01-30 13:33:11 +0000611}
612
613root_type SerializedGraph;