blob: e8d72fc997a4d74729d95b4f38b8e250dc418f78 [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,
123 Switch = 38
Nattapat Chaimanowong969eea32019-01-30 13:33:11 +0000124}
125
126// Base layer table to be used as part of other layers
127table LayerBase {
128 index:uint;
129 layerName:string;
130 layerType:LayerType;
131 inputSlots:[InputSlot];
132 outputSlots:[OutputSlot];
133}
134
135table BindableLayerBase {
136 base:LayerBase;
137 layerBindingId:int;
138}
139
140// Table for each layer defined below
Mike Kellyaf484012019-02-20 16:53:11 +0000141table ActivationLayer {
142 base:LayerBase;
143 descriptor:ActivationDescriptor;
144}
145
146table ActivationDescriptor {
147 function:ActivationFunction = Sigmoid;
148 a:float;
149 b:float;
150}
151
Nattapat Chaimanowong969eea32019-01-30 13:33:11 +0000152table AdditionLayer {
153 base:LayerBase;
154}
155
Conor Kennedy76277882019-02-26 08:29:54 +0000156table ConstantLayer {
157 base:LayerBase;
158 input:ConstTensor;
159}
160
Mike Kellya0766c32019-02-19 17:22:07 +0000161table Convolution2dLayer {
162 base:LayerBase;
163 descriptor:Convolution2dDescriptor;
164 weights:ConstTensor;
165 biases:ConstTensor;
166}
167
168table Convolution2dDescriptor {
169 padLeft:uint;
170 padRight:uint;
171 padTop:uint;
172 padBottom:uint;
173 strideX:uint;
174 strideY:uint;
175 biasEnabled:bool = false;
176 dataLayout:DataLayout = NCHW;
177}
178
Éanna Ó Catháin58885892019-02-27 16:16:39 +0000179table DivisionLayer {
180 base:LayerBase;
181}
182
Nattapat Chaimanowong235cea52019-02-28 16:27:30 +0000183table EqualLayer {
184 base:LayerBase;
185}
186
Finn Williamsdd2ba7e2019-03-01 11:51:52 +0000187table FloorLayer{
188 base:LayerBase;
189}
190
Sadik Armagandbb0c0c2019-02-21 09:01:41 +0000191table FullyConnectedLayer {
192 base:LayerBase;
193 descriptor:FullyConnectedDescriptor;
194 weights:ConstTensor;
195 biases:ConstTensor;
196}
197
198table FullyConnectedDescriptor {
199 biasEnabled:bool = false;
200 transposeWeightsMatrix:bool = false;
201}
202
Saoirse Stewarta1ed73a2019-03-04 13:40:12 +0000203table GatherLayer {
204 base:LayerBase;
205}
206
Conor Kennedy79ffdf52019-03-01 14:24:54 +0000207table GreaterLayer {
208 base:LayerBase;
209}
210
Nattapat Chaimanowong969eea32019-01-30 13:33:11 +0000211table InputLayer {
212 base:BindableLayerBase;
213}
214
Narumol Prangnawarat495701f2019-03-07 17:31:34 +0000215table L2NormalizationLayer {
216 base:LayerBase;
217 descriptor:L2NormalizationDescriptor;
218}
219
220table L2NormalizationDescriptor {
221 dataLayout:DataLayout = NCHW;
222}
223
Aron Virginas-Tar0fe32452019-02-28 13:12:47 +0000224table MinimumLayer {
225 base:LayerBase;
226}
227
Aron Virginas-Tar377351e2019-02-27 14:42:31 +0000228table MaximumLayer {
229 base:LayerBase;
230}
231
Sadik Armagan5f450272019-02-12 14:31:45 +0000232table MultiplicationLayer {
233 base:LayerBase;
234}
235
Saoirse Stewart3166c3e2019-02-18 15:24:53 +0000236table Pooling2dLayer {
237 base:LayerBase;
238 descriptor:Pooling2dDescriptor;
239}
240
241enum PoolingAlgorithm : byte {
242 Max = 0,
243 Average = 1,
244 L2 = 2
245}
246
247enum OutputShapeRounding : byte {
248 Floor = 0,
249 Ceiling = 1
250}
251
252enum PaddingMethod : byte {
253 IgnoreValue = 0,
254 Exclude = 1
255}
256
257table Pooling2dDescriptor {
258 poolType:PoolingAlgorithm;
259 padLeft:uint;
260 padRight:uint;
261 padTop:uint;
262 padBottom:uint;
263 poolWidth:uint;
264 poolHeight:uint;
265 strideX:uint;
266 strideY:uint;
267 outputShapeRounding:OutputShapeRounding;
268 paddingMethod:PaddingMethod;
269 dataLayout:DataLayout;
270}
271
Derek Lamberti87acb272019-03-27 16:51:31 +0000272table QuantizeLayer {
273 base:LayerBase;
274}
275
Aron Virginas-Tarfc413c02019-02-13 15:41:52 +0000276table SoftmaxLayer {
277 base:LayerBase;
278 descriptor:SoftmaxDescriptor;
279}
280
281table SoftmaxDescriptor {
282 beta:float;
283}
284
Aron Virginas-Tarc04125f2019-02-19 16:31:08 +0000285table DepthwiseConvolution2dLayer {
286 base:LayerBase;
287 descriptor:DepthwiseConvolution2dDescriptor;
288 weights:ConstTensor;
289 biases:ConstTensor;
290}
291
292table DepthwiseConvolution2dDescriptor {
293 padLeft:uint;
294 padRight:uint;
295 padTop:uint;
296 padBottom:uint;
297 strideX:uint;
298 strideY:uint;
299 biasEnabled:bool = false;
300 dataLayout:DataLayout = NCHW;
301}
302
Nattapat Chaimanowong969eea32019-01-30 13:33:11 +0000303table OutputLayer {
304 base:BindableLayerBase;
305}
306
Saoirse Stewart263829c2019-02-19 15:54:14 +0000307table ReshapeLayer {
308 base:LayerBase;
309 descriptor:ReshapeDescriptor;
310}
311
312table ReshapeDescriptor {
313 targetShape:[uint];
314}
315
Nattapat Chaimanowong30b00202019-02-20 17:31:34 +0000316table PermuteLayer {
317 base:LayerBase;
318 descriptor:PermuteDescriptor;
319}
320
321table PermuteDescriptor {
322 dimMappings:[uint];
323}
324
Nattapat Chaimanowong45286992019-02-26 15:53:02 +0000325table SpaceToBatchNdLayer {
326 base:LayerBase;
327 descriptor:SpaceToBatchNdDescriptor;
328}
329
330table SpaceToBatchNdDescriptor {
331 blockShape:[uint];
332 padList:[uint];
333 dataLayout:DataLayout;
334}
335
Conor Kennedyda1f9752019-03-01 14:37:12 +0000336table SubtractionLayer {
337 base:LayerBase;
338}
339
Nattapat Chaimanowong6b4ed982019-02-26 17:24:13 +0000340table BatchToSpaceNdLayer {
341 base:LayerBase;
342 descriptor:BatchToSpaceNdDescriptor;
343}
344
345table BatchToSpaceNdDescriptor {
346 blockShape:[uint];
347 crops:[uint];
348 dataLayout:DataLayout;
349}
350
Nina Drozd57728782019-02-27 10:53:27 +0000351enum NormalizationAlgorithmChannel : byte {
352 Across = 0,
353 Within = 1
354}
355
356enum NormalizationAlgorithmMethod : byte {
357 LocalBrightness = 0,
358 LocalContrast = 1
359}
360
361table NormalizationLayer {
362 base:LayerBase;
363 descriptor:NormalizationDescriptor;
364}
365
366table NormalizationDescriptor {
367 normChannelType:NormalizationAlgorithmChannel = Across;
368 normMethodType:NormalizationAlgorithmMethod = LocalBrightness;
369 normSize:uint;
370 alpha:float;
371 beta:float;
372 k:float;
373 dataLayout:DataLayout = NCHW;
374}
375
Sadik Armaganac97c8c2019-03-04 17:44:21 +0000376table MeanLayer {
377 base:LayerBase;
378 descriptor:MeanDescriptor;
379}
380
381table MeanDescriptor {
382 axis:[uint];
383 keepDims:bool = false;
384}
385
Nattapat Chaimanowongebb0f9c2019-03-01 12:14:06 +0000386table PadLayer {
387 base:LayerBase;
388 descriptor:PadDescriptor;
389}
390
391table PadDescriptor {
392 padList:[uint];
393}
394
Sadik Armagan8b42a382019-03-01 14:24:49 +0000395table RsqrtLayer {
396 base:LayerBase;
397}
398
ruoyan018e7fa232019-02-28 15:09:07 +0000399table BatchNormalizationLayer {
400 base:LayerBase;
401 descriptor:BatchNormalizationDescriptor;
402 mean:ConstTensor;
403 variance:ConstTensor;
404 beta:ConstTensor;
405 gamma:ConstTensor;
406}
407
408table BatchNormalizationDescriptor {
409 eps:float;
410 dataLayout:DataLayout;
411}
412
Nattapat Chaimanowong6522cdc2019-03-01 16:14:13 +0000413table ResizeBilinearLayer {
414 base:LayerBase;
415 descriptor:ResizeBilinearDescriptor;
416}
417
418table ResizeBilinearDescriptor {
419 targetWidth:uint;
420 targetHeight:uint;
421 dataLayout:DataLayout;
422}
423
Nattapat Chaimanowongb3485212019-03-04 12:35:39 +0000424table StridedSliceLayer {
425 base:LayerBase;
426 descriptor:StridedSliceDescriptor;
427}
428
429table StridedSliceDescriptor {
430 begin:[int];
431 end:[int];
432 stride:[int];
433 beginMask:int;
434 endMask:int;
435 shrinkAxisMask:int;
436 ellipsisMask:int;
437 newAxisMask:int;
438 dataLayout:DataLayout;
439}
440
Jim Flynnac25a1b2019-02-28 10:40:49 +0000441table MergerLayer {
442 base:LayerBase;
443 descriptor:OriginsDescriptor;
444}
445
446table UintVector {
447 data:[uint];
448}
449
450table OriginsDescriptor {
451 concatAxis:uint;
452 numViews:uint;
453 numDimensions:uint;
454 viewOrigins:[UintVector];
455}
456
Jim Flynn18ce3382019-03-08 11:08:30 +0000457table ViewsDescriptor {
458 origins:OriginsDescriptor;
459 viewSizes:[UintVector];
460}
461
462table SplitterLayer {
463 base:LayerBase;
464 descriptor:ViewsDescriptor;
465}
466
Nattapat Chaimanowong3e14a9d2019-03-18 12:37:06 +0000467table DetectionPostProcessLayer {
468 base:LayerBase;
469 descriptor:DetectionPostProcessDescriptor;
470 anchors:ConstTensor;
471}
472
473table DetectionPostProcessDescriptor {
474 maxDetections:uint;
475 maxClassesPerDetection:uint;
476 detectionsPerClass:uint;
477 nmsScoreThreshold:float;
478 nmsIouThreshold:float;
479 numClasses:uint;
480 useRegularNms:bool;
481 scaleX:float;
482 scaleY:float;
483 scaleW:float;
484 scaleH:float;
485}
486
Jim Flynn11af3752019-03-19 17:22:29 +0000487table LstmInputParams {
488 inputToForgetWeights:ConstTensor;
489 inputToCellWeights:ConstTensor;
490 inputToOutputWeights:ConstTensor;
491 recurrentToForgetWeights:ConstTensor;
492 recurrentToCellWeights:ConstTensor;
493 recurrentToOutputWeights:ConstTensor;
494 forgetGateBias:ConstTensor;
495 cellBias:ConstTensor;
496 outputGateBias:ConstTensor;
497
498 inputToInputWeights:ConstTensor;
499 recurrentToInputWeights:ConstTensor;
500 cellToInputWeights:ConstTensor;
501 inputGateBias:ConstTensor;
502
503 projectionWeights:ConstTensor;
504 projectionBias:ConstTensor;
505
506 cellToForgetWeights:ConstTensor;
507 cellToOutputWeights:ConstTensor;
508}
509
510table LstmDescriptor {
511 activationFunc:uint;
512 clippingThresCell:float;
513 clippingThresProj:float;
514 cifgEnabled:bool = true;
515 peepholeEnabled:bool = false;
516 projectionEnabled:bool = false;
517}
518
519table LstmLayer {
520 base:LayerBase;
521 descriptor:LstmDescriptor;
522 inputParams:LstmInputParams;
523}
524
Nattapat Chaimanowonge4294fd2019-03-28 09:56:53 +0000525table DequantizeLayer {
526 base:LayerBase;
527}
528
Nattapat Chaimanowong1f886302019-04-05 13:37:19 +0100529table MergeLayer {
530 base:LayerBase;
531}
532
Sadik Armaganeff363d2019-04-05 15:25:46 +0100533table SwitchLayer {
534 base:LayerBase;
535}
536
Nattapat Chaimanowong969eea32019-01-30 13:33:11 +0000537union Layer {
Mike Kellyaf484012019-02-20 16:53:11 +0000538 ActivationLayer,
Nattapat Chaimanowong969eea32019-01-30 13:33:11 +0000539 AdditionLayer,
Nattapat Chaimanowong6b4ed982019-02-26 17:24:13 +0000540 BatchToSpaceNdLayer,
ruoyan018e7fa232019-02-28 15:09:07 +0000541 BatchNormalizationLayer,
Conor Kennedy76277882019-02-26 08:29:54 +0000542 ConstantLayer,
Mike Kellya0766c32019-02-19 17:22:07 +0000543 Convolution2dLayer,
Aron Virginas-Tarc04125f2019-02-19 16:31:08 +0000544 DepthwiseConvolution2dLayer,
Sadik Armagandbb0c0c2019-02-21 09:01:41 +0000545 FullyConnectedLayer,
Nattapat Chaimanowong969eea32019-01-30 13:33:11 +0000546 InputLayer,
Sadik Armagan5f450272019-02-12 14:31:45 +0000547 MultiplicationLayer,
Aron Virginas-Tarfc413c02019-02-13 15:41:52 +0000548 OutputLayer,
Nattapat Chaimanowong30b00202019-02-20 17:31:34 +0000549 PermuteLayer,
Saoirse Stewart3166c3e2019-02-18 15:24:53 +0000550 Pooling2dLayer,
Saoirse Stewart263829c2019-02-19 15:54:14 +0000551 ReshapeLayer,
Nattapat Chaimanowong45286992019-02-26 15:53:02 +0000552 SoftmaxLayer,
Éanna Ó Catháin58885892019-02-27 16:16:39 +0000553 SpaceToBatchNdLayer,
Aron Virginas-Tar0fe32452019-02-28 13:12:47 +0000554 DivisionLayer,
Nattapat Chaimanowong235cea52019-02-28 16:27:30 +0000555 MinimumLayer,
Aron Virginas-Tar377351e2019-02-27 14:42:31 +0000556 EqualLayer,
Nina Drozd57728782019-02-27 10:53:27 +0000557 MaximumLayer,
Nattapat Chaimanowongebb0f9c2019-03-01 12:14:06 +0000558 NormalizationLayer,
Sadik Armagan8b42a382019-03-01 14:24:49 +0000559 PadLayer,
Finn Williamsdd2ba7e2019-03-01 11:51:52 +0000560 RsqrtLayer,
Conor Kennedy79ffdf52019-03-01 14:24:54 +0000561 FloorLayer,
Nattapat Chaimanowong6522cdc2019-03-01 16:14:13 +0000562 GreaterLayer,
Conor Kennedyda1f9752019-03-01 14:37:12 +0000563 ResizeBilinearLayer,
Nattapat Chaimanowongb3485212019-03-04 12:35:39 +0000564 SubtractionLayer,
Saoirse Stewarta1ed73a2019-03-04 13:40:12 +0000565 StridedSliceLayer,
Sadik Armaganac97c8c2019-03-04 17:44:21 +0000566 GatherLayer,
Jim Flynnac25a1b2019-02-28 10:40:49 +0000567 MeanLayer,
Narumol Prangnawarat495701f2019-03-07 17:31:34 +0000568 MergerLayer,
Jim Flynn18ce3382019-03-08 11:08:30 +0000569 L2NormalizationLayer,
Nattapat Chaimanowong3e14a9d2019-03-18 12:37:06 +0000570 SplitterLayer,
Jim Flynn11af3752019-03-19 17:22:29 +0000571 DetectionPostProcessLayer,
Derek Lamberti87acb272019-03-27 16:51:31 +0000572 LstmLayer,
Nattapat Chaimanowonge4294fd2019-03-28 09:56:53 +0000573 QuantizeLayer,
Nattapat Chaimanowong1f886302019-04-05 13:37:19 +0100574 DequantizeLayer,
Sadik Armaganeff363d2019-04-05 15:25:46 +0100575 MergeLayer,
576 SwitchLayer
Nattapat Chaimanowong969eea32019-01-30 13:33:11 +0000577}
578
Saoirse Stewart49dbe0e2019-02-05 17:27:06 +0000579table AnyLayer {
580 layer:Layer;
581}
582
Nattapat Chaimanowong969eea32019-01-30 13:33:11 +0000583// Root type for serialized data is the graph of the network
584table SerializedGraph {
Saoirse Stewart49dbe0e2019-02-05 17:27:06 +0000585 layers:[AnyLayer];
Mike Kelly8c1701a2019-02-11 17:01:27 +0000586 inputIds:[uint];
587 outputIds:[uint];
Nattapat Chaimanowong969eea32019-01-30 13:33:11 +0000588}
589
590root_type SerializedGraph;