blob: 5a001de545d9695486f793a2bc6e323f901ee26a [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,
124 Concat = 39
Nattapat Chaimanowong969eea32019-01-30 13:33:11 +0000125}
126
127// Base layer table to be used as part of other layers
128table LayerBase {
129 index:uint;
130 layerName:string;
131 layerType:LayerType;
132 inputSlots:[InputSlot];
133 outputSlots:[OutputSlot];
134}
135
136table BindableLayerBase {
137 base:LayerBase;
138 layerBindingId:int;
139}
140
141// Table for each layer defined below
Mike Kellyaf484012019-02-20 16:53:11 +0000142table ActivationLayer {
143 base:LayerBase;
144 descriptor:ActivationDescriptor;
145}
146
147table ActivationDescriptor {
148 function:ActivationFunction = Sigmoid;
149 a:float;
150 b:float;
151}
152
Nattapat Chaimanowong969eea32019-01-30 13:33:11 +0000153table AdditionLayer {
154 base:LayerBase;
155}
156
Conor Kennedy76277882019-02-26 08:29:54 +0000157table ConstantLayer {
158 base:LayerBase;
159 input:ConstTensor;
160}
161
Mike Kellya0766c32019-02-19 17:22:07 +0000162table Convolution2dLayer {
163 base:LayerBase;
164 descriptor:Convolution2dDescriptor;
165 weights:ConstTensor;
166 biases:ConstTensor;
167}
168
169table Convolution2dDescriptor {
170 padLeft:uint;
171 padRight:uint;
172 padTop:uint;
173 padBottom:uint;
174 strideX:uint;
175 strideY:uint;
Matthew Benthamacad04e2019-05-13 10:02:45 +0100176 dilationX:uint = 1;
177 dilationY:uint = 1;
Mike Kellya0766c32019-02-19 17:22:07 +0000178 biasEnabled:bool = false;
179 dataLayout:DataLayout = NCHW;
180}
181
Éanna Ó Catháin58885892019-02-27 16:16:39 +0000182table DivisionLayer {
183 base:LayerBase;
184}
185
Nattapat Chaimanowong235cea52019-02-28 16:27:30 +0000186table EqualLayer {
187 base:LayerBase;
188}
189
Finn Williamsdd2ba7e2019-03-01 11:51:52 +0000190table FloorLayer{
191 base:LayerBase;
192}
193
Sadik Armagandbb0c0c2019-02-21 09:01:41 +0000194table FullyConnectedLayer {
195 base:LayerBase;
196 descriptor:FullyConnectedDescriptor;
197 weights:ConstTensor;
198 biases:ConstTensor;
199}
200
201table FullyConnectedDescriptor {
202 biasEnabled:bool = false;
203 transposeWeightsMatrix:bool = false;
204}
205
Saoirse Stewarta1ed73a2019-03-04 13:40:12 +0000206table GatherLayer {
207 base:LayerBase;
208}
209
Conor Kennedy79ffdf52019-03-01 14:24:54 +0000210table GreaterLayer {
211 base:LayerBase;
212}
213
Nattapat Chaimanowong969eea32019-01-30 13:33:11 +0000214table InputLayer {
215 base:BindableLayerBase;
216}
217
Narumol Prangnawarat495701f2019-03-07 17:31:34 +0000218table L2NormalizationLayer {
219 base:LayerBase;
220 descriptor:L2NormalizationDescriptor;
221}
222
223table L2NormalizationDescriptor {
224 dataLayout:DataLayout = NCHW;
225}
226
Aron Virginas-Tar0fe32452019-02-28 13:12:47 +0000227table MinimumLayer {
228 base:LayerBase;
229}
230
Aron Virginas-Tar377351e2019-02-27 14:42:31 +0000231table MaximumLayer {
232 base:LayerBase;
233}
234
Sadik Armagan5f450272019-02-12 14:31:45 +0000235table MultiplicationLayer {
236 base:LayerBase;
237}
238
Saoirse Stewart3166c3e2019-02-18 15:24:53 +0000239table Pooling2dLayer {
240 base:LayerBase;
241 descriptor:Pooling2dDescriptor;
242}
243
244enum PoolingAlgorithm : byte {
245 Max = 0,
246 Average = 1,
247 L2 = 2
248}
249
250enum OutputShapeRounding : byte {
251 Floor = 0,
252 Ceiling = 1
253}
254
255enum PaddingMethod : byte {
256 IgnoreValue = 0,
257 Exclude = 1
258}
259
260table Pooling2dDescriptor {
261 poolType:PoolingAlgorithm;
262 padLeft:uint;
263 padRight:uint;
264 padTop:uint;
265 padBottom:uint;
266 poolWidth:uint;
267 poolHeight:uint;
268 strideX:uint;
269 strideY:uint;
270 outputShapeRounding:OutputShapeRounding;
271 paddingMethod:PaddingMethod;
272 dataLayout:DataLayout;
273}
274
Derek Lamberti87acb272019-03-27 16:51:31 +0000275table QuantizeLayer {
276 base:LayerBase;
277}
278
Aron Virginas-Tarfc413c02019-02-13 15:41:52 +0000279table SoftmaxLayer {
280 base:LayerBase;
281 descriptor:SoftmaxDescriptor;
282}
283
284table SoftmaxDescriptor {
285 beta:float;
286}
287
Aron Virginas-Tarc04125f2019-02-19 16:31:08 +0000288table DepthwiseConvolution2dLayer {
289 base:LayerBase;
290 descriptor:DepthwiseConvolution2dDescriptor;
291 weights:ConstTensor;
292 biases:ConstTensor;
293}
294
295table DepthwiseConvolution2dDescriptor {
296 padLeft:uint;
297 padRight:uint;
298 padTop:uint;
299 padBottom:uint;
300 strideX:uint;
301 strideY:uint;
Matthew Benthamacad04e2019-05-13 10:02:45 +0100302 dilationX:uint = 1;
303 dilationY:uint = 1;
Aron Virginas-Tarc04125f2019-02-19 16:31:08 +0000304 biasEnabled:bool = false;
305 dataLayout:DataLayout = NCHW;
306}
307
Nattapat Chaimanowong969eea32019-01-30 13:33:11 +0000308table OutputLayer {
309 base:BindableLayerBase;
310}
311
Saoirse Stewart263829c2019-02-19 15:54:14 +0000312table ReshapeLayer {
313 base:LayerBase;
314 descriptor:ReshapeDescriptor;
315}
316
317table ReshapeDescriptor {
318 targetShape:[uint];
319}
320
Nattapat Chaimanowong30b00202019-02-20 17:31:34 +0000321table PermuteLayer {
322 base:LayerBase;
323 descriptor:PermuteDescriptor;
324}
325
326table PermuteDescriptor {
327 dimMappings:[uint];
328}
329
Nattapat Chaimanowong45286992019-02-26 15:53:02 +0000330table SpaceToBatchNdLayer {
331 base:LayerBase;
332 descriptor:SpaceToBatchNdDescriptor;
333}
334
335table SpaceToBatchNdDescriptor {
336 blockShape:[uint];
337 padList:[uint];
338 dataLayout:DataLayout;
339}
340
Conor Kennedyda1f9752019-03-01 14:37:12 +0000341table SubtractionLayer {
342 base:LayerBase;
343}
344
Nattapat Chaimanowong6b4ed982019-02-26 17:24:13 +0000345table BatchToSpaceNdLayer {
346 base:LayerBase;
347 descriptor:BatchToSpaceNdDescriptor;
348}
349
350table BatchToSpaceNdDescriptor {
351 blockShape:[uint];
352 crops:[uint];
353 dataLayout:DataLayout;
354}
355
Nina Drozd57728782019-02-27 10:53:27 +0000356enum NormalizationAlgorithmChannel : byte {
357 Across = 0,
358 Within = 1
359}
360
361enum NormalizationAlgorithmMethod : byte {
362 LocalBrightness = 0,
363 LocalContrast = 1
364}
365
366table NormalizationLayer {
367 base:LayerBase;
368 descriptor:NormalizationDescriptor;
369}
370
371table NormalizationDescriptor {
372 normChannelType:NormalizationAlgorithmChannel = Across;
373 normMethodType:NormalizationAlgorithmMethod = LocalBrightness;
374 normSize:uint;
375 alpha:float;
376 beta:float;
377 k:float;
378 dataLayout:DataLayout = NCHW;
379}
380
Sadik Armaganac97c8c2019-03-04 17:44:21 +0000381table MeanLayer {
382 base:LayerBase;
383 descriptor:MeanDescriptor;
384}
385
386table MeanDescriptor {
387 axis:[uint];
388 keepDims:bool = false;
389}
390
Nattapat Chaimanowongebb0f9c2019-03-01 12:14:06 +0000391table PadLayer {
392 base:LayerBase;
393 descriptor:PadDescriptor;
394}
395
396table PadDescriptor {
397 padList:[uint];
398}
399
Sadik Armagan8b42a382019-03-01 14:24:49 +0000400table RsqrtLayer {
401 base:LayerBase;
402}
403
ruoyan018e7fa232019-02-28 15:09:07 +0000404table BatchNormalizationLayer {
405 base:LayerBase;
406 descriptor:BatchNormalizationDescriptor;
407 mean:ConstTensor;
408 variance:ConstTensor;
409 beta:ConstTensor;
410 gamma:ConstTensor;
411}
412
413table BatchNormalizationDescriptor {
414 eps:float;
415 dataLayout:DataLayout;
416}
417
Nattapat Chaimanowong6522cdc2019-03-01 16:14:13 +0000418table ResizeBilinearLayer {
419 base:LayerBase;
420 descriptor:ResizeBilinearDescriptor;
421}
422
423table ResizeBilinearDescriptor {
424 targetWidth:uint;
425 targetHeight:uint;
426 dataLayout:DataLayout;
427}
428
Nattapat Chaimanowongb3485212019-03-04 12:35:39 +0000429table StridedSliceLayer {
430 base:LayerBase;
431 descriptor:StridedSliceDescriptor;
432}
433
434table StridedSliceDescriptor {
435 begin:[int];
436 end:[int];
437 stride:[int];
438 beginMask:int;
439 endMask:int;
440 shrinkAxisMask:int;
441 ellipsisMask:int;
442 newAxisMask:int;
443 dataLayout:DataLayout;
444}
445
Jim Flynne242f2d2019-05-22 14:24:13 +0100446table ConcatLayer {
447 base:LayerBase;
448 descriptor:OriginsDescriptor;
449}
450
Jim Flynnac25a1b2019-02-28 10:40:49 +0000451table MergerLayer {
452 base:LayerBase;
453 descriptor:OriginsDescriptor;
454}
455
456table UintVector {
457 data:[uint];
458}
459
460table OriginsDescriptor {
461 concatAxis:uint;
462 numViews:uint;
463 numDimensions:uint;
464 viewOrigins:[UintVector];
465}
466
Jim Flynn18ce3382019-03-08 11:08:30 +0000467table ViewsDescriptor {
468 origins:OriginsDescriptor;
469 viewSizes:[UintVector];
470}
471
472table SplitterLayer {
473 base:LayerBase;
474 descriptor:ViewsDescriptor;
475}
476
Nattapat Chaimanowong3e14a9d2019-03-18 12:37:06 +0000477table DetectionPostProcessLayer {
478 base:LayerBase;
479 descriptor:DetectionPostProcessDescriptor;
480 anchors:ConstTensor;
481}
482
483table DetectionPostProcessDescriptor {
484 maxDetections:uint;
485 maxClassesPerDetection:uint;
486 detectionsPerClass:uint;
487 nmsScoreThreshold:float;
488 nmsIouThreshold:float;
489 numClasses:uint;
490 useRegularNms:bool;
491 scaleX:float;
492 scaleY:float;
493 scaleW:float;
494 scaleH:float;
495}
496
Jim Flynn11af3752019-03-19 17:22:29 +0000497table LstmInputParams {
498 inputToForgetWeights:ConstTensor;
499 inputToCellWeights:ConstTensor;
500 inputToOutputWeights:ConstTensor;
501 recurrentToForgetWeights:ConstTensor;
502 recurrentToCellWeights:ConstTensor;
503 recurrentToOutputWeights:ConstTensor;
504 forgetGateBias:ConstTensor;
505 cellBias:ConstTensor;
506 outputGateBias:ConstTensor;
507
508 inputToInputWeights:ConstTensor;
509 recurrentToInputWeights:ConstTensor;
510 cellToInputWeights:ConstTensor;
511 inputGateBias:ConstTensor;
512
513 projectionWeights:ConstTensor;
514 projectionBias:ConstTensor;
515
516 cellToForgetWeights:ConstTensor;
517 cellToOutputWeights:ConstTensor;
518}
519
520table LstmDescriptor {
521 activationFunc:uint;
522 clippingThresCell:float;
523 clippingThresProj:float;
524 cifgEnabled:bool = true;
525 peepholeEnabled:bool = false;
526 projectionEnabled:bool = false;
527}
528
529table LstmLayer {
530 base:LayerBase;
531 descriptor:LstmDescriptor;
532 inputParams:LstmInputParams;
533}
534
Nattapat Chaimanowonge4294fd2019-03-28 09:56:53 +0000535table DequantizeLayer {
536 base:LayerBase;
537}
538
Nattapat Chaimanowong1f886302019-04-05 13:37:19 +0100539table MergeLayer {
540 base:LayerBase;
541}
542
Sadik Armaganeff363d2019-04-05 15:25:46 +0100543table SwitchLayer {
544 base:LayerBase;
545}
546
Nattapat Chaimanowong969eea32019-01-30 13:33:11 +0000547union Layer {
Mike Kellyaf484012019-02-20 16:53:11 +0000548 ActivationLayer,
Nattapat Chaimanowong969eea32019-01-30 13:33:11 +0000549 AdditionLayer,
Nattapat Chaimanowong6b4ed982019-02-26 17:24:13 +0000550 BatchToSpaceNdLayer,
ruoyan018e7fa232019-02-28 15:09:07 +0000551 BatchNormalizationLayer,
Conor Kennedy76277882019-02-26 08:29:54 +0000552 ConstantLayer,
Mike Kellya0766c32019-02-19 17:22:07 +0000553 Convolution2dLayer,
Aron Virginas-Tarc04125f2019-02-19 16:31:08 +0000554 DepthwiseConvolution2dLayer,
Sadik Armagandbb0c0c2019-02-21 09:01:41 +0000555 FullyConnectedLayer,
Nattapat Chaimanowong969eea32019-01-30 13:33:11 +0000556 InputLayer,
Sadik Armagan5f450272019-02-12 14:31:45 +0000557 MultiplicationLayer,
Aron Virginas-Tarfc413c02019-02-13 15:41:52 +0000558 OutputLayer,
Nattapat Chaimanowong30b00202019-02-20 17:31:34 +0000559 PermuteLayer,
Saoirse Stewart3166c3e2019-02-18 15:24:53 +0000560 Pooling2dLayer,
Saoirse Stewart263829c2019-02-19 15:54:14 +0000561 ReshapeLayer,
Nattapat Chaimanowong45286992019-02-26 15:53:02 +0000562 SoftmaxLayer,
Éanna Ó Catháin58885892019-02-27 16:16:39 +0000563 SpaceToBatchNdLayer,
Aron Virginas-Tar0fe32452019-02-28 13:12:47 +0000564 DivisionLayer,
Nattapat Chaimanowong235cea52019-02-28 16:27:30 +0000565 MinimumLayer,
Aron Virginas-Tar377351e2019-02-27 14:42:31 +0000566 EqualLayer,
Nina Drozd57728782019-02-27 10:53:27 +0000567 MaximumLayer,
Nattapat Chaimanowongebb0f9c2019-03-01 12:14:06 +0000568 NormalizationLayer,
Sadik Armagan8b42a382019-03-01 14:24:49 +0000569 PadLayer,
Finn Williamsdd2ba7e2019-03-01 11:51:52 +0000570 RsqrtLayer,
Conor Kennedy79ffdf52019-03-01 14:24:54 +0000571 FloorLayer,
Nattapat Chaimanowong6522cdc2019-03-01 16:14:13 +0000572 GreaterLayer,
Conor Kennedyda1f9752019-03-01 14:37:12 +0000573 ResizeBilinearLayer,
Nattapat Chaimanowongb3485212019-03-04 12:35:39 +0000574 SubtractionLayer,
Saoirse Stewarta1ed73a2019-03-04 13:40:12 +0000575 StridedSliceLayer,
Sadik Armaganac97c8c2019-03-04 17:44:21 +0000576 GatherLayer,
Jim Flynnac25a1b2019-02-28 10:40:49 +0000577 MeanLayer,
Narumol Prangnawarat495701f2019-03-07 17:31:34 +0000578 MergerLayer,
Jim Flynn18ce3382019-03-08 11:08:30 +0000579 L2NormalizationLayer,
Nattapat Chaimanowong3e14a9d2019-03-18 12:37:06 +0000580 SplitterLayer,
Jim Flynn11af3752019-03-19 17:22:29 +0000581 DetectionPostProcessLayer,
Derek Lamberti87acb272019-03-27 16:51:31 +0000582 LstmLayer,
Nattapat Chaimanowonge4294fd2019-03-28 09:56:53 +0000583 QuantizeLayer,
Nattapat Chaimanowong1f886302019-04-05 13:37:19 +0100584 DequantizeLayer,
Sadik Armaganeff363d2019-04-05 15:25:46 +0100585 MergeLayer,
Jim Flynne242f2d2019-05-22 14:24:13 +0100586 SwitchLayer,
587 ConcatLayer
Nattapat Chaimanowong969eea32019-01-30 13:33:11 +0000588}
589
Saoirse Stewart49dbe0e2019-02-05 17:27:06 +0000590table AnyLayer {
591 layer:Layer;
592}
593
Nattapat Chaimanowong969eea32019-01-30 13:33:11 +0000594// Root type for serialized data is the graph of the network
595table SerializedGraph {
Saoirse Stewart49dbe0e2019-02-05 17:27:06 +0000596 layers:[AnyLayer];
Mike Kelly8c1701a2019-02-11 17:01:27 +0000597 inputIds:[uint];
598 outputIds:[uint];
Nattapat Chaimanowong969eea32019-01-30 13:33:11 +0000599}
600
601root_type SerializedGraph;