blob: 23fd811cdb36d1e212cd4074d2477c8f7cb28ae0 [file] [log] [blame]
Matthew Sloyanb63a3112021-09-08 13:05:51 +01001//
2// Copyright © 2021 Arm Ltd and Contributors. All rights reserved.
3// SPDX-License-Identifier: MIT
4//
5
6#include "ParserFlatbuffersSerializeFixture.hpp"
7#include <armnnDeserializer/IDeserializer.hpp>
8
9#include <string>
10
11TEST_SUITE("Deserializer_Convolution3d")
12{
13struct Convolution3dFixture : public ParserFlatbuffersSerializeFixture
14{
15 explicit Convolution3dFixture(const std::string& inputShape,
16 const std::string& outputShape,
17 const std::string& weightsShape,
18 const std::string& dataType)
19 {
20 m_JsonString = R"(
21 {
22 inputIds: [0],
23 outputIds: [2],
24 layers: [
25 {
26 layer_type: "InputLayer",
27 layer: {
28 base: {
29 layerBindingId: 0,
30 base: {
31 layerName: "InputLayer",
32 layerType: "Input",
Matthew Sloyan5d7b0a32021-10-18 13:07:49 +010033 inputSlots: [
34
35 ],
Matthew Sloyanb63a3112021-09-08 13:05:51 +010036 outputSlots: [
37 {
Matthew Sloyanb63a3112021-09-08 13:05:51 +010038 tensorInfo: {
39 dimensions: )" + inputShape + R"(,
40 dataType: )" + dataType + R"(,
41 quantizationScale: 0.1,
42 dimensionSpecificity: [
43 true,
44 true,
45 true,
46 true,
47 true
48 ]
49 }
50 }
51 ]
52 }
53 }
54 }
55 },
56 {
Matthew Sloyan5d7b0a32021-10-18 13:07:49 +010057 layer_type: "ConstantLayer",
Matthew Sloyanb63a3112021-09-08 13:05:51 +010058 layer: {
59 base: {
60 index: 1,
Matthew Sloyan5d7b0a32021-10-18 13:07:49 +010061 layerName: "Weights",
62 layerType: "Constant",
Matthew Sloyanb63a3112021-09-08 13:05:51 +010063 inputSlots: [
Matthew Sloyan5d7b0a32021-10-18 13:07:49 +010064
Matthew Sloyanb63a3112021-09-08 13:05:51 +010065 ],
66 outputSlots: [
67 {
Matthew Sloyanb63a3112021-09-08 13:05:51 +010068 tensorInfo: {
Matthew Sloyan5d7b0a32021-10-18 13:07:49 +010069 dimensions: )" + weightsShape + R"(,
Matthew Sloyanb63a3112021-09-08 13:05:51 +010070 dataType: )" + dataType + R"(,
71 quantizationScale: 0.1,
72 dimensionSpecificity: [
73 true,
74 true,
75 true,
76 true,
77 true
78 ]
79 }
80 }
81 ]
82 },
Matthew Sloyan5d7b0a32021-10-18 13:07:49 +010083 input: {
Matthew Sloyanb63a3112021-09-08 13:05:51 +010084 info: {
85 dimensions: )" + weightsShape + R"(,
86 dataType: )" + dataType + R"(,
87 quantizationScale: 0.1,
88 dimensionSpecificity: [
89 true,
90 true,
91 true,
92 true,
93 true
94 ]
95 },
96 data_type: "ByteData",
97 data: {
98 data: [
99 1, 1, 1,
100 1, 1, 1,
101 1, 1, 1,
102
103 0, 0, 0,
104 0, 0, 0,
105 0, 0, 0,
106
107 0, 0, 0,
108 0, 0, 0,
109 0, 0, 0
110 ]
111 }
112 }
113 }
114 },
115 {
Matthew Sloyan5d7b0a32021-10-18 13:07:49 +0100116 layer_type: "Convolution3dLayer",
117 layer: {
118 base: {
119 index: 2,
120 layerName: "convolution3d",
121 layerType: "Convolution3d",
122 inputSlots: [
123 {
124 connection: {
125 sourceLayerIndex: 0,
126 outputSlotIndex: 0
127 }
128 },
129 {
130 index: 1,
131 connection: {
132 sourceLayerIndex: 1,
133 outputSlotIndex: 0
134 }
135 }
136 ],
137 outputSlots: [
138 {
139 tensorInfo: {
140 dimensions: )" + outputShape + R"(,
141 dataType: )" + dataType + R"(,
142 quantizationScale: 0.1,
143 dimensionSpecificity: [
144 true,
145 true,
146 true,
147 true,
148 true
149 ]
150 }
151 }
152 ]
153 },
154 descriptor: {
155 strideX: 2,
156 strideY: 2,
157 strideZ: 2
158 }
159 }
160 },
161 {
Matthew Sloyanb63a3112021-09-08 13:05:51 +0100162 layer_type: "OutputLayer",
163 layer: {
164 base: {
165 layerBindingId: 2,
166 base: {
Matthew Sloyan5d7b0a32021-10-18 13:07:49 +0100167 index: 3,
Matthew Sloyanb63a3112021-09-08 13:05:51 +0100168 layerName: "OutputLayer",
169 layerType: "Output",
170 inputSlots: [
171 {
172 connection: {
Matthew Sloyan5d7b0a32021-10-18 13:07:49 +0100173 sourceLayerIndex: 2,
Matthew Sloyanb63a3112021-09-08 13:05:51 +0100174 outputSlotIndex: 0
175 }
176 }
177 ],
Matthew Sloyan5d7b0a32021-10-18 13:07:49 +0100178 outputSlots: [
179
180 ]
Matthew Sloyanb63a3112021-09-08 13:05:51 +0100181 }
182 }
183 }
184 }
185 ],
186 featureVersions: {
187 bindingIdsScheme: 1,
188 weightsLayoutScheme: 1,
189 constantTensorsAsInputs: 1
190 }
191 }
192 )";
193 Setup();
194 }
195
196
197};
198
199struct SimpleConvolution3dFixture : Convolution3dFixture
200{
201 SimpleConvolution3dFixture() : Convolution3dFixture(
202 "[ 1, 5, 5, 5, 1 ]",
203 "[ 1, 2, 2, 2, 1 ]",
204 "[ 3, 3, 3, 1, 1 ]",
205 "QAsymmS8") {}
206};
207
208TEST_CASE_FIXTURE(SimpleConvolution3dFixture, "Convolution3dInt8")
209{
210 RunTest<5, armnn::DataType::QAsymmS8>(
211 0,
212 {{"InputLayer", { 0, 1, 2, 3, 4,
213 5, 6, 7, 8, 9,
214 10, 11, 12, 13, 14,
215 15, 16, 17, 18, 19,
216
217 20, 21, 22, 23, 24,
218 25, 26, 27, 28, 29,
219 30, 31, 32, 33, 34,
220 35, 36, 37, 38, 39,
221 40, 41, 42, 43, 44,
222
223 45, 46, 47, 48, 49,
224 50, 51, 52, 53, 54,
225 55, 56, 57, 58, 59,
226 60, 61, 62, 63, 64,
227 65, 66, 67, 68, 69,
228
229 70, 71, 72, 73, 74,
230 75, 76, 77, 78, 79,
231 80, 81, 82, 83, 84,
232 85, 86, 87, 88, 89,
233 90, 91, 92, 93, 94,
234 95, 96, 97, 98, 99,
235
236 100, 101, 102, 103, 104,
237 105, 106, 107, 108, 109,
238 110, 111, 112, 113, 114,
239 115, 116, 117, 118, 119,
240 120, 121, 122, 123, 124
241 }}},
242 {{"OutputLayer", {5, 7,
243
244 14, 16,
245
246 50, 52,
247
248 59, 61}}});
249}
250
251}