blob: 552c2cc056545f81a73ce6f55f25b6284bc86fde [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,
104 Pad = 20
Nattapat Chaimanowong969eea32019-01-30 13:33:11 +0000105}
106
107// Base layer table to be used as part of other layers
108table LayerBase {
109 index:uint;
110 layerName:string;
111 layerType:LayerType;
112 inputSlots:[InputSlot];
113 outputSlots:[OutputSlot];
114}
115
116table BindableLayerBase {
117 base:LayerBase;
118 layerBindingId:int;
119}
120
121// Table for each layer defined below
Mike Kellyaf484012019-02-20 16:53:11 +0000122table ActivationLayer {
123 base:LayerBase;
124 descriptor:ActivationDescriptor;
125}
126
127table ActivationDescriptor {
128 function:ActivationFunction = Sigmoid;
129 a:float;
130 b:float;
131}
132
Nattapat Chaimanowong969eea32019-01-30 13:33:11 +0000133table AdditionLayer {
134 base:LayerBase;
135}
136
Conor Kennedy76277882019-02-26 08:29:54 +0000137table ConstantLayer {
138 base:LayerBase;
139 input:ConstTensor;
140}
141
Mike Kellya0766c32019-02-19 17:22:07 +0000142table Convolution2dLayer {
143 base:LayerBase;
144 descriptor:Convolution2dDescriptor;
145 weights:ConstTensor;
146 biases:ConstTensor;
147}
148
149table Convolution2dDescriptor {
150 padLeft:uint;
151 padRight:uint;
152 padTop:uint;
153 padBottom:uint;
154 strideX:uint;
155 strideY:uint;
156 biasEnabled:bool = false;
157 dataLayout:DataLayout = NCHW;
158}
159
Éanna Ó Catháin58885892019-02-27 16:16:39 +0000160table DivisionLayer {
161 base:LayerBase;
162}
163
Nattapat Chaimanowong235cea52019-02-28 16:27:30 +0000164table EqualLayer {
165 base:LayerBase;
166}
167
Sadik Armagandbb0c0c2019-02-21 09:01:41 +0000168table FullyConnectedLayer {
169 base:LayerBase;
170 descriptor:FullyConnectedDescriptor;
171 weights:ConstTensor;
172 biases:ConstTensor;
173}
174
175table FullyConnectedDescriptor {
176 biasEnabled:bool = false;
177 transposeWeightsMatrix:bool = false;
178}
179
Nattapat Chaimanowong969eea32019-01-30 13:33:11 +0000180table InputLayer {
181 base:BindableLayerBase;
182}
183
Aron Virginas-Tar0fe32452019-02-28 13:12:47 +0000184table MinimumLayer {
185 base:LayerBase;
186}
187
Aron Virginas-Tar377351e2019-02-27 14:42:31 +0000188table MaximumLayer {
189 base:LayerBase;
190}
191
Sadik Armagan5f450272019-02-12 14:31:45 +0000192table MultiplicationLayer {
193 base:LayerBase;
194}
195
Saoirse Stewart3166c3e2019-02-18 15:24:53 +0000196table Pooling2dLayer {
197 base:LayerBase;
198 descriptor:Pooling2dDescriptor;
199}
200
201enum PoolingAlgorithm : byte {
202 Max = 0,
203 Average = 1,
204 L2 = 2
205}
206
207enum OutputShapeRounding : byte {
208 Floor = 0,
209 Ceiling = 1
210}
211
212enum PaddingMethod : byte {
213 IgnoreValue = 0,
214 Exclude = 1
215}
216
217table Pooling2dDescriptor {
218 poolType:PoolingAlgorithm;
219 padLeft:uint;
220 padRight:uint;
221 padTop:uint;
222 padBottom:uint;
223 poolWidth:uint;
224 poolHeight:uint;
225 strideX:uint;
226 strideY:uint;
227 outputShapeRounding:OutputShapeRounding;
228 paddingMethod:PaddingMethod;
229 dataLayout:DataLayout;
230}
231
Aron Virginas-Tarfc413c02019-02-13 15:41:52 +0000232table SoftmaxLayer {
233 base:LayerBase;
234 descriptor:SoftmaxDescriptor;
235}
236
237table SoftmaxDescriptor {
238 beta:float;
239}
240
Aron Virginas-Tarc04125f2019-02-19 16:31:08 +0000241table DepthwiseConvolution2dLayer {
242 base:LayerBase;
243 descriptor:DepthwiseConvolution2dDescriptor;
244 weights:ConstTensor;
245 biases:ConstTensor;
246}
247
248table DepthwiseConvolution2dDescriptor {
249 padLeft:uint;
250 padRight:uint;
251 padTop:uint;
252 padBottom:uint;
253 strideX:uint;
254 strideY:uint;
255 biasEnabled:bool = false;
256 dataLayout:DataLayout = NCHW;
257}
258
Nattapat Chaimanowong969eea32019-01-30 13:33:11 +0000259table OutputLayer {
260 base:BindableLayerBase;
261}
262
Saoirse Stewart263829c2019-02-19 15:54:14 +0000263table ReshapeLayer {
264 base:LayerBase;
265 descriptor:ReshapeDescriptor;
266}
267
268table ReshapeDescriptor {
269 targetShape:[uint];
270}
271
Nattapat Chaimanowong30b00202019-02-20 17:31:34 +0000272table PermuteLayer {
273 base:LayerBase;
274 descriptor:PermuteDescriptor;
275}
276
277table PermuteDescriptor {
278 dimMappings:[uint];
279}
280
Nattapat Chaimanowong45286992019-02-26 15:53:02 +0000281table SpaceToBatchNdLayer {
282 base:LayerBase;
283 descriptor:SpaceToBatchNdDescriptor;
284}
285
286table SpaceToBatchNdDescriptor {
287 blockShape:[uint];
288 padList:[uint];
289 dataLayout:DataLayout;
290}
291
Nattapat Chaimanowong6b4ed982019-02-26 17:24:13 +0000292table BatchToSpaceNdLayer {
293 base:LayerBase;
294 descriptor:BatchToSpaceNdDescriptor;
295}
296
297table BatchToSpaceNdDescriptor {
298 blockShape:[uint];
299 crops:[uint];
300 dataLayout:DataLayout;
301}
302
Nina Drozd57728782019-02-27 10:53:27 +0000303enum NormalizationAlgorithmChannel : byte {
304 Across = 0,
305 Within = 1
306}
307
308enum NormalizationAlgorithmMethod : byte {
309 LocalBrightness = 0,
310 LocalContrast = 1
311}
312
313table NormalizationLayer {
314 base:LayerBase;
315 descriptor:NormalizationDescriptor;
316}
317
318table NormalizationDescriptor {
319 normChannelType:NormalizationAlgorithmChannel = Across;
320 normMethodType:NormalizationAlgorithmMethod = LocalBrightness;
321 normSize:uint;
322 alpha:float;
323 beta:float;
324 k:float;
325 dataLayout:DataLayout = NCHW;
326}
327
Nattapat Chaimanowongebb0f9c2019-03-01 12:14:06 +0000328table PadLayer {
329 base:LayerBase;
330 descriptor:PadDescriptor;
331}
332
333table PadDescriptor {
334 padList:[uint];
335}
336
Nattapat Chaimanowong969eea32019-01-30 13:33:11 +0000337union Layer {
Mike Kellyaf484012019-02-20 16:53:11 +0000338 ActivationLayer,
Nattapat Chaimanowong969eea32019-01-30 13:33:11 +0000339 AdditionLayer,
Nattapat Chaimanowong6b4ed982019-02-26 17:24:13 +0000340 BatchToSpaceNdLayer,
Conor Kennedy76277882019-02-26 08:29:54 +0000341 ConstantLayer,
Mike Kellya0766c32019-02-19 17:22:07 +0000342 Convolution2dLayer,
Aron Virginas-Tarc04125f2019-02-19 16:31:08 +0000343 DepthwiseConvolution2dLayer,
Sadik Armagandbb0c0c2019-02-21 09:01:41 +0000344 FullyConnectedLayer,
Nattapat Chaimanowong969eea32019-01-30 13:33:11 +0000345 InputLayer,
Sadik Armagan5f450272019-02-12 14:31:45 +0000346 MultiplicationLayer,
Aron Virginas-Tarfc413c02019-02-13 15:41:52 +0000347 OutputLayer,
Nattapat Chaimanowong30b00202019-02-20 17:31:34 +0000348 PermuteLayer,
Saoirse Stewart3166c3e2019-02-18 15:24:53 +0000349 Pooling2dLayer,
Saoirse Stewart263829c2019-02-19 15:54:14 +0000350 ReshapeLayer,
Nattapat Chaimanowong45286992019-02-26 15:53:02 +0000351 SoftmaxLayer,
Éanna Ó Catháin58885892019-02-27 16:16:39 +0000352 SpaceToBatchNdLayer,
Aron Virginas-Tar0fe32452019-02-28 13:12:47 +0000353 DivisionLayer,
Nattapat Chaimanowong235cea52019-02-28 16:27:30 +0000354 MinimumLayer,
Aron Virginas-Tar377351e2019-02-27 14:42:31 +0000355 EqualLayer,
Nina Drozd57728782019-02-27 10:53:27 +0000356 MaximumLayer,
Nattapat Chaimanowongebb0f9c2019-03-01 12:14:06 +0000357 NormalizationLayer,
358 PadLayer
Nattapat Chaimanowong969eea32019-01-30 13:33:11 +0000359}
360
Saoirse Stewart49dbe0e2019-02-05 17:27:06 +0000361table AnyLayer {
362 layer:Layer;
363}
364
Nattapat Chaimanowong969eea32019-01-30 13:33:11 +0000365// Root type for serialized data is the graph of the network
366table SerializedGraph {
Saoirse Stewart49dbe0e2019-02-05 17:27:06 +0000367 layers:[AnyLayer];
Mike Kelly8c1701a2019-02-11 17:01:27 +0000368 inputIds:[uint];
369 outputIds:[uint];
Nattapat Chaimanowong969eea32019-01-30 13:33:11 +0000370}
371
372root_type SerializedGraph;