blob: 95b4cdc1c41909aaa97f373790bebe48cbc3a7cd [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,
99 Division = 15
Nattapat Chaimanowong969eea32019-01-30 13:33:11 +0000100}
101
102// Base layer table to be used as part of other layers
103table LayerBase {
104 index:uint;
105 layerName:string;
106 layerType:LayerType;
107 inputSlots:[InputSlot];
108 outputSlots:[OutputSlot];
109}
110
111table BindableLayerBase {
112 base:LayerBase;
113 layerBindingId:int;
114}
115
116// Table for each layer defined below
Mike Kellyaf484012019-02-20 16:53:11 +0000117table ActivationLayer {
118 base:LayerBase;
119 descriptor:ActivationDescriptor;
120}
121
122table ActivationDescriptor {
123 function:ActivationFunction = Sigmoid;
124 a:float;
125 b:float;
126}
127
Nattapat Chaimanowong969eea32019-01-30 13:33:11 +0000128table AdditionLayer {
129 base:LayerBase;
130}
131
Conor Kennedy76277882019-02-26 08:29:54 +0000132table ConstantLayer {
133 base:LayerBase;
134 input:ConstTensor;
135}
136
Mike Kellya0766c32019-02-19 17:22:07 +0000137table Convolution2dLayer {
138 base:LayerBase;
139 descriptor:Convolution2dDescriptor;
140 weights:ConstTensor;
141 biases:ConstTensor;
142}
143
144table Convolution2dDescriptor {
145 padLeft:uint;
146 padRight:uint;
147 padTop:uint;
148 padBottom:uint;
149 strideX:uint;
150 strideY:uint;
151 biasEnabled:bool = false;
152 dataLayout:DataLayout = NCHW;
153}
154
Éanna Ó Catháin58885892019-02-27 16:16:39 +0000155table DivisionLayer {
156 base:LayerBase;
157}
158
Sadik Armagandbb0c0c2019-02-21 09:01:41 +0000159table FullyConnectedLayer {
160 base:LayerBase;
161 descriptor:FullyConnectedDescriptor;
162 weights:ConstTensor;
163 biases:ConstTensor;
164}
165
166table FullyConnectedDescriptor {
167 biasEnabled:bool = false;
168 transposeWeightsMatrix:bool = false;
169}
170
Nattapat Chaimanowong969eea32019-01-30 13:33:11 +0000171table InputLayer {
172 base:BindableLayerBase;
173}
174
Sadik Armagan5f450272019-02-12 14:31:45 +0000175table MultiplicationLayer {
176 base:LayerBase;
177}
178
Saoirse Stewart3166c3e2019-02-18 15:24:53 +0000179table Pooling2dLayer {
180 base:LayerBase;
181 descriptor:Pooling2dDescriptor;
182}
183
184enum PoolingAlgorithm : byte {
185 Max = 0,
186 Average = 1,
187 L2 = 2
188}
189
190enum OutputShapeRounding : byte {
191 Floor = 0,
192 Ceiling = 1
193}
194
195enum PaddingMethod : byte {
196 IgnoreValue = 0,
197 Exclude = 1
198}
199
200table Pooling2dDescriptor {
201 poolType:PoolingAlgorithm;
202 padLeft:uint;
203 padRight:uint;
204 padTop:uint;
205 padBottom:uint;
206 poolWidth:uint;
207 poolHeight:uint;
208 strideX:uint;
209 strideY:uint;
210 outputShapeRounding:OutputShapeRounding;
211 paddingMethod:PaddingMethod;
212 dataLayout:DataLayout;
213}
214
Aron Virginas-Tarfc413c02019-02-13 15:41:52 +0000215table SoftmaxLayer {
216 base:LayerBase;
217 descriptor:SoftmaxDescriptor;
218}
219
220table SoftmaxDescriptor {
221 beta:float;
222}
223
Aron Virginas-Tarc04125f2019-02-19 16:31:08 +0000224table DepthwiseConvolution2dLayer {
225 base:LayerBase;
226 descriptor:DepthwiseConvolution2dDescriptor;
227 weights:ConstTensor;
228 biases:ConstTensor;
229}
230
231table DepthwiseConvolution2dDescriptor {
232 padLeft:uint;
233 padRight:uint;
234 padTop:uint;
235 padBottom:uint;
236 strideX:uint;
237 strideY:uint;
238 biasEnabled:bool = false;
239 dataLayout:DataLayout = NCHW;
240}
241
Nattapat Chaimanowong969eea32019-01-30 13:33:11 +0000242table OutputLayer {
243 base:BindableLayerBase;
244}
245
Saoirse Stewart263829c2019-02-19 15:54:14 +0000246table ReshapeLayer {
247 base:LayerBase;
248 descriptor:ReshapeDescriptor;
249}
250
251table ReshapeDescriptor {
252 targetShape:[uint];
253}
254
Nattapat Chaimanowong30b00202019-02-20 17:31:34 +0000255table PermuteLayer {
256 base:LayerBase;
257 descriptor:PermuteDescriptor;
258}
259
260table PermuteDescriptor {
261 dimMappings:[uint];
262}
263
Nattapat Chaimanowong45286992019-02-26 15:53:02 +0000264table SpaceToBatchNdLayer {
265 base:LayerBase;
266 descriptor:SpaceToBatchNdDescriptor;
267}
268
269table SpaceToBatchNdDescriptor {
270 blockShape:[uint];
271 padList:[uint];
272 dataLayout:DataLayout;
273}
274
Nattapat Chaimanowong6b4ed982019-02-26 17:24:13 +0000275table BatchToSpaceNdLayer {
276 base:LayerBase;
277 descriptor:BatchToSpaceNdDescriptor;
278}
279
280table BatchToSpaceNdDescriptor {
281 blockShape:[uint];
282 crops:[uint];
283 dataLayout:DataLayout;
284}
285
Nattapat Chaimanowong969eea32019-01-30 13:33:11 +0000286union Layer {
Mike Kellyaf484012019-02-20 16:53:11 +0000287 ActivationLayer,
Nattapat Chaimanowong969eea32019-01-30 13:33:11 +0000288 AdditionLayer,
Nattapat Chaimanowong6b4ed982019-02-26 17:24:13 +0000289 BatchToSpaceNdLayer,
Conor Kennedy76277882019-02-26 08:29:54 +0000290 ConstantLayer,
Mike Kellya0766c32019-02-19 17:22:07 +0000291 Convolution2dLayer,
Aron Virginas-Tarc04125f2019-02-19 16:31:08 +0000292 DepthwiseConvolution2dLayer,
Sadik Armagandbb0c0c2019-02-21 09:01:41 +0000293 FullyConnectedLayer,
Nattapat Chaimanowong969eea32019-01-30 13:33:11 +0000294 InputLayer,
Sadik Armagan5f450272019-02-12 14:31:45 +0000295 MultiplicationLayer,
Aron Virginas-Tarfc413c02019-02-13 15:41:52 +0000296 OutputLayer,
Nattapat Chaimanowong30b00202019-02-20 17:31:34 +0000297 PermuteLayer,
Saoirse Stewart3166c3e2019-02-18 15:24:53 +0000298 Pooling2dLayer,
Saoirse Stewart263829c2019-02-19 15:54:14 +0000299 ReshapeLayer,
Nattapat Chaimanowong45286992019-02-26 15:53:02 +0000300 SoftmaxLayer,
Éanna Ó Catháin58885892019-02-27 16:16:39 +0000301 SpaceToBatchNdLayer,
302 DivisionLayer
Nattapat Chaimanowong969eea32019-01-30 13:33:11 +0000303}
304
Saoirse Stewart49dbe0e2019-02-05 17:27:06 +0000305table AnyLayer {
306 layer:Layer;
307}
308
Nattapat Chaimanowong969eea32019-01-30 13:33:11 +0000309// Root type for serialized data is the graph of the network
310table SerializedGraph {
Saoirse Stewart49dbe0e2019-02-05 17:27:06 +0000311 layers:[AnyLayer];
Mike Kelly8c1701a2019-02-11 17:01:27 +0000312 inputIds:[uint];
313 outputIds:[uint];
Nattapat Chaimanowong969eea32019-01-30 13:33:11 +0000314}
315
316root_type SerializedGraph;