blob: cbc7da066fccb08fe68b9fcae11e894c03675604 [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,
78 Convolution2d = 7
Nattapat Chaimanowong969eea32019-01-30 13:33:11 +000079}
80
81// Base layer table to be used as part of other layers
82table LayerBase {
83 index:uint;
84 layerName:string;
85 layerType:LayerType;
86 inputSlots:[InputSlot];
87 outputSlots:[OutputSlot];
88}
89
90table BindableLayerBase {
91 base:LayerBase;
92 layerBindingId:int;
93}
94
95// Table for each layer defined below
96table AdditionLayer {
97 base:LayerBase;
98}
99
Mike Kellya0766c32019-02-19 17:22:07 +0000100table Convolution2dLayer {
101 base:LayerBase;
102 descriptor:Convolution2dDescriptor;
103 weights:ConstTensor;
104 biases:ConstTensor;
105}
106
107table Convolution2dDescriptor {
108 padLeft:uint;
109 padRight:uint;
110 padTop:uint;
111 padBottom:uint;
112 strideX:uint;
113 strideY:uint;
114 biasEnabled:bool = false;
115 dataLayout:DataLayout = NCHW;
116}
117
Nattapat Chaimanowong969eea32019-01-30 13:33:11 +0000118table InputLayer {
119 base:BindableLayerBase;
120}
121
Sadik Armagan5f450272019-02-12 14:31:45 +0000122table MultiplicationLayer {
123 base:LayerBase;
124}
125
Saoirse Stewart3166c3e2019-02-18 15:24:53 +0000126table Pooling2dLayer {
127 base:LayerBase;
128 descriptor:Pooling2dDescriptor;
129}
130
131enum PoolingAlgorithm : byte {
132 Max = 0,
133 Average = 1,
134 L2 = 2
135}
136
137enum OutputShapeRounding : byte {
138 Floor = 0,
139 Ceiling = 1
140}
141
142enum PaddingMethod : byte {
143 IgnoreValue = 0,
144 Exclude = 1
145}
146
147table Pooling2dDescriptor {
148 poolType:PoolingAlgorithm;
149 padLeft:uint;
150 padRight:uint;
151 padTop:uint;
152 padBottom:uint;
153 poolWidth:uint;
154 poolHeight:uint;
155 strideX:uint;
156 strideY:uint;
157 outputShapeRounding:OutputShapeRounding;
158 paddingMethod:PaddingMethod;
159 dataLayout:DataLayout;
160}
161
Aron Virginas-Tarfc413c02019-02-13 15:41:52 +0000162table SoftmaxLayer {
163 base:LayerBase;
164 descriptor:SoftmaxDescriptor;
165}
166
167table SoftmaxDescriptor {
168 beta:float;
169}
170
Nattapat Chaimanowong969eea32019-01-30 13:33:11 +0000171table OutputLayer {
172 base:BindableLayerBase;
173}
174
Saoirse Stewart263829c2019-02-19 15:54:14 +0000175table ReshapeLayer {
176 base:LayerBase;
177 descriptor:ReshapeDescriptor;
178}
179
180table ReshapeDescriptor {
181 targetShape:[uint];
182}
183
Nattapat Chaimanowong969eea32019-01-30 13:33:11 +0000184union Layer {
185 AdditionLayer,
Mike Kellya0766c32019-02-19 17:22:07 +0000186 Convolution2dLayer,
Nattapat Chaimanowong969eea32019-01-30 13:33:11 +0000187 InputLayer,
Sadik Armagan5f450272019-02-12 14:31:45 +0000188 MultiplicationLayer,
Aron Virginas-Tarfc413c02019-02-13 15:41:52 +0000189 OutputLayer,
Saoirse Stewart3166c3e2019-02-18 15:24:53 +0000190 Pooling2dLayer,
Saoirse Stewart263829c2019-02-19 15:54:14 +0000191 ReshapeLayer,
Aron Virginas-Tarfc413c02019-02-13 15:41:52 +0000192 SoftmaxLayer
Nattapat Chaimanowong969eea32019-01-30 13:33:11 +0000193}
194
Saoirse Stewart49dbe0e2019-02-05 17:27:06 +0000195table AnyLayer {
196 layer:Layer;
197}
198
Nattapat Chaimanowong969eea32019-01-30 13:33:11 +0000199// Root type for serialized data is the graph of the network
200table SerializedGraph {
Saoirse Stewart49dbe0e2019-02-05 17:27:06 +0000201 layers:[AnyLayer];
Mike Kelly8c1701a2019-02-11 17:01:27 +0000202 inputIds:[uint];
203 outputIds:[uint];
Nattapat Chaimanowong969eea32019-01-30 13:33:11 +0000204}
205
206root_type SerializedGraph;