blob: b59adcf82b2f32fc43ee2a6511e003339b059153 [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,
102 Maximum = 18
Nattapat Chaimanowong969eea32019-01-30 13:33:11 +0000103}
104
105// Base layer table to be used as part of other layers
106table LayerBase {
107 index:uint;
108 layerName:string;
109 layerType:LayerType;
110 inputSlots:[InputSlot];
111 outputSlots:[OutputSlot];
112}
113
114table BindableLayerBase {
115 base:LayerBase;
116 layerBindingId:int;
117}
118
119// Table for each layer defined below
Mike Kellyaf484012019-02-20 16:53:11 +0000120table ActivationLayer {
121 base:LayerBase;
122 descriptor:ActivationDescriptor;
123}
124
125table ActivationDescriptor {
126 function:ActivationFunction = Sigmoid;
127 a:float;
128 b:float;
129}
130
Nattapat Chaimanowong969eea32019-01-30 13:33:11 +0000131table AdditionLayer {
132 base:LayerBase;
133}
134
Conor Kennedy76277882019-02-26 08:29:54 +0000135table ConstantLayer {
136 base:LayerBase;
137 input:ConstTensor;
138}
139
Mike Kellya0766c32019-02-19 17:22:07 +0000140table Convolution2dLayer {
141 base:LayerBase;
142 descriptor:Convolution2dDescriptor;
143 weights:ConstTensor;
144 biases:ConstTensor;
145}
146
147table Convolution2dDescriptor {
148 padLeft:uint;
149 padRight:uint;
150 padTop:uint;
151 padBottom:uint;
152 strideX:uint;
153 strideY:uint;
154 biasEnabled:bool = false;
155 dataLayout:DataLayout = NCHW;
156}
157
Éanna Ó Catháin58885892019-02-27 16:16:39 +0000158table DivisionLayer {
159 base:LayerBase;
160}
161
Nattapat Chaimanowong235cea52019-02-28 16:27:30 +0000162table EqualLayer {
163 base:LayerBase;
164}
165
Sadik Armagandbb0c0c2019-02-21 09:01:41 +0000166table FullyConnectedLayer {
167 base:LayerBase;
168 descriptor:FullyConnectedDescriptor;
169 weights:ConstTensor;
170 biases:ConstTensor;
171}
172
173table FullyConnectedDescriptor {
174 biasEnabled:bool = false;
175 transposeWeightsMatrix:bool = false;
176}
177
Nattapat Chaimanowong969eea32019-01-30 13:33:11 +0000178table InputLayer {
179 base:BindableLayerBase;
180}
181
Aron Virginas-Tar0fe32452019-02-28 13:12:47 +0000182table MinimumLayer {
183 base:LayerBase;
184}
185
Aron Virginas-Tar377351e2019-02-27 14:42:31 +0000186table MaximumLayer {
187 base:LayerBase;
188}
189
Sadik Armagan5f450272019-02-12 14:31:45 +0000190table MultiplicationLayer {
191 base:LayerBase;
192}
193
Saoirse Stewart3166c3e2019-02-18 15:24:53 +0000194table Pooling2dLayer {
195 base:LayerBase;
196 descriptor:Pooling2dDescriptor;
197}
198
199enum PoolingAlgorithm : byte {
200 Max = 0,
201 Average = 1,
202 L2 = 2
203}
204
205enum OutputShapeRounding : byte {
206 Floor = 0,
207 Ceiling = 1
208}
209
210enum PaddingMethod : byte {
211 IgnoreValue = 0,
212 Exclude = 1
213}
214
215table Pooling2dDescriptor {
216 poolType:PoolingAlgorithm;
217 padLeft:uint;
218 padRight:uint;
219 padTop:uint;
220 padBottom:uint;
221 poolWidth:uint;
222 poolHeight:uint;
223 strideX:uint;
224 strideY:uint;
225 outputShapeRounding:OutputShapeRounding;
226 paddingMethod:PaddingMethod;
227 dataLayout:DataLayout;
228}
229
Aron Virginas-Tarfc413c02019-02-13 15:41:52 +0000230table SoftmaxLayer {
231 base:LayerBase;
232 descriptor:SoftmaxDescriptor;
233}
234
235table SoftmaxDescriptor {
236 beta:float;
237}
238
Aron Virginas-Tarc04125f2019-02-19 16:31:08 +0000239table DepthwiseConvolution2dLayer {
240 base:LayerBase;
241 descriptor:DepthwiseConvolution2dDescriptor;
242 weights:ConstTensor;
243 biases:ConstTensor;
244}
245
246table DepthwiseConvolution2dDescriptor {
247 padLeft:uint;
248 padRight:uint;
249 padTop:uint;
250 padBottom:uint;
251 strideX:uint;
252 strideY:uint;
253 biasEnabled:bool = false;
254 dataLayout:DataLayout = NCHW;
255}
256
Nattapat Chaimanowong969eea32019-01-30 13:33:11 +0000257table OutputLayer {
258 base:BindableLayerBase;
259}
260
Saoirse Stewart263829c2019-02-19 15:54:14 +0000261table ReshapeLayer {
262 base:LayerBase;
263 descriptor:ReshapeDescriptor;
264}
265
266table ReshapeDescriptor {
267 targetShape:[uint];
268}
269
Nattapat Chaimanowong30b00202019-02-20 17:31:34 +0000270table PermuteLayer {
271 base:LayerBase;
272 descriptor:PermuteDescriptor;
273}
274
275table PermuteDescriptor {
276 dimMappings:[uint];
277}
278
Nattapat Chaimanowong45286992019-02-26 15:53:02 +0000279table SpaceToBatchNdLayer {
280 base:LayerBase;
281 descriptor:SpaceToBatchNdDescriptor;
282}
283
284table SpaceToBatchNdDescriptor {
285 blockShape:[uint];
286 padList:[uint];
287 dataLayout:DataLayout;
288}
289
Nattapat Chaimanowong6b4ed982019-02-26 17:24:13 +0000290table BatchToSpaceNdLayer {
291 base:LayerBase;
292 descriptor:BatchToSpaceNdDescriptor;
293}
294
295table BatchToSpaceNdDescriptor {
296 blockShape:[uint];
297 crops:[uint];
298 dataLayout:DataLayout;
299}
300
Nattapat Chaimanowong969eea32019-01-30 13:33:11 +0000301union Layer {
Mike Kellyaf484012019-02-20 16:53:11 +0000302 ActivationLayer,
Nattapat Chaimanowong969eea32019-01-30 13:33:11 +0000303 AdditionLayer,
Nattapat Chaimanowong6b4ed982019-02-26 17:24:13 +0000304 BatchToSpaceNdLayer,
Conor Kennedy76277882019-02-26 08:29:54 +0000305 ConstantLayer,
Mike Kellya0766c32019-02-19 17:22:07 +0000306 Convolution2dLayer,
Aron Virginas-Tarc04125f2019-02-19 16:31:08 +0000307 DepthwiseConvolution2dLayer,
Sadik Armagandbb0c0c2019-02-21 09:01:41 +0000308 FullyConnectedLayer,
Nattapat Chaimanowong969eea32019-01-30 13:33:11 +0000309 InputLayer,
Sadik Armagan5f450272019-02-12 14:31:45 +0000310 MultiplicationLayer,
Aron Virginas-Tarfc413c02019-02-13 15:41:52 +0000311 OutputLayer,
Nattapat Chaimanowong30b00202019-02-20 17:31:34 +0000312 PermuteLayer,
Saoirse Stewart3166c3e2019-02-18 15:24:53 +0000313 Pooling2dLayer,
Saoirse Stewart263829c2019-02-19 15:54:14 +0000314 ReshapeLayer,
Nattapat Chaimanowong45286992019-02-26 15:53:02 +0000315 SoftmaxLayer,
Éanna Ó Catháin58885892019-02-27 16:16:39 +0000316 SpaceToBatchNdLayer,
Aron Virginas-Tar0fe32452019-02-28 13:12:47 +0000317 DivisionLayer,
Nattapat Chaimanowong235cea52019-02-28 16:27:30 +0000318 MinimumLayer,
Aron Virginas-Tar377351e2019-02-27 14:42:31 +0000319 EqualLayer,
320 MaximumLayer
Nattapat Chaimanowong969eea32019-01-30 13:33:11 +0000321}
322
Saoirse Stewart49dbe0e2019-02-05 17:27:06 +0000323table AnyLayer {
324 layer:Layer;
325}
326
Nattapat Chaimanowong969eea32019-01-30 13:33:11 +0000327// Root type for serialized data is the graph of the network
328table SerializedGraph {
Saoirse Stewart49dbe0e2019-02-05 17:27:06 +0000329 layers:[AnyLayer];
Mike Kelly8c1701a2019-02-11 17:01:27 +0000330 inputIds:[uint];
331 outputIds:[uint];
Nattapat Chaimanowong969eea32019-01-30 13:33:11 +0000332}
333
334root_type SerializedGraph;