blob: 501953c60b3cb79ca681dc8c72e98392752f0220 [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,
100 Minimum = 16
Nattapat Chaimanowong969eea32019-01-30 13:33:11 +0000101}
102
103// Base layer table to be used as part of other layers
104table LayerBase {
105 index:uint;
106 layerName:string;
107 layerType:LayerType;
108 inputSlots:[InputSlot];
109 outputSlots:[OutputSlot];
110}
111
112table BindableLayerBase {
113 base:LayerBase;
114 layerBindingId:int;
115}
116
117// Table for each layer defined below
Mike Kellyaf484012019-02-20 16:53:11 +0000118table ActivationLayer {
119 base:LayerBase;
120 descriptor:ActivationDescriptor;
121}
122
123table ActivationDescriptor {
124 function:ActivationFunction = Sigmoid;
125 a:float;
126 b:float;
127}
128
Nattapat Chaimanowong969eea32019-01-30 13:33:11 +0000129table AdditionLayer {
130 base:LayerBase;
131}
132
Conor Kennedy76277882019-02-26 08:29:54 +0000133table ConstantLayer {
134 base:LayerBase;
135 input:ConstTensor;
136}
137
Mike Kellya0766c32019-02-19 17:22:07 +0000138table Convolution2dLayer {
139 base:LayerBase;
140 descriptor:Convolution2dDescriptor;
141 weights:ConstTensor;
142 biases:ConstTensor;
143}
144
145table Convolution2dDescriptor {
146 padLeft:uint;
147 padRight:uint;
148 padTop:uint;
149 padBottom:uint;
150 strideX:uint;
151 strideY:uint;
152 biasEnabled:bool = false;
153 dataLayout:DataLayout = NCHW;
154}
155
Éanna Ó Catháin58885892019-02-27 16:16:39 +0000156table DivisionLayer {
157 base:LayerBase;
158}
159
Sadik Armagandbb0c0c2019-02-21 09:01:41 +0000160table FullyConnectedLayer {
161 base:LayerBase;
162 descriptor:FullyConnectedDescriptor;
163 weights:ConstTensor;
164 biases:ConstTensor;
165}
166
167table FullyConnectedDescriptor {
168 biasEnabled:bool = false;
169 transposeWeightsMatrix:bool = false;
170}
171
Nattapat Chaimanowong969eea32019-01-30 13:33:11 +0000172table InputLayer {
173 base:BindableLayerBase;
174}
175
Aron Virginas-Tar0fe32452019-02-28 13:12:47 +0000176table MinimumLayer {
177 base:LayerBase;
178}
179
Sadik Armagan5f450272019-02-12 14:31:45 +0000180table MultiplicationLayer {
181 base:LayerBase;
182}
183
Saoirse Stewart3166c3e2019-02-18 15:24:53 +0000184table Pooling2dLayer {
185 base:LayerBase;
186 descriptor:Pooling2dDescriptor;
187}
188
189enum PoolingAlgorithm : byte {
190 Max = 0,
191 Average = 1,
192 L2 = 2
193}
194
195enum OutputShapeRounding : byte {
196 Floor = 0,
197 Ceiling = 1
198}
199
200enum PaddingMethod : byte {
201 IgnoreValue = 0,
202 Exclude = 1
203}
204
205table Pooling2dDescriptor {
206 poolType:PoolingAlgorithm;
207 padLeft:uint;
208 padRight:uint;
209 padTop:uint;
210 padBottom:uint;
211 poolWidth:uint;
212 poolHeight:uint;
213 strideX:uint;
214 strideY:uint;
215 outputShapeRounding:OutputShapeRounding;
216 paddingMethod:PaddingMethod;
217 dataLayout:DataLayout;
218}
219
Aron Virginas-Tarfc413c02019-02-13 15:41:52 +0000220table SoftmaxLayer {
221 base:LayerBase;
222 descriptor:SoftmaxDescriptor;
223}
224
225table SoftmaxDescriptor {
226 beta:float;
227}
228
Aron Virginas-Tarc04125f2019-02-19 16:31:08 +0000229table DepthwiseConvolution2dLayer {
230 base:LayerBase;
231 descriptor:DepthwiseConvolution2dDescriptor;
232 weights:ConstTensor;
233 biases:ConstTensor;
234}
235
236table DepthwiseConvolution2dDescriptor {
237 padLeft:uint;
238 padRight:uint;
239 padTop:uint;
240 padBottom:uint;
241 strideX:uint;
242 strideY:uint;
243 biasEnabled:bool = false;
244 dataLayout:DataLayout = NCHW;
245}
246
Nattapat Chaimanowong969eea32019-01-30 13:33:11 +0000247table OutputLayer {
248 base:BindableLayerBase;
249}
250
Saoirse Stewart263829c2019-02-19 15:54:14 +0000251table ReshapeLayer {
252 base:LayerBase;
253 descriptor:ReshapeDescriptor;
254}
255
256table ReshapeDescriptor {
257 targetShape:[uint];
258}
259
Nattapat Chaimanowong30b00202019-02-20 17:31:34 +0000260table PermuteLayer {
261 base:LayerBase;
262 descriptor:PermuteDescriptor;
263}
264
265table PermuteDescriptor {
266 dimMappings:[uint];
267}
268
Nattapat Chaimanowong45286992019-02-26 15:53:02 +0000269table SpaceToBatchNdLayer {
270 base:LayerBase;
271 descriptor:SpaceToBatchNdDescriptor;
272}
273
274table SpaceToBatchNdDescriptor {
275 blockShape:[uint];
276 padList:[uint];
277 dataLayout:DataLayout;
278}
279
Nattapat Chaimanowong6b4ed982019-02-26 17:24:13 +0000280table BatchToSpaceNdLayer {
281 base:LayerBase;
282 descriptor:BatchToSpaceNdDescriptor;
283}
284
285table BatchToSpaceNdDescriptor {
286 blockShape:[uint];
287 crops:[uint];
288 dataLayout:DataLayout;
289}
290
Nattapat Chaimanowong969eea32019-01-30 13:33:11 +0000291union Layer {
Mike Kellyaf484012019-02-20 16:53:11 +0000292 ActivationLayer,
Nattapat Chaimanowong969eea32019-01-30 13:33:11 +0000293 AdditionLayer,
Nattapat Chaimanowong6b4ed982019-02-26 17:24:13 +0000294 BatchToSpaceNdLayer,
Conor Kennedy76277882019-02-26 08:29:54 +0000295 ConstantLayer,
Mike Kellya0766c32019-02-19 17:22:07 +0000296 Convolution2dLayer,
Aron Virginas-Tarc04125f2019-02-19 16:31:08 +0000297 DepthwiseConvolution2dLayer,
Sadik Armagandbb0c0c2019-02-21 09:01:41 +0000298 FullyConnectedLayer,
Nattapat Chaimanowong969eea32019-01-30 13:33:11 +0000299 InputLayer,
Sadik Armagan5f450272019-02-12 14:31:45 +0000300 MultiplicationLayer,
Aron Virginas-Tarfc413c02019-02-13 15:41:52 +0000301 OutputLayer,
Nattapat Chaimanowong30b00202019-02-20 17:31:34 +0000302 PermuteLayer,
Saoirse Stewart3166c3e2019-02-18 15:24:53 +0000303 Pooling2dLayer,
Saoirse Stewart263829c2019-02-19 15:54:14 +0000304 ReshapeLayer,
Nattapat Chaimanowong45286992019-02-26 15:53:02 +0000305 SoftmaxLayer,
Éanna Ó Catháin58885892019-02-27 16:16:39 +0000306 SpaceToBatchNdLayer,
Aron Virginas-Tar0fe32452019-02-28 13:12:47 +0000307 DivisionLayer,
308 MinimumLayer
Nattapat Chaimanowong969eea32019-01-30 13:33:11 +0000309}
310
Saoirse Stewart49dbe0e2019-02-05 17:27:06 +0000311table AnyLayer {
312 layer:Layer;
313}
314
Nattapat Chaimanowong969eea32019-01-30 13:33:11 +0000315// Root type for serialized data is the graph of the network
316table SerializedGraph {
Saoirse Stewart49dbe0e2019-02-05 17:27:06 +0000317 layers:[AnyLayer];
Mike Kelly8c1701a2019-02-11 17:01:27 +0000318 inputIds:[uint];
319 outputIds:[uint];
Nattapat Chaimanowong969eea32019-01-30 13:33:11 +0000320}
321
322root_type SerializedGraph;