blob: 3aa644dbe56584fba3f67dd9e81eecd9981973b0 [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,
121 Dequantize = 36
Nattapat Chaimanowong969eea32019-01-30 13:33:11 +0000122}
123
124// Base layer table to be used as part of other layers
125table LayerBase {
126 index:uint;
127 layerName:string;
128 layerType:LayerType;
129 inputSlots:[InputSlot];
130 outputSlots:[OutputSlot];
131}
132
133table BindableLayerBase {
134 base:LayerBase;
135 layerBindingId:int;
136}
137
138// Table for each layer defined below
Mike Kellyaf484012019-02-20 16:53:11 +0000139table ActivationLayer {
140 base:LayerBase;
141 descriptor:ActivationDescriptor;
142}
143
144table ActivationDescriptor {
145 function:ActivationFunction = Sigmoid;
146 a:float;
147 b:float;
148}
149
Nattapat Chaimanowong969eea32019-01-30 13:33:11 +0000150table AdditionLayer {
151 base:LayerBase;
152}
153
Conor Kennedy76277882019-02-26 08:29:54 +0000154table ConstantLayer {
155 base:LayerBase;
156 input:ConstTensor;
157}
158
Mike Kellya0766c32019-02-19 17:22:07 +0000159table Convolution2dLayer {
160 base:LayerBase;
161 descriptor:Convolution2dDescriptor;
162 weights:ConstTensor;
163 biases:ConstTensor;
164}
165
166table Convolution2dDescriptor {
167 padLeft:uint;
168 padRight:uint;
169 padTop:uint;
170 padBottom:uint;
171 strideX:uint;
172 strideY:uint;
173 biasEnabled:bool = false;
174 dataLayout:DataLayout = NCHW;
175}
176
Éanna Ó Catháin58885892019-02-27 16:16:39 +0000177table DivisionLayer {
178 base:LayerBase;
179}
180
Nattapat Chaimanowong235cea52019-02-28 16:27:30 +0000181table EqualLayer {
182 base:LayerBase;
183}
184
Finn Williamsdd2ba7e2019-03-01 11:51:52 +0000185table FloorLayer{
186 base:LayerBase;
187}
188
Sadik Armagandbb0c0c2019-02-21 09:01:41 +0000189table FullyConnectedLayer {
190 base:LayerBase;
191 descriptor:FullyConnectedDescriptor;
192 weights:ConstTensor;
193 biases:ConstTensor;
194}
195
196table FullyConnectedDescriptor {
197 biasEnabled:bool = false;
198 transposeWeightsMatrix:bool = false;
199}
200
Saoirse Stewarta1ed73a2019-03-04 13:40:12 +0000201table GatherLayer {
202 base:LayerBase;
203}
204
Conor Kennedy79ffdf52019-03-01 14:24:54 +0000205table GreaterLayer {
206 base:LayerBase;
207}
208
Nattapat Chaimanowong969eea32019-01-30 13:33:11 +0000209table InputLayer {
210 base:BindableLayerBase;
211}
212
Narumol Prangnawarat495701f2019-03-07 17:31:34 +0000213table L2NormalizationLayer {
214 base:LayerBase;
215 descriptor:L2NormalizationDescriptor;
216}
217
218table L2NormalizationDescriptor {
219 dataLayout:DataLayout = NCHW;
220}
221
Aron Virginas-Tar0fe32452019-02-28 13:12:47 +0000222table MinimumLayer {
223 base:LayerBase;
224}
225
Aron Virginas-Tar377351e2019-02-27 14:42:31 +0000226table MaximumLayer {
227 base:LayerBase;
228}
229
Sadik Armagan5f450272019-02-12 14:31:45 +0000230table MultiplicationLayer {
231 base:LayerBase;
232}
233
Saoirse Stewart3166c3e2019-02-18 15:24:53 +0000234table Pooling2dLayer {
235 base:LayerBase;
236 descriptor:Pooling2dDescriptor;
237}
238
239enum PoolingAlgorithm : byte {
240 Max = 0,
241 Average = 1,
242 L2 = 2
243}
244
245enum OutputShapeRounding : byte {
246 Floor = 0,
247 Ceiling = 1
248}
249
250enum PaddingMethod : byte {
251 IgnoreValue = 0,
252 Exclude = 1
253}
254
255table Pooling2dDescriptor {
256 poolType:PoolingAlgorithm;
257 padLeft:uint;
258 padRight:uint;
259 padTop:uint;
260 padBottom:uint;
261 poolWidth:uint;
262 poolHeight:uint;
263 strideX:uint;
264 strideY:uint;
265 outputShapeRounding:OutputShapeRounding;
266 paddingMethod:PaddingMethod;
267 dataLayout:DataLayout;
268}
269
Derek Lamberti87acb272019-03-27 16:51:31 +0000270table QuantizeLayer {
271 base:LayerBase;
272}
273
Aron Virginas-Tarfc413c02019-02-13 15:41:52 +0000274table SoftmaxLayer {
275 base:LayerBase;
276 descriptor:SoftmaxDescriptor;
277}
278
279table SoftmaxDescriptor {
280 beta:float;
281}
282
Aron Virginas-Tarc04125f2019-02-19 16:31:08 +0000283table DepthwiseConvolution2dLayer {
284 base:LayerBase;
285 descriptor:DepthwiseConvolution2dDescriptor;
286 weights:ConstTensor;
287 biases:ConstTensor;
288}
289
290table DepthwiseConvolution2dDescriptor {
291 padLeft:uint;
292 padRight:uint;
293 padTop:uint;
294 padBottom:uint;
295 strideX:uint;
296 strideY:uint;
297 biasEnabled:bool = false;
298 dataLayout:DataLayout = NCHW;
299}
300
Nattapat Chaimanowong969eea32019-01-30 13:33:11 +0000301table OutputLayer {
302 base:BindableLayerBase;
303}
304
Saoirse Stewart263829c2019-02-19 15:54:14 +0000305table ReshapeLayer {
306 base:LayerBase;
307 descriptor:ReshapeDescriptor;
308}
309
310table ReshapeDescriptor {
311 targetShape:[uint];
312}
313
Nattapat Chaimanowong30b00202019-02-20 17:31:34 +0000314table PermuteLayer {
315 base:LayerBase;
316 descriptor:PermuteDescriptor;
317}
318
319table PermuteDescriptor {
320 dimMappings:[uint];
321}
322
Nattapat Chaimanowong45286992019-02-26 15:53:02 +0000323table SpaceToBatchNdLayer {
324 base:LayerBase;
325 descriptor:SpaceToBatchNdDescriptor;
326}
327
328table SpaceToBatchNdDescriptor {
329 blockShape:[uint];
330 padList:[uint];
331 dataLayout:DataLayout;
332}
333
Conor Kennedyda1f9752019-03-01 14:37:12 +0000334table SubtractionLayer {
335 base:LayerBase;
336}
337
Nattapat Chaimanowong6b4ed982019-02-26 17:24:13 +0000338table BatchToSpaceNdLayer {
339 base:LayerBase;
340 descriptor:BatchToSpaceNdDescriptor;
341}
342
343table BatchToSpaceNdDescriptor {
344 blockShape:[uint];
345 crops:[uint];
346 dataLayout:DataLayout;
347}
348
Nina Drozd57728782019-02-27 10:53:27 +0000349enum NormalizationAlgorithmChannel : byte {
350 Across = 0,
351 Within = 1
352}
353
354enum NormalizationAlgorithmMethod : byte {
355 LocalBrightness = 0,
356 LocalContrast = 1
357}
358
359table NormalizationLayer {
360 base:LayerBase;
361 descriptor:NormalizationDescriptor;
362}
363
364table NormalizationDescriptor {
365 normChannelType:NormalizationAlgorithmChannel = Across;
366 normMethodType:NormalizationAlgorithmMethod = LocalBrightness;
367 normSize:uint;
368 alpha:float;
369 beta:float;
370 k:float;
371 dataLayout:DataLayout = NCHW;
372}
373
Sadik Armaganac97c8c2019-03-04 17:44:21 +0000374table MeanLayer {
375 base:LayerBase;
376 descriptor:MeanDescriptor;
377}
378
379table MeanDescriptor {
380 axis:[uint];
381 keepDims:bool = false;
382}
383
Nattapat Chaimanowongebb0f9c2019-03-01 12:14:06 +0000384table PadLayer {
385 base:LayerBase;
386 descriptor:PadDescriptor;
387}
388
389table PadDescriptor {
390 padList:[uint];
391}
392
Sadik Armagan8b42a382019-03-01 14:24:49 +0000393table RsqrtLayer {
394 base:LayerBase;
395}
396
ruoyan018e7fa232019-02-28 15:09:07 +0000397table BatchNormalizationLayer {
398 base:LayerBase;
399 descriptor:BatchNormalizationDescriptor;
400 mean:ConstTensor;
401 variance:ConstTensor;
402 beta:ConstTensor;
403 gamma:ConstTensor;
404}
405
406table BatchNormalizationDescriptor {
407 eps:float;
408 dataLayout:DataLayout;
409}
410
Nattapat Chaimanowong6522cdc2019-03-01 16:14:13 +0000411table ResizeBilinearLayer {
412 base:LayerBase;
413 descriptor:ResizeBilinearDescriptor;
414}
415
416table ResizeBilinearDescriptor {
417 targetWidth:uint;
418 targetHeight:uint;
419 dataLayout:DataLayout;
420}
421
Nattapat Chaimanowongb3485212019-03-04 12:35:39 +0000422table StridedSliceLayer {
423 base:LayerBase;
424 descriptor:StridedSliceDescriptor;
425}
426
427table StridedSliceDescriptor {
428 begin:[int];
429 end:[int];
430 stride:[int];
431 beginMask:int;
432 endMask:int;
433 shrinkAxisMask:int;
434 ellipsisMask:int;
435 newAxisMask:int;
436 dataLayout:DataLayout;
437}
438
Jim Flynnac25a1b2019-02-28 10:40:49 +0000439table MergerLayer {
440 base:LayerBase;
441 descriptor:OriginsDescriptor;
442}
443
444table UintVector {
445 data:[uint];
446}
447
448table OriginsDescriptor {
449 concatAxis:uint;
450 numViews:uint;
451 numDimensions:uint;
452 viewOrigins:[UintVector];
453}
454
Jim Flynn18ce3382019-03-08 11:08:30 +0000455table ViewsDescriptor {
456 origins:OriginsDescriptor;
457 viewSizes:[UintVector];
458}
459
460table SplitterLayer {
461 base:LayerBase;
462 descriptor:ViewsDescriptor;
463}
464
Nattapat Chaimanowong3e14a9d2019-03-18 12:37:06 +0000465table DetectionPostProcessLayer {
466 base:LayerBase;
467 descriptor:DetectionPostProcessDescriptor;
468 anchors:ConstTensor;
469}
470
471table DetectionPostProcessDescriptor {
472 maxDetections:uint;
473 maxClassesPerDetection:uint;
474 detectionsPerClass:uint;
475 nmsScoreThreshold:float;
476 nmsIouThreshold:float;
477 numClasses:uint;
478 useRegularNms:bool;
479 scaleX:float;
480 scaleY:float;
481 scaleW:float;
482 scaleH:float;
483}
484
Jim Flynn11af3752019-03-19 17:22:29 +0000485table LstmInputParams {
486 inputToForgetWeights:ConstTensor;
487 inputToCellWeights:ConstTensor;
488 inputToOutputWeights:ConstTensor;
489 recurrentToForgetWeights:ConstTensor;
490 recurrentToCellWeights:ConstTensor;
491 recurrentToOutputWeights:ConstTensor;
492 forgetGateBias:ConstTensor;
493 cellBias:ConstTensor;
494 outputGateBias:ConstTensor;
495
496 inputToInputWeights:ConstTensor;
497 recurrentToInputWeights:ConstTensor;
498 cellToInputWeights:ConstTensor;
499 inputGateBias:ConstTensor;
500
501 projectionWeights:ConstTensor;
502 projectionBias:ConstTensor;
503
504 cellToForgetWeights:ConstTensor;
505 cellToOutputWeights:ConstTensor;
506}
507
508table LstmDescriptor {
509 activationFunc:uint;
510 clippingThresCell:float;
511 clippingThresProj:float;
512 cifgEnabled:bool = true;
513 peepholeEnabled:bool = false;
514 projectionEnabled:bool = false;
515}
516
517table LstmLayer {
518 base:LayerBase;
519 descriptor:LstmDescriptor;
520 inputParams:LstmInputParams;
521}
522
Nattapat Chaimanowonge4294fd2019-03-28 09:56:53 +0000523table DequantizeLayer {
524 base:LayerBase;
525}
526
Nattapat Chaimanowong969eea32019-01-30 13:33:11 +0000527union Layer {
Mike Kellyaf484012019-02-20 16:53:11 +0000528 ActivationLayer,
Nattapat Chaimanowong969eea32019-01-30 13:33:11 +0000529 AdditionLayer,
Nattapat Chaimanowong6b4ed982019-02-26 17:24:13 +0000530 BatchToSpaceNdLayer,
ruoyan018e7fa232019-02-28 15:09:07 +0000531 BatchNormalizationLayer,
Conor Kennedy76277882019-02-26 08:29:54 +0000532 ConstantLayer,
Mike Kellya0766c32019-02-19 17:22:07 +0000533 Convolution2dLayer,
Aron Virginas-Tarc04125f2019-02-19 16:31:08 +0000534 DepthwiseConvolution2dLayer,
Sadik Armagandbb0c0c2019-02-21 09:01:41 +0000535 FullyConnectedLayer,
Nattapat Chaimanowong969eea32019-01-30 13:33:11 +0000536 InputLayer,
Sadik Armagan5f450272019-02-12 14:31:45 +0000537 MultiplicationLayer,
Aron Virginas-Tarfc413c02019-02-13 15:41:52 +0000538 OutputLayer,
Nattapat Chaimanowong30b00202019-02-20 17:31:34 +0000539 PermuteLayer,
Saoirse Stewart3166c3e2019-02-18 15:24:53 +0000540 Pooling2dLayer,
Saoirse Stewart263829c2019-02-19 15:54:14 +0000541 ReshapeLayer,
Nattapat Chaimanowong45286992019-02-26 15:53:02 +0000542 SoftmaxLayer,
Éanna Ó Catháin58885892019-02-27 16:16:39 +0000543 SpaceToBatchNdLayer,
Aron Virginas-Tar0fe32452019-02-28 13:12:47 +0000544 DivisionLayer,
Nattapat Chaimanowong235cea52019-02-28 16:27:30 +0000545 MinimumLayer,
Aron Virginas-Tar377351e2019-02-27 14:42:31 +0000546 EqualLayer,
Nina Drozd57728782019-02-27 10:53:27 +0000547 MaximumLayer,
Nattapat Chaimanowongebb0f9c2019-03-01 12:14:06 +0000548 NormalizationLayer,
Sadik Armagan8b42a382019-03-01 14:24:49 +0000549 PadLayer,
Finn Williamsdd2ba7e2019-03-01 11:51:52 +0000550 RsqrtLayer,
Conor Kennedy79ffdf52019-03-01 14:24:54 +0000551 FloorLayer,
Nattapat Chaimanowong6522cdc2019-03-01 16:14:13 +0000552 GreaterLayer,
Conor Kennedyda1f9752019-03-01 14:37:12 +0000553 ResizeBilinearLayer,
Nattapat Chaimanowongb3485212019-03-04 12:35:39 +0000554 SubtractionLayer,
Saoirse Stewarta1ed73a2019-03-04 13:40:12 +0000555 StridedSliceLayer,
Sadik Armaganac97c8c2019-03-04 17:44:21 +0000556 GatherLayer,
Jim Flynnac25a1b2019-02-28 10:40:49 +0000557 MeanLayer,
Narumol Prangnawarat495701f2019-03-07 17:31:34 +0000558 MergerLayer,
Jim Flynn18ce3382019-03-08 11:08:30 +0000559 L2NormalizationLayer,
Nattapat Chaimanowong3e14a9d2019-03-18 12:37:06 +0000560 SplitterLayer,
Jim Flynn11af3752019-03-19 17:22:29 +0000561 DetectionPostProcessLayer,
Derek Lamberti87acb272019-03-27 16:51:31 +0000562 LstmLayer,
Nattapat Chaimanowonge4294fd2019-03-28 09:56:53 +0000563 QuantizeLayer,
564 DequantizeLayer
Nattapat Chaimanowong969eea32019-01-30 13:33:11 +0000565}
566
Saoirse Stewart49dbe0e2019-02-05 17:27:06 +0000567table AnyLayer {
568 layer:Layer;
569}
570
Nattapat Chaimanowong969eea32019-01-30 13:33:11 +0000571// Root type for serialized data is the graph of the network
572table SerializedGraph {
Saoirse Stewart49dbe0e2019-02-05 17:27:06 +0000573 layers:[AnyLayer];
Mike Kelly8c1701a2019-02-11 17:01:27 +0000574 inputIds:[uint];
575 outputIds:[uint];
Nattapat Chaimanowong969eea32019-01-30 13:33:11 +0000576}
577
578root_type SerializedGraph;