blob: ac32e661c0140e77c439503f292ee84c6c1360a1 [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,
112 Gather = 28
Nattapat Chaimanowong969eea32019-01-30 13:33:11 +0000113}
114
115// Base layer table to be used as part of other layers
116table LayerBase {
117 index:uint;
118 layerName:string;
119 layerType:LayerType;
120 inputSlots:[InputSlot];
121 outputSlots:[OutputSlot];
122}
123
124table BindableLayerBase {
125 base:LayerBase;
126 layerBindingId:int;
127}
128
129// Table for each layer defined below
Mike Kellyaf484012019-02-20 16:53:11 +0000130table ActivationLayer {
131 base:LayerBase;
132 descriptor:ActivationDescriptor;
133}
134
135table ActivationDescriptor {
136 function:ActivationFunction = Sigmoid;
137 a:float;
138 b:float;
139}
140
Nattapat Chaimanowong969eea32019-01-30 13:33:11 +0000141table AdditionLayer {
142 base:LayerBase;
143}
144
Conor Kennedy76277882019-02-26 08:29:54 +0000145table ConstantLayer {
146 base:LayerBase;
147 input:ConstTensor;
148}
149
Mike Kellya0766c32019-02-19 17:22:07 +0000150table Convolution2dLayer {
151 base:LayerBase;
152 descriptor:Convolution2dDescriptor;
153 weights:ConstTensor;
154 biases:ConstTensor;
155}
156
157table Convolution2dDescriptor {
158 padLeft:uint;
159 padRight:uint;
160 padTop:uint;
161 padBottom:uint;
162 strideX:uint;
163 strideY:uint;
164 biasEnabled:bool = false;
165 dataLayout:DataLayout = NCHW;
166}
167
Éanna Ó Catháin58885892019-02-27 16:16:39 +0000168table DivisionLayer {
169 base:LayerBase;
170}
171
Nattapat Chaimanowong235cea52019-02-28 16:27:30 +0000172table EqualLayer {
173 base:LayerBase;
174}
175
Finn Williamsdd2ba7e2019-03-01 11:51:52 +0000176table FloorLayer{
177 base:LayerBase;
178}
179
Sadik Armagandbb0c0c2019-02-21 09:01:41 +0000180table FullyConnectedLayer {
181 base:LayerBase;
182 descriptor:FullyConnectedDescriptor;
183 weights:ConstTensor;
184 biases:ConstTensor;
185}
186
187table FullyConnectedDescriptor {
188 biasEnabled:bool = false;
189 transposeWeightsMatrix:bool = false;
190}
191
Saoirse Stewarta1ed73a2019-03-04 13:40:12 +0000192table GatherLayer {
193 base:LayerBase;
194}
195
Conor Kennedy79ffdf52019-03-01 14:24:54 +0000196table GreaterLayer {
197 base:LayerBase;
198}
199
Nattapat Chaimanowong969eea32019-01-30 13:33:11 +0000200table InputLayer {
201 base:BindableLayerBase;
202}
203
Aron Virginas-Tar0fe32452019-02-28 13:12:47 +0000204table MinimumLayer {
205 base:LayerBase;
206}
207
Aron Virginas-Tar377351e2019-02-27 14:42:31 +0000208table MaximumLayer {
209 base:LayerBase;
210}
211
Sadik Armagan5f450272019-02-12 14:31:45 +0000212table MultiplicationLayer {
213 base:LayerBase;
214}
215
Saoirse Stewart3166c3e2019-02-18 15:24:53 +0000216table Pooling2dLayer {
217 base:LayerBase;
218 descriptor:Pooling2dDescriptor;
219}
220
221enum PoolingAlgorithm : byte {
222 Max = 0,
223 Average = 1,
224 L2 = 2
225}
226
227enum OutputShapeRounding : byte {
228 Floor = 0,
229 Ceiling = 1
230}
231
232enum PaddingMethod : byte {
233 IgnoreValue = 0,
234 Exclude = 1
235}
236
237table Pooling2dDescriptor {
238 poolType:PoolingAlgorithm;
239 padLeft:uint;
240 padRight:uint;
241 padTop:uint;
242 padBottom:uint;
243 poolWidth:uint;
244 poolHeight:uint;
245 strideX:uint;
246 strideY:uint;
247 outputShapeRounding:OutputShapeRounding;
248 paddingMethod:PaddingMethod;
249 dataLayout:DataLayout;
250}
251
Aron Virginas-Tarfc413c02019-02-13 15:41:52 +0000252table SoftmaxLayer {
253 base:LayerBase;
254 descriptor:SoftmaxDescriptor;
255}
256
257table SoftmaxDescriptor {
258 beta:float;
259}
260
Aron Virginas-Tarc04125f2019-02-19 16:31:08 +0000261table DepthwiseConvolution2dLayer {
262 base:LayerBase;
263 descriptor:DepthwiseConvolution2dDescriptor;
264 weights:ConstTensor;
265 biases:ConstTensor;
266}
267
268table DepthwiseConvolution2dDescriptor {
269 padLeft:uint;
270 padRight:uint;
271 padTop:uint;
272 padBottom:uint;
273 strideX:uint;
274 strideY:uint;
275 biasEnabled:bool = false;
276 dataLayout:DataLayout = NCHW;
277}
278
Nattapat Chaimanowong969eea32019-01-30 13:33:11 +0000279table OutputLayer {
280 base:BindableLayerBase;
281}
282
Saoirse Stewart263829c2019-02-19 15:54:14 +0000283table ReshapeLayer {
284 base:LayerBase;
285 descriptor:ReshapeDescriptor;
286}
287
288table ReshapeDescriptor {
289 targetShape:[uint];
290}
291
Nattapat Chaimanowong30b00202019-02-20 17:31:34 +0000292table PermuteLayer {
293 base:LayerBase;
294 descriptor:PermuteDescriptor;
295}
296
297table PermuteDescriptor {
298 dimMappings:[uint];
299}
300
Nattapat Chaimanowong45286992019-02-26 15:53:02 +0000301table SpaceToBatchNdLayer {
302 base:LayerBase;
303 descriptor:SpaceToBatchNdDescriptor;
304}
305
306table SpaceToBatchNdDescriptor {
307 blockShape:[uint];
308 padList:[uint];
309 dataLayout:DataLayout;
310}
311
Conor Kennedyda1f9752019-03-01 14:37:12 +0000312table SubtractionLayer {
313 base:LayerBase;
314}
315
Nattapat Chaimanowong6b4ed982019-02-26 17:24:13 +0000316table BatchToSpaceNdLayer {
317 base:LayerBase;
318 descriptor:BatchToSpaceNdDescriptor;
319}
320
321table BatchToSpaceNdDescriptor {
322 blockShape:[uint];
323 crops:[uint];
324 dataLayout:DataLayout;
325}
326
Nina Drozd57728782019-02-27 10:53:27 +0000327enum NormalizationAlgorithmChannel : byte {
328 Across = 0,
329 Within = 1
330}
331
332enum NormalizationAlgorithmMethod : byte {
333 LocalBrightness = 0,
334 LocalContrast = 1
335}
336
337table NormalizationLayer {
338 base:LayerBase;
339 descriptor:NormalizationDescriptor;
340}
341
342table NormalizationDescriptor {
343 normChannelType:NormalizationAlgorithmChannel = Across;
344 normMethodType:NormalizationAlgorithmMethod = LocalBrightness;
345 normSize:uint;
346 alpha:float;
347 beta:float;
348 k:float;
349 dataLayout:DataLayout = NCHW;
350}
351
Nattapat Chaimanowongebb0f9c2019-03-01 12:14:06 +0000352table PadLayer {
353 base:LayerBase;
354 descriptor:PadDescriptor;
355}
356
357table PadDescriptor {
358 padList:[uint];
359}
360
Sadik Armagan8b42a382019-03-01 14:24:49 +0000361table RsqrtLayer {
362 base:LayerBase;
363}
364
ruoyan018e7fa232019-02-28 15:09:07 +0000365table BatchNormalizationLayer {
366 base:LayerBase;
367 descriptor:BatchNormalizationDescriptor;
368 mean:ConstTensor;
369 variance:ConstTensor;
370 beta:ConstTensor;
371 gamma:ConstTensor;
372}
373
374table BatchNormalizationDescriptor {
375 eps:float;
376 dataLayout:DataLayout;
377}
378
Nattapat Chaimanowong6522cdc2019-03-01 16:14:13 +0000379table ResizeBilinearLayer {
380 base:LayerBase;
381 descriptor:ResizeBilinearDescriptor;
382}
383
384table ResizeBilinearDescriptor {
385 targetWidth:uint;
386 targetHeight:uint;
387 dataLayout:DataLayout;
388}
389
Nattapat Chaimanowongb3485212019-03-04 12:35:39 +0000390table StridedSliceLayer {
391 base:LayerBase;
392 descriptor:StridedSliceDescriptor;
393}
394
395table StridedSliceDescriptor {
396 begin:[int];
397 end:[int];
398 stride:[int];
399 beginMask:int;
400 endMask:int;
401 shrinkAxisMask:int;
402 ellipsisMask:int;
403 newAxisMask:int;
404 dataLayout:DataLayout;
405}
406
Nattapat Chaimanowong969eea32019-01-30 13:33:11 +0000407union Layer {
Mike Kellyaf484012019-02-20 16:53:11 +0000408 ActivationLayer,
Nattapat Chaimanowong969eea32019-01-30 13:33:11 +0000409 AdditionLayer,
Nattapat Chaimanowong6b4ed982019-02-26 17:24:13 +0000410 BatchToSpaceNdLayer,
ruoyan018e7fa232019-02-28 15:09:07 +0000411 BatchNormalizationLayer,
Conor Kennedy76277882019-02-26 08:29:54 +0000412 ConstantLayer,
Mike Kellya0766c32019-02-19 17:22:07 +0000413 Convolution2dLayer,
Aron Virginas-Tarc04125f2019-02-19 16:31:08 +0000414 DepthwiseConvolution2dLayer,
Sadik Armagandbb0c0c2019-02-21 09:01:41 +0000415 FullyConnectedLayer,
Nattapat Chaimanowong969eea32019-01-30 13:33:11 +0000416 InputLayer,
Sadik Armagan5f450272019-02-12 14:31:45 +0000417 MultiplicationLayer,
Aron Virginas-Tarfc413c02019-02-13 15:41:52 +0000418 OutputLayer,
Nattapat Chaimanowong30b00202019-02-20 17:31:34 +0000419 PermuteLayer,
Saoirse Stewart3166c3e2019-02-18 15:24:53 +0000420 Pooling2dLayer,
Saoirse Stewart263829c2019-02-19 15:54:14 +0000421 ReshapeLayer,
Nattapat Chaimanowong45286992019-02-26 15:53:02 +0000422 SoftmaxLayer,
Éanna Ó Catháin58885892019-02-27 16:16:39 +0000423 SpaceToBatchNdLayer,
Aron Virginas-Tar0fe32452019-02-28 13:12:47 +0000424 DivisionLayer,
Nattapat Chaimanowong235cea52019-02-28 16:27:30 +0000425 MinimumLayer,
Aron Virginas-Tar377351e2019-02-27 14:42:31 +0000426 EqualLayer,
Nina Drozd57728782019-02-27 10:53:27 +0000427 MaximumLayer,
Nattapat Chaimanowongebb0f9c2019-03-01 12:14:06 +0000428 NormalizationLayer,
Sadik Armagan8b42a382019-03-01 14:24:49 +0000429 PadLayer,
Finn Williamsdd2ba7e2019-03-01 11:51:52 +0000430 RsqrtLayer,
Conor Kennedy79ffdf52019-03-01 14:24:54 +0000431 FloorLayer,
Nattapat Chaimanowong6522cdc2019-03-01 16:14:13 +0000432 GreaterLayer,
Conor Kennedyda1f9752019-03-01 14:37:12 +0000433 ResizeBilinearLayer,
Nattapat Chaimanowongb3485212019-03-04 12:35:39 +0000434 SubtractionLayer,
Saoirse Stewarta1ed73a2019-03-04 13:40:12 +0000435 StridedSliceLayer,
436 GatherLayer
Nattapat Chaimanowong969eea32019-01-30 13:33:11 +0000437}
438
Saoirse Stewart49dbe0e2019-02-05 17:27:06 +0000439table AnyLayer {
440 layer:Layer;
441}
442
Nattapat Chaimanowong969eea32019-01-30 13:33:11 +0000443// Root type for serialized data is the graph of the network
444table SerializedGraph {
Saoirse Stewart49dbe0e2019-02-05 17:27:06 +0000445 layers:[AnyLayer];
Mike Kelly8c1701a2019-02-11 17:01:27 +0000446 inputIds:[uint];
447 outputIds:[uint];
Nattapat Chaimanowong969eea32019-01-30 13:33:11 +0000448}
449
450root_type SerializedGraph;