blob: 9b23d8508c3e5bb2823c35960157692a1ef0c8e2 [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,
105 Rsqrt = 21
Nattapat Chaimanowong969eea32019-01-30 13:33:11 +0000106}
107
108// Base layer table to be used as part of other layers
109table LayerBase {
110 index:uint;
111 layerName:string;
112 layerType:LayerType;
113 inputSlots:[InputSlot];
114 outputSlots:[OutputSlot];
115}
116
117table BindableLayerBase {
118 base:LayerBase;
119 layerBindingId:int;
120}
121
122// Table for each layer defined below
Mike Kellyaf484012019-02-20 16:53:11 +0000123table ActivationLayer {
124 base:LayerBase;
125 descriptor:ActivationDescriptor;
126}
127
128table ActivationDescriptor {
129 function:ActivationFunction = Sigmoid;
130 a:float;
131 b:float;
132}
133
Nattapat Chaimanowong969eea32019-01-30 13:33:11 +0000134table AdditionLayer {
135 base:LayerBase;
136}
137
Conor Kennedy76277882019-02-26 08:29:54 +0000138table ConstantLayer {
139 base:LayerBase;
140 input:ConstTensor;
141}
142
Mike Kellya0766c32019-02-19 17:22:07 +0000143table Convolution2dLayer {
144 base:LayerBase;
145 descriptor:Convolution2dDescriptor;
146 weights:ConstTensor;
147 biases:ConstTensor;
148}
149
150table Convolution2dDescriptor {
151 padLeft:uint;
152 padRight:uint;
153 padTop:uint;
154 padBottom:uint;
155 strideX:uint;
156 strideY:uint;
157 biasEnabled:bool = false;
158 dataLayout:DataLayout = NCHW;
159}
160
Éanna Ó Catháin58885892019-02-27 16:16:39 +0000161table DivisionLayer {
162 base:LayerBase;
163}
164
Nattapat Chaimanowong235cea52019-02-28 16:27:30 +0000165table EqualLayer {
166 base:LayerBase;
167}
168
Sadik Armagandbb0c0c2019-02-21 09:01:41 +0000169table FullyConnectedLayer {
170 base:LayerBase;
171 descriptor:FullyConnectedDescriptor;
172 weights:ConstTensor;
173 biases:ConstTensor;
174}
175
176table FullyConnectedDescriptor {
177 biasEnabled:bool = false;
178 transposeWeightsMatrix:bool = false;
179}
180
Nattapat Chaimanowong969eea32019-01-30 13:33:11 +0000181table InputLayer {
182 base:BindableLayerBase;
183}
184
Aron Virginas-Tar0fe32452019-02-28 13:12:47 +0000185table MinimumLayer {
186 base:LayerBase;
187}
188
Aron Virginas-Tar377351e2019-02-27 14:42:31 +0000189table MaximumLayer {
190 base:LayerBase;
191}
192
Sadik Armagan5f450272019-02-12 14:31:45 +0000193table MultiplicationLayer {
194 base:LayerBase;
195}
196
Saoirse Stewart3166c3e2019-02-18 15:24:53 +0000197table Pooling2dLayer {
198 base:LayerBase;
199 descriptor:Pooling2dDescriptor;
200}
201
202enum PoolingAlgorithm : byte {
203 Max = 0,
204 Average = 1,
205 L2 = 2
206}
207
208enum OutputShapeRounding : byte {
209 Floor = 0,
210 Ceiling = 1
211}
212
213enum PaddingMethod : byte {
214 IgnoreValue = 0,
215 Exclude = 1
216}
217
218table Pooling2dDescriptor {
219 poolType:PoolingAlgorithm;
220 padLeft:uint;
221 padRight:uint;
222 padTop:uint;
223 padBottom:uint;
224 poolWidth:uint;
225 poolHeight:uint;
226 strideX:uint;
227 strideY:uint;
228 outputShapeRounding:OutputShapeRounding;
229 paddingMethod:PaddingMethod;
230 dataLayout:DataLayout;
231}
232
Aron Virginas-Tarfc413c02019-02-13 15:41:52 +0000233table SoftmaxLayer {
234 base:LayerBase;
235 descriptor:SoftmaxDescriptor;
236}
237
238table SoftmaxDescriptor {
239 beta:float;
240}
241
Aron Virginas-Tarc04125f2019-02-19 16:31:08 +0000242table DepthwiseConvolution2dLayer {
243 base:LayerBase;
244 descriptor:DepthwiseConvolution2dDescriptor;
245 weights:ConstTensor;
246 biases:ConstTensor;
247}
248
249table DepthwiseConvolution2dDescriptor {
250 padLeft:uint;
251 padRight:uint;
252 padTop:uint;
253 padBottom:uint;
254 strideX:uint;
255 strideY:uint;
256 biasEnabled:bool = false;
257 dataLayout:DataLayout = NCHW;
258}
259
Nattapat Chaimanowong969eea32019-01-30 13:33:11 +0000260table OutputLayer {
261 base:BindableLayerBase;
262}
263
Saoirse Stewart263829c2019-02-19 15:54:14 +0000264table ReshapeLayer {
265 base:LayerBase;
266 descriptor:ReshapeDescriptor;
267}
268
269table ReshapeDescriptor {
270 targetShape:[uint];
271}
272
Nattapat Chaimanowong30b00202019-02-20 17:31:34 +0000273table PermuteLayer {
274 base:LayerBase;
275 descriptor:PermuteDescriptor;
276}
277
278table PermuteDescriptor {
279 dimMappings:[uint];
280}
281
Nattapat Chaimanowong45286992019-02-26 15:53:02 +0000282table SpaceToBatchNdLayer {
283 base:LayerBase;
284 descriptor:SpaceToBatchNdDescriptor;
285}
286
287table SpaceToBatchNdDescriptor {
288 blockShape:[uint];
289 padList:[uint];
290 dataLayout:DataLayout;
291}
292
Nattapat Chaimanowong6b4ed982019-02-26 17:24:13 +0000293table BatchToSpaceNdLayer {
294 base:LayerBase;
295 descriptor:BatchToSpaceNdDescriptor;
296}
297
298table BatchToSpaceNdDescriptor {
299 blockShape:[uint];
300 crops:[uint];
301 dataLayout:DataLayout;
302}
303
Nina Drozd57728782019-02-27 10:53:27 +0000304enum NormalizationAlgorithmChannel : byte {
305 Across = 0,
306 Within = 1
307}
308
309enum NormalizationAlgorithmMethod : byte {
310 LocalBrightness = 0,
311 LocalContrast = 1
312}
313
314table NormalizationLayer {
315 base:LayerBase;
316 descriptor:NormalizationDescriptor;
317}
318
319table NormalizationDescriptor {
320 normChannelType:NormalizationAlgorithmChannel = Across;
321 normMethodType:NormalizationAlgorithmMethod = LocalBrightness;
322 normSize:uint;
323 alpha:float;
324 beta:float;
325 k:float;
326 dataLayout:DataLayout = NCHW;
327}
328
Nattapat Chaimanowongebb0f9c2019-03-01 12:14:06 +0000329table PadLayer {
330 base:LayerBase;
331 descriptor:PadDescriptor;
332}
333
334table PadDescriptor {
335 padList:[uint];
336}
337
Sadik Armagan8b42a382019-03-01 14:24:49 +0000338table RsqrtLayer {
339 base:LayerBase;
340}
341
Nattapat Chaimanowong969eea32019-01-30 13:33:11 +0000342union Layer {
Mike Kellyaf484012019-02-20 16:53:11 +0000343 ActivationLayer,
Nattapat Chaimanowong969eea32019-01-30 13:33:11 +0000344 AdditionLayer,
Nattapat Chaimanowong6b4ed982019-02-26 17:24:13 +0000345 BatchToSpaceNdLayer,
Conor Kennedy76277882019-02-26 08:29:54 +0000346 ConstantLayer,
Mike Kellya0766c32019-02-19 17:22:07 +0000347 Convolution2dLayer,
Aron Virginas-Tarc04125f2019-02-19 16:31:08 +0000348 DepthwiseConvolution2dLayer,
Sadik Armagandbb0c0c2019-02-21 09:01:41 +0000349 FullyConnectedLayer,
Nattapat Chaimanowong969eea32019-01-30 13:33:11 +0000350 InputLayer,
Sadik Armagan5f450272019-02-12 14:31:45 +0000351 MultiplicationLayer,
Aron Virginas-Tarfc413c02019-02-13 15:41:52 +0000352 OutputLayer,
Nattapat Chaimanowong30b00202019-02-20 17:31:34 +0000353 PermuteLayer,
Saoirse Stewart3166c3e2019-02-18 15:24:53 +0000354 Pooling2dLayer,
Saoirse Stewart263829c2019-02-19 15:54:14 +0000355 ReshapeLayer,
Nattapat Chaimanowong45286992019-02-26 15:53:02 +0000356 SoftmaxLayer,
Éanna Ó Catháin58885892019-02-27 16:16:39 +0000357 SpaceToBatchNdLayer,
Aron Virginas-Tar0fe32452019-02-28 13:12:47 +0000358 DivisionLayer,
Nattapat Chaimanowong235cea52019-02-28 16:27:30 +0000359 MinimumLayer,
Aron Virginas-Tar377351e2019-02-27 14:42:31 +0000360 EqualLayer,
Nina Drozd57728782019-02-27 10:53:27 +0000361 MaximumLayer,
Nattapat Chaimanowongebb0f9c2019-03-01 12:14:06 +0000362 NormalizationLayer,
Sadik Armagan8b42a382019-03-01 14:24:49 +0000363 PadLayer,
364 RsqrtLayer
Nattapat Chaimanowong969eea32019-01-30 13:33:11 +0000365}
366
Saoirse Stewart49dbe0e2019-02-05 17:27:06 +0000367table AnyLayer {
368 layer:Layer;
369}
370
Nattapat Chaimanowong969eea32019-01-30 13:33:11 +0000371// Root type for serialized data is the graph of the network
372table SerializedGraph {
Saoirse Stewart49dbe0e2019-02-05 17:27:06 +0000373 layers:[AnyLayer];
Mike Kelly8c1701a2019-02-11 17:01:27 +0000374 inputIds:[uint];
375 outputIds:[uint];
Nattapat Chaimanowong969eea32019-01-30 13:33:11 +0000376}
377
378root_type SerializedGraph;