blob: e81365166f7ec0fed6420fbcf49cccf42f76ff42 [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,
93 Activation = 9
Nattapat Chaimanowong969eea32019-01-30 13:33:11 +000094}
95
96// Base layer table to be used as part of other layers
97table LayerBase {
98 index:uint;
99 layerName:string;
100 layerType:LayerType;
101 inputSlots:[InputSlot];
102 outputSlots:[OutputSlot];
103}
104
105table BindableLayerBase {
106 base:LayerBase;
107 layerBindingId:int;
108}
109
110// Table for each layer defined below
Mike Kellyaf484012019-02-20 16:53:11 +0000111table ActivationLayer {
112 base:LayerBase;
113 descriptor:ActivationDescriptor;
114}
115
116table ActivationDescriptor {
117 function:ActivationFunction = Sigmoid;
118 a:float;
119 b:float;
120}
121
Nattapat Chaimanowong969eea32019-01-30 13:33:11 +0000122table AdditionLayer {
123 base:LayerBase;
124}
125
Mike Kellya0766c32019-02-19 17:22:07 +0000126table Convolution2dLayer {
127 base:LayerBase;
128 descriptor:Convolution2dDescriptor;
129 weights:ConstTensor;
130 biases:ConstTensor;
131}
132
133table Convolution2dDescriptor {
134 padLeft:uint;
135 padRight:uint;
136 padTop:uint;
137 padBottom:uint;
138 strideX:uint;
139 strideY:uint;
140 biasEnabled:bool = false;
141 dataLayout:DataLayout = NCHW;
142}
143
Nattapat Chaimanowong969eea32019-01-30 13:33:11 +0000144table InputLayer {
145 base:BindableLayerBase;
146}
147
Sadik Armagan5f450272019-02-12 14:31:45 +0000148table MultiplicationLayer {
149 base:LayerBase;
150}
151
Saoirse Stewart3166c3e2019-02-18 15:24:53 +0000152table Pooling2dLayer {
153 base:LayerBase;
154 descriptor:Pooling2dDescriptor;
155}
156
157enum PoolingAlgorithm : byte {
158 Max = 0,
159 Average = 1,
160 L2 = 2
161}
162
163enum OutputShapeRounding : byte {
164 Floor = 0,
165 Ceiling = 1
166}
167
168enum PaddingMethod : byte {
169 IgnoreValue = 0,
170 Exclude = 1
171}
172
173table Pooling2dDescriptor {
174 poolType:PoolingAlgorithm;
175 padLeft:uint;
176 padRight:uint;
177 padTop:uint;
178 padBottom:uint;
179 poolWidth:uint;
180 poolHeight:uint;
181 strideX:uint;
182 strideY:uint;
183 outputShapeRounding:OutputShapeRounding;
184 paddingMethod:PaddingMethod;
185 dataLayout:DataLayout;
186}
187
Aron Virginas-Tarfc413c02019-02-13 15:41:52 +0000188table SoftmaxLayer {
189 base:LayerBase;
190 descriptor:SoftmaxDescriptor;
191}
192
193table SoftmaxDescriptor {
194 beta:float;
195}
196
Aron Virginas-Tarc04125f2019-02-19 16:31:08 +0000197table DepthwiseConvolution2dLayer {
198 base:LayerBase;
199 descriptor:DepthwiseConvolution2dDescriptor;
200 weights:ConstTensor;
201 biases:ConstTensor;
202}
203
204table DepthwiseConvolution2dDescriptor {
205 padLeft:uint;
206 padRight:uint;
207 padTop:uint;
208 padBottom:uint;
209 strideX:uint;
210 strideY:uint;
211 biasEnabled:bool = false;
212 dataLayout:DataLayout = NCHW;
213}
214
Nattapat Chaimanowong969eea32019-01-30 13:33:11 +0000215table OutputLayer {
216 base:BindableLayerBase;
217}
218
Saoirse Stewart263829c2019-02-19 15:54:14 +0000219table ReshapeLayer {
220 base:LayerBase;
221 descriptor:ReshapeDescriptor;
222}
223
224table ReshapeDescriptor {
225 targetShape:[uint];
226}
227
Nattapat Chaimanowong969eea32019-01-30 13:33:11 +0000228union Layer {
Mike Kellyaf484012019-02-20 16:53:11 +0000229 ActivationLayer,
Nattapat Chaimanowong969eea32019-01-30 13:33:11 +0000230 AdditionLayer,
Mike Kellya0766c32019-02-19 17:22:07 +0000231 Convolution2dLayer,
Aron Virginas-Tarc04125f2019-02-19 16:31:08 +0000232 DepthwiseConvolution2dLayer,
Nattapat Chaimanowong969eea32019-01-30 13:33:11 +0000233 InputLayer,
Sadik Armagan5f450272019-02-12 14:31:45 +0000234 MultiplicationLayer,
Aron Virginas-Tarfc413c02019-02-13 15:41:52 +0000235 OutputLayer,
Saoirse Stewart3166c3e2019-02-18 15:24:53 +0000236 Pooling2dLayer,
Saoirse Stewart263829c2019-02-19 15:54:14 +0000237 ReshapeLayer,
Aron Virginas-Tarfc413c02019-02-13 15:41:52 +0000238 SoftmaxLayer
Nattapat Chaimanowong969eea32019-01-30 13:33:11 +0000239}
240
Saoirse Stewart49dbe0e2019-02-05 17:27:06 +0000241table AnyLayer {
242 layer:Layer;
243}
244
Nattapat Chaimanowong969eea32019-01-30 13:33:11 +0000245// Root type for serialized data is the graph of the network
246table SerializedGraph {
Saoirse Stewart49dbe0e2019-02-05 17:27:06 +0000247 layers:[AnyLayer];
Mike Kelly8c1701a2019-02-11 17:01:27 +0000248 inputIds:[uint];
249 outputIds:[uint];
Nattapat Chaimanowong969eea32019-01-30 13:33:11 +0000250}
251
252root_type SerializedGraph;