blob: 83dede15c688135ee127d5aa8027fd6292ea20fd [file] [log] [blame]
Jan Eilers53ef7952021-06-02 12:01:25 +01001//
2// Copyright © 2021 Arm Ltd and Contributors. All rights reserved.
3// SPDX-License-Identifier: MIT
4//
5
6#include "ParserFlatbuffersSerializeFixture.hpp"
7
8#include <armnnDeserializer/IDeserializer.hpp>
9
10#include <boost/test/unit_test.hpp>
11
12#include <string>
13
14BOOST_AUTO_TEST_SUITE(Deserializer)
15
16struct DepthwiseConv2dFlatbufferVersion1Fixture : public ParserFlatbuffersSerializeFixture
17{
18 explicit DepthwiseConv2dFlatbufferVersion1Fixture()
19 {
20 m_JsonString = R"(
21 {
22 "layers": [
23 {
24 "layer_type": "InputLayer",
25 "layer": {
26 "base": {
27 "base": {
28 "index": 0,
29 "layerName": "Input",
30 "layerType": "Input",
31 "inputSlots": [
32
33 ],
34 "outputSlots": [
35 {
36 "index": 0,
37 "tensorInfo": {
38 "dimensions": [
39 1,
40 3,
41 3,
42 3
43 ],
44 "dataType": "QAsymmS8",
45 "quantizationScale": 1.0,
46 "quantizationOffset": 0,
47 "quantizationDim": 0,
48 "dimensionality": 1,
49 "dimensionSpecificity": [
50 true,
51 true,
52 true,
53 true
54 ]
55 }
56 }
57 ]
58 },
59 "layerBindingId": 0
60 }
61 }
62 },
63 {
64 "layer_type": "DepthwiseConvolution2dLayer",
65 "layer": {
66 "base": {
67 "index": 1,
68 "layerName": "depwiseConvolution2dWithPerAxis",
69 "layerType": "DepthwiseConvolution2d",
70 "inputSlots": [
71 {
72 "index": 0,
73 "connection": {
74 "sourceLayerIndex": 0,
75 "outputSlotIndex": 0
76 }
77 }
78 ],
79 "outputSlots": [
80 {
81 "index": 0,
82 "tensorInfo": {
83 "dimensions": [
84 1,
85 3,
86 3,
87 3
88 ],
89 "dataType": "QAsymmS8",
90 "quantizationScale": 1.0,
91 "quantizationOffset": 0,
92 "quantizationDim": 0,
93 "dimensionality": 1,
94 "dimensionSpecificity": [
95 true,
96 true,
97 true,
98 true
99 ]
100 }
101 }
102 ]
103 },
104 "descriptor": {
105 "padLeft": 1,
106 "padRight": 1,
107 "padTop": 1,
108 "padBottom": 1,
109 "strideX": 1,
110 "strideY": 1,
111 "dilationX": 1,
112 "dilationY": 1,
113 "biasEnabled": false,
114 "dataLayout": "NHWC"
115 },
116 "weights": {
117 "info": {
118 "dimensions": [
119 1,
120 3,
121 3,
122 3
123 ],
124 "dataType": "QSymmS8",
125 "quantizationScale": 0.25,
126 "quantizationOffset": 0,
127 "quantizationScales": [
128 0.25,
129 0.2,
130 0.1
131 ],
132 "quantizationDim": 0,
133 "dimensionality": 1,
134 "dimensionSpecificity": [
135 true,
136 true,
137 true,
138 true
139 ]
140 },
141 "data_type": "ByteData",
142 "data": {
143 "data": [
144 4,
145 20,
146 0,
147 8,
148 20,
149 30,
150 4,
151 0,
152 10,
153 12,
154 0,
155 40,
156 0,
157 5,
158 30,
159 16,
160 10,
161 40,
162 12,
163 0,
164 30,
165 16,
166 20,
167 0,
168 12,
169 20,
170 20
171 ]
172 }
173 }
174 }
175 },
176 {
177 "layer_type": "OutputLayer",
178 "layer": {
179 "base": {
180 "base": {
181 "index": 2,
182 "layerName": "Output",
183 "layerType": "Output",
184 "inputSlots": [
185 {
186 "index": 0,
187 "connection": {
188 "sourceLayerIndex": 1,
189 "outputSlotIndex": 0
190 }
191 }
192 ],
193 "outputSlots": [
194
195 ]
196 },
197 "layerBindingId": 0
198 }
199 }
200 }
201 ],
202 "inputIds": [
203 0
204 ],
205 "outputIds": [
206 0
207 ],
208 "featureVersions": {
209 "bindingIdsScheme": 1
210 }
211 }
212 )";
213 SetupSingleInputSingleOutput("Input", "Output");
214 }
215};
216
217// This test uses a model that was created before weights layout scheme version was added to our flatbuffers
218// file. It ensures older models can still be read and executed
219// featureVersion weights layout scheme 1 indicates a change in the depthwise weights layout within
220// armm from [M,I,H,W] --> [1,H,W,I*M]
221BOOST_FIXTURE_TEST_CASE(DepthwiseConv2d_FlatbufferVersion1, DepthwiseConv2dFlatbufferVersion1Fixture)
222{
223 RunTest<4, armnn::DataType::QAsymmS8>(
224 0,
225 { 3,2,0,0,4,3,0,1,2,
226 0,1,3,0,4,2,2,2,3,
227 2,4,3,2,0,4,3,4,0},
228 { 15,60,10,11,37,20, 0,18,17,
229 20,65,28,28,74,26,12,20,18,
230 25,36,12,37,42,25,29,14, 9});
231}
232
233BOOST_AUTO_TEST_SUITE_END()