blob: 7ac83598e1cd5d59694038b8a67cd6cf4cf1710d [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,
120 Quantize = 35
Nattapat Chaimanowong969eea32019-01-30 13:33:11 +0000121}
122
123// Base layer table to be used as part of other layers
124table LayerBase {
125 index:uint;
126 layerName:string;
127 layerType:LayerType;
128 inputSlots:[InputSlot];
129 outputSlots:[OutputSlot];
130}
131
132table BindableLayerBase {
133 base:LayerBase;
134 layerBindingId:int;
135}
136
137// Table for each layer defined below
Mike Kellyaf484012019-02-20 16:53:11 +0000138table ActivationLayer {
139 base:LayerBase;
140 descriptor:ActivationDescriptor;
141}
142
143table ActivationDescriptor {
144 function:ActivationFunction = Sigmoid;
145 a:float;
146 b:float;
147}
148
Nattapat Chaimanowong969eea32019-01-30 13:33:11 +0000149table AdditionLayer {
150 base:LayerBase;
151}
152
Conor Kennedy76277882019-02-26 08:29:54 +0000153table ConstantLayer {
154 base:LayerBase;
155 input:ConstTensor;
156}
157
Mike Kellya0766c32019-02-19 17:22:07 +0000158table Convolution2dLayer {
159 base:LayerBase;
160 descriptor:Convolution2dDescriptor;
161 weights:ConstTensor;
162 biases:ConstTensor;
163}
164
165table Convolution2dDescriptor {
166 padLeft:uint;
167 padRight:uint;
168 padTop:uint;
169 padBottom:uint;
170 strideX:uint;
171 strideY:uint;
172 biasEnabled:bool = false;
173 dataLayout:DataLayout = NCHW;
174}
175
Éanna Ó Catháin58885892019-02-27 16:16:39 +0000176table DivisionLayer {
177 base:LayerBase;
178}
179
Nattapat Chaimanowong235cea52019-02-28 16:27:30 +0000180table EqualLayer {
181 base:LayerBase;
182}
183
Finn Williamsdd2ba7e2019-03-01 11:51:52 +0000184table FloorLayer{
185 base:LayerBase;
186}
187
Sadik Armagandbb0c0c2019-02-21 09:01:41 +0000188table FullyConnectedLayer {
189 base:LayerBase;
190 descriptor:FullyConnectedDescriptor;
191 weights:ConstTensor;
192 biases:ConstTensor;
193}
194
195table FullyConnectedDescriptor {
196 biasEnabled:bool = false;
197 transposeWeightsMatrix:bool = false;
198}
199
Saoirse Stewarta1ed73a2019-03-04 13:40:12 +0000200table GatherLayer {
201 base:LayerBase;
202}
203
Conor Kennedy79ffdf52019-03-01 14:24:54 +0000204table GreaterLayer {
205 base:LayerBase;
206}
207
Nattapat Chaimanowong969eea32019-01-30 13:33:11 +0000208table InputLayer {
209 base:BindableLayerBase;
210}
211
Narumol Prangnawarat495701f2019-03-07 17:31:34 +0000212table L2NormalizationLayer {
213 base:LayerBase;
214 descriptor:L2NormalizationDescriptor;
215}
216
217table L2NormalizationDescriptor {
218 dataLayout:DataLayout = NCHW;
219}
220
Aron Virginas-Tar0fe32452019-02-28 13:12:47 +0000221table MinimumLayer {
222 base:LayerBase;
223}
224
Aron Virginas-Tar377351e2019-02-27 14:42:31 +0000225table MaximumLayer {
226 base:LayerBase;
227}
228
Sadik Armagan5f450272019-02-12 14:31:45 +0000229table MultiplicationLayer {
230 base:LayerBase;
231}
232
Saoirse Stewart3166c3e2019-02-18 15:24:53 +0000233table Pooling2dLayer {
234 base:LayerBase;
235 descriptor:Pooling2dDescriptor;
236}
237
238enum PoolingAlgorithm : byte {
239 Max = 0,
240 Average = 1,
241 L2 = 2
242}
243
244enum OutputShapeRounding : byte {
245 Floor = 0,
246 Ceiling = 1
247}
248
249enum PaddingMethod : byte {
250 IgnoreValue = 0,
251 Exclude = 1
252}
253
254table Pooling2dDescriptor {
255 poolType:PoolingAlgorithm;
256 padLeft:uint;
257 padRight:uint;
258 padTop:uint;
259 padBottom:uint;
260 poolWidth:uint;
261 poolHeight:uint;
262 strideX:uint;
263 strideY:uint;
264 outputShapeRounding:OutputShapeRounding;
265 paddingMethod:PaddingMethod;
266 dataLayout:DataLayout;
267}
268
Derek Lamberti87acb272019-03-27 16:51:31 +0000269table QuantizeLayer {
270 base:LayerBase;
271}
272
Aron Virginas-Tarfc413c02019-02-13 15:41:52 +0000273table SoftmaxLayer {
274 base:LayerBase;
275 descriptor:SoftmaxDescriptor;
276}
277
278table SoftmaxDescriptor {
279 beta:float;
280}
281
Aron Virginas-Tarc04125f2019-02-19 16:31:08 +0000282table DepthwiseConvolution2dLayer {
283 base:LayerBase;
284 descriptor:DepthwiseConvolution2dDescriptor;
285 weights:ConstTensor;
286 biases:ConstTensor;
287}
288
289table DepthwiseConvolution2dDescriptor {
290 padLeft:uint;
291 padRight:uint;
292 padTop:uint;
293 padBottom:uint;
294 strideX:uint;
295 strideY:uint;
296 biasEnabled:bool = false;
297 dataLayout:DataLayout = NCHW;
298}
299
Nattapat Chaimanowong969eea32019-01-30 13:33:11 +0000300table OutputLayer {
301 base:BindableLayerBase;
302}
303
Saoirse Stewart263829c2019-02-19 15:54:14 +0000304table ReshapeLayer {
305 base:LayerBase;
306 descriptor:ReshapeDescriptor;
307}
308
309table ReshapeDescriptor {
310 targetShape:[uint];
311}
312
Nattapat Chaimanowong30b00202019-02-20 17:31:34 +0000313table PermuteLayer {
314 base:LayerBase;
315 descriptor:PermuteDescriptor;
316}
317
318table PermuteDescriptor {
319 dimMappings:[uint];
320}
321
Nattapat Chaimanowong45286992019-02-26 15:53:02 +0000322table SpaceToBatchNdLayer {
323 base:LayerBase;
324 descriptor:SpaceToBatchNdDescriptor;
325}
326
327table SpaceToBatchNdDescriptor {
328 blockShape:[uint];
329 padList:[uint];
330 dataLayout:DataLayout;
331}
332
Conor Kennedyda1f9752019-03-01 14:37:12 +0000333table SubtractionLayer {
334 base:LayerBase;
335}
336
Nattapat Chaimanowong6b4ed982019-02-26 17:24:13 +0000337table BatchToSpaceNdLayer {
338 base:LayerBase;
339 descriptor:BatchToSpaceNdDescriptor;
340}
341
342table BatchToSpaceNdDescriptor {
343 blockShape:[uint];
344 crops:[uint];
345 dataLayout:DataLayout;
346}
347
Nina Drozd57728782019-02-27 10:53:27 +0000348enum NormalizationAlgorithmChannel : byte {
349 Across = 0,
350 Within = 1
351}
352
353enum NormalizationAlgorithmMethod : byte {
354 LocalBrightness = 0,
355 LocalContrast = 1
356}
357
358table NormalizationLayer {
359 base:LayerBase;
360 descriptor:NormalizationDescriptor;
361}
362
363table NormalizationDescriptor {
364 normChannelType:NormalizationAlgorithmChannel = Across;
365 normMethodType:NormalizationAlgorithmMethod = LocalBrightness;
366 normSize:uint;
367 alpha:float;
368 beta:float;
369 k:float;
370 dataLayout:DataLayout = NCHW;
371}
372
Sadik Armaganac97c8c2019-03-04 17:44:21 +0000373table MeanLayer {
374 base:LayerBase;
375 descriptor:MeanDescriptor;
376}
377
378table MeanDescriptor {
379 axis:[uint];
380 keepDims:bool = false;
381}
382
Nattapat Chaimanowongebb0f9c2019-03-01 12:14:06 +0000383table PadLayer {
384 base:LayerBase;
385 descriptor:PadDescriptor;
386}
387
388table PadDescriptor {
389 padList:[uint];
390}
391
Sadik Armagan8b42a382019-03-01 14:24:49 +0000392table RsqrtLayer {
393 base:LayerBase;
394}
395
ruoyan018e7fa232019-02-28 15:09:07 +0000396table BatchNormalizationLayer {
397 base:LayerBase;
398 descriptor:BatchNormalizationDescriptor;
399 mean:ConstTensor;
400 variance:ConstTensor;
401 beta:ConstTensor;
402 gamma:ConstTensor;
403}
404
405table BatchNormalizationDescriptor {
406 eps:float;
407 dataLayout:DataLayout;
408}
409
Nattapat Chaimanowong6522cdc2019-03-01 16:14:13 +0000410table ResizeBilinearLayer {
411 base:LayerBase;
412 descriptor:ResizeBilinearDescriptor;
413}
414
415table ResizeBilinearDescriptor {
416 targetWidth:uint;
417 targetHeight:uint;
418 dataLayout:DataLayout;
419}
420
Nattapat Chaimanowongb3485212019-03-04 12:35:39 +0000421table StridedSliceLayer {
422 base:LayerBase;
423 descriptor:StridedSliceDescriptor;
424}
425
426table StridedSliceDescriptor {
427 begin:[int];
428 end:[int];
429 stride:[int];
430 beginMask:int;
431 endMask:int;
432 shrinkAxisMask:int;
433 ellipsisMask:int;
434 newAxisMask:int;
435 dataLayout:DataLayout;
436}
437
Jim Flynnac25a1b2019-02-28 10:40:49 +0000438table MergerLayer {
439 base:LayerBase;
440 descriptor:OriginsDescriptor;
441}
442
443table UintVector {
444 data:[uint];
445}
446
447table OriginsDescriptor {
448 concatAxis:uint;
449 numViews:uint;
450 numDimensions:uint;
451 viewOrigins:[UintVector];
452}
453
Jim Flynn18ce3382019-03-08 11:08:30 +0000454table ViewsDescriptor {
455 origins:OriginsDescriptor;
456 viewSizes:[UintVector];
457}
458
459table SplitterLayer {
460 base:LayerBase;
461 descriptor:ViewsDescriptor;
462}
463
Nattapat Chaimanowong3e14a9d2019-03-18 12:37:06 +0000464table DetectionPostProcessLayer {
465 base:LayerBase;
466 descriptor:DetectionPostProcessDescriptor;
467 anchors:ConstTensor;
468}
469
470table DetectionPostProcessDescriptor {
471 maxDetections:uint;
472 maxClassesPerDetection:uint;
473 detectionsPerClass:uint;
474 nmsScoreThreshold:float;
475 nmsIouThreshold:float;
476 numClasses:uint;
477 useRegularNms:bool;
478 scaleX:float;
479 scaleY:float;
480 scaleW:float;
481 scaleH:float;
482}
483
Jim Flynn11af3752019-03-19 17:22:29 +0000484table LstmInputParams {
485 inputToForgetWeights:ConstTensor;
486 inputToCellWeights:ConstTensor;
487 inputToOutputWeights:ConstTensor;
488 recurrentToForgetWeights:ConstTensor;
489 recurrentToCellWeights:ConstTensor;
490 recurrentToOutputWeights:ConstTensor;
491 forgetGateBias:ConstTensor;
492 cellBias:ConstTensor;
493 outputGateBias:ConstTensor;
494
495 inputToInputWeights:ConstTensor;
496 recurrentToInputWeights:ConstTensor;
497 cellToInputWeights:ConstTensor;
498 inputGateBias:ConstTensor;
499
500 projectionWeights:ConstTensor;
501 projectionBias:ConstTensor;
502
503 cellToForgetWeights:ConstTensor;
504 cellToOutputWeights:ConstTensor;
505}
506
507table LstmDescriptor {
508 activationFunc:uint;
509 clippingThresCell:float;
510 clippingThresProj:float;
511 cifgEnabled:bool = true;
512 peepholeEnabled:bool = false;
513 projectionEnabled:bool = false;
514}
515
516table LstmLayer {
517 base:LayerBase;
518 descriptor:LstmDescriptor;
519 inputParams:LstmInputParams;
520}
521
Nattapat Chaimanowong969eea32019-01-30 13:33:11 +0000522union Layer {
Mike Kellyaf484012019-02-20 16:53:11 +0000523 ActivationLayer,
Nattapat Chaimanowong969eea32019-01-30 13:33:11 +0000524 AdditionLayer,
Nattapat Chaimanowong6b4ed982019-02-26 17:24:13 +0000525 BatchToSpaceNdLayer,
ruoyan018e7fa232019-02-28 15:09:07 +0000526 BatchNormalizationLayer,
Conor Kennedy76277882019-02-26 08:29:54 +0000527 ConstantLayer,
Mike Kellya0766c32019-02-19 17:22:07 +0000528 Convolution2dLayer,
Aron Virginas-Tarc04125f2019-02-19 16:31:08 +0000529 DepthwiseConvolution2dLayer,
Sadik Armagandbb0c0c2019-02-21 09:01:41 +0000530 FullyConnectedLayer,
Nattapat Chaimanowong969eea32019-01-30 13:33:11 +0000531 InputLayer,
Sadik Armagan5f450272019-02-12 14:31:45 +0000532 MultiplicationLayer,
Aron Virginas-Tarfc413c02019-02-13 15:41:52 +0000533 OutputLayer,
Nattapat Chaimanowong30b00202019-02-20 17:31:34 +0000534 PermuteLayer,
Saoirse Stewart3166c3e2019-02-18 15:24:53 +0000535 Pooling2dLayer,
Saoirse Stewart263829c2019-02-19 15:54:14 +0000536 ReshapeLayer,
Nattapat Chaimanowong45286992019-02-26 15:53:02 +0000537 SoftmaxLayer,
Éanna Ó Catháin58885892019-02-27 16:16:39 +0000538 SpaceToBatchNdLayer,
Aron Virginas-Tar0fe32452019-02-28 13:12:47 +0000539 DivisionLayer,
Nattapat Chaimanowong235cea52019-02-28 16:27:30 +0000540 MinimumLayer,
Aron Virginas-Tar377351e2019-02-27 14:42:31 +0000541 EqualLayer,
Nina Drozd57728782019-02-27 10:53:27 +0000542 MaximumLayer,
Nattapat Chaimanowongebb0f9c2019-03-01 12:14:06 +0000543 NormalizationLayer,
Sadik Armagan8b42a382019-03-01 14:24:49 +0000544 PadLayer,
Finn Williamsdd2ba7e2019-03-01 11:51:52 +0000545 RsqrtLayer,
Conor Kennedy79ffdf52019-03-01 14:24:54 +0000546 FloorLayer,
Nattapat Chaimanowong6522cdc2019-03-01 16:14:13 +0000547 GreaterLayer,
Conor Kennedyda1f9752019-03-01 14:37:12 +0000548 ResizeBilinearLayer,
Nattapat Chaimanowongb3485212019-03-04 12:35:39 +0000549 SubtractionLayer,
Saoirse Stewarta1ed73a2019-03-04 13:40:12 +0000550 StridedSliceLayer,
Sadik Armaganac97c8c2019-03-04 17:44:21 +0000551 GatherLayer,
Jim Flynnac25a1b2019-02-28 10:40:49 +0000552 MeanLayer,
Narumol Prangnawarat495701f2019-03-07 17:31:34 +0000553 MergerLayer,
Jim Flynn18ce3382019-03-08 11:08:30 +0000554 L2NormalizationLayer,
Nattapat Chaimanowong3e14a9d2019-03-18 12:37:06 +0000555 SplitterLayer,
Jim Flynn11af3752019-03-19 17:22:29 +0000556 DetectionPostProcessLayer,
Derek Lamberti87acb272019-03-27 16:51:31 +0000557 LstmLayer,
558 QuantizeLayer
Nattapat Chaimanowong969eea32019-01-30 13:33:11 +0000559}
560
Saoirse Stewart49dbe0e2019-02-05 17:27:06 +0000561table AnyLayer {
562 layer:Layer;
563}
564
Nattapat Chaimanowong969eea32019-01-30 13:33:11 +0000565// Root type for serialized data is the graph of the network
566table SerializedGraph {
Saoirse Stewart49dbe0e2019-02-05 17:27:06 +0000567 layers:[AnyLayer];
Mike Kelly8c1701a2019-02-11 17:01:27 +0000568 inputIds:[uint];
569 outputIds:[uint];
Nattapat Chaimanowong969eea32019-01-30 13:33:11 +0000570}
571
572root_type SerializedGraph;