blob: 00c1a4502b7b48ff29587a69305f125e0fce7331 [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,
30 Boolean = 4
31}
32
Saoirse Stewart3166c3e2019-02-18 15:24:53 +000033enum DataLayout : byte {
34 NHWC = 0,
35 NCHW = 1
36}
37
Nattapat Chaimanowong969eea32019-01-30 13:33:11 +000038table TensorInfo {
39 dimensions:[uint];
40 dataType:DataType;
41 quantizationScale:float = 1.0;
42 quantizationOffset:int = 0;
43}
44
45struct Connection {
46 sourceLayerIndex:uint;
47 outputSlotIndex:uint;
48}
49
50table ByteData {
51 data:[byte];
52}
53
54table ShortData {
55 data:[short];
56}
57
58table IntData {
59 data:[int];
60}
61
62table LongData {
63 data:[long];
64}
65
66union ConstTensorData { ByteData, ShortData, IntData, LongData }
67
68table ConstTensor {
69 info:TensorInfo;
70 data:ConstTensorData;
71}
72
73table InputSlot {
74 index:uint;
75 connection:Connection;
76}
77
78table OutputSlot {
79 index:uint;
80 tensorInfo:TensorInfo;
81}
82
83enum LayerType : uint {
84 Addition = 0,
85 Input = 1,
Sadik Armagan5f450272019-02-12 14:31:45 +000086 Multiplication = 2,
Aron Virginas-Tarfc413c02019-02-13 15:41:52 +000087 Output = 3,
Saoirse Stewart3166c3e2019-02-18 15:24:53 +000088 Pooling2d = 4,
Saoirse Stewart263829c2019-02-19 15:54:14 +000089 Reshape = 5,
Mike Kellya0766c32019-02-19 17:22:07 +000090 Softmax = 6,
Aron Virginas-Tarc04125f2019-02-19 16:31:08 +000091 Convolution2d = 7,
Mike Kellyaf484012019-02-20 16:53:11 +000092 DepthwiseConvolution2d = 8,
Nattapat Chaimanowong30b00202019-02-20 17:31:34 +000093 Activation = 9,
Sadik Armagandbb0c0c2019-02-21 09:01:41 +000094 Permute = 10,
Conor Kennedy76277882019-02-26 08:29:54 +000095 FullyConnected = 11,
Nattapat Chaimanowong45286992019-02-26 15:53:02 +000096 Constant = 12,
Nattapat Chaimanowong6b4ed982019-02-26 17:24:13 +000097 SpaceToBatchNd = 13,
Éanna Ó Catháin58885892019-02-27 16:16:39 +000098 BatchToSpaceNd = 14,
Aron Virginas-Tar0fe32452019-02-28 13:12:47 +000099 Division = 15,
Nattapat Chaimanowong235cea52019-02-28 16:27:30 +0000100 Minimum = 16,
Aron Virginas-Tar377351e2019-02-27 14:42:31 +0000101 Equal = 17,
Nina Drozd57728782019-02-27 10:53:27 +0000102 Maximum = 18,
Nattapat Chaimanowongebb0f9c2019-03-01 12:14:06 +0000103 Normalization = 19,
Sadik Armagan8b42a382019-03-01 14:24:49 +0000104 Pad = 20,
Finn Williamsdd2ba7e2019-03-01 11:51:52 +0000105 Rsqrt = 21,
ruoyan018e7fa232019-02-28 15:09:07 +0000106 Floor = 22,
Conor Kennedy79ffdf52019-03-01 14:24:54 +0000107 BatchNormalization = 23,
Nattapat Chaimanowong6522cdc2019-03-01 16:14:13 +0000108 Greater = 24,
Conor Kennedyda1f9752019-03-01 14:37:12 +0000109 ResizeBilinear = 25,
Nattapat Chaimanowongb3485212019-03-04 12:35:39 +0000110 Subtraction = 26,
Saoirse Stewarta1ed73a2019-03-04 13:40:12 +0000111 StridedSlice = 27,
Sadik Armaganac97c8c2019-03-04 17:44:21 +0000112 Gather = 28,
Jim Flynnac25a1b2019-02-28 10:40:49 +0000113 Mean = 29,
Narumol Prangnawarat495701f2019-03-07 17:31:34 +0000114 Merger = 30,
Jim Flynn18ce3382019-03-08 11:08:30 +0000115 L2Normalization = 31,
Nattapat Chaimanowong3e14a9d2019-03-18 12:37:06 +0000116 Splitter = 32,
117 DetectionPostProcess = 33
Nattapat Chaimanowong969eea32019-01-30 13:33:11 +0000118}
119
120// Base layer table to be used as part of other layers
121table LayerBase {
122 index:uint;
123 layerName:string;
124 layerType:LayerType;
125 inputSlots:[InputSlot];
126 outputSlots:[OutputSlot];
127}
128
129table BindableLayerBase {
130 base:LayerBase;
131 layerBindingId:int;
132}
133
134// Table for each layer defined below
Mike Kellyaf484012019-02-20 16:53:11 +0000135table ActivationLayer {
136 base:LayerBase;
137 descriptor:ActivationDescriptor;
138}
139
140table ActivationDescriptor {
141 function:ActivationFunction = Sigmoid;
142 a:float;
143 b:float;
144}
145
Nattapat Chaimanowong969eea32019-01-30 13:33:11 +0000146table AdditionLayer {
147 base:LayerBase;
148}
149
Conor Kennedy76277882019-02-26 08:29:54 +0000150table ConstantLayer {
151 base:LayerBase;
152 input:ConstTensor;
153}
154
Mike Kellya0766c32019-02-19 17:22:07 +0000155table Convolution2dLayer {
156 base:LayerBase;
157 descriptor:Convolution2dDescriptor;
158 weights:ConstTensor;
159 biases:ConstTensor;
160}
161
162table Convolution2dDescriptor {
163 padLeft:uint;
164 padRight:uint;
165 padTop:uint;
166 padBottom:uint;
167 strideX:uint;
168 strideY:uint;
169 biasEnabled:bool = false;
170 dataLayout:DataLayout = NCHW;
171}
172
Éanna Ó Catháin58885892019-02-27 16:16:39 +0000173table DivisionLayer {
174 base:LayerBase;
175}
176
Nattapat Chaimanowong235cea52019-02-28 16:27:30 +0000177table EqualLayer {
178 base:LayerBase;
179}
180
Finn Williamsdd2ba7e2019-03-01 11:51:52 +0000181table FloorLayer{
182 base:LayerBase;
183}
184
Sadik Armagandbb0c0c2019-02-21 09:01:41 +0000185table FullyConnectedLayer {
186 base:LayerBase;
187 descriptor:FullyConnectedDescriptor;
188 weights:ConstTensor;
189 biases:ConstTensor;
190}
191
192table FullyConnectedDescriptor {
193 biasEnabled:bool = false;
194 transposeWeightsMatrix:bool = false;
195}
196
Saoirse Stewarta1ed73a2019-03-04 13:40:12 +0000197table GatherLayer {
198 base:LayerBase;
199}
200
Conor Kennedy79ffdf52019-03-01 14:24:54 +0000201table GreaterLayer {
202 base:LayerBase;
203}
204
Nattapat Chaimanowong969eea32019-01-30 13:33:11 +0000205table InputLayer {
206 base:BindableLayerBase;
207}
208
Narumol Prangnawarat495701f2019-03-07 17:31:34 +0000209table L2NormalizationLayer {
210 base:LayerBase;
211 descriptor:L2NormalizationDescriptor;
212}
213
214table L2NormalizationDescriptor {
215 dataLayout:DataLayout = NCHW;
216}
217
Aron Virginas-Tar0fe32452019-02-28 13:12:47 +0000218table MinimumLayer {
219 base:LayerBase;
220}
221
Aron Virginas-Tar377351e2019-02-27 14:42:31 +0000222table MaximumLayer {
223 base:LayerBase;
224}
225
Sadik Armagan5f450272019-02-12 14:31:45 +0000226table MultiplicationLayer {
227 base:LayerBase;
228}
229
Saoirse Stewart3166c3e2019-02-18 15:24:53 +0000230table Pooling2dLayer {
231 base:LayerBase;
232 descriptor:Pooling2dDescriptor;
233}
234
235enum PoolingAlgorithm : byte {
236 Max = 0,
237 Average = 1,
238 L2 = 2
239}
240
241enum OutputShapeRounding : byte {
242 Floor = 0,
243 Ceiling = 1
244}
245
246enum PaddingMethod : byte {
247 IgnoreValue = 0,
248 Exclude = 1
249}
250
251table Pooling2dDescriptor {
252 poolType:PoolingAlgorithm;
253 padLeft:uint;
254 padRight:uint;
255 padTop:uint;
256 padBottom:uint;
257 poolWidth:uint;
258 poolHeight:uint;
259 strideX:uint;
260 strideY:uint;
261 outputShapeRounding:OutputShapeRounding;
262 paddingMethod:PaddingMethod;
263 dataLayout:DataLayout;
264}
265
Aron Virginas-Tarfc413c02019-02-13 15:41:52 +0000266table SoftmaxLayer {
267 base:LayerBase;
268 descriptor:SoftmaxDescriptor;
269}
270
271table SoftmaxDescriptor {
272 beta:float;
273}
274
Aron Virginas-Tarc04125f2019-02-19 16:31:08 +0000275table DepthwiseConvolution2dLayer {
276 base:LayerBase;
277 descriptor:DepthwiseConvolution2dDescriptor;
278 weights:ConstTensor;
279 biases:ConstTensor;
280}
281
282table DepthwiseConvolution2dDescriptor {
283 padLeft:uint;
284 padRight:uint;
285 padTop:uint;
286 padBottom:uint;
287 strideX:uint;
288 strideY:uint;
289 biasEnabled:bool = false;
290 dataLayout:DataLayout = NCHW;
291}
292
Nattapat Chaimanowong969eea32019-01-30 13:33:11 +0000293table OutputLayer {
294 base:BindableLayerBase;
295}
296
Saoirse Stewart263829c2019-02-19 15:54:14 +0000297table ReshapeLayer {
298 base:LayerBase;
299 descriptor:ReshapeDescriptor;
300}
301
302table ReshapeDescriptor {
303 targetShape:[uint];
304}
305
Nattapat Chaimanowong30b00202019-02-20 17:31:34 +0000306table PermuteLayer {
307 base:LayerBase;
308 descriptor:PermuteDescriptor;
309}
310
311table PermuteDescriptor {
312 dimMappings:[uint];
313}
314
Nattapat Chaimanowong45286992019-02-26 15:53:02 +0000315table SpaceToBatchNdLayer {
316 base:LayerBase;
317 descriptor:SpaceToBatchNdDescriptor;
318}
319
320table SpaceToBatchNdDescriptor {
321 blockShape:[uint];
322 padList:[uint];
323 dataLayout:DataLayout;
324}
325
Conor Kennedyda1f9752019-03-01 14:37:12 +0000326table SubtractionLayer {
327 base:LayerBase;
328}
329
Nattapat Chaimanowong6b4ed982019-02-26 17:24:13 +0000330table BatchToSpaceNdLayer {
331 base:LayerBase;
332 descriptor:BatchToSpaceNdDescriptor;
333}
334
335table BatchToSpaceNdDescriptor {
336 blockShape:[uint];
337 crops:[uint];
338 dataLayout:DataLayout;
339}
340
Nina Drozd57728782019-02-27 10:53:27 +0000341enum NormalizationAlgorithmChannel : byte {
342 Across = 0,
343 Within = 1
344}
345
346enum NormalizationAlgorithmMethod : byte {
347 LocalBrightness = 0,
348 LocalContrast = 1
349}
350
351table NormalizationLayer {
352 base:LayerBase;
353 descriptor:NormalizationDescriptor;
354}
355
356table NormalizationDescriptor {
357 normChannelType:NormalizationAlgorithmChannel = Across;
358 normMethodType:NormalizationAlgorithmMethod = LocalBrightness;
359 normSize:uint;
360 alpha:float;
361 beta:float;
362 k:float;
363 dataLayout:DataLayout = NCHW;
364}
365
Sadik Armaganac97c8c2019-03-04 17:44:21 +0000366table MeanLayer {
367 base:LayerBase;
368 descriptor:MeanDescriptor;
369}
370
371table MeanDescriptor {
372 axis:[uint];
373 keepDims:bool = false;
374}
375
Nattapat Chaimanowongebb0f9c2019-03-01 12:14:06 +0000376table PadLayer {
377 base:LayerBase;
378 descriptor:PadDescriptor;
379}
380
381table PadDescriptor {
382 padList:[uint];
383}
384
Sadik Armagan8b42a382019-03-01 14:24:49 +0000385table RsqrtLayer {
386 base:LayerBase;
387}
388
ruoyan018e7fa232019-02-28 15:09:07 +0000389table BatchNormalizationLayer {
390 base:LayerBase;
391 descriptor:BatchNormalizationDescriptor;
392 mean:ConstTensor;
393 variance:ConstTensor;
394 beta:ConstTensor;
395 gamma:ConstTensor;
396}
397
398table BatchNormalizationDescriptor {
399 eps:float;
400 dataLayout:DataLayout;
401}
402
Nattapat Chaimanowong6522cdc2019-03-01 16:14:13 +0000403table ResizeBilinearLayer {
404 base:LayerBase;
405 descriptor:ResizeBilinearDescriptor;
406}
407
408table ResizeBilinearDescriptor {
409 targetWidth:uint;
410 targetHeight:uint;
411 dataLayout:DataLayout;
412}
413
Nattapat Chaimanowongb3485212019-03-04 12:35:39 +0000414table StridedSliceLayer {
415 base:LayerBase;
416 descriptor:StridedSliceDescriptor;
417}
418
419table StridedSliceDescriptor {
420 begin:[int];
421 end:[int];
422 stride:[int];
423 beginMask:int;
424 endMask:int;
425 shrinkAxisMask:int;
426 ellipsisMask:int;
427 newAxisMask:int;
428 dataLayout:DataLayout;
429}
430
Jim Flynnac25a1b2019-02-28 10:40:49 +0000431table MergerLayer {
432 base:LayerBase;
433 descriptor:OriginsDescriptor;
434}
435
436table UintVector {
437 data:[uint];
438}
439
440table OriginsDescriptor {
441 concatAxis:uint;
442 numViews:uint;
443 numDimensions:uint;
444 viewOrigins:[UintVector];
445}
446
Jim Flynn18ce3382019-03-08 11:08:30 +0000447table ViewsDescriptor {
448 origins:OriginsDescriptor;
449 viewSizes:[UintVector];
450}
451
452table SplitterLayer {
453 base:LayerBase;
454 descriptor:ViewsDescriptor;
455}
456
Nattapat Chaimanowong3e14a9d2019-03-18 12:37:06 +0000457table DetectionPostProcessLayer {
458 base:LayerBase;
459 descriptor:DetectionPostProcessDescriptor;
460 anchors:ConstTensor;
461}
462
463table DetectionPostProcessDescriptor {
464 maxDetections:uint;
465 maxClassesPerDetection:uint;
466 detectionsPerClass:uint;
467 nmsScoreThreshold:float;
468 nmsIouThreshold:float;
469 numClasses:uint;
470 useRegularNms:bool;
471 scaleX:float;
472 scaleY:float;
473 scaleW:float;
474 scaleH:float;
475}
476
Nattapat Chaimanowong969eea32019-01-30 13:33:11 +0000477union Layer {
Mike Kellyaf484012019-02-20 16:53:11 +0000478 ActivationLayer,
Nattapat Chaimanowong969eea32019-01-30 13:33:11 +0000479 AdditionLayer,
Nattapat Chaimanowong6b4ed982019-02-26 17:24:13 +0000480 BatchToSpaceNdLayer,
ruoyan018e7fa232019-02-28 15:09:07 +0000481 BatchNormalizationLayer,
Conor Kennedy76277882019-02-26 08:29:54 +0000482 ConstantLayer,
Mike Kellya0766c32019-02-19 17:22:07 +0000483 Convolution2dLayer,
Aron Virginas-Tarc04125f2019-02-19 16:31:08 +0000484 DepthwiseConvolution2dLayer,
Sadik Armagandbb0c0c2019-02-21 09:01:41 +0000485 FullyConnectedLayer,
Nattapat Chaimanowong969eea32019-01-30 13:33:11 +0000486 InputLayer,
Sadik Armagan5f450272019-02-12 14:31:45 +0000487 MultiplicationLayer,
Aron Virginas-Tarfc413c02019-02-13 15:41:52 +0000488 OutputLayer,
Nattapat Chaimanowong30b00202019-02-20 17:31:34 +0000489 PermuteLayer,
Saoirse Stewart3166c3e2019-02-18 15:24:53 +0000490 Pooling2dLayer,
Saoirse Stewart263829c2019-02-19 15:54:14 +0000491 ReshapeLayer,
Nattapat Chaimanowong45286992019-02-26 15:53:02 +0000492 SoftmaxLayer,
Éanna Ó Catháin58885892019-02-27 16:16:39 +0000493 SpaceToBatchNdLayer,
Aron Virginas-Tar0fe32452019-02-28 13:12:47 +0000494 DivisionLayer,
Nattapat Chaimanowong235cea52019-02-28 16:27:30 +0000495 MinimumLayer,
Aron Virginas-Tar377351e2019-02-27 14:42:31 +0000496 EqualLayer,
Nina Drozd57728782019-02-27 10:53:27 +0000497 MaximumLayer,
Nattapat Chaimanowongebb0f9c2019-03-01 12:14:06 +0000498 NormalizationLayer,
Sadik Armagan8b42a382019-03-01 14:24:49 +0000499 PadLayer,
Finn Williamsdd2ba7e2019-03-01 11:51:52 +0000500 RsqrtLayer,
Conor Kennedy79ffdf52019-03-01 14:24:54 +0000501 FloorLayer,
Nattapat Chaimanowong6522cdc2019-03-01 16:14:13 +0000502 GreaterLayer,
Conor Kennedyda1f9752019-03-01 14:37:12 +0000503 ResizeBilinearLayer,
Nattapat Chaimanowongb3485212019-03-04 12:35:39 +0000504 SubtractionLayer,
Saoirse Stewarta1ed73a2019-03-04 13:40:12 +0000505 StridedSliceLayer,
Sadik Armaganac97c8c2019-03-04 17:44:21 +0000506 GatherLayer,
Jim Flynnac25a1b2019-02-28 10:40:49 +0000507 MeanLayer,
Narumol Prangnawarat495701f2019-03-07 17:31:34 +0000508 MergerLayer,
Jim Flynn18ce3382019-03-08 11:08:30 +0000509 L2NormalizationLayer,
Nattapat Chaimanowong3e14a9d2019-03-18 12:37:06 +0000510 SplitterLayer,
511 DetectionPostProcessLayer
Nattapat Chaimanowong969eea32019-01-30 13:33:11 +0000512}
513
Saoirse Stewart49dbe0e2019-02-05 17:27:06 +0000514table AnyLayer {
515 layer:Layer;
516}
517
Nattapat Chaimanowong969eea32019-01-30 13:33:11 +0000518// Root type for serialized data is the graph of the network
519table SerializedGraph {
Saoirse Stewart49dbe0e2019-02-05 17:27:06 +0000520 layers:[AnyLayer];
Mike Kelly8c1701a2019-02-11 17:01:27 +0000521 inputIds:[uint];
522 outputIds:[uint];
Nattapat Chaimanowong969eea32019-01-30 13:33:11 +0000523}
524
525root_type SerializedGraph;