blob: dea588918625a7d7e66cd9b3695e211903486b22 [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,
109 ResizeBilinear = 25
Nattapat Chaimanowong969eea32019-01-30 13:33:11 +0000110}
111
112// Base layer table to be used as part of other layers
113table LayerBase {
114 index:uint;
115 layerName:string;
116 layerType:LayerType;
117 inputSlots:[InputSlot];
118 outputSlots:[OutputSlot];
119}
120
121table BindableLayerBase {
122 base:LayerBase;
123 layerBindingId:int;
124}
125
126// Table for each layer defined below
Mike Kellyaf484012019-02-20 16:53:11 +0000127table ActivationLayer {
128 base:LayerBase;
129 descriptor:ActivationDescriptor;
130}
131
132table ActivationDescriptor {
133 function:ActivationFunction = Sigmoid;
134 a:float;
135 b:float;
136}
137
Nattapat Chaimanowong969eea32019-01-30 13:33:11 +0000138table AdditionLayer {
139 base:LayerBase;
140}
141
Conor Kennedy76277882019-02-26 08:29:54 +0000142table ConstantLayer {
143 base:LayerBase;
144 input:ConstTensor;
145}
146
Mike Kellya0766c32019-02-19 17:22:07 +0000147table Convolution2dLayer {
148 base:LayerBase;
149 descriptor:Convolution2dDescriptor;
150 weights:ConstTensor;
151 biases:ConstTensor;
152}
153
154table Convolution2dDescriptor {
155 padLeft:uint;
156 padRight:uint;
157 padTop:uint;
158 padBottom:uint;
159 strideX:uint;
160 strideY:uint;
161 biasEnabled:bool = false;
162 dataLayout:DataLayout = NCHW;
163}
164
Éanna Ó Catháin58885892019-02-27 16:16:39 +0000165table DivisionLayer {
166 base:LayerBase;
167}
168
Nattapat Chaimanowong235cea52019-02-28 16:27:30 +0000169table EqualLayer {
170 base:LayerBase;
171}
172
Finn Williamsdd2ba7e2019-03-01 11:51:52 +0000173table FloorLayer{
174 base:LayerBase;
175}
176
Sadik Armagandbb0c0c2019-02-21 09:01:41 +0000177table FullyConnectedLayer {
178 base:LayerBase;
179 descriptor:FullyConnectedDescriptor;
180 weights:ConstTensor;
181 biases:ConstTensor;
182}
183
184table FullyConnectedDescriptor {
185 biasEnabled:bool = false;
186 transposeWeightsMatrix:bool = false;
187}
188
Conor Kennedy79ffdf52019-03-01 14:24:54 +0000189table GreaterLayer {
190 base:LayerBase;
191}
192
Nattapat Chaimanowong969eea32019-01-30 13:33:11 +0000193table InputLayer {
194 base:BindableLayerBase;
195}
196
Aron Virginas-Tar0fe32452019-02-28 13:12:47 +0000197table MinimumLayer {
198 base:LayerBase;
199}
200
Aron Virginas-Tar377351e2019-02-27 14:42:31 +0000201table MaximumLayer {
202 base:LayerBase;
203}
204
Sadik Armagan5f450272019-02-12 14:31:45 +0000205table MultiplicationLayer {
206 base:LayerBase;
207}
208
Saoirse Stewart3166c3e2019-02-18 15:24:53 +0000209table Pooling2dLayer {
210 base:LayerBase;
211 descriptor:Pooling2dDescriptor;
212}
213
214enum PoolingAlgorithm : byte {
215 Max = 0,
216 Average = 1,
217 L2 = 2
218}
219
220enum OutputShapeRounding : byte {
221 Floor = 0,
222 Ceiling = 1
223}
224
225enum PaddingMethod : byte {
226 IgnoreValue = 0,
227 Exclude = 1
228}
229
230table Pooling2dDescriptor {
231 poolType:PoolingAlgorithm;
232 padLeft:uint;
233 padRight:uint;
234 padTop:uint;
235 padBottom:uint;
236 poolWidth:uint;
237 poolHeight:uint;
238 strideX:uint;
239 strideY:uint;
240 outputShapeRounding:OutputShapeRounding;
241 paddingMethod:PaddingMethod;
242 dataLayout:DataLayout;
243}
244
Aron Virginas-Tarfc413c02019-02-13 15:41:52 +0000245table SoftmaxLayer {
246 base:LayerBase;
247 descriptor:SoftmaxDescriptor;
248}
249
250table SoftmaxDescriptor {
251 beta:float;
252}
253
Aron Virginas-Tarc04125f2019-02-19 16:31:08 +0000254table DepthwiseConvolution2dLayer {
255 base:LayerBase;
256 descriptor:DepthwiseConvolution2dDescriptor;
257 weights:ConstTensor;
258 biases:ConstTensor;
259}
260
261table DepthwiseConvolution2dDescriptor {
262 padLeft:uint;
263 padRight:uint;
264 padTop:uint;
265 padBottom:uint;
266 strideX:uint;
267 strideY:uint;
268 biasEnabled:bool = false;
269 dataLayout:DataLayout = NCHW;
270}
271
Nattapat Chaimanowong969eea32019-01-30 13:33:11 +0000272table OutputLayer {
273 base:BindableLayerBase;
274}
275
Saoirse Stewart263829c2019-02-19 15:54:14 +0000276table ReshapeLayer {
277 base:LayerBase;
278 descriptor:ReshapeDescriptor;
279}
280
281table ReshapeDescriptor {
282 targetShape:[uint];
283}
284
Nattapat Chaimanowong30b00202019-02-20 17:31:34 +0000285table PermuteLayer {
286 base:LayerBase;
287 descriptor:PermuteDescriptor;
288}
289
290table PermuteDescriptor {
291 dimMappings:[uint];
292}
293
Nattapat Chaimanowong45286992019-02-26 15:53:02 +0000294table SpaceToBatchNdLayer {
295 base:LayerBase;
296 descriptor:SpaceToBatchNdDescriptor;
297}
298
299table SpaceToBatchNdDescriptor {
300 blockShape:[uint];
301 padList:[uint];
302 dataLayout:DataLayout;
303}
304
Nattapat Chaimanowong6b4ed982019-02-26 17:24:13 +0000305table BatchToSpaceNdLayer {
306 base:LayerBase;
307 descriptor:BatchToSpaceNdDescriptor;
308}
309
310table BatchToSpaceNdDescriptor {
311 blockShape:[uint];
312 crops:[uint];
313 dataLayout:DataLayout;
314}
315
Nina Drozd57728782019-02-27 10:53:27 +0000316enum NormalizationAlgorithmChannel : byte {
317 Across = 0,
318 Within = 1
319}
320
321enum NormalizationAlgorithmMethod : byte {
322 LocalBrightness = 0,
323 LocalContrast = 1
324}
325
326table NormalizationLayer {
327 base:LayerBase;
328 descriptor:NormalizationDescriptor;
329}
330
331table NormalizationDescriptor {
332 normChannelType:NormalizationAlgorithmChannel = Across;
333 normMethodType:NormalizationAlgorithmMethod = LocalBrightness;
334 normSize:uint;
335 alpha:float;
336 beta:float;
337 k:float;
338 dataLayout:DataLayout = NCHW;
339}
340
Nattapat Chaimanowongebb0f9c2019-03-01 12:14:06 +0000341table PadLayer {
342 base:LayerBase;
343 descriptor:PadDescriptor;
344}
345
346table PadDescriptor {
347 padList:[uint];
348}
349
Sadik Armagan8b42a382019-03-01 14:24:49 +0000350table RsqrtLayer {
351 base:LayerBase;
352}
353
ruoyan018e7fa232019-02-28 15:09:07 +0000354table BatchNormalizationLayer {
355 base:LayerBase;
356 descriptor:BatchNormalizationDescriptor;
357 mean:ConstTensor;
358 variance:ConstTensor;
359 beta:ConstTensor;
360 gamma:ConstTensor;
361}
362
363table BatchNormalizationDescriptor {
364 eps:float;
365 dataLayout:DataLayout;
366}
367
Nattapat Chaimanowong6522cdc2019-03-01 16:14:13 +0000368table ResizeBilinearLayer {
369 base:LayerBase;
370 descriptor:ResizeBilinearDescriptor;
371}
372
373table ResizeBilinearDescriptor {
374 targetWidth:uint;
375 targetHeight:uint;
376 dataLayout:DataLayout;
377}
378
Nattapat Chaimanowong969eea32019-01-30 13:33:11 +0000379union Layer {
Mike Kellyaf484012019-02-20 16:53:11 +0000380 ActivationLayer,
Nattapat Chaimanowong969eea32019-01-30 13:33:11 +0000381 AdditionLayer,
Nattapat Chaimanowong6b4ed982019-02-26 17:24:13 +0000382 BatchToSpaceNdLayer,
ruoyan018e7fa232019-02-28 15:09:07 +0000383 BatchNormalizationLayer,
Conor Kennedy76277882019-02-26 08:29:54 +0000384 ConstantLayer,
Mike Kellya0766c32019-02-19 17:22:07 +0000385 Convolution2dLayer,
Aron Virginas-Tarc04125f2019-02-19 16:31:08 +0000386 DepthwiseConvolution2dLayer,
Sadik Armagandbb0c0c2019-02-21 09:01:41 +0000387 FullyConnectedLayer,
Nattapat Chaimanowong969eea32019-01-30 13:33:11 +0000388 InputLayer,
Sadik Armagan5f450272019-02-12 14:31:45 +0000389 MultiplicationLayer,
Aron Virginas-Tarfc413c02019-02-13 15:41:52 +0000390 OutputLayer,
Nattapat Chaimanowong30b00202019-02-20 17:31:34 +0000391 PermuteLayer,
Saoirse Stewart3166c3e2019-02-18 15:24:53 +0000392 Pooling2dLayer,
Saoirse Stewart263829c2019-02-19 15:54:14 +0000393 ReshapeLayer,
Nattapat Chaimanowong45286992019-02-26 15:53:02 +0000394 SoftmaxLayer,
Éanna Ó Catháin58885892019-02-27 16:16:39 +0000395 SpaceToBatchNdLayer,
Aron Virginas-Tar0fe32452019-02-28 13:12:47 +0000396 DivisionLayer,
Nattapat Chaimanowong235cea52019-02-28 16:27:30 +0000397 MinimumLayer,
Aron Virginas-Tar377351e2019-02-27 14:42:31 +0000398 EqualLayer,
Nina Drozd57728782019-02-27 10:53:27 +0000399 MaximumLayer,
Nattapat Chaimanowongebb0f9c2019-03-01 12:14:06 +0000400 NormalizationLayer,
Sadik Armagan8b42a382019-03-01 14:24:49 +0000401 PadLayer,
Finn Williamsdd2ba7e2019-03-01 11:51:52 +0000402 RsqrtLayer,
Conor Kennedy79ffdf52019-03-01 14:24:54 +0000403 FloorLayer,
Nattapat Chaimanowong6522cdc2019-03-01 16:14:13 +0000404 GreaterLayer,
405 ResizeBilinearLayer
Nattapat Chaimanowong969eea32019-01-30 13:33:11 +0000406}
407
Saoirse Stewart49dbe0e2019-02-05 17:27:06 +0000408table AnyLayer {
409 layer:Layer;
410}
411
Nattapat Chaimanowong969eea32019-01-30 13:33:11 +0000412// Root type for serialized data is the graph of the network
413table SerializedGraph {
Saoirse Stewart49dbe0e2019-02-05 17:27:06 +0000414 layers:[AnyLayer];
Mike Kelly8c1701a2019-02-11 17:01:27 +0000415 inputIds:[uint];
416 outputIds:[uint];
Nattapat Chaimanowong969eea32019-01-30 13:33:11 +0000417}
418
419root_type SerializedGraph;