blob: a5fb4b66973ad57dfdfcfb6691cd37b486e3c6d9 [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,
114 Merger = 30
Nattapat Chaimanowong969eea32019-01-30 13:33:11 +0000115}
116
117// Base layer table to be used as part of other layers
118table LayerBase {
119 index:uint;
120 layerName:string;
121 layerType:LayerType;
122 inputSlots:[InputSlot];
123 outputSlots:[OutputSlot];
124}
125
126table BindableLayerBase {
127 base:LayerBase;
128 layerBindingId:int;
129}
130
131// Table for each layer defined below
Mike Kellyaf484012019-02-20 16:53:11 +0000132table ActivationLayer {
133 base:LayerBase;
134 descriptor:ActivationDescriptor;
135}
136
137table ActivationDescriptor {
138 function:ActivationFunction = Sigmoid;
139 a:float;
140 b:float;
141}
142
Nattapat Chaimanowong969eea32019-01-30 13:33:11 +0000143table AdditionLayer {
144 base:LayerBase;
145}
146
Conor Kennedy76277882019-02-26 08:29:54 +0000147table ConstantLayer {
148 base:LayerBase;
149 input:ConstTensor;
150}
151
Mike Kellya0766c32019-02-19 17:22:07 +0000152table Convolution2dLayer {
153 base:LayerBase;
154 descriptor:Convolution2dDescriptor;
155 weights:ConstTensor;
156 biases:ConstTensor;
157}
158
159table Convolution2dDescriptor {
160 padLeft:uint;
161 padRight:uint;
162 padTop:uint;
163 padBottom:uint;
164 strideX:uint;
165 strideY:uint;
166 biasEnabled:bool = false;
167 dataLayout:DataLayout = NCHW;
168}
169
Éanna Ó Catháin58885892019-02-27 16:16:39 +0000170table DivisionLayer {
171 base:LayerBase;
172}
173
Nattapat Chaimanowong235cea52019-02-28 16:27:30 +0000174table EqualLayer {
175 base:LayerBase;
176}
177
Finn Williamsdd2ba7e2019-03-01 11:51:52 +0000178table FloorLayer{
179 base:LayerBase;
180}
181
Sadik Armagandbb0c0c2019-02-21 09:01:41 +0000182table FullyConnectedLayer {
183 base:LayerBase;
184 descriptor:FullyConnectedDescriptor;
185 weights:ConstTensor;
186 biases:ConstTensor;
187}
188
189table FullyConnectedDescriptor {
190 biasEnabled:bool = false;
191 transposeWeightsMatrix:bool = false;
192}
193
Saoirse Stewarta1ed73a2019-03-04 13:40:12 +0000194table GatherLayer {
195 base:LayerBase;
196}
197
Conor Kennedy79ffdf52019-03-01 14:24:54 +0000198table GreaterLayer {
199 base:LayerBase;
200}
201
Nattapat Chaimanowong969eea32019-01-30 13:33:11 +0000202table InputLayer {
203 base:BindableLayerBase;
204}
205
Aron Virginas-Tar0fe32452019-02-28 13:12:47 +0000206table MinimumLayer {
207 base:LayerBase;
208}
209
Aron Virginas-Tar377351e2019-02-27 14:42:31 +0000210table MaximumLayer {
211 base:LayerBase;
212}
213
Sadik Armagan5f450272019-02-12 14:31:45 +0000214table MultiplicationLayer {
215 base:LayerBase;
216}
217
Saoirse Stewart3166c3e2019-02-18 15:24:53 +0000218table Pooling2dLayer {
219 base:LayerBase;
220 descriptor:Pooling2dDescriptor;
221}
222
223enum PoolingAlgorithm : byte {
224 Max = 0,
225 Average = 1,
226 L2 = 2
227}
228
229enum OutputShapeRounding : byte {
230 Floor = 0,
231 Ceiling = 1
232}
233
234enum PaddingMethod : byte {
235 IgnoreValue = 0,
236 Exclude = 1
237}
238
239table Pooling2dDescriptor {
240 poolType:PoolingAlgorithm;
241 padLeft:uint;
242 padRight:uint;
243 padTop:uint;
244 padBottom:uint;
245 poolWidth:uint;
246 poolHeight:uint;
247 strideX:uint;
248 strideY:uint;
249 outputShapeRounding:OutputShapeRounding;
250 paddingMethod:PaddingMethod;
251 dataLayout:DataLayout;
252}
253
Aron Virginas-Tarfc413c02019-02-13 15:41:52 +0000254table SoftmaxLayer {
255 base:LayerBase;
256 descriptor:SoftmaxDescriptor;
257}
258
259table SoftmaxDescriptor {
260 beta:float;
261}
262
Aron Virginas-Tarc04125f2019-02-19 16:31:08 +0000263table DepthwiseConvolution2dLayer {
264 base:LayerBase;
265 descriptor:DepthwiseConvolution2dDescriptor;
266 weights:ConstTensor;
267 biases:ConstTensor;
268}
269
270table DepthwiseConvolution2dDescriptor {
271 padLeft:uint;
272 padRight:uint;
273 padTop:uint;
274 padBottom:uint;
275 strideX:uint;
276 strideY:uint;
277 biasEnabled:bool = false;
278 dataLayout:DataLayout = NCHW;
279}
280
Nattapat Chaimanowong969eea32019-01-30 13:33:11 +0000281table OutputLayer {
282 base:BindableLayerBase;
283}
284
Saoirse Stewart263829c2019-02-19 15:54:14 +0000285table ReshapeLayer {
286 base:LayerBase;
287 descriptor:ReshapeDescriptor;
288}
289
290table ReshapeDescriptor {
291 targetShape:[uint];
292}
293
Nattapat Chaimanowong30b00202019-02-20 17:31:34 +0000294table PermuteLayer {
295 base:LayerBase;
296 descriptor:PermuteDescriptor;
297}
298
299table PermuteDescriptor {
300 dimMappings:[uint];
301}
302
Nattapat Chaimanowong45286992019-02-26 15:53:02 +0000303table SpaceToBatchNdLayer {
304 base:LayerBase;
305 descriptor:SpaceToBatchNdDescriptor;
306}
307
308table SpaceToBatchNdDescriptor {
309 blockShape:[uint];
310 padList:[uint];
311 dataLayout:DataLayout;
312}
313
Conor Kennedyda1f9752019-03-01 14:37:12 +0000314table SubtractionLayer {
315 base:LayerBase;
316}
317
Nattapat Chaimanowong6b4ed982019-02-26 17:24:13 +0000318table BatchToSpaceNdLayer {
319 base:LayerBase;
320 descriptor:BatchToSpaceNdDescriptor;
321}
322
323table BatchToSpaceNdDescriptor {
324 blockShape:[uint];
325 crops:[uint];
326 dataLayout:DataLayout;
327}
328
Nina Drozd57728782019-02-27 10:53:27 +0000329enum NormalizationAlgorithmChannel : byte {
330 Across = 0,
331 Within = 1
332}
333
334enum NormalizationAlgorithmMethod : byte {
335 LocalBrightness = 0,
336 LocalContrast = 1
337}
338
339table NormalizationLayer {
340 base:LayerBase;
341 descriptor:NormalizationDescriptor;
342}
343
344table NormalizationDescriptor {
345 normChannelType:NormalizationAlgorithmChannel = Across;
346 normMethodType:NormalizationAlgorithmMethod = LocalBrightness;
347 normSize:uint;
348 alpha:float;
349 beta:float;
350 k:float;
351 dataLayout:DataLayout = NCHW;
352}
353
Sadik Armaganac97c8c2019-03-04 17:44:21 +0000354table MeanLayer {
355 base:LayerBase;
356 descriptor:MeanDescriptor;
357}
358
359table MeanDescriptor {
360 axis:[uint];
361 keepDims:bool = false;
362}
363
Nattapat Chaimanowongebb0f9c2019-03-01 12:14:06 +0000364table PadLayer {
365 base:LayerBase;
366 descriptor:PadDescriptor;
367}
368
369table PadDescriptor {
370 padList:[uint];
371}
372
Sadik Armagan8b42a382019-03-01 14:24:49 +0000373table RsqrtLayer {
374 base:LayerBase;
375}
376
ruoyan018e7fa232019-02-28 15:09:07 +0000377table BatchNormalizationLayer {
378 base:LayerBase;
379 descriptor:BatchNormalizationDescriptor;
380 mean:ConstTensor;
381 variance:ConstTensor;
382 beta:ConstTensor;
383 gamma:ConstTensor;
384}
385
386table BatchNormalizationDescriptor {
387 eps:float;
388 dataLayout:DataLayout;
389}
390
Nattapat Chaimanowong6522cdc2019-03-01 16:14:13 +0000391table ResizeBilinearLayer {
392 base:LayerBase;
393 descriptor:ResizeBilinearDescriptor;
394}
395
396table ResizeBilinearDescriptor {
397 targetWidth:uint;
398 targetHeight:uint;
399 dataLayout:DataLayout;
400}
401
Nattapat Chaimanowongb3485212019-03-04 12:35:39 +0000402table StridedSliceLayer {
403 base:LayerBase;
404 descriptor:StridedSliceDescriptor;
405}
406
407table StridedSliceDescriptor {
408 begin:[int];
409 end:[int];
410 stride:[int];
411 beginMask:int;
412 endMask:int;
413 shrinkAxisMask:int;
414 ellipsisMask:int;
415 newAxisMask:int;
416 dataLayout:DataLayout;
417}
418
Jim Flynnac25a1b2019-02-28 10:40:49 +0000419table MergerLayer {
420 base:LayerBase;
421 descriptor:OriginsDescriptor;
422}
423
424table UintVector {
425 data:[uint];
426}
427
428table OriginsDescriptor {
429 concatAxis:uint;
430 numViews:uint;
431 numDimensions:uint;
432 viewOrigins:[UintVector];
433}
434
Nattapat Chaimanowong969eea32019-01-30 13:33:11 +0000435union Layer {
Mike Kellyaf484012019-02-20 16:53:11 +0000436 ActivationLayer,
Nattapat Chaimanowong969eea32019-01-30 13:33:11 +0000437 AdditionLayer,
Nattapat Chaimanowong6b4ed982019-02-26 17:24:13 +0000438 BatchToSpaceNdLayer,
ruoyan018e7fa232019-02-28 15:09:07 +0000439 BatchNormalizationLayer,
Conor Kennedy76277882019-02-26 08:29:54 +0000440 ConstantLayer,
Mike Kellya0766c32019-02-19 17:22:07 +0000441 Convolution2dLayer,
Aron Virginas-Tarc04125f2019-02-19 16:31:08 +0000442 DepthwiseConvolution2dLayer,
Sadik Armagandbb0c0c2019-02-21 09:01:41 +0000443 FullyConnectedLayer,
Nattapat Chaimanowong969eea32019-01-30 13:33:11 +0000444 InputLayer,
Sadik Armagan5f450272019-02-12 14:31:45 +0000445 MultiplicationLayer,
Aron Virginas-Tarfc413c02019-02-13 15:41:52 +0000446 OutputLayer,
Nattapat Chaimanowong30b00202019-02-20 17:31:34 +0000447 PermuteLayer,
Saoirse Stewart3166c3e2019-02-18 15:24:53 +0000448 Pooling2dLayer,
Saoirse Stewart263829c2019-02-19 15:54:14 +0000449 ReshapeLayer,
Nattapat Chaimanowong45286992019-02-26 15:53:02 +0000450 SoftmaxLayer,
Éanna Ó Catháin58885892019-02-27 16:16:39 +0000451 SpaceToBatchNdLayer,
Aron Virginas-Tar0fe32452019-02-28 13:12:47 +0000452 DivisionLayer,
Nattapat Chaimanowong235cea52019-02-28 16:27:30 +0000453 MinimumLayer,
Aron Virginas-Tar377351e2019-02-27 14:42:31 +0000454 EqualLayer,
Nina Drozd57728782019-02-27 10:53:27 +0000455 MaximumLayer,
Nattapat Chaimanowongebb0f9c2019-03-01 12:14:06 +0000456 NormalizationLayer,
Sadik Armagan8b42a382019-03-01 14:24:49 +0000457 PadLayer,
Finn Williamsdd2ba7e2019-03-01 11:51:52 +0000458 RsqrtLayer,
Conor Kennedy79ffdf52019-03-01 14:24:54 +0000459 FloorLayer,
Nattapat Chaimanowong6522cdc2019-03-01 16:14:13 +0000460 GreaterLayer,
Conor Kennedyda1f9752019-03-01 14:37:12 +0000461 ResizeBilinearLayer,
Nattapat Chaimanowongb3485212019-03-04 12:35:39 +0000462 SubtractionLayer,
Saoirse Stewarta1ed73a2019-03-04 13:40:12 +0000463 StridedSliceLayer,
Sadik Armaganac97c8c2019-03-04 17:44:21 +0000464 GatherLayer,
Jim Flynnac25a1b2019-02-28 10:40:49 +0000465 MeanLayer,
466 MergerLayer
Nattapat Chaimanowong969eea32019-01-30 13:33:11 +0000467}
468
Saoirse Stewart49dbe0e2019-02-05 17:27:06 +0000469table AnyLayer {
470 layer:Layer;
471}
472
Nattapat Chaimanowong969eea32019-01-30 13:33:11 +0000473// Root type for serialized data is the graph of the network
474table SerializedGraph {
Saoirse Stewart49dbe0e2019-02-05 17:27:06 +0000475 layers:[AnyLayer];
Mike Kelly8c1701a2019-02-11 17:01:27 +0000476 inputIds:[uint];
477 outputIds:[uint];
Nattapat Chaimanowong969eea32019-01-30 13:33:11 +0000478}
479
480root_type SerializedGraph;