blob: a11eeadf1243ebf3b5cf8698ef1197b861808cd4 [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,
118 DetectionPostProcess = 33
Nattapat Chaimanowong969eea32019-01-30 13:33:11 +0000119}
120
121// Base layer table to be used as part of other layers
122table LayerBase {
123 index:uint;
124 layerName:string;
125 layerType:LayerType;
126 inputSlots:[InputSlot];
127 outputSlots:[OutputSlot];
128}
129
130table BindableLayerBase {
131 base:LayerBase;
132 layerBindingId:int;
133}
134
135// Table for each layer defined below
Mike Kellyaf484012019-02-20 16:53:11 +0000136table ActivationLayer {
137 base:LayerBase;
138 descriptor:ActivationDescriptor;
139}
140
141table ActivationDescriptor {
142 function:ActivationFunction = Sigmoid;
143 a:float;
144 b:float;
145}
146
Nattapat Chaimanowong969eea32019-01-30 13:33:11 +0000147table AdditionLayer {
148 base:LayerBase;
149}
150
Conor Kennedy76277882019-02-26 08:29:54 +0000151table ConstantLayer {
152 base:LayerBase;
153 input:ConstTensor;
154}
155
Mike Kellya0766c32019-02-19 17:22:07 +0000156table Convolution2dLayer {
157 base:LayerBase;
158 descriptor:Convolution2dDescriptor;
159 weights:ConstTensor;
160 biases:ConstTensor;
161}
162
163table Convolution2dDescriptor {
164 padLeft:uint;
165 padRight:uint;
166 padTop:uint;
167 padBottom:uint;
168 strideX:uint;
169 strideY:uint;
170 biasEnabled:bool = false;
171 dataLayout:DataLayout = NCHW;
172}
173
Éanna Ó Catháin58885892019-02-27 16:16:39 +0000174table DivisionLayer {
175 base:LayerBase;
176}
177
Nattapat Chaimanowong235cea52019-02-28 16:27:30 +0000178table EqualLayer {
179 base:LayerBase;
180}
181
Finn Williamsdd2ba7e2019-03-01 11:51:52 +0000182table FloorLayer{
183 base:LayerBase;
184}
185
Sadik Armagandbb0c0c2019-02-21 09:01:41 +0000186table FullyConnectedLayer {
187 base:LayerBase;
188 descriptor:FullyConnectedDescriptor;
189 weights:ConstTensor;
190 biases:ConstTensor;
191}
192
193table FullyConnectedDescriptor {
194 biasEnabled:bool = false;
195 transposeWeightsMatrix:bool = false;
196}
197
Saoirse Stewarta1ed73a2019-03-04 13:40:12 +0000198table GatherLayer {
199 base:LayerBase;
200}
201
Conor Kennedy79ffdf52019-03-01 14:24:54 +0000202table GreaterLayer {
203 base:LayerBase;
204}
205
Nattapat Chaimanowong969eea32019-01-30 13:33:11 +0000206table InputLayer {
207 base:BindableLayerBase;
208}
209
Narumol Prangnawarat495701f2019-03-07 17:31:34 +0000210table L2NormalizationLayer {
211 base:LayerBase;
212 descriptor:L2NormalizationDescriptor;
213}
214
215table L2NormalizationDescriptor {
216 dataLayout:DataLayout = NCHW;
217}
218
Aron Virginas-Tar0fe32452019-02-28 13:12:47 +0000219table MinimumLayer {
220 base:LayerBase;
221}
222
Aron Virginas-Tar377351e2019-02-27 14:42:31 +0000223table MaximumLayer {
224 base:LayerBase;
225}
226
Sadik Armagan5f450272019-02-12 14:31:45 +0000227table MultiplicationLayer {
228 base:LayerBase;
229}
230
Saoirse Stewart3166c3e2019-02-18 15:24:53 +0000231table Pooling2dLayer {
232 base:LayerBase;
233 descriptor:Pooling2dDescriptor;
234}
235
236enum PoolingAlgorithm : byte {
237 Max = 0,
238 Average = 1,
239 L2 = 2
240}
241
242enum OutputShapeRounding : byte {
243 Floor = 0,
244 Ceiling = 1
245}
246
247enum PaddingMethod : byte {
248 IgnoreValue = 0,
249 Exclude = 1
250}
251
252table Pooling2dDescriptor {
253 poolType:PoolingAlgorithm;
254 padLeft:uint;
255 padRight:uint;
256 padTop:uint;
257 padBottom:uint;
258 poolWidth:uint;
259 poolHeight:uint;
260 strideX:uint;
261 strideY:uint;
262 outputShapeRounding:OutputShapeRounding;
263 paddingMethod:PaddingMethod;
264 dataLayout:DataLayout;
265}
266
Aron Virginas-Tarfc413c02019-02-13 15:41:52 +0000267table SoftmaxLayer {
268 base:LayerBase;
269 descriptor:SoftmaxDescriptor;
270}
271
272table SoftmaxDescriptor {
273 beta:float;
274}
275
Aron Virginas-Tarc04125f2019-02-19 16:31:08 +0000276table DepthwiseConvolution2dLayer {
277 base:LayerBase;
278 descriptor:DepthwiseConvolution2dDescriptor;
279 weights:ConstTensor;
280 biases:ConstTensor;
281}
282
283table DepthwiseConvolution2dDescriptor {
284 padLeft:uint;
285 padRight:uint;
286 padTop:uint;
287 padBottom:uint;
288 strideX:uint;
289 strideY:uint;
290 biasEnabled:bool = false;
291 dataLayout:DataLayout = NCHW;
292}
293
Nattapat Chaimanowong969eea32019-01-30 13:33:11 +0000294table OutputLayer {
295 base:BindableLayerBase;
296}
297
Saoirse Stewart263829c2019-02-19 15:54:14 +0000298table ReshapeLayer {
299 base:LayerBase;
300 descriptor:ReshapeDescriptor;
301}
302
303table ReshapeDescriptor {
304 targetShape:[uint];
305}
306
Nattapat Chaimanowong30b00202019-02-20 17:31:34 +0000307table PermuteLayer {
308 base:LayerBase;
309 descriptor:PermuteDescriptor;
310}
311
312table PermuteDescriptor {
313 dimMappings:[uint];
314}
315
Nattapat Chaimanowong45286992019-02-26 15:53:02 +0000316table SpaceToBatchNdLayer {
317 base:LayerBase;
318 descriptor:SpaceToBatchNdDescriptor;
319}
320
321table SpaceToBatchNdDescriptor {
322 blockShape:[uint];
323 padList:[uint];
324 dataLayout:DataLayout;
325}
326
Conor Kennedyda1f9752019-03-01 14:37:12 +0000327table SubtractionLayer {
328 base:LayerBase;
329}
330
Nattapat Chaimanowong6b4ed982019-02-26 17:24:13 +0000331table BatchToSpaceNdLayer {
332 base:LayerBase;
333 descriptor:BatchToSpaceNdDescriptor;
334}
335
336table BatchToSpaceNdDescriptor {
337 blockShape:[uint];
338 crops:[uint];
339 dataLayout:DataLayout;
340}
341
Nina Drozd57728782019-02-27 10:53:27 +0000342enum NormalizationAlgorithmChannel : byte {
343 Across = 0,
344 Within = 1
345}
346
347enum NormalizationAlgorithmMethod : byte {
348 LocalBrightness = 0,
349 LocalContrast = 1
350}
351
352table NormalizationLayer {
353 base:LayerBase;
354 descriptor:NormalizationDescriptor;
355}
356
357table NormalizationDescriptor {
358 normChannelType:NormalizationAlgorithmChannel = Across;
359 normMethodType:NormalizationAlgorithmMethod = LocalBrightness;
360 normSize:uint;
361 alpha:float;
362 beta:float;
363 k:float;
364 dataLayout:DataLayout = NCHW;
365}
366
Sadik Armaganac97c8c2019-03-04 17:44:21 +0000367table MeanLayer {
368 base:LayerBase;
369 descriptor:MeanDescriptor;
370}
371
372table MeanDescriptor {
373 axis:[uint];
374 keepDims:bool = false;
375}
376
Nattapat Chaimanowongebb0f9c2019-03-01 12:14:06 +0000377table PadLayer {
378 base:LayerBase;
379 descriptor:PadDescriptor;
380}
381
382table PadDescriptor {
383 padList:[uint];
384}
385
Sadik Armagan8b42a382019-03-01 14:24:49 +0000386table RsqrtLayer {
387 base:LayerBase;
388}
389
ruoyan018e7fa232019-02-28 15:09:07 +0000390table BatchNormalizationLayer {
391 base:LayerBase;
392 descriptor:BatchNormalizationDescriptor;
393 mean:ConstTensor;
394 variance:ConstTensor;
395 beta:ConstTensor;
396 gamma:ConstTensor;
397}
398
399table BatchNormalizationDescriptor {
400 eps:float;
401 dataLayout:DataLayout;
402}
403
Nattapat Chaimanowong6522cdc2019-03-01 16:14:13 +0000404table ResizeBilinearLayer {
405 base:LayerBase;
406 descriptor:ResizeBilinearDescriptor;
407}
408
409table ResizeBilinearDescriptor {
410 targetWidth:uint;
411 targetHeight:uint;
412 dataLayout:DataLayout;
413}
414
Nattapat Chaimanowongb3485212019-03-04 12:35:39 +0000415table StridedSliceLayer {
416 base:LayerBase;
417 descriptor:StridedSliceDescriptor;
418}
419
420table StridedSliceDescriptor {
421 begin:[int];
422 end:[int];
423 stride:[int];
424 beginMask:int;
425 endMask:int;
426 shrinkAxisMask:int;
427 ellipsisMask:int;
428 newAxisMask:int;
429 dataLayout:DataLayout;
430}
431
Jim Flynnac25a1b2019-02-28 10:40:49 +0000432table MergerLayer {
433 base:LayerBase;
434 descriptor:OriginsDescriptor;
435}
436
437table UintVector {
438 data:[uint];
439}
440
441table OriginsDescriptor {
442 concatAxis:uint;
443 numViews:uint;
444 numDimensions:uint;
445 viewOrigins:[UintVector];
446}
447
Jim Flynn18ce3382019-03-08 11:08:30 +0000448table ViewsDescriptor {
449 origins:OriginsDescriptor;
450 viewSizes:[UintVector];
451}
452
453table SplitterLayer {
454 base:LayerBase;
455 descriptor:ViewsDescriptor;
456}
457
Nattapat Chaimanowong3e14a9d2019-03-18 12:37:06 +0000458table DetectionPostProcessLayer {
459 base:LayerBase;
460 descriptor:DetectionPostProcessDescriptor;
461 anchors:ConstTensor;
462}
463
464table DetectionPostProcessDescriptor {
465 maxDetections:uint;
466 maxClassesPerDetection:uint;
467 detectionsPerClass:uint;
468 nmsScoreThreshold:float;
469 nmsIouThreshold:float;
470 numClasses:uint;
471 useRegularNms:bool;
472 scaleX:float;
473 scaleY:float;
474 scaleW:float;
475 scaleH:float;
476}
477
Nattapat Chaimanowong969eea32019-01-30 13:33:11 +0000478union Layer {
Mike Kellyaf484012019-02-20 16:53:11 +0000479 ActivationLayer,
Nattapat Chaimanowong969eea32019-01-30 13:33:11 +0000480 AdditionLayer,
Nattapat Chaimanowong6b4ed982019-02-26 17:24:13 +0000481 BatchToSpaceNdLayer,
ruoyan018e7fa232019-02-28 15:09:07 +0000482 BatchNormalizationLayer,
Conor Kennedy76277882019-02-26 08:29:54 +0000483 ConstantLayer,
Mike Kellya0766c32019-02-19 17:22:07 +0000484 Convolution2dLayer,
Aron Virginas-Tarc04125f2019-02-19 16:31:08 +0000485 DepthwiseConvolution2dLayer,
Sadik Armagandbb0c0c2019-02-21 09:01:41 +0000486 FullyConnectedLayer,
Nattapat Chaimanowong969eea32019-01-30 13:33:11 +0000487 InputLayer,
Sadik Armagan5f450272019-02-12 14:31:45 +0000488 MultiplicationLayer,
Aron Virginas-Tarfc413c02019-02-13 15:41:52 +0000489 OutputLayer,
Nattapat Chaimanowong30b00202019-02-20 17:31:34 +0000490 PermuteLayer,
Saoirse Stewart3166c3e2019-02-18 15:24:53 +0000491 Pooling2dLayer,
Saoirse Stewart263829c2019-02-19 15:54:14 +0000492 ReshapeLayer,
Nattapat Chaimanowong45286992019-02-26 15:53:02 +0000493 SoftmaxLayer,
Éanna Ó Catháin58885892019-02-27 16:16:39 +0000494 SpaceToBatchNdLayer,
Aron Virginas-Tar0fe32452019-02-28 13:12:47 +0000495 DivisionLayer,
Nattapat Chaimanowong235cea52019-02-28 16:27:30 +0000496 MinimumLayer,
Aron Virginas-Tar377351e2019-02-27 14:42:31 +0000497 EqualLayer,
Nina Drozd57728782019-02-27 10:53:27 +0000498 MaximumLayer,
Nattapat Chaimanowongebb0f9c2019-03-01 12:14:06 +0000499 NormalizationLayer,
Sadik Armagan8b42a382019-03-01 14:24:49 +0000500 PadLayer,
Finn Williamsdd2ba7e2019-03-01 11:51:52 +0000501 RsqrtLayer,
Conor Kennedy79ffdf52019-03-01 14:24:54 +0000502 FloorLayer,
Nattapat Chaimanowong6522cdc2019-03-01 16:14:13 +0000503 GreaterLayer,
Conor Kennedyda1f9752019-03-01 14:37:12 +0000504 ResizeBilinearLayer,
Nattapat Chaimanowongb3485212019-03-04 12:35:39 +0000505 SubtractionLayer,
Saoirse Stewarta1ed73a2019-03-04 13:40:12 +0000506 StridedSliceLayer,
Sadik Armaganac97c8c2019-03-04 17:44:21 +0000507 GatherLayer,
Jim Flynnac25a1b2019-02-28 10:40:49 +0000508 MeanLayer,
Narumol Prangnawarat495701f2019-03-07 17:31:34 +0000509 MergerLayer,
Jim Flynn18ce3382019-03-08 11:08:30 +0000510 L2NormalizationLayer,
Nattapat Chaimanowong3e14a9d2019-03-18 12:37:06 +0000511 SplitterLayer,
512 DetectionPostProcessLayer
Nattapat Chaimanowong969eea32019-01-30 13:33:11 +0000513}
514
Saoirse Stewart49dbe0e2019-02-05 17:27:06 +0000515table AnyLayer {
516 layer:Layer;
517}
518
Nattapat Chaimanowong969eea32019-01-30 13:33:11 +0000519// Root type for serialized data is the graph of the network
520table SerializedGraph {
Saoirse Stewart49dbe0e2019-02-05 17:27:06 +0000521 layers:[AnyLayer];
Mike Kelly8c1701a2019-02-11 17:01:27 +0000522 inputIds:[uint];
523 outputIds:[uint];
Nattapat Chaimanowong969eea32019-01-30 13:33:11 +0000524}
525
526root_type SerializedGraph;