blob: c1e4e3826a948ed1b64a02cb23ce8e2fdf4a5322 [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,
97 SpaceToBatchNd = 13
Nattapat Chaimanowong969eea32019-01-30 13:33:11 +000098}
99
100// Base layer table to be used as part of other layers
101table LayerBase {
102 index:uint;
103 layerName:string;
104 layerType:LayerType;
105 inputSlots:[InputSlot];
106 outputSlots:[OutputSlot];
107}
108
109table BindableLayerBase {
110 base:LayerBase;
111 layerBindingId:int;
112}
113
114// Table for each layer defined below
Mike Kellyaf484012019-02-20 16:53:11 +0000115table ActivationLayer {
116 base:LayerBase;
117 descriptor:ActivationDescriptor;
118}
119
120table ActivationDescriptor {
121 function:ActivationFunction = Sigmoid;
122 a:float;
123 b:float;
124}
125
Nattapat Chaimanowong969eea32019-01-30 13:33:11 +0000126table AdditionLayer {
127 base:LayerBase;
128}
129
Conor Kennedy76277882019-02-26 08:29:54 +0000130table ConstantLayer {
131 base:LayerBase;
132 input:ConstTensor;
133}
134
Mike Kellya0766c32019-02-19 17:22:07 +0000135table Convolution2dLayer {
136 base:LayerBase;
137 descriptor:Convolution2dDescriptor;
138 weights:ConstTensor;
139 biases:ConstTensor;
140}
141
142table Convolution2dDescriptor {
143 padLeft:uint;
144 padRight:uint;
145 padTop:uint;
146 padBottom:uint;
147 strideX:uint;
148 strideY:uint;
149 biasEnabled:bool = false;
150 dataLayout:DataLayout = NCHW;
151}
152
Sadik Armagandbb0c0c2019-02-21 09:01:41 +0000153table FullyConnectedLayer {
154 base:LayerBase;
155 descriptor:FullyConnectedDescriptor;
156 weights:ConstTensor;
157 biases:ConstTensor;
158}
159
160table FullyConnectedDescriptor {
161 biasEnabled:bool = false;
162 transposeWeightsMatrix:bool = false;
163}
164
Nattapat Chaimanowong969eea32019-01-30 13:33:11 +0000165table InputLayer {
166 base:BindableLayerBase;
167}
168
Sadik Armagan5f450272019-02-12 14:31:45 +0000169table MultiplicationLayer {
170 base:LayerBase;
171}
172
Saoirse Stewart3166c3e2019-02-18 15:24:53 +0000173table Pooling2dLayer {
174 base:LayerBase;
175 descriptor:Pooling2dDescriptor;
176}
177
178enum PoolingAlgorithm : byte {
179 Max = 0,
180 Average = 1,
181 L2 = 2
182}
183
184enum OutputShapeRounding : byte {
185 Floor = 0,
186 Ceiling = 1
187}
188
189enum PaddingMethod : byte {
190 IgnoreValue = 0,
191 Exclude = 1
192}
193
194table Pooling2dDescriptor {
195 poolType:PoolingAlgorithm;
196 padLeft:uint;
197 padRight:uint;
198 padTop:uint;
199 padBottom:uint;
200 poolWidth:uint;
201 poolHeight:uint;
202 strideX:uint;
203 strideY:uint;
204 outputShapeRounding:OutputShapeRounding;
205 paddingMethod:PaddingMethod;
206 dataLayout:DataLayout;
207}
208
Aron Virginas-Tarfc413c02019-02-13 15:41:52 +0000209table SoftmaxLayer {
210 base:LayerBase;
211 descriptor:SoftmaxDescriptor;
212}
213
214table SoftmaxDescriptor {
215 beta:float;
216}
217
Aron Virginas-Tarc04125f2019-02-19 16:31:08 +0000218table DepthwiseConvolution2dLayer {
219 base:LayerBase;
220 descriptor:DepthwiseConvolution2dDescriptor;
221 weights:ConstTensor;
222 biases:ConstTensor;
223}
224
225table DepthwiseConvolution2dDescriptor {
226 padLeft:uint;
227 padRight:uint;
228 padTop:uint;
229 padBottom:uint;
230 strideX:uint;
231 strideY:uint;
232 biasEnabled:bool = false;
233 dataLayout:DataLayout = NCHW;
234}
235
Nattapat Chaimanowong969eea32019-01-30 13:33:11 +0000236table OutputLayer {
237 base:BindableLayerBase;
238}
239
Saoirse Stewart263829c2019-02-19 15:54:14 +0000240table ReshapeLayer {
241 base:LayerBase;
242 descriptor:ReshapeDescriptor;
243}
244
245table ReshapeDescriptor {
246 targetShape:[uint];
247}
248
Nattapat Chaimanowong30b00202019-02-20 17:31:34 +0000249table PermuteLayer {
250 base:LayerBase;
251 descriptor:PermuteDescriptor;
252}
253
254table PermuteDescriptor {
255 dimMappings:[uint];
256}
257
Nattapat Chaimanowong45286992019-02-26 15:53:02 +0000258table SpaceToBatchNdLayer {
259 base:LayerBase;
260 descriptor:SpaceToBatchNdDescriptor;
261}
262
263table SpaceToBatchNdDescriptor {
264 blockShape:[uint];
265 padList:[uint];
266 dataLayout:DataLayout;
267}
268
Nattapat Chaimanowong969eea32019-01-30 13:33:11 +0000269union Layer {
Mike Kellyaf484012019-02-20 16:53:11 +0000270 ActivationLayer,
Nattapat Chaimanowong969eea32019-01-30 13:33:11 +0000271 AdditionLayer,
Conor Kennedy76277882019-02-26 08:29:54 +0000272 ConstantLayer,
Mike Kellya0766c32019-02-19 17:22:07 +0000273 Convolution2dLayer,
Aron Virginas-Tarc04125f2019-02-19 16:31:08 +0000274 DepthwiseConvolution2dLayer,
Sadik Armagandbb0c0c2019-02-21 09:01:41 +0000275 FullyConnectedLayer,
Nattapat Chaimanowong969eea32019-01-30 13:33:11 +0000276 InputLayer,
Sadik Armagan5f450272019-02-12 14:31:45 +0000277 MultiplicationLayer,
Aron Virginas-Tarfc413c02019-02-13 15:41:52 +0000278 OutputLayer,
Nattapat Chaimanowong30b00202019-02-20 17:31:34 +0000279 PermuteLayer,
Saoirse Stewart3166c3e2019-02-18 15:24:53 +0000280 Pooling2dLayer,
Saoirse Stewart263829c2019-02-19 15:54:14 +0000281 ReshapeLayer,
Nattapat Chaimanowong45286992019-02-26 15:53:02 +0000282 SoftmaxLayer,
283 SpaceToBatchNdLayer
Nattapat Chaimanowong969eea32019-01-30 13:33:11 +0000284}
285
Saoirse Stewart49dbe0e2019-02-05 17:27:06 +0000286table AnyLayer {
287 layer:Layer;
288}
289
Nattapat Chaimanowong969eea32019-01-30 13:33:11 +0000290// Root type for serialized data is the graph of the network
291table SerializedGraph {
Saoirse Stewart49dbe0e2019-02-05 17:27:06 +0000292 layers:[AnyLayer];
Mike Kelly8c1701a2019-02-11 17:01:27 +0000293 inputIds:[uint];
294 outputIds:[uint];
Nattapat Chaimanowong969eea32019-01-30 13:33:11 +0000295}
296
297root_type SerializedGraph;