blob: ed3de83f55ddd3ec82db5fdafe6f81d2221405e2 [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,
111 StridedSlice = 27
Nattapat Chaimanowong969eea32019-01-30 13:33:11 +0000112}
113
114// Base layer table to be used as part of other layers
115table LayerBase {
116 index:uint;
117 layerName:string;
118 layerType:LayerType;
119 inputSlots:[InputSlot];
120 outputSlots:[OutputSlot];
121}
122
123table BindableLayerBase {
124 base:LayerBase;
125 layerBindingId:int;
126}
127
128// Table for each layer defined below
Mike Kellyaf484012019-02-20 16:53:11 +0000129table ActivationLayer {
130 base:LayerBase;
131 descriptor:ActivationDescriptor;
132}
133
134table ActivationDescriptor {
135 function:ActivationFunction = Sigmoid;
136 a:float;
137 b:float;
138}
139
Nattapat Chaimanowong969eea32019-01-30 13:33:11 +0000140table AdditionLayer {
141 base:LayerBase;
142}
143
Conor Kennedy76277882019-02-26 08:29:54 +0000144table ConstantLayer {
145 base:LayerBase;
146 input:ConstTensor;
147}
148
Mike Kellya0766c32019-02-19 17:22:07 +0000149table Convolution2dLayer {
150 base:LayerBase;
151 descriptor:Convolution2dDescriptor;
152 weights:ConstTensor;
153 biases:ConstTensor;
154}
155
156table Convolution2dDescriptor {
157 padLeft:uint;
158 padRight:uint;
159 padTop:uint;
160 padBottom:uint;
161 strideX:uint;
162 strideY:uint;
163 biasEnabled:bool = false;
164 dataLayout:DataLayout = NCHW;
165}
166
Éanna Ó Catháin58885892019-02-27 16:16:39 +0000167table DivisionLayer {
168 base:LayerBase;
169}
170
Nattapat Chaimanowong235cea52019-02-28 16:27:30 +0000171table EqualLayer {
172 base:LayerBase;
173}
174
Finn Williamsdd2ba7e2019-03-01 11:51:52 +0000175table FloorLayer{
176 base:LayerBase;
177}
178
Sadik Armagandbb0c0c2019-02-21 09:01:41 +0000179table FullyConnectedLayer {
180 base:LayerBase;
181 descriptor:FullyConnectedDescriptor;
182 weights:ConstTensor;
183 biases:ConstTensor;
184}
185
186table FullyConnectedDescriptor {
187 biasEnabled:bool = false;
188 transposeWeightsMatrix:bool = false;
189}
190
Conor Kennedy79ffdf52019-03-01 14:24:54 +0000191table GreaterLayer {
192 base:LayerBase;
193}
194
Nattapat Chaimanowong969eea32019-01-30 13:33:11 +0000195table InputLayer {
196 base:BindableLayerBase;
197}
198
Aron Virginas-Tar0fe32452019-02-28 13:12:47 +0000199table MinimumLayer {
200 base:LayerBase;
201}
202
Aron Virginas-Tar377351e2019-02-27 14:42:31 +0000203table MaximumLayer {
204 base:LayerBase;
205}
206
Sadik Armagan5f450272019-02-12 14:31:45 +0000207table MultiplicationLayer {
208 base:LayerBase;
209}
210
Saoirse Stewart3166c3e2019-02-18 15:24:53 +0000211table Pooling2dLayer {
212 base:LayerBase;
213 descriptor:Pooling2dDescriptor;
214}
215
216enum PoolingAlgorithm : byte {
217 Max = 0,
218 Average = 1,
219 L2 = 2
220}
221
222enum OutputShapeRounding : byte {
223 Floor = 0,
224 Ceiling = 1
225}
226
227enum PaddingMethod : byte {
228 IgnoreValue = 0,
229 Exclude = 1
230}
231
232table Pooling2dDescriptor {
233 poolType:PoolingAlgorithm;
234 padLeft:uint;
235 padRight:uint;
236 padTop:uint;
237 padBottom:uint;
238 poolWidth:uint;
239 poolHeight:uint;
240 strideX:uint;
241 strideY:uint;
242 outputShapeRounding:OutputShapeRounding;
243 paddingMethod:PaddingMethod;
244 dataLayout:DataLayout;
245}
246
Aron Virginas-Tarfc413c02019-02-13 15:41:52 +0000247table SoftmaxLayer {
248 base:LayerBase;
249 descriptor:SoftmaxDescriptor;
250}
251
252table SoftmaxDescriptor {
253 beta:float;
254}
255
Aron Virginas-Tarc04125f2019-02-19 16:31:08 +0000256table DepthwiseConvolution2dLayer {
257 base:LayerBase;
258 descriptor:DepthwiseConvolution2dDescriptor;
259 weights:ConstTensor;
260 biases:ConstTensor;
261}
262
263table DepthwiseConvolution2dDescriptor {
264 padLeft:uint;
265 padRight:uint;
266 padTop:uint;
267 padBottom:uint;
268 strideX:uint;
269 strideY:uint;
270 biasEnabled:bool = false;
271 dataLayout:DataLayout = NCHW;
272}
273
Nattapat Chaimanowong969eea32019-01-30 13:33:11 +0000274table OutputLayer {
275 base:BindableLayerBase;
276}
277
Saoirse Stewart263829c2019-02-19 15:54:14 +0000278table ReshapeLayer {
279 base:LayerBase;
280 descriptor:ReshapeDescriptor;
281}
282
283table ReshapeDescriptor {
284 targetShape:[uint];
285}
286
Nattapat Chaimanowong30b00202019-02-20 17:31:34 +0000287table PermuteLayer {
288 base:LayerBase;
289 descriptor:PermuteDescriptor;
290}
291
292table PermuteDescriptor {
293 dimMappings:[uint];
294}
295
Nattapat Chaimanowong45286992019-02-26 15:53:02 +0000296table SpaceToBatchNdLayer {
297 base:LayerBase;
298 descriptor:SpaceToBatchNdDescriptor;
299}
300
301table SpaceToBatchNdDescriptor {
302 blockShape:[uint];
303 padList:[uint];
304 dataLayout:DataLayout;
305}
306
Conor Kennedyda1f9752019-03-01 14:37:12 +0000307table SubtractionLayer {
308 base:LayerBase;
309}
310
Nattapat Chaimanowong6b4ed982019-02-26 17:24:13 +0000311table BatchToSpaceNdLayer {
312 base:LayerBase;
313 descriptor:BatchToSpaceNdDescriptor;
314}
315
316table BatchToSpaceNdDescriptor {
317 blockShape:[uint];
318 crops:[uint];
319 dataLayout:DataLayout;
320}
321
Nina Drozd57728782019-02-27 10:53:27 +0000322enum NormalizationAlgorithmChannel : byte {
323 Across = 0,
324 Within = 1
325}
326
327enum NormalizationAlgorithmMethod : byte {
328 LocalBrightness = 0,
329 LocalContrast = 1
330}
331
332table NormalizationLayer {
333 base:LayerBase;
334 descriptor:NormalizationDescriptor;
335}
336
337table NormalizationDescriptor {
338 normChannelType:NormalizationAlgorithmChannel = Across;
339 normMethodType:NormalizationAlgorithmMethod = LocalBrightness;
340 normSize:uint;
341 alpha:float;
342 beta:float;
343 k:float;
344 dataLayout:DataLayout = NCHW;
345}
346
Nattapat Chaimanowongebb0f9c2019-03-01 12:14:06 +0000347table PadLayer {
348 base:LayerBase;
349 descriptor:PadDescriptor;
350}
351
352table PadDescriptor {
353 padList:[uint];
354}
355
Sadik Armagan8b42a382019-03-01 14:24:49 +0000356table RsqrtLayer {
357 base:LayerBase;
358}
359
ruoyan018e7fa232019-02-28 15:09:07 +0000360table BatchNormalizationLayer {
361 base:LayerBase;
362 descriptor:BatchNormalizationDescriptor;
363 mean:ConstTensor;
364 variance:ConstTensor;
365 beta:ConstTensor;
366 gamma:ConstTensor;
367}
368
369table BatchNormalizationDescriptor {
370 eps:float;
371 dataLayout:DataLayout;
372}
373
Nattapat Chaimanowong6522cdc2019-03-01 16:14:13 +0000374table ResizeBilinearLayer {
375 base:LayerBase;
376 descriptor:ResizeBilinearDescriptor;
377}
378
379table ResizeBilinearDescriptor {
380 targetWidth:uint;
381 targetHeight:uint;
382 dataLayout:DataLayout;
383}
384
Nattapat Chaimanowongb3485212019-03-04 12:35:39 +0000385table StridedSliceLayer {
386 base:LayerBase;
387 descriptor:StridedSliceDescriptor;
388}
389
390table StridedSliceDescriptor {
391 begin:[int];
392 end:[int];
393 stride:[int];
394 beginMask:int;
395 endMask:int;
396 shrinkAxisMask:int;
397 ellipsisMask:int;
398 newAxisMask:int;
399 dataLayout:DataLayout;
400}
401
Nattapat Chaimanowong969eea32019-01-30 13:33:11 +0000402union Layer {
Mike Kellyaf484012019-02-20 16:53:11 +0000403 ActivationLayer,
Nattapat Chaimanowong969eea32019-01-30 13:33:11 +0000404 AdditionLayer,
Nattapat Chaimanowong6b4ed982019-02-26 17:24:13 +0000405 BatchToSpaceNdLayer,
ruoyan018e7fa232019-02-28 15:09:07 +0000406 BatchNormalizationLayer,
Conor Kennedy76277882019-02-26 08:29:54 +0000407 ConstantLayer,
Mike Kellya0766c32019-02-19 17:22:07 +0000408 Convolution2dLayer,
Aron Virginas-Tarc04125f2019-02-19 16:31:08 +0000409 DepthwiseConvolution2dLayer,
Sadik Armagandbb0c0c2019-02-21 09:01:41 +0000410 FullyConnectedLayer,
Nattapat Chaimanowong969eea32019-01-30 13:33:11 +0000411 InputLayer,
Sadik Armagan5f450272019-02-12 14:31:45 +0000412 MultiplicationLayer,
Aron Virginas-Tarfc413c02019-02-13 15:41:52 +0000413 OutputLayer,
Nattapat Chaimanowong30b00202019-02-20 17:31:34 +0000414 PermuteLayer,
Saoirse Stewart3166c3e2019-02-18 15:24:53 +0000415 Pooling2dLayer,
Saoirse Stewart263829c2019-02-19 15:54:14 +0000416 ReshapeLayer,
Nattapat Chaimanowong45286992019-02-26 15:53:02 +0000417 SoftmaxLayer,
Éanna Ó Catháin58885892019-02-27 16:16:39 +0000418 SpaceToBatchNdLayer,
Aron Virginas-Tar0fe32452019-02-28 13:12:47 +0000419 DivisionLayer,
Nattapat Chaimanowong235cea52019-02-28 16:27:30 +0000420 MinimumLayer,
Aron Virginas-Tar377351e2019-02-27 14:42:31 +0000421 EqualLayer,
Nina Drozd57728782019-02-27 10:53:27 +0000422 MaximumLayer,
Nattapat Chaimanowongebb0f9c2019-03-01 12:14:06 +0000423 NormalizationLayer,
Sadik Armagan8b42a382019-03-01 14:24:49 +0000424 PadLayer,
Finn Williamsdd2ba7e2019-03-01 11:51:52 +0000425 RsqrtLayer,
Conor Kennedy79ffdf52019-03-01 14:24:54 +0000426 FloorLayer,
Nattapat Chaimanowong6522cdc2019-03-01 16:14:13 +0000427 GreaterLayer,
Conor Kennedyda1f9752019-03-01 14:37:12 +0000428 ResizeBilinearLayer,
Nattapat Chaimanowongb3485212019-03-04 12:35:39 +0000429 SubtractionLayer,
430 StridedSliceLayer
Nattapat Chaimanowong969eea32019-01-30 13:33:11 +0000431}
432
Saoirse Stewart49dbe0e2019-02-05 17:27:06 +0000433table AnyLayer {
434 layer:Layer;
435}
436
Nattapat Chaimanowong969eea32019-01-30 13:33:11 +0000437// Root type for serialized data is the graph of the network
438table SerializedGraph {
Saoirse Stewart49dbe0e2019-02-05 17:27:06 +0000439 layers:[AnyLayer];
Mike Kelly8c1701a2019-02-11 17:01:27 +0000440 inputIds:[uint];
441 outputIds:[uint];
Nattapat Chaimanowong969eea32019-01-30 13:33:11 +0000442}
443
444root_type SerializedGraph;