blob: 2b96ad8de12f997823fb22b9ff2d4931cd488eda [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,
77 Softmax = 6
Nattapat Chaimanowong969eea32019-01-30 13:33:11 +000078}
79
80// Base layer table to be used as part of other layers
81table LayerBase {
82 index:uint;
83 layerName:string;
84 layerType:LayerType;
85 inputSlots:[InputSlot];
86 outputSlots:[OutputSlot];
87}
88
89table BindableLayerBase {
90 base:LayerBase;
91 layerBindingId:int;
92}
93
94// Table for each layer defined below
95table AdditionLayer {
96 base:LayerBase;
97}
98
99table InputLayer {
100 base:BindableLayerBase;
101}
102
Sadik Armagan5f450272019-02-12 14:31:45 +0000103table MultiplicationLayer {
104 base:LayerBase;
105}
106
Saoirse Stewart3166c3e2019-02-18 15:24:53 +0000107table Pooling2dLayer {
108 base:LayerBase;
109 descriptor:Pooling2dDescriptor;
110}
111
112enum PoolingAlgorithm : byte {
113 Max = 0,
114 Average = 1,
115 L2 = 2
116}
117
118enum OutputShapeRounding : byte {
119 Floor = 0,
120 Ceiling = 1
121}
122
123enum PaddingMethod : byte {
124 IgnoreValue = 0,
125 Exclude = 1
126}
127
128table Pooling2dDescriptor {
129 poolType:PoolingAlgorithm;
130 padLeft:uint;
131 padRight:uint;
132 padTop:uint;
133 padBottom:uint;
134 poolWidth:uint;
135 poolHeight:uint;
136 strideX:uint;
137 strideY:uint;
138 outputShapeRounding:OutputShapeRounding;
139 paddingMethod:PaddingMethod;
140 dataLayout:DataLayout;
141}
142
Aron Virginas-Tarfc413c02019-02-13 15:41:52 +0000143table SoftmaxLayer {
144 base:LayerBase;
145 descriptor:SoftmaxDescriptor;
146}
147
148table SoftmaxDescriptor {
149 beta:float;
150}
151
Nattapat Chaimanowong969eea32019-01-30 13:33:11 +0000152table OutputLayer {
153 base:BindableLayerBase;
154}
155
Saoirse Stewart263829c2019-02-19 15:54:14 +0000156table ReshapeLayer {
157 base:LayerBase;
158 descriptor:ReshapeDescriptor;
159}
160
161table ReshapeDescriptor {
162 targetShape:[uint];
163}
164
Nattapat Chaimanowong969eea32019-01-30 13:33:11 +0000165union Layer {
166 AdditionLayer,
167 InputLayer,
Sadik Armagan5f450272019-02-12 14:31:45 +0000168 MultiplicationLayer,
Aron Virginas-Tarfc413c02019-02-13 15:41:52 +0000169 OutputLayer,
Saoirse Stewart3166c3e2019-02-18 15:24:53 +0000170 Pooling2dLayer,
Saoirse Stewart263829c2019-02-19 15:54:14 +0000171 ReshapeLayer,
Aron Virginas-Tarfc413c02019-02-13 15:41:52 +0000172 SoftmaxLayer
Nattapat Chaimanowong969eea32019-01-30 13:33:11 +0000173}
174
Saoirse Stewart49dbe0e2019-02-05 17:27:06 +0000175table AnyLayer {
176 layer:Layer;
177}
178
Nattapat Chaimanowong969eea32019-01-30 13:33:11 +0000179// Root type for serialized data is the graph of the network
180table SerializedGraph {
Saoirse Stewart49dbe0e2019-02-05 17:27:06 +0000181 layers:[AnyLayer];
Mike Kelly8c1701a2019-02-11 17:01:27 +0000182 inputIds:[uint];
183 outputIds:[uint];
Nattapat Chaimanowong969eea32019-01-30 13:33:11 +0000184}
185
186root_type SerializedGraph;