blob: 5787f512a2c538553859b34edbd4988892ff0db5 [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,
101 Equal = 17
Nattapat Chaimanowong969eea32019-01-30 13:33:11 +0000102}
103
104// Base layer table to be used as part of other layers
105table LayerBase {
106 index:uint;
107 layerName:string;
108 layerType:LayerType;
109 inputSlots:[InputSlot];
110 outputSlots:[OutputSlot];
111}
112
113table BindableLayerBase {
114 base:LayerBase;
115 layerBindingId:int;
116}
117
118// Table for each layer defined below
Mike Kellyaf484012019-02-20 16:53:11 +0000119table ActivationLayer {
120 base:LayerBase;
121 descriptor:ActivationDescriptor;
122}
123
124table ActivationDescriptor {
125 function:ActivationFunction = Sigmoid;
126 a:float;
127 b:float;
128}
129
Nattapat Chaimanowong969eea32019-01-30 13:33:11 +0000130table AdditionLayer {
131 base:LayerBase;
132}
133
Conor Kennedy76277882019-02-26 08:29:54 +0000134table ConstantLayer {
135 base:LayerBase;
136 input:ConstTensor;
137}
138
Mike Kellya0766c32019-02-19 17:22:07 +0000139table Convolution2dLayer {
140 base:LayerBase;
141 descriptor:Convolution2dDescriptor;
142 weights:ConstTensor;
143 biases:ConstTensor;
144}
145
146table Convolution2dDescriptor {
147 padLeft:uint;
148 padRight:uint;
149 padTop:uint;
150 padBottom:uint;
151 strideX:uint;
152 strideY:uint;
153 biasEnabled:bool = false;
154 dataLayout:DataLayout = NCHW;
155}
156
Éanna Ó Catháin58885892019-02-27 16:16:39 +0000157table DivisionLayer {
158 base:LayerBase;
159}
160
Nattapat Chaimanowong235cea52019-02-28 16:27:30 +0000161table EqualLayer {
162 base:LayerBase;
163}
164
Sadik Armagandbb0c0c2019-02-21 09:01:41 +0000165table FullyConnectedLayer {
166 base:LayerBase;
167 descriptor:FullyConnectedDescriptor;
168 weights:ConstTensor;
169 biases:ConstTensor;
170}
171
172table FullyConnectedDescriptor {
173 biasEnabled:bool = false;
174 transposeWeightsMatrix:bool = false;
175}
176
Nattapat Chaimanowong969eea32019-01-30 13:33:11 +0000177table InputLayer {
178 base:BindableLayerBase;
179}
180
Aron Virginas-Tar0fe32452019-02-28 13:12:47 +0000181table MinimumLayer {
182 base:LayerBase;
183}
184
Sadik Armagan5f450272019-02-12 14:31:45 +0000185table MultiplicationLayer {
186 base:LayerBase;
187}
188
Saoirse Stewart3166c3e2019-02-18 15:24:53 +0000189table Pooling2dLayer {
190 base:LayerBase;
191 descriptor:Pooling2dDescriptor;
192}
193
194enum PoolingAlgorithm : byte {
195 Max = 0,
196 Average = 1,
197 L2 = 2
198}
199
200enum OutputShapeRounding : byte {
201 Floor = 0,
202 Ceiling = 1
203}
204
205enum PaddingMethod : byte {
206 IgnoreValue = 0,
207 Exclude = 1
208}
209
210table Pooling2dDescriptor {
211 poolType:PoolingAlgorithm;
212 padLeft:uint;
213 padRight:uint;
214 padTop:uint;
215 padBottom:uint;
216 poolWidth:uint;
217 poolHeight:uint;
218 strideX:uint;
219 strideY:uint;
220 outputShapeRounding:OutputShapeRounding;
221 paddingMethod:PaddingMethod;
222 dataLayout:DataLayout;
223}
224
Aron Virginas-Tarfc413c02019-02-13 15:41:52 +0000225table SoftmaxLayer {
226 base:LayerBase;
227 descriptor:SoftmaxDescriptor;
228}
229
230table SoftmaxDescriptor {
231 beta:float;
232}
233
Aron Virginas-Tarc04125f2019-02-19 16:31:08 +0000234table DepthwiseConvolution2dLayer {
235 base:LayerBase;
236 descriptor:DepthwiseConvolution2dDescriptor;
237 weights:ConstTensor;
238 biases:ConstTensor;
239}
240
241table DepthwiseConvolution2dDescriptor {
242 padLeft:uint;
243 padRight:uint;
244 padTop:uint;
245 padBottom:uint;
246 strideX:uint;
247 strideY:uint;
248 biasEnabled:bool = false;
249 dataLayout:DataLayout = NCHW;
250}
251
Nattapat Chaimanowong969eea32019-01-30 13:33:11 +0000252table OutputLayer {
253 base:BindableLayerBase;
254}
255
Saoirse Stewart263829c2019-02-19 15:54:14 +0000256table ReshapeLayer {
257 base:LayerBase;
258 descriptor:ReshapeDescriptor;
259}
260
261table ReshapeDescriptor {
262 targetShape:[uint];
263}
264
Nattapat Chaimanowong30b00202019-02-20 17:31:34 +0000265table PermuteLayer {
266 base:LayerBase;
267 descriptor:PermuteDescriptor;
268}
269
270table PermuteDescriptor {
271 dimMappings:[uint];
272}
273
Nattapat Chaimanowong45286992019-02-26 15:53:02 +0000274table SpaceToBatchNdLayer {
275 base:LayerBase;
276 descriptor:SpaceToBatchNdDescriptor;
277}
278
279table SpaceToBatchNdDescriptor {
280 blockShape:[uint];
281 padList:[uint];
282 dataLayout:DataLayout;
283}
284
Nattapat Chaimanowong6b4ed982019-02-26 17:24:13 +0000285table BatchToSpaceNdLayer {
286 base:LayerBase;
287 descriptor:BatchToSpaceNdDescriptor;
288}
289
290table BatchToSpaceNdDescriptor {
291 blockShape:[uint];
292 crops:[uint];
293 dataLayout:DataLayout;
294}
295
Nattapat Chaimanowong969eea32019-01-30 13:33:11 +0000296union Layer {
Mike Kellyaf484012019-02-20 16:53:11 +0000297 ActivationLayer,
Nattapat Chaimanowong969eea32019-01-30 13:33:11 +0000298 AdditionLayer,
Nattapat Chaimanowong6b4ed982019-02-26 17:24:13 +0000299 BatchToSpaceNdLayer,
Conor Kennedy76277882019-02-26 08:29:54 +0000300 ConstantLayer,
Mike Kellya0766c32019-02-19 17:22:07 +0000301 Convolution2dLayer,
Aron Virginas-Tarc04125f2019-02-19 16:31:08 +0000302 DepthwiseConvolution2dLayer,
Sadik Armagandbb0c0c2019-02-21 09:01:41 +0000303 FullyConnectedLayer,
Nattapat Chaimanowong969eea32019-01-30 13:33:11 +0000304 InputLayer,
Sadik Armagan5f450272019-02-12 14:31:45 +0000305 MultiplicationLayer,
Aron Virginas-Tarfc413c02019-02-13 15:41:52 +0000306 OutputLayer,
Nattapat Chaimanowong30b00202019-02-20 17:31:34 +0000307 PermuteLayer,
Saoirse Stewart3166c3e2019-02-18 15:24:53 +0000308 Pooling2dLayer,
Saoirse Stewart263829c2019-02-19 15:54:14 +0000309 ReshapeLayer,
Nattapat Chaimanowong45286992019-02-26 15:53:02 +0000310 SoftmaxLayer,
Éanna Ó Catháin58885892019-02-27 16:16:39 +0000311 SpaceToBatchNdLayer,
Aron Virginas-Tar0fe32452019-02-28 13:12:47 +0000312 DivisionLayer,
Nattapat Chaimanowong235cea52019-02-28 16:27:30 +0000313 MinimumLayer,
314 EqualLayer
Nattapat Chaimanowong969eea32019-01-30 13:33:11 +0000315}
316
Saoirse Stewart49dbe0e2019-02-05 17:27:06 +0000317table AnyLayer {
318 layer:Layer;
319}
320
Nattapat Chaimanowong969eea32019-01-30 13:33:11 +0000321// Root type for serialized data is the graph of the network
322table SerializedGraph {
Saoirse Stewart49dbe0e2019-02-05 17:27:06 +0000323 layers:[AnyLayer];
Mike Kelly8c1701a2019-02-11 17:01:27 +0000324 inputIds:[uint];
325 outputIds:[uint];
Nattapat Chaimanowong969eea32019-01-30 13:33:11 +0000326}
327
328root_type SerializedGraph;