blob: 8b275b6f179eaffd200a0ff74ad168194f356373 [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,
122 Merge = 37
Nattapat Chaimanowong969eea32019-01-30 13:33:11 +0000123}
124
125// Base layer table to be used as part of other layers
126table LayerBase {
127 index:uint;
128 layerName:string;
129 layerType:LayerType;
130 inputSlots:[InputSlot];
131 outputSlots:[OutputSlot];
132}
133
134table BindableLayerBase {
135 base:LayerBase;
136 layerBindingId:int;
137}
138
139// Table for each layer defined below
Mike Kellyaf484012019-02-20 16:53:11 +0000140table ActivationLayer {
141 base:LayerBase;
142 descriptor:ActivationDescriptor;
143}
144
145table ActivationDescriptor {
146 function:ActivationFunction = Sigmoid;
147 a:float;
148 b:float;
149}
150
Nattapat Chaimanowong969eea32019-01-30 13:33:11 +0000151table AdditionLayer {
152 base:LayerBase;
153}
154
Conor Kennedy76277882019-02-26 08:29:54 +0000155table ConstantLayer {
156 base:LayerBase;
157 input:ConstTensor;
158}
159
Mike Kellya0766c32019-02-19 17:22:07 +0000160table Convolution2dLayer {
161 base:LayerBase;
162 descriptor:Convolution2dDescriptor;
163 weights:ConstTensor;
164 biases:ConstTensor;
165}
166
167table Convolution2dDescriptor {
168 padLeft:uint;
169 padRight:uint;
170 padTop:uint;
171 padBottom:uint;
172 strideX:uint;
173 strideY:uint;
174 biasEnabled:bool = false;
175 dataLayout:DataLayout = NCHW;
176}
177
Éanna Ó Catháin58885892019-02-27 16:16:39 +0000178table DivisionLayer {
179 base:LayerBase;
180}
181
Nattapat Chaimanowong235cea52019-02-28 16:27:30 +0000182table EqualLayer {
183 base:LayerBase;
184}
185
Finn Williamsdd2ba7e2019-03-01 11:51:52 +0000186table FloorLayer{
187 base:LayerBase;
188}
189
Sadik Armagandbb0c0c2019-02-21 09:01:41 +0000190table FullyConnectedLayer {
191 base:LayerBase;
192 descriptor:FullyConnectedDescriptor;
193 weights:ConstTensor;
194 biases:ConstTensor;
195}
196
197table FullyConnectedDescriptor {
198 biasEnabled:bool = false;
199 transposeWeightsMatrix:bool = false;
200}
201
Saoirse Stewarta1ed73a2019-03-04 13:40:12 +0000202table GatherLayer {
203 base:LayerBase;
204}
205
Conor Kennedy79ffdf52019-03-01 14:24:54 +0000206table GreaterLayer {
207 base:LayerBase;
208}
209
Nattapat Chaimanowong969eea32019-01-30 13:33:11 +0000210table InputLayer {
211 base:BindableLayerBase;
212}
213
Narumol Prangnawarat495701f2019-03-07 17:31:34 +0000214table L2NormalizationLayer {
215 base:LayerBase;
216 descriptor:L2NormalizationDescriptor;
217}
218
219table L2NormalizationDescriptor {
220 dataLayout:DataLayout = NCHW;
221}
222
Aron Virginas-Tar0fe32452019-02-28 13:12:47 +0000223table MinimumLayer {
224 base:LayerBase;
225}
226
Aron Virginas-Tar377351e2019-02-27 14:42:31 +0000227table MaximumLayer {
228 base:LayerBase;
229}
230
Sadik Armagan5f450272019-02-12 14:31:45 +0000231table MultiplicationLayer {
232 base:LayerBase;
233}
234
Saoirse Stewart3166c3e2019-02-18 15:24:53 +0000235table Pooling2dLayer {
236 base:LayerBase;
237 descriptor:Pooling2dDescriptor;
238}
239
240enum PoolingAlgorithm : byte {
241 Max = 0,
242 Average = 1,
243 L2 = 2
244}
245
246enum OutputShapeRounding : byte {
247 Floor = 0,
248 Ceiling = 1
249}
250
251enum PaddingMethod : byte {
252 IgnoreValue = 0,
253 Exclude = 1
254}
255
256table Pooling2dDescriptor {
257 poolType:PoolingAlgorithm;
258 padLeft:uint;
259 padRight:uint;
260 padTop:uint;
261 padBottom:uint;
262 poolWidth:uint;
263 poolHeight:uint;
264 strideX:uint;
265 strideY:uint;
266 outputShapeRounding:OutputShapeRounding;
267 paddingMethod:PaddingMethod;
268 dataLayout:DataLayout;
269}
270
Derek Lamberti87acb272019-03-27 16:51:31 +0000271table QuantizeLayer {
272 base:LayerBase;
273}
274
Aron Virginas-Tarfc413c02019-02-13 15:41:52 +0000275table SoftmaxLayer {
276 base:LayerBase;
277 descriptor:SoftmaxDescriptor;
278}
279
280table SoftmaxDescriptor {
281 beta:float;
282}
283
Aron Virginas-Tarc04125f2019-02-19 16:31:08 +0000284table DepthwiseConvolution2dLayer {
285 base:LayerBase;
286 descriptor:DepthwiseConvolution2dDescriptor;
287 weights:ConstTensor;
288 biases:ConstTensor;
289}
290
291table DepthwiseConvolution2dDescriptor {
292 padLeft:uint;
293 padRight:uint;
294 padTop:uint;
295 padBottom:uint;
296 strideX:uint;
297 strideY:uint;
298 biasEnabled:bool = false;
299 dataLayout:DataLayout = NCHW;
300}
301
Nattapat Chaimanowong969eea32019-01-30 13:33:11 +0000302table OutputLayer {
303 base:BindableLayerBase;
304}
305
Saoirse Stewart263829c2019-02-19 15:54:14 +0000306table ReshapeLayer {
307 base:LayerBase;
308 descriptor:ReshapeDescriptor;
309}
310
311table ReshapeDescriptor {
312 targetShape:[uint];
313}
314
Nattapat Chaimanowong30b00202019-02-20 17:31:34 +0000315table PermuteLayer {
316 base:LayerBase;
317 descriptor:PermuteDescriptor;
318}
319
320table PermuteDescriptor {
321 dimMappings:[uint];
322}
323
Nattapat Chaimanowong45286992019-02-26 15:53:02 +0000324table SpaceToBatchNdLayer {
325 base:LayerBase;
326 descriptor:SpaceToBatchNdDescriptor;
327}
328
329table SpaceToBatchNdDescriptor {
330 blockShape:[uint];
331 padList:[uint];
332 dataLayout:DataLayout;
333}
334
Conor Kennedyda1f9752019-03-01 14:37:12 +0000335table SubtractionLayer {
336 base:LayerBase;
337}
338
Nattapat Chaimanowong6b4ed982019-02-26 17:24:13 +0000339table BatchToSpaceNdLayer {
340 base:LayerBase;
341 descriptor:BatchToSpaceNdDescriptor;
342}
343
344table BatchToSpaceNdDescriptor {
345 blockShape:[uint];
346 crops:[uint];
347 dataLayout:DataLayout;
348}
349
Nina Drozd57728782019-02-27 10:53:27 +0000350enum NormalizationAlgorithmChannel : byte {
351 Across = 0,
352 Within = 1
353}
354
355enum NormalizationAlgorithmMethod : byte {
356 LocalBrightness = 0,
357 LocalContrast = 1
358}
359
360table NormalizationLayer {
361 base:LayerBase;
362 descriptor:NormalizationDescriptor;
363}
364
365table NormalizationDescriptor {
366 normChannelType:NormalizationAlgorithmChannel = Across;
367 normMethodType:NormalizationAlgorithmMethod = LocalBrightness;
368 normSize:uint;
369 alpha:float;
370 beta:float;
371 k:float;
372 dataLayout:DataLayout = NCHW;
373}
374
Sadik Armaganac97c8c2019-03-04 17:44:21 +0000375table MeanLayer {
376 base:LayerBase;
377 descriptor:MeanDescriptor;
378}
379
380table MeanDescriptor {
381 axis:[uint];
382 keepDims:bool = false;
383}
384
Nattapat Chaimanowongebb0f9c2019-03-01 12:14:06 +0000385table PadLayer {
386 base:LayerBase;
387 descriptor:PadDescriptor;
388}
389
390table PadDescriptor {
391 padList:[uint];
392}
393
Sadik Armagan8b42a382019-03-01 14:24:49 +0000394table RsqrtLayer {
395 base:LayerBase;
396}
397
ruoyan018e7fa232019-02-28 15:09:07 +0000398table BatchNormalizationLayer {
399 base:LayerBase;
400 descriptor:BatchNormalizationDescriptor;
401 mean:ConstTensor;
402 variance:ConstTensor;
403 beta:ConstTensor;
404 gamma:ConstTensor;
405}
406
407table BatchNormalizationDescriptor {
408 eps:float;
409 dataLayout:DataLayout;
410}
411
Nattapat Chaimanowong6522cdc2019-03-01 16:14:13 +0000412table ResizeBilinearLayer {
413 base:LayerBase;
414 descriptor:ResizeBilinearDescriptor;
415}
416
417table ResizeBilinearDescriptor {
418 targetWidth:uint;
419 targetHeight:uint;
420 dataLayout:DataLayout;
421}
422
Nattapat Chaimanowongb3485212019-03-04 12:35:39 +0000423table StridedSliceLayer {
424 base:LayerBase;
425 descriptor:StridedSliceDescriptor;
426}
427
428table StridedSliceDescriptor {
429 begin:[int];
430 end:[int];
431 stride:[int];
432 beginMask:int;
433 endMask:int;
434 shrinkAxisMask:int;
435 ellipsisMask:int;
436 newAxisMask:int;
437 dataLayout:DataLayout;
438}
439
Jim Flynnac25a1b2019-02-28 10:40:49 +0000440table MergerLayer {
441 base:LayerBase;
442 descriptor:OriginsDescriptor;
443}
444
445table UintVector {
446 data:[uint];
447}
448
449table OriginsDescriptor {
450 concatAxis:uint;
451 numViews:uint;
452 numDimensions:uint;
453 viewOrigins:[UintVector];
454}
455
Jim Flynn18ce3382019-03-08 11:08:30 +0000456table ViewsDescriptor {
457 origins:OriginsDescriptor;
458 viewSizes:[UintVector];
459}
460
461table SplitterLayer {
462 base:LayerBase;
463 descriptor:ViewsDescriptor;
464}
465
Nattapat Chaimanowong3e14a9d2019-03-18 12:37:06 +0000466table DetectionPostProcessLayer {
467 base:LayerBase;
468 descriptor:DetectionPostProcessDescriptor;
469 anchors:ConstTensor;
470}
471
472table DetectionPostProcessDescriptor {
473 maxDetections:uint;
474 maxClassesPerDetection:uint;
475 detectionsPerClass:uint;
476 nmsScoreThreshold:float;
477 nmsIouThreshold:float;
478 numClasses:uint;
479 useRegularNms:bool;
480 scaleX:float;
481 scaleY:float;
482 scaleW:float;
483 scaleH:float;
484}
485
Jim Flynn11af3752019-03-19 17:22:29 +0000486table LstmInputParams {
487 inputToForgetWeights:ConstTensor;
488 inputToCellWeights:ConstTensor;
489 inputToOutputWeights:ConstTensor;
490 recurrentToForgetWeights:ConstTensor;
491 recurrentToCellWeights:ConstTensor;
492 recurrentToOutputWeights:ConstTensor;
493 forgetGateBias:ConstTensor;
494 cellBias:ConstTensor;
495 outputGateBias:ConstTensor;
496
497 inputToInputWeights:ConstTensor;
498 recurrentToInputWeights:ConstTensor;
499 cellToInputWeights:ConstTensor;
500 inputGateBias:ConstTensor;
501
502 projectionWeights:ConstTensor;
503 projectionBias:ConstTensor;
504
505 cellToForgetWeights:ConstTensor;
506 cellToOutputWeights:ConstTensor;
507}
508
509table LstmDescriptor {
510 activationFunc:uint;
511 clippingThresCell:float;
512 clippingThresProj:float;
513 cifgEnabled:bool = true;
514 peepholeEnabled:bool = false;
515 projectionEnabled:bool = false;
516}
517
518table LstmLayer {
519 base:LayerBase;
520 descriptor:LstmDescriptor;
521 inputParams:LstmInputParams;
522}
523
Nattapat Chaimanowonge4294fd2019-03-28 09:56:53 +0000524table DequantizeLayer {
525 base:LayerBase;
526}
527
Nattapat Chaimanowong1f886302019-04-05 13:37:19 +0100528table MergeLayer {
529 base:LayerBase;
530}
531
Nattapat Chaimanowong969eea32019-01-30 13:33:11 +0000532union Layer {
Mike Kellyaf484012019-02-20 16:53:11 +0000533 ActivationLayer,
Nattapat Chaimanowong969eea32019-01-30 13:33:11 +0000534 AdditionLayer,
Nattapat Chaimanowong6b4ed982019-02-26 17:24:13 +0000535 BatchToSpaceNdLayer,
ruoyan018e7fa232019-02-28 15:09:07 +0000536 BatchNormalizationLayer,
Conor Kennedy76277882019-02-26 08:29:54 +0000537 ConstantLayer,
Mike Kellya0766c32019-02-19 17:22:07 +0000538 Convolution2dLayer,
Aron Virginas-Tarc04125f2019-02-19 16:31:08 +0000539 DepthwiseConvolution2dLayer,
Sadik Armagandbb0c0c2019-02-21 09:01:41 +0000540 FullyConnectedLayer,
Nattapat Chaimanowong969eea32019-01-30 13:33:11 +0000541 InputLayer,
Sadik Armagan5f450272019-02-12 14:31:45 +0000542 MultiplicationLayer,
Aron Virginas-Tarfc413c02019-02-13 15:41:52 +0000543 OutputLayer,
Nattapat Chaimanowong30b00202019-02-20 17:31:34 +0000544 PermuteLayer,
Saoirse Stewart3166c3e2019-02-18 15:24:53 +0000545 Pooling2dLayer,
Saoirse Stewart263829c2019-02-19 15:54:14 +0000546 ReshapeLayer,
Nattapat Chaimanowong45286992019-02-26 15:53:02 +0000547 SoftmaxLayer,
Éanna Ó Catháin58885892019-02-27 16:16:39 +0000548 SpaceToBatchNdLayer,
Aron Virginas-Tar0fe32452019-02-28 13:12:47 +0000549 DivisionLayer,
Nattapat Chaimanowong235cea52019-02-28 16:27:30 +0000550 MinimumLayer,
Aron Virginas-Tar377351e2019-02-27 14:42:31 +0000551 EqualLayer,
Nina Drozd57728782019-02-27 10:53:27 +0000552 MaximumLayer,
Nattapat Chaimanowongebb0f9c2019-03-01 12:14:06 +0000553 NormalizationLayer,
Sadik Armagan8b42a382019-03-01 14:24:49 +0000554 PadLayer,
Finn Williamsdd2ba7e2019-03-01 11:51:52 +0000555 RsqrtLayer,
Conor Kennedy79ffdf52019-03-01 14:24:54 +0000556 FloorLayer,
Nattapat Chaimanowong6522cdc2019-03-01 16:14:13 +0000557 GreaterLayer,
Conor Kennedyda1f9752019-03-01 14:37:12 +0000558 ResizeBilinearLayer,
Nattapat Chaimanowongb3485212019-03-04 12:35:39 +0000559 SubtractionLayer,
Saoirse Stewarta1ed73a2019-03-04 13:40:12 +0000560 StridedSliceLayer,
Sadik Armaganac97c8c2019-03-04 17:44:21 +0000561 GatherLayer,
Jim Flynnac25a1b2019-02-28 10:40:49 +0000562 MeanLayer,
Narumol Prangnawarat495701f2019-03-07 17:31:34 +0000563 MergerLayer,
Jim Flynn18ce3382019-03-08 11:08:30 +0000564 L2NormalizationLayer,
Nattapat Chaimanowong3e14a9d2019-03-18 12:37:06 +0000565 SplitterLayer,
Jim Flynn11af3752019-03-19 17:22:29 +0000566 DetectionPostProcessLayer,
Derek Lamberti87acb272019-03-27 16:51:31 +0000567 LstmLayer,
Nattapat Chaimanowonge4294fd2019-03-28 09:56:53 +0000568 QuantizeLayer,
Nattapat Chaimanowong1f886302019-04-05 13:37:19 +0100569 DequantizeLayer,
570 MergeLayer
Nattapat Chaimanowong969eea32019-01-30 13:33:11 +0000571}
572
Saoirse Stewart49dbe0e2019-02-05 17:27:06 +0000573table AnyLayer {
574 layer:Layer;
575}
576
Nattapat Chaimanowong969eea32019-01-30 13:33:11 +0000577// Root type for serialized data is the graph of the network
578table SerializedGraph {
Saoirse Stewart49dbe0e2019-02-05 17:27:06 +0000579 layers:[AnyLayer];
Mike Kelly8c1701a2019-02-11 17:01:27 +0000580 inputIds:[uint];
581 outputIds:[uint];
Nattapat Chaimanowong969eea32019-01-30 13:33:11 +0000582}
583
584root_type SerializedGraph;