blob: 6c542b1b2dbe5d39e3f4f3ed15865dc4ee7b893b [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
6namespace armnn.armnnSerializer;
7
8file_identifier "ARMN";
9
10file_extension "armnn";
11
12enum DataType : byte {
13 Float16 = 0,
14 Float32 = 1,
15 QuantisedAsymm8 = 2,
16 Signed32 = 3,
17 Boolean = 4
18}
19
Saoirse Stewart3166c3e2019-02-18 15:24:53 +000020enum DataLayout : byte {
21 NHWC = 0,
22 NCHW = 1
23}
24
Nattapat Chaimanowong969eea32019-01-30 13:33:11 +000025table TensorInfo {
26 dimensions:[uint];
27 dataType:DataType;
28 quantizationScale:float = 1.0;
29 quantizationOffset:int = 0;
30}
31
32struct Connection {
33 sourceLayerIndex:uint;
34 outputSlotIndex:uint;
35}
36
37table ByteData {
38 data:[byte];
39}
40
41table ShortData {
42 data:[short];
43}
44
45table IntData {
46 data:[int];
47}
48
49table LongData {
50 data:[long];
51}
52
53union ConstTensorData { ByteData, ShortData, IntData, LongData }
54
55table ConstTensor {
56 info:TensorInfo;
57 data:ConstTensorData;
58}
59
60table InputSlot {
61 index:uint;
62 connection:Connection;
63}
64
65table OutputSlot {
66 index:uint;
67 tensorInfo:TensorInfo;
68}
69
70enum LayerType : uint {
71 Addition = 0,
72 Input = 1,
Sadik Armagan5f450272019-02-12 14:31:45 +000073 Multiplication = 2,
Aron Virginas-Tarfc413c02019-02-13 15:41:52 +000074 Output = 3,
Saoirse Stewart3166c3e2019-02-18 15:24:53 +000075 Pooling2d = 4,
Saoirse Stewart263829c2019-02-19 15:54:14 +000076 Reshape = 5,
Mike Kellya0766c32019-02-19 17:22:07 +000077 Softmax = 6,
Aron Virginas-Tarc04125f2019-02-19 16:31:08 +000078 Convolution2d = 7,
79 DepthwiseConvolution2d = 8
Nattapat Chaimanowong969eea32019-01-30 13:33:11 +000080}
81
82// Base layer table to be used as part of other layers
83table LayerBase {
84 index:uint;
85 layerName:string;
86 layerType:LayerType;
87 inputSlots:[InputSlot];
88 outputSlots:[OutputSlot];
89}
90
91table BindableLayerBase {
92 base:LayerBase;
93 layerBindingId:int;
94}
95
96// Table for each layer defined below
97table AdditionLayer {
98 base:LayerBase;
99}
100
Mike Kellya0766c32019-02-19 17:22:07 +0000101table Convolution2dLayer {
102 base:LayerBase;
103 descriptor:Convolution2dDescriptor;
104 weights:ConstTensor;
105 biases:ConstTensor;
106}
107
108table Convolution2dDescriptor {
109 padLeft:uint;
110 padRight:uint;
111 padTop:uint;
112 padBottom:uint;
113 strideX:uint;
114 strideY:uint;
115 biasEnabled:bool = false;
116 dataLayout:DataLayout = NCHW;
117}
118
Nattapat Chaimanowong969eea32019-01-30 13:33:11 +0000119table InputLayer {
120 base:BindableLayerBase;
121}
122
Sadik Armagan5f450272019-02-12 14:31:45 +0000123table MultiplicationLayer {
124 base:LayerBase;
125}
126
Saoirse Stewart3166c3e2019-02-18 15:24:53 +0000127table Pooling2dLayer {
128 base:LayerBase;
129 descriptor:Pooling2dDescriptor;
130}
131
132enum PoolingAlgorithm : byte {
133 Max = 0,
134 Average = 1,
135 L2 = 2
136}
137
138enum OutputShapeRounding : byte {
139 Floor = 0,
140 Ceiling = 1
141}
142
143enum PaddingMethod : byte {
144 IgnoreValue = 0,
145 Exclude = 1
146}
147
148table Pooling2dDescriptor {
149 poolType:PoolingAlgorithm;
150 padLeft:uint;
151 padRight:uint;
152 padTop:uint;
153 padBottom:uint;
154 poolWidth:uint;
155 poolHeight:uint;
156 strideX:uint;
157 strideY:uint;
158 outputShapeRounding:OutputShapeRounding;
159 paddingMethod:PaddingMethod;
160 dataLayout:DataLayout;
161}
162
Aron Virginas-Tarfc413c02019-02-13 15:41:52 +0000163table SoftmaxLayer {
164 base:LayerBase;
165 descriptor:SoftmaxDescriptor;
166}
167
168table SoftmaxDescriptor {
169 beta:float;
170}
171
Aron Virginas-Tarc04125f2019-02-19 16:31:08 +0000172table DepthwiseConvolution2dLayer {
173 base:LayerBase;
174 descriptor:DepthwiseConvolution2dDescriptor;
175 weights:ConstTensor;
176 biases:ConstTensor;
177}
178
179table DepthwiseConvolution2dDescriptor {
180 padLeft:uint;
181 padRight:uint;
182 padTop:uint;
183 padBottom:uint;
184 strideX:uint;
185 strideY:uint;
186 biasEnabled:bool = false;
187 dataLayout:DataLayout = NCHW;
188}
189
Nattapat Chaimanowong969eea32019-01-30 13:33:11 +0000190table OutputLayer {
191 base:BindableLayerBase;
192}
193
Saoirse Stewart263829c2019-02-19 15:54:14 +0000194table ReshapeLayer {
195 base:LayerBase;
196 descriptor:ReshapeDescriptor;
197}
198
199table ReshapeDescriptor {
200 targetShape:[uint];
201}
202
Nattapat Chaimanowong969eea32019-01-30 13:33:11 +0000203union Layer {
204 AdditionLayer,
Mike Kellya0766c32019-02-19 17:22:07 +0000205 Convolution2dLayer,
Aron Virginas-Tarc04125f2019-02-19 16:31:08 +0000206 DepthwiseConvolution2dLayer,
Nattapat Chaimanowong969eea32019-01-30 13:33:11 +0000207 InputLayer,
Sadik Armagan5f450272019-02-12 14:31:45 +0000208 MultiplicationLayer,
Aron Virginas-Tarfc413c02019-02-13 15:41:52 +0000209 OutputLayer,
Saoirse Stewart3166c3e2019-02-18 15:24:53 +0000210 Pooling2dLayer,
Saoirse Stewart263829c2019-02-19 15:54:14 +0000211 ReshapeLayer,
Aron Virginas-Tarfc413c02019-02-13 15:41:52 +0000212 SoftmaxLayer
Nattapat Chaimanowong969eea32019-01-30 13:33:11 +0000213}
214
Saoirse Stewart49dbe0e2019-02-05 17:27:06 +0000215table AnyLayer {
216 layer:Layer;
217}
218
Nattapat Chaimanowong969eea32019-01-30 13:33:11 +0000219// Root type for serialized data is the graph of the network
220table SerializedGraph {
Saoirse Stewart49dbe0e2019-02-05 17:27:06 +0000221 layers:[AnyLayer];
Mike Kelly8c1701a2019-02-11 17:01:27 +0000222 inputIds:[uint];
223 outputIds:[uint];
Nattapat Chaimanowong969eea32019-01-30 13:33:11 +0000224}
225
226root_type SerializedGraph;