blob: 2cceaae03106507f0ed49d02df7c5529a6788d4c [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,
119 Lstm = 34
Nattapat Chaimanowong969eea32019-01-30 13:33:11 +0000120}
121
122// Base layer table to be used as part of other layers
123table LayerBase {
124 index:uint;
125 layerName:string;
126 layerType:LayerType;
127 inputSlots:[InputSlot];
128 outputSlots:[OutputSlot];
129}
130
131table BindableLayerBase {
132 base:LayerBase;
133 layerBindingId:int;
134}
135
136// Table for each layer defined below
Mike Kellyaf484012019-02-20 16:53:11 +0000137table ActivationLayer {
138 base:LayerBase;
139 descriptor:ActivationDescriptor;
140}
141
142table ActivationDescriptor {
143 function:ActivationFunction = Sigmoid;
144 a:float;
145 b:float;
146}
147
Nattapat Chaimanowong969eea32019-01-30 13:33:11 +0000148table AdditionLayer {
149 base:LayerBase;
150}
151
Conor Kennedy76277882019-02-26 08:29:54 +0000152table ConstantLayer {
153 base:LayerBase;
154 input:ConstTensor;
155}
156
Mike Kellya0766c32019-02-19 17:22:07 +0000157table Convolution2dLayer {
158 base:LayerBase;
159 descriptor:Convolution2dDescriptor;
160 weights:ConstTensor;
161 biases:ConstTensor;
162}
163
164table Convolution2dDescriptor {
165 padLeft:uint;
166 padRight:uint;
167 padTop:uint;
168 padBottom:uint;
169 strideX:uint;
170 strideY:uint;
171 biasEnabled:bool = false;
172 dataLayout:DataLayout = NCHW;
173}
174
Éanna Ó Catháin58885892019-02-27 16:16:39 +0000175table DivisionLayer {
176 base:LayerBase;
177}
178
Nattapat Chaimanowong235cea52019-02-28 16:27:30 +0000179table EqualLayer {
180 base:LayerBase;
181}
182
Finn Williamsdd2ba7e2019-03-01 11:51:52 +0000183table FloorLayer{
184 base:LayerBase;
185}
186
Sadik Armagandbb0c0c2019-02-21 09:01:41 +0000187table FullyConnectedLayer {
188 base:LayerBase;
189 descriptor:FullyConnectedDescriptor;
190 weights:ConstTensor;
191 biases:ConstTensor;
192}
193
194table FullyConnectedDescriptor {
195 biasEnabled:bool = false;
196 transposeWeightsMatrix:bool = false;
197}
198
Saoirse Stewarta1ed73a2019-03-04 13:40:12 +0000199table GatherLayer {
200 base:LayerBase;
201}
202
Conor Kennedy79ffdf52019-03-01 14:24:54 +0000203table GreaterLayer {
204 base:LayerBase;
205}
206
Nattapat Chaimanowong969eea32019-01-30 13:33:11 +0000207table InputLayer {
208 base:BindableLayerBase;
209}
210
Narumol Prangnawarat495701f2019-03-07 17:31:34 +0000211table L2NormalizationLayer {
212 base:LayerBase;
213 descriptor:L2NormalizationDescriptor;
214}
215
216table L2NormalizationDescriptor {
217 dataLayout:DataLayout = NCHW;
218}
219
Aron Virginas-Tar0fe32452019-02-28 13:12:47 +0000220table MinimumLayer {
221 base:LayerBase;
222}
223
Aron Virginas-Tar377351e2019-02-27 14:42:31 +0000224table MaximumLayer {
225 base:LayerBase;
226}
227
Sadik Armagan5f450272019-02-12 14:31:45 +0000228table MultiplicationLayer {
229 base:LayerBase;
230}
231
Saoirse Stewart3166c3e2019-02-18 15:24:53 +0000232table Pooling2dLayer {
233 base:LayerBase;
234 descriptor:Pooling2dDescriptor;
235}
236
237enum PoolingAlgorithm : byte {
238 Max = 0,
239 Average = 1,
240 L2 = 2
241}
242
243enum OutputShapeRounding : byte {
244 Floor = 0,
245 Ceiling = 1
246}
247
248enum PaddingMethod : byte {
249 IgnoreValue = 0,
250 Exclude = 1
251}
252
253table Pooling2dDescriptor {
254 poolType:PoolingAlgorithm;
255 padLeft:uint;
256 padRight:uint;
257 padTop:uint;
258 padBottom:uint;
259 poolWidth:uint;
260 poolHeight:uint;
261 strideX:uint;
262 strideY:uint;
263 outputShapeRounding:OutputShapeRounding;
264 paddingMethod:PaddingMethod;
265 dataLayout:DataLayout;
266}
267
Aron Virginas-Tarfc413c02019-02-13 15:41:52 +0000268table SoftmaxLayer {
269 base:LayerBase;
270 descriptor:SoftmaxDescriptor;
271}
272
273table SoftmaxDescriptor {
274 beta:float;
275}
276
Aron Virginas-Tarc04125f2019-02-19 16:31:08 +0000277table DepthwiseConvolution2dLayer {
278 base:LayerBase;
279 descriptor:DepthwiseConvolution2dDescriptor;
280 weights:ConstTensor;
281 biases:ConstTensor;
282}
283
284table DepthwiseConvolution2dDescriptor {
285 padLeft:uint;
286 padRight:uint;
287 padTop:uint;
288 padBottom:uint;
289 strideX:uint;
290 strideY:uint;
291 biasEnabled:bool = false;
292 dataLayout:DataLayout = NCHW;
293}
294
Nattapat Chaimanowong969eea32019-01-30 13:33:11 +0000295table OutputLayer {
296 base:BindableLayerBase;
297}
298
Saoirse Stewart263829c2019-02-19 15:54:14 +0000299table ReshapeLayer {
300 base:LayerBase;
301 descriptor:ReshapeDescriptor;
302}
303
304table ReshapeDescriptor {
305 targetShape:[uint];
306}
307
Nattapat Chaimanowong30b00202019-02-20 17:31:34 +0000308table PermuteLayer {
309 base:LayerBase;
310 descriptor:PermuteDescriptor;
311}
312
313table PermuteDescriptor {
314 dimMappings:[uint];
315}
316
Nattapat Chaimanowong45286992019-02-26 15:53:02 +0000317table SpaceToBatchNdLayer {
318 base:LayerBase;
319 descriptor:SpaceToBatchNdDescriptor;
320}
321
322table SpaceToBatchNdDescriptor {
323 blockShape:[uint];
324 padList:[uint];
325 dataLayout:DataLayout;
326}
327
Conor Kennedyda1f9752019-03-01 14:37:12 +0000328table SubtractionLayer {
329 base:LayerBase;
330}
331
Nattapat Chaimanowong6b4ed982019-02-26 17:24:13 +0000332table BatchToSpaceNdLayer {
333 base:LayerBase;
334 descriptor:BatchToSpaceNdDescriptor;
335}
336
337table BatchToSpaceNdDescriptor {
338 blockShape:[uint];
339 crops:[uint];
340 dataLayout:DataLayout;
341}
342
Nina Drozd57728782019-02-27 10:53:27 +0000343enum NormalizationAlgorithmChannel : byte {
344 Across = 0,
345 Within = 1
346}
347
348enum NormalizationAlgorithmMethod : byte {
349 LocalBrightness = 0,
350 LocalContrast = 1
351}
352
353table NormalizationLayer {
354 base:LayerBase;
355 descriptor:NormalizationDescriptor;
356}
357
358table NormalizationDescriptor {
359 normChannelType:NormalizationAlgorithmChannel = Across;
360 normMethodType:NormalizationAlgorithmMethod = LocalBrightness;
361 normSize:uint;
362 alpha:float;
363 beta:float;
364 k:float;
365 dataLayout:DataLayout = NCHW;
366}
367
Sadik Armaganac97c8c2019-03-04 17:44:21 +0000368table MeanLayer {
369 base:LayerBase;
370 descriptor:MeanDescriptor;
371}
372
373table MeanDescriptor {
374 axis:[uint];
375 keepDims:bool = false;
376}
377
Nattapat Chaimanowongebb0f9c2019-03-01 12:14:06 +0000378table PadLayer {
379 base:LayerBase;
380 descriptor:PadDescriptor;
381}
382
383table PadDescriptor {
384 padList:[uint];
385}
386
Sadik Armagan8b42a382019-03-01 14:24:49 +0000387table RsqrtLayer {
388 base:LayerBase;
389}
390
ruoyan018e7fa232019-02-28 15:09:07 +0000391table BatchNormalizationLayer {
392 base:LayerBase;
393 descriptor:BatchNormalizationDescriptor;
394 mean:ConstTensor;
395 variance:ConstTensor;
396 beta:ConstTensor;
397 gamma:ConstTensor;
398}
399
400table BatchNormalizationDescriptor {
401 eps:float;
402 dataLayout:DataLayout;
403}
404
Nattapat Chaimanowong6522cdc2019-03-01 16:14:13 +0000405table ResizeBilinearLayer {
406 base:LayerBase;
407 descriptor:ResizeBilinearDescriptor;
408}
409
410table ResizeBilinearDescriptor {
411 targetWidth:uint;
412 targetHeight:uint;
413 dataLayout:DataLayout;
414}
415
Nattapat Chaimanowongb3485212019-03-04 12:35:39 +0000416table StridedSliceLayer {
417 base:LayerBase;
418 descriptor:StridedSliceDescriptor;
419}
420
421table StridedSliceDescriptor {
422 begin:[int];
423 end:[int];
424 stride:[int];
425 beginMask:int;
426 endMask:int;
427 shrinkAxisMask:int;
428 ellipsisMask:int;
429 newAxisMask:int;
430 dataLayout:DataLayout;
431}
432
Jim Flynnac25a1b2019-02-28 10:40:49 +0000433table MergerLayer {
434 base:LayerBase;
435 descriptor:OriginsDescriptor;
436}
437
438table UintVector {
439 data:[uint];
440}
441
442table OriginsDescriptor {
443 concatAxis:uint;
444 numViews:uint;
445 numDimensions:uint;
446 viewOrigins:[UintVector];
447}
448
Jim Flynn18ce3382019-03-08 11:08:30 +0000449table ViewsDescriptor {
450 origins:OriginsDescriptor;
451 viewSizes:[UintVector];
452}
453
454table SplitterLayer {
455 base:LayerBase;
456 descriptor:ViewsDescriptor;
457}
458
Nattapat Chaimanowong3e14a9d2019-03-18 12:37:06 +0000459table DetectionPostProcessLayer {
460 base:LayerBase;
461 descriptor:DetectionPostProcessDescriptor;
462 anchors:ConstTensor;
463}
464
465table DetectionPostProcessDescriptor {
466 maxDetections:uint;
467 maxClassesPerDetection:uint;
468 detectionsPerClass:uint;
469 nmsScoreThreshold:float;
470 nmsIouThreshold:float;
471 numClasses:uint;
472 useRegularNms:bool;
473 scaleX:float;
474 scaleY:float;
475 scaleW:float;
476 scaleH:float;
477}
478
Jim Flynn11af3752019-03-19 17:22:29 +0000479table LstmInputParams {
480 inputToForgetWeights:ConstTensor;
481 inputToCellWeights:ConstTensor;
482 inputToOutputWeights:ConstTensor;
483 recurrentToForgetWeights:ConstTensor;
484 recurrentToCellWeights:ConstTensor;
485 recurrentToOutputWeights:ConstTensor;
486 forgetGateBias:ConstTensor;
487 cellBias:ConstTensor;
488 outputGateBias:ConstTensor;
489
490 inputToInputWeights:ConstTensor;
491 recurrentToInputWeights:ConstTensor;
492 cellToInputWeights:ConstTensor;
493 inputGateBias:ConstTensor;
494
495 projectionWeights:ConstTensor;
496 projectionBias:ConstTensor;
497
498 cellToForgetWeights:ConstTensor;
499 cellToOutputWeights:ConstTensor;
500}
501
502table LstmDescriptor {
503 activationFunc:uint;
504 clippingThresCell:float;
505 clippingThresProj:float;
506 cifgEnabled:bool = true;
507 peepholeEnabled:bool = false;
508 projectionEnabled:bool = false;
509}
510
511table LstmLayer {
512 base:LayerBase;
513 descriptor:LstmDescriptor;
514 inputParams:LstmInputParams;
515}
516
Nattapat Chaimanowong969eea32019-01-30 13:33:11 +0000517union Layer {
Mike Kellyaf484012019-02-20 16:53:11 +0000518 ActivationLayer,
Nattapat Chaimanowong969eea32019-01-30 13:33:11 +0000519 AdditionLayer,
Nattapat Chaimanowong6b4ed982019-02-26 17:24:13 +0000520 BatchToSpaceNdLayer,
ruoyan018e7fa232019-02-28 15:09:07 +0000521 BatchNormalizationLayer,
Conor Kennedy76277882019-02-26 08:29:54 +0000522 ConstantLayer,
Mike Kellya0766c32019-02-19 17:22:07 +0000523 Convolution2dLayer,
Aron Virginas-Tarc04125f2019-02-19 16:31:08 +0000524 DepthwiseConvolution2dLayer,
Sadik Armagandbb0c0c2019-02-21 09:01:41 +0000525 FullyConnectedLayer,
Nattapat Chaimanowong969eea32019-01-30 13:33:11 +0000526 InputLayer,
Sadik Armagan5f450272019-02-12 14:31:45 +0000527 MultiplicationLayer,
Aron Virginas-Tarfc413c02019-02-13 15:41:52 +0000528 OutputLayer,
Nattapat Chaimanowong30b00202019-02-20 17:31:34 +0000529 PermuteLayer,
Saoirse Stewart3166c3e2019-02-18 15:24:53 +0000530 Pooling2dLayer,
Saoirse Stewart263829c2019-02-19 15:54:14 +0000531 ReshapeLayer,
Nattapat Chaimanowong45286992019-02-26 15:53:02 +0000532 SoftmaxLayer,
Éanna Ó Catháin58885892019-02-27 16:16:39 +0000533 SpaceToBatchNdLayer,
Aron Virginas-Tar0fe32452019-02-28 13:12:47 +0000534 DivisionLayer,
Nattapat Chaimanowong235cea52019-02-28 16:27:30 +0000535 MinimumLayer,
Aron Virginas-Tar377351e2019-02-27 14:42:31 +0000536 EqualLayer,
Nina Drozd57728782019-02-27 10:53:27 +0000537 MaximumLayer,
Nattapat Chaimanowongebb0f9c2019-03-01 12:14:06 +0000538 NormalizationLayer,
Sadik Armagan8b42a382019-03-01 14:24:49 +0000539 PadLayer,
Finn Williamsdd2ba7e2019-03-01 11:51:52 +0000540 RsqrtLayer,
Conor Kennedy79ffdf52019-03-01 14:24:54 +0000541 FloorLayer,
Nattapat Chaimanowong6522cdc2019-03-01 16:14:13 +0000542 GreaterLayer,
Conor Kennedyda1f9752019-03-01 14:37:12 +0000543 ResizeBilinearLayer,
Nattapat Chaimanowongb3485212019-03-04 12:35:39 +0000544 SubtractionLayer,
Saoirse Stewarta1ed73a2019-03-04 13:40:12 +0000545 StridedSliceLayer,
Sadik Armaganac97c8c2019-03-04 17:44:21 +0000546 GatherLayer,
Jim Flynnac25a1b2019-02-28 10:40:49 +0000547 MeanLayer,
Narumol Prangnawarat495701f2019-03-07 17:31:34 +0000548 MergerLayer,
Jim Flynn18ce3382019-03-08 11:08:30 +0000549 L2NormalizationLayer,
Nattapat Chaimanowong3e14a9d2019-03-18 12:37:06 +0000550 SplitterLayer,
Jim Flynn11af3752019-03-19 17:22:29 +0000551 DetectionPostProcessLayer,
552 LstmLayer
Nattapat Chaimanowong969eea32019-01-30 13:33:11 +0000553}
554
Saoirse Stewart49dbe0e2019-02-05 17:27:06 +0000555table AnyLayer {
556 layer:Layer;
557}
558
Nattapat Chaimanowong969eea32019-01-30 13:33:11 +0000559// Root type for serialized data is the graph of the network
560table SerializedGraph {
Saoirse Stewart49dbe0e2019-02-05 17:27:06 +0000561 layers:[AnyLayer];
Mike Kelly8c1701a2019-02-11 17:01:27 +0000562 inputIds:[uint];
563 outputIds:[uint];
Nattapat Chaimanowong969eea32019-01-30 13:33:11 +0000564}
565
566root_type SerializedGraph;