blob: 36389b780b548eb8c32f2812a9ab778cffa4aacb [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,
115 L2Normalization = 31
Nattapat Chaimanowong969eea32019-01-30 13:33:11 +0000116}
117
118// Base layer table to be used as part of other layers
119table LayerBase {
120 index:uint;
121 layerName:string;
122 layerType:LayerType;
123 inputSlots:[InputSlot];
124 outputSlots:[OutputSlot];
125}
126
127table BindableLayerBase {
128 base:LayerBase;
129 layerBindingId:int;
130}
131
132// Table for each layer defined below
Mike Kellyaf484012019-02-20 16:53:11 +0000133table ActivationLayer {
134 base:LayerBase;
135 descriptor:ActivationDescriptor;
136}
137
138table ActivationDescriptor {
139 function:ActivationFunction = Sigmoid;
140 a:float;
141 b:float;
142}
143
Nattapat Chaimanowong969eea32019-01-30 13:33:11 +0000144table AdditionLayer {
145 base:LayerBase;
146}
147
Conor Kennedy76277882019-02-26 08:29:54 +0000148table ConstantLayer {
149 base:LayerBase;
150 input:ConstTensor;
151}
152
Mike Kellya0766c32019-02-19 17:22:07 +0000153table Convolution2dLayer {
154 base:LayerBase;
155 descriptor:Convolution2dDescriptor;
156 weights:ConstTensor;
157 biases:ConstTensor;
158}
159
160table Convolution2dDescriptor {
161 padLeft:uint;
162 padRight:uint;
163 padTop:uint;
164 padBottom:uint;
165 strideX:uint;
166 strideY:uint;
167 biasEnabled:bool = false;
168 dataLayout:DataLayout = NCHW;
169}
170
Éanna Ó Catháin58885892019-02-27 16:16:39 +0000171table DivisionLayer {
172 base:LayerBase;
173}
174
Nattapat Chaimanowong235cea52019-02-28 16:27:30 +0000175table EqualLayer {
176 base:LayerBase;
177}
178
Finn Williamsdd2ba7e2019-03-01 11:51:52 +0000179table FloorLayer{
180 base:LayerBase;
181}
182
Sadik Armagandbb0c0c2019-02-21 09:01:41 +0000183table FullyConnectedLayer {
184 base:LayerBase;
185 descriptor:FullyConnectedDescriptor;
186 weights:ConstTensor;
187 biases:ConstTensor;
188}
189
190table FullyConnectedDescriptor {
191 biasEnabled:bool = false;
192 transposeWeightsMatrix:bool = false;
193}
194
Saoirse Stewarta1ed73a2019-03-04 13:40:12 +0000195table GatherLayer {
196 base:LayerBase;
197}
198
Conor Kennedy79ffdf52019-03-01 14:24:54 +0000199table GreaterLayer {
200 base:LayerBase;
201}
202
Nattapat Chaimanowong969eea32019-01-30 13:33:11 +0000203table InputLayer {
204 base:BindableLayerBase;
205}
206
Narumol Prangnawarat495701f2019-03-07 17:31:34 +0000207table L2NormalizationLayer {
208 base:LayerBase;
209 descriptor:L2NormalizationDescriptor;
210}
211
212table L2NormalizationDescriptor {
213 dataLayout:DataLayout = NCHW;
214}
215
Aron Virginas-Tar0fe32452019-02-28 13:12:47 +0000216table MinimumLayer {
217 base:LayerBase;
218}
219
Aron Virginas-Tar377351e2019-02-27 14:42:31 +0000220table MaximumLayer {
221 base:LayerBase;
222}
223
Sadik Armagan5f450272019-02-12 14:31:45 +0000224table MultiplicationLayer {
225 base:LayerBase;
226}
227
Saoirse Stewart3166c3e2019-02-18 15:24:53 +0000228table Pooling2dLayer {
229 base:LayerBase;
230 descriptor:Pooling2dDescriptor;
231}
232
233enum PoolingAlgorithm : byte {
234 Max = 0,
235 Average = 1,
236 L2 = 2
237}
238
239enum OutputShapeRounding : byte {
240 Floor = 0,
241 Ceiling = 1
242}
243
244enum PaddingMethod : byte {
245 IgnoreValue = 0,
246 Exclude = 1
247}
248
249table Pooling2dDescriptor {
250 poolType:PoolingAlgorithm;
251 padLeft:uint;
252 padRight:uint;
253 padTop:uint;
254 padBottom:uint;
255 poolWidth:uint;
256 poolHeight:uint;
257 strideX:uint;
258 strideY:uint;
259 outputShapeRounding:OutputShapeRounding;
260 paddingMethod:PaddingMethod;
261 dataLayout:DataLayout;
262}
263
Aron Virginas-Tarfc413c02019-02-13 15:41:52 +0000264table SoftmaxLayer {
265 base:LayerBase;
266 descriptor:SoftmaxDescriptor;
267}
268
269table SoftmaxDescriptor {
270 beta:float;
271}
272
Aron Virginas-Tarc04125f2019-02-19 16:31:08 +0000273table DepthwiseConvolution2dLayer {
274 base:LayerBase;
275 descriptor:DepthwiseConvolution2dDescriptor;
276 weights:ConstTensor;
277 biases:ConstTensor;
278}
279
280table DepthwiseConvolution2dDescriptor {
281 padLeft:uint;
282 padRight:uint;
283 padTop:uint;
284 padBottom:uint;
285 strideX:uint;
286 strideY:uint;
287 biasEnabled:bool = false;
288 dataLayout:DataLayout = NCHW;
289}
290
Nattapat Chaimanowong969eea32019-01-30 13:33:11 +0000291table OutputLayer {
292 base:BindableLayerBase;
293}
294
Saoirse Stewart263829c2019-02-19 15:54:14 +0000295table ReshapeLayer {
296 base:LayerBase;
297 descriptor:ReshapeDescriptor;
298}
299
300table ReshapeDescriptor {
301 targetShape:[uint];
302}
303
Nattapat Chaimanowong30b00202019-02-20 17:31:34 +0000304table PermuteLayer {
305 base:LayerBase;
306 descriptor:PermuteDescriptor;
307}
308
309table PermuteDescriptor {
310 dimMappings:[uint];
311}
312
Nattapat Chaimanowong45286992019-02-26 15:53:02 +0000313table SpaceToBatchNdLayer {
314 base:LayerBase;
315 descriptor:SpaceToBatchNdDescriptor;
316}
317
318table SpaceToBatchNdDescriptor {
319 blockShape:[uint];
320 padList:[uint];
321 dataLayout:DataLayout;
322}
323
Conor Kennedyda1f9752019-03-01 14:37:12 +0000324table SubtractionLayer {
325 base:LayerBase;
326}
327
Nattapat Chaimanowong6b4ed982019-02-26 17:24:13 +0000328table BatchToSpaceNdLayer {
329 base:LayerBase;
330 descriptor:BatchToSpaceNdDescriptor;
331}
332
333table BatchToSpaceNdDescriptor {
334 blockShape:[uint];
335 crops:[uint];
336 dataLayout:DataLayout;
337}
338
Nina Drozd57728782019-02-27 10:53:27 +0000339enum NormalizationAlgorithmChannel : byte {
340 Across = 0,
341 Within = 1
342}
343
344enum NormalizationAlgorithmMethod : byte {
345 LocalBrightness = 0,
346 LocalContrast = 1
347}
348
349table NormalizationLayer {
350 base:LayerBase;
351 descriptor:NormalizationDescriptor;
352}
353
354table NormalizationDescriptor {
355 normChannelType:NormalizationAlgorithmChannel = Across;
356 normMethodType:NormalizationAlgorithmMethod = LocalBrightness;
357 normSize:uint;
358 alpha:float;
359 beta:float;
360 k:float;
361 dataLayout:DataLayout = NCHW;
362}
363
Sadik Armaganac97c8c2019-03-04 17:44:21 +0000364table MeanLayer {
365 base:LayerBase;
366 descriptor:MeanDescriptor;
367}
368
369table MeanDescriptor {
370 axis:[uint];
371 keepDims:bool = false;
372}
373
Nattapat Chaimanowongebb0f9c2019-03-01 12:14:06 +0000374table PadLayer {
375 base:LayerBase;
376 descriptor:PadDescriptor;
377}
378
379table PadDescriptor {
380 padList:[uint];
381}
382
Sadik Armagan8b42a382019-03-01 14:24:49 +0000383table RsqrtLayer {
384 base:LayerBase;
385}
386
ruoyan018e7fa232019-02-28 15:09:07 +0000387table BatchNormalizationLayer {
388 base:LayerBase;
389 descriptor:BatchNormalizationDescriptor;
390 mean:ConstTensor;
391 variance:ConstTensor;
392 beta:ConstTensor;
393 gamma:ConstTensor;
394}
395
396table BatchNormalizationDescriptor {
397 eps:float;
398 dataLayout:DataLayout;
399}
400
Nattapat Chaimanowong6522cdc2019-03-01 16:14:13 +0000401table ResizeBilinearLayer {
402 base:LayerBase;
403 descriptor:ResizeBilinearDescriptor;
404}
405
406table ResizeBilinearDescriptor {
407 targetWidth:uint;
408 targetHeight:uint;
409 dataLayout:DataLayout;
410}
411
Nattapat Chaimanowongb3485212019-03-04 12:35:39 +0000412table StridedSliceLayer {
413 base:LayerBase;
414 descriptor:StridedSliceDescriptor;
415}
416
417table StridedSliceDescriptor {
418 begin:[int];
419 end:[int];
420 stride:[int];
421 beginMask:int;
422 endMask:int;
423 shrinkAxisMask:int;
424 ellipsisMask:int;
425 newAxisMask:int;
426 dataLayout:DataLayout;
427}
428
Jim Flynnac25a1b2019-02-28 10:40:49 +0000429table MergerLayer {
430 base:LayerBase;
431 descriptor:OriginsDescriptor;
432}
433
434table UintVector {
435 data:[uint];
436}
437
438table OriginsDescriptor {
439 concatAxis:uint;
440 numViews:uint;
441 numDimensions:uint;
442 viewOrigins:[UintVector];
443}
444
Nattapat Chaimanowong969eea32019-01-30 13:33:11 +0000445union Layer {
Mike Kellyaf484012019-02-20 16:53:11 +0000446 ActivationLayer,
Nattapat Chaimanowong969eea32019-01-30 13:33:11 +0000447 AdditionLayer,
Nattapat Chaimanowong6b4ed982019-02-26 17:24:13 +0000448 BatchToSpaceNdLayer,
ruoyan018e7fa232019-02-28 15:09:07 +0000449 BatchNormalizationLayer,
Conor Kennedy76277882019-02-26 08:29:54 +0000450 ConstantLayer,
Mike Kellya0766c32019-02-19 17:22:07 +0000451 Convolution2dLayer,
Aron Virginas-Tarc04125f2019-02-19 16:31:08 +0000452 DepthwiseConvolution2dLayer,
Sadik Armagandbb0c0c2019-02-21 09:01:41 +0000453 FullyConnectedLayer,
Nattapat Chaimanowong969eea32019-01-30 13:33:11 +0000454 InputLayer,
Sadik Armagan5f450272019-02-12 14:31:45 +0000455 MultiplicationLayer,
Aron Virginas-Tarfc413c02019-02-13 15:41:52 +0000456 OutputLayer,
Nattapat Chaimanowong30b00202019-02-20 17:31:34 +0000457 PermuteLayer,
Saoirse Stewart3166c3e2019-02-18 15:24:53 +0000458 Pooling2dLayer,
Saoirse Stewart263829c2019-02-19 15:54:14 +0000459 ReshapeLayer,
Nattapat Chaimanowong45286992019-02-26 15:53:02 +0000460 SoftmaxLayer,
Éanna Ó Catháin58885892019-02-27 16:16:39 +0000461 SpaceToBatchNdLayer,
Aron Virginas-Tar0fe32452019-02-28 13:12:47 +0000462 DivisionLayer,
Nattapat Chaimanowong235cea52019-02-28 16:27:30 +0000463 MinimumLayer,
Aron Virginas-Tar377351e2019-02-27 14:42:31 +0000464 EqualLayer,
Nina Drozd57728782019-02-27 10:53:27 +0000465 MaximumLayer,
Nattapat Chaimanowongebb0f9c2019-03-01 12:14:06 +0000466 NormalizationLayer,
Sadik Armagan8b42a382019-03-01 14:24:49 +0000467 PadLayer,
Finn Williamsdd2ba7e2019-03-01 11:51:52 +0000468 RsqrtLayer,
Conor Kennedy79ffdf52019-03-01 14:24:54 +0000469 FloorLayer,
Nattapat Chaimanowong6522cdc2019-03-01 16:14:13 +0000470 GreaterLayer,
Conor Kennedyda1f9752019-03-01 14:37:12 +0000471 ResizeBilinearLayer,
Nattapat Chaimanowongb3485212019-03-04 12:35:39 +0000472 SubtractionLayer,
Saoirse Stewarta1ed73a2019-03-04 13:40:12 +0000473 StridedSliceLayer,
Sadik Armaganac97c8c2019-03-04 17:44:21 +0000474 GatherLayer,
Jim Flynnac25a1b2019-02-28 10:40:49 +0000475 MeanLayer,
Narumol Prangnawarat495701f2019-03-07 17:31:34 +0000476 MergerLayer,
477 L2NormalizationLayer
Nattapat Chaimanowong969eea32019-01-30 13:33:11 +0000478}
479
Saoirse Stewart49dbe0e2019-02-05 17:27:06 +0000480table AnyLayer {
481 layer:Layer;
482}
483
Nattapat Chaimanowong969eea32019-01-30 13:33:11 +0000484// Root type for serialized data is the graph of the network
485table SerializedGraph {
Saoirse Stewart49dbe0e2019-02-05 17:27:06 +0000486 layers:[AnyLayer];
Mike Kelly8c1701a2019-02-11 17:01:27 +0000487 inputIds:[uint];
488 outputIds:[uint];
Nattapat Chaimanowong969eea32019-01-30 13:33:11 +0000489}
490
491root_type SerializedGraph;