blob: a901b442abe11efbf5ebce011cdf22940e93cae9 [file] [log] [blame]
Pablo Tello299025a2017-09-29 11:30:12 +01001/*
2 * Copyright (c) 2017 ARM Limited.
3 *
4 * SPDX-License-Identifier: MIT
5 *
6 * Permission is hereby granted, free of charge, to any person obtaining a copy
7 * of this software and associated documentation files (the "Software"), to
8 * deal in the Software without restriction, including without limitation the
9 * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
10 * sell copies of the Software, and to permit persons to whom the Software is
11 * furnished to do so, subject to the following conditions:
12 *
13 * The above copyright notice and this permission notice shall be included in all
14 * copies or substantial portions of the Software.
15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 * SOFTWARE.
23 */
Gian Marco Iodiceab182122017-10-09 15:05:40 +010024#include "arm_compute/core/NEON/kernels/NEGEMMInterleaveBlockedKernel.h"
Pablo Tello181e6512017-11-15 13:28:27 +000025#include "arm_compute/core/NEON/kernels/arm64/NEGEMMLowpAArch64Kernel.h"
Pablo Tello299025a2017-09-29 11:30:12 +010026#include "arm_compute/core/Types.h"
Pablo Tello181e6512017-11-15 13:28:27 +000027#include "arm_compute/runtime/NEON/functions/NEGEMMLowpAssemblyMatrixMultiplyCore.h"
Gian Marcoe75a02b2017-11-08 12:24:09 +000028#include "arm_compute/runtime/NEON/functions/NEGEMMLowpMatrixMultiplyCore.h"
29#include "arm_compute/runtime/NEON/functions/NEGEMMLowpOutputStage.h"
Pablo Tello299025a2017-09-29 11:30:12 +010030#include "arm_compute/runtime/Tensor.h"
31#include "arm_compute/runtime/TensorAllocator.h"
32#include "tests/NEON/Accessor.h"
Gian Marco Iodiceab182122017-10-09 15:05:40 +010033#include "tests/NEON/Helper.h"
Gian Marcoe75a02b2017-11-08 12:24:09 +000034#include "tests/PaddingCalculator.h"
Gian Marcofa4cacd2017-10-18 17:05:02 +010035#include "tests/datasets/LargeGEMMLowpDataset.h"
Gian Marcoe75a02b2017-11-08 12:24:09 +000036#include "tests/datasets/ShapeDatasets.h"
Gian Marcofa4cacd2017-10-18 17:05:02 +010037#include "tests/datasets/SmallGEMMLowpDataset.h"
Pablo Tello299025a2017-09-29 11:30:12 +010038#include "tests/framework/Asserts.h"
39#include "tests/framework/Macros.h"
40#include "tests/framework/datasets/Datasets.h"
41#include "tests/validation/Validation.h"
Pablo Tellobf2fb952017-09-29 16:43:25 +010042#include "tests/validation/fixtures/GEMMInterleaveBlockedFixture.h"
Pablo Tello181e6512017-11-15 13:28:27 +000043#include "tests/validation/fixtures/GEMMLowpAssemblyFixture.h"
Pablo Tello299025a2017-09-29 11:30:12 +010044#include "tests/validation/fixtures/GEMMLowpFixture.h"
45
46namespace arm_compute
47{
48namespace test
49{
50namespace validation
51{
52namespace
53{
Pablo Tello181e6512017-11-15 13:28:27 +000054const auto data_int_blk = framework::dataset::make("M", 8, 12) * framework::dataset::make("N", 8, 12) * framework::dataset::make("by", 8, 13) * framework::dataset::make("block", 4, 9);
55const auto data_int_blk_tr = framework::dataset::make("M", 8, 17) * framework::dataset::make("N", 8, 14) * framework::dataset::make("by", 12) * framework::dataset::make("block", 4);
56const auto data_matrix_multiply = framework::dataset::make("M", 12, 20) * framework::dataset::make("N", 12, 20) * framework::dataset::make("K", 16);
Pablo Tello299025a2017-09-29 11:30:12 +010057} // namespace
58
59TEST_SUITE(NEON)
Pablo Tello181e6512017-11-15 13:28:27 +000060TEST_SUITE(ASSEMBLY_MATRIX_MULTIPLY)
Michalis Spyrouf3dfa272017-11-21 17:52:12 +000061
62using NEGEMMAssemblyFixture_S8 = GEMMLowpAssemblyFixture<Tensor, Accessor, NEGEMMLowpAssemblyMatrixMultiplyCore, int8_t>;
63using NEGEMMAssemblyFixture_U8 = GEMMLowpAssemblyFixture<Tensor, Accessor, NEGEMMLowpAssemblyMatrixMultiplyCore, uint8_t>;
64
65TEST_SUITE(S8)
66FIXTURE_DATA_TEST_CASE(RunSmall, NEGEMMAssemblyFixture_S8, framework::DatasetMode::PRECOMMIT, data_matrix_multiply)
Pablo Tello181e6512017-11-15 13:28:27 +000067{
68 // Validate output
69 validate(Accessor(_target), _reference);
70}
71TEST_SUITE_END()
72
Michalis Spyrouf3dfa272017-11-21 17:52:12 +000073TEST_SUITE(U8)
74FIXTURE_DATA_TEST_CASE(RunSmall, NEGEMMAssemblyFixture_U8, framework::DatasetMode::PRECOMMIT, data_matrix_multiply)
75{
76 // Validate output
77 validate(Accessor(_target), _reference);
78}
79TEST_SUITE_END()
80TEST_SUITE_END()
81
Pablo Tello299025a2017-09-29 11:30:12 +010082TEST_SUITE(GEMMLowp)
83
Pablo Tellobf2fb952017-09-29 16:43:25 +010084TEST_SUITE(INTERLEAVE_BLOCKED)
85
86using NEInterleaveBlocked = NESynthetizeFunction<NEGEMMInterleaveBlockedKernel>;
87using NEGEMMInterleaveBlockedFixture = GEMMInterleaveBlockedValidationFixture<Tensor, Accessor, NEInterleaveBlocked>;
88FIXTURE_DATA_TEST_CASE(RunSmall, NEGEMMInterleaveBlockedFixture, framework::DatasetMode::PRECOMMIT, data_int_blk)
89{
90 // Validate output
Gian Marcofa4cacd2017-10-18 17:05:02 +010091 validate(Accessor(_target), _reference);
Pablo Tellobf2fb952017-09-29 16:43:25 +010092}
93TEST_SUITE_END()
94
95TEST_SUITE(INTERLEAVE_BLOCKED_TRANSPOSED)
96using NEInterleaveBlockedTransposed = NESynthetizeFunction<NEGEMMInterleaveBlockedKernel>;
97using NEGEMMInterleaveBlockedTransposedFixture = GEMMInterleaveBlockedValidationFixture<Tensor, Accessor, NEInterleaveBlockedTransposed, true>;
98FIXTURE_DATA_TEST_CASE(RunSmall, NEGEMMInterleaveBlockedTransposedFixture, framework::DatasetMode::PRECOMMIT, data_int_blk_tr)
99{
100 // Validate output
Gian Marcofa4cacd2017-10-18 17:05:02 +0100101 validate(Accessor(_target), _reference);
Pablo Tellobf2fb952017-09-29 16:43:25 +0100102}
103
104TEST_SUITE_END()
105
Gian Marcoe75a02b2017-11-08 12:24:09 +0000106TEST_SUITE(MatrixMultiplyCore)
107using NEGEMMLowpMatrixMultiplyCoreFixture = GEMMLowpMatrixMultiplyCoreValidationFixture<Tensor, Accessor, NEGEMMLowpMatrixMultiplyCore>;
Gian Marcofa4cacd2017-10-18 17:05:02 +0100108
Gian Marcoe75a02b2017-11-08 12:24:09 +0000109DATA_TEST_CASE(Configuration, framework::DatasetMode::ALL, framework::dataset::concat(datasets::SmallGEMMLowpDataset(), datasets::LargeGEMMLowpDataset()),
110 shape_a, shape_b, shape_c, a_offset, b_offset)
Gian Marcofa4cacd2017-10-18 17:05:02 +0100111{
112 // Create tensors
Gian Marcoe75a02b2017-11-08 12:24:09 +0000113 Tensor a = create_tensor<Tensor>(shape_a, DataType::QASYMM8);
114 Tensor b = create_tensor<Tensor>(shape_b, DataType::QASYMM8);
115 Tensor c = create_tensor<Tensor>(shape_c, DataType::S32);
116
117 a.info()->set_quantization_info(QuantizationInfo(1.0f / 255, a_offset));
118 b.info()->set_quantization_info(QuantizationInfo(1.0f / 255, b_offset));
Gian Marcofa4cacd2017-10-18 17:05:02 +0100119
120 ARM_COMPUTE_EXPECT(a.info()->is_resizable(), framework::LogLevel::ERRORS);
121 ARM_COMPUTE_EXPECT(b.info()->is_resizable(), framework::LogLevel::ERRORS);
122 ARM_COMPUTE_EXPECT(c.info()->is_resizable(), framework::LogLevel::ERRORS);
123
124 // Create and configure function
Gian Marcoe75a02b2017-11-08 12:24:09 +0000125 NEGEMMLowpMatrixMultiplyCore gemmlowp_mm;
126 gemmlowp_mm.configure(&a, &b, &c);
Gian Marcofa4cacd2017-10-18 17:05:02 +0100127}
128
Georgios Pinitasa3b1b462017-11-16 19:24:39 +0000129// *INDENT-OFF*
130// clang-format off
131DATA_TEST_CASE(Validate, framework::DatasetMode::ALL, zip(zip(zip(
132 framework::dataset::make("InputAInfo", { TensorInfo(TensorShape(21U, 13U), 1, DataType::QASYMM8, QuantizationInfo(1.f/255, 10)), // Input not a multiple of 4
133 TensorInfo(TensorShape(21U, 13U), 1, DataType::QS8, 2), // Mismatching data type
134 TensorInfo(TensorShape(20U, 13U), 1, DataType::QASYMM8, QuantizationInfo(1.f/255, 10)), // Invalid dimensions
135 TensorInfo(TensorShape(21U, 13U), 1, DataType::QASYMM8, QuantizationInfo(1.f/255, 10)), // Invalid dimensions
136 TensorInfo(TensorShape(16U, 32U), 1, DataType::QASYMM8, QuantizationInfo(1.f/255, 10)),
137 }),
138 framework::dataset::make("InputBInfo",{ TensorInfo(TensorShape(33U, 21U), 1, DataType::QASYMM8, QuantizationInfo(1.f/256, 10)),
139 TensorInfo(TensorShape(33U, 21U), 1, DataType::QASYMM8, QuantizationInfo(1.f/256, 10)),
140 TensorInfo(TensorShape(33U, 21U), 1, DataType::QASYMM8, QuantizationInfo(1.f/256, 10)),
141 TensorInfo(TensorShape(33U, 21U), 1, DataType::QASYMM8, QuantizationInfo(1.f/256, 10)),
142 TensorInfo(TensorShape(64U, 16U), 1, DataType::QASYMM8, QuantizationInfo(1.f/256, 10)),
143 })),
144 framework::dataset::make("OutputInfo",{ TensorInfo(TensorShape(33U, 13U), 1, DataType::S32),
145 TensorInfo(TensorShape(33U, 13U), 1, DataType::S32),
146 TensorInfo(TensorShape(33U, 13U), 1, DataType::S32),
147 TensorInfo(TensorShape(8U, 11U), 1, DataType::S32),
148 TensorInfo(TensorShape(64U, 32U), 1, DataType::S32),
149 })),
Georgios Pinitas631c41a2017-12-06 11:53:03 +0000150 framework::dataset::make("Expected", { false, false, false, false, true })),
Georgios Pinitasa3b1b462017-11-16 19:24:39 +0000151 a_info, b_info, output_info, expected)
152{
153 // Lock tensors
Georgios Pinitas631c41a2017-12-06 11:53:03 +0000154 Status status = NEGEMMLowpMatrixMultiplyCore::validate(&a_info.clone()->set_is_resizable(false),
155 &b_info.clone()->set_is_resizable(false),
156 &output_info.clone()->set_is_resizable(false));
157 ARM_COMPUTE_EXPECT(bool(status) == expected, framework::LogLevel::ERRORS);
Georgios Pinitasa3b1b462017-11-16 19:24:39 +0000158}
159// clang-format on
160// *INDENT-ON*
161
Gian Marcoe75a02b2017-11-08 12:24:09 +0000162FIXTURE_DATA_TEST_CASE(RunSmall, NEGEMMLowpMatrixMultiplyCoreFixture, framework::DatasetMode::ALL, datasets::SmallGEMMLowpDataset())
Pablo Tello299025a2017-09-29 11:30:12 +0100163{
164 // Validate output
Gian Marcofa4cacd2017-10-18 17:05:02 +0100165 validate(Accessor(_target), _reference);
166}
167
Gian Marcoe75a02b2017-11-08 12:24:09 +0000168FIXTURE_DATA_TEST_CASE(RunLarge, NEGEMMLowpMatrixMultiplyCoreFixture, framework::DatasetMode::NIGHTLY, datasets::LargeGEMMLowpDataset())
Gian Marcofa4cacd2017-10-18 17:05:02 +0100169{
170 // Validate output
171 validate(Accessor(_target), _reference);
Pablo Tello299025a2017-09-29 11:30:12 +0100172}
Pablo Tello299025a2017-09-29 11:30:12 +0100173
Gian Marcoe75a02b2017-11-08 12:24:09 +0000174TEST_SUITE_END() // MatrixMultiplyCore
175
176TEST_SUITE(OutputStage)
177
178TEST_SUITE(QuantizeDownInt32ToUint8Scale)
179
Gian Marco05288a22017-11-21 10:57:50 +0000180const auto quantize_down_int32_to_uint8_scale_cases = framework::dataset::make("result_offset", -2, 1) * framework::dataset::make("result_mult_int", 1, 2) * framework::dataset::make("result_shift", 2,
Gian Marco6b77e912017-11-17 09:27:57 +0000181 3)
182 * framework::dataset::make("min", 0) * framework::dataset::make("max", 0) * framework::dataset::make("addBias", { false, true });
183
Gian Marco05288a22017-11-21 10:57:50 +0000184const auto quantize_down_int32_to_uint8_scale_relu_cases = framework::dataset::make("result_offset", -2, 1) * framework::dataset::make("result_mult_int", 1,
Gian Marco6b77e912017-11-17 09:27:57 +0000185 2)
186 * framework::dataset::make("result_shift", 2, 3) * framework::dataset::make("min", 0, 2) * framework::dataset::make("max", 171, 174) * framework::dataset::make("addBias", { false, true });
187
Gian Marcoe75a02b2017-11-08 12:24:09 +0000188using NEGEMMLowpQuantizeDownInt32ToUint8ScaleFixture = GEMMLowpQuantizeDownInt32ToUint8ScaleValidationFixture<Tensor, Accessor, NEGEMMLowpQuantizeDownInt32ToUint8Scale>;
189
Gian Marco7f0f7902017-12-07 09:26:56 +0000190// *INDENT-OFF*
191// clang-format off
192DATA_TEST_CASE(Validate, framework::DatasetMode::ALL, zip(zip(zip(zip(zip(
193 framework::dataset::make("InputAInfo", { TensorInfo(TensorShape(21U, 13U), 1, DataType::S32), // Input not a multiple of 16
194 TensorInfo(TensorShape(21U, 13U), 1, DataType::S32), // Invalid min and max
195 TensorInfo(TensorShape(20U, 13U), 1, DataType::S32), // Wrong output data type
196 }),
197 framework::dataset::make("InputBInfo",{ TensorInfo(TensorShape(21U), 1, DataType::S32),
198 TensorInfo(TensorShape(21U), 1, DataType::S32),
199 TensorInfo(TensorShape(20U), 1, DataType::S32),
200 })),
201 framework::dataset::make("OutputInfo",{ TensorInfo(TensorShape(21U, 13U), 1, DataType::QASYMM8),
202 TensorInfo(TensorShape(21U, 13U), 1, DataType::QASYMM8),
203 TensorInfo(TensorShape(20U, 13U), 1, DataType::S32),
204 })),
205 framework::dataset::make("Min",{ 0,
206 8,
207 13,
208 })),
209 framework::dataset::make("Max",{ 205,
210 300,
211 180,
212 })),
213 framework::dataset::make("Expected", { true, false, false })),
214 a_info, b_info, output_info, min, max, expected)
215{
216 // Lock tensors
217 Status status = NEGEMMLowpQuantizeDownInt32ToUint8Scale::validate(&a_info.clone()->set_is_resizable(false),
218 &b_info.clone()->set_is_resizable(false),
219 &output_info.clone()->set_is_resizable(false),
220 min,
221 max);
222 ARM_COMPUTE_EXPECT(bool(status) == expected, framework::LogLevel::ERRORS);
223}
224// clang-format on
225// *INDENT-ON*
226
Gian Marcoe75a02b2017-11-08 12:24:09 +0000227DATA_TEST_CASE(Configuration, framework::DatasetMode::ALL, combine(framework::dataset::concat(datasets::SmallShapes(), datasets::LargeShapes()), quantize_down_int32_to_uint8_scale_cases),
Gian Marco6b77e912017-11-17 09:27:57 +0000228 shape, result_offset, result_mult_int, result_shift, min, max, add_bias)
Gian Marcoe75a02b2017-11-08 12:24:09 +0000229{
Gian Marco6b77e912017-11-17 09:27:57 +0000230 TensorShape shape_bias(shape[0]);
231
Gian Marcoe75a02b2017-11-08 12:24:09 +0000232 // Create tensors
Gian Marco6b77e912017-11-17 09:27:57 +0000233 Tensor in = create_tensor<Tensor>(shape, DataType::S32);
234 Tensor bias = create_tensor<Tensor>(shape_bias, DataType::S32);
235 Tensor out = create_tensor<Tensor>(shape, DataType::QASYMM8);
Gian Marcoe75a02b2017-11-08 12:24:09 +0000236
237 ARM_COMPUTE_EXPECT(in.info()->is_resizable(), framework::LogLevel::ERRORS);
Gian Marco6b77e912017-11-17 09:27:57 +0000238 ARM_COMPUTE_EXPECT(bias.info()->is_resizable(), framework::LogLevel::ERRORS);
Gian Marcoe75a02b2017-11-08 12:24:09 +0000239 ARM_COMPUTE_EXPECT(out.info()->is_resizable(), framework::LogLevel::ERRORS);
240
241 // Create and configure function
242 NEGEMMLowpQuantizeDownInt32ToUint8Scale output_stage;
Gian Marco6b77e912017-11-17 09:27:57 +0000243 output_stage.configure(&in, add_bias ? &bias : nullptr, &out, result_offset, result_mult_int, result_shift, min, max);
Gian Marcoe75a02b2017-11-08 12:24:09 +0000244
Gian Marco6b77e912017-11-17 09:27:57 +0000245 // Validate valid region input and output
Gian Marcoe75a02b2017-11-08 12:24:09 +0000246 const ValidRegion valid_region = shape_to_valid_region(shape);
247 validate(in.info()->valid_region(), valid_region);
248 validate(out.info()->valid_region(), valid_region);
249
Gian Marco6b77e912017-11-17 09:27:57 +0000250 // Validate valid region bias
251 if(add_bias)
252 {
253 const ValidRegion valid_region_bias = shape_to_valid_region(shape_bias);
254 validate(bias.info()->valid_region(), valid_region_bias);
255 }
256
Gian Marcoe75a02b2017-11-08 12:24:09 +0000257 // Validate padding
Gian Marco7f0f7902017-12-07 09:26:56 +0000258 const PaddingSize padding(0);
Gian Marcoe75a02b2017-11-08 12:24:09 +0000259 validate(in.info()->padding(), padding);
260 validate(out.info()->padding(), padding);
Gian Marco6b77e912017-11-17 09:27:57 +0000261
262 if(add_bias)
263 {
264 validate(bias.info()->padding(), padding);
265 }
Gian Marcoe75a02b2017-11-08 12:24:09 +0000266}
267
268FIXTURE_DATA_TEST_CASE(RunSmall, NEGEMMLowpQuantizeDownInt32ToUint8ScaleFixture, framework::DatasetMode::ALL, combine(datasets::SmallShapes(), quantize_down_int32_to_uint8_scale_cases))
Pablo Tellobf2fb952017-09-29 16:43:25 +0100269{
270 // Validate output
Gian Marcofa4cacd2017-10-18 17:05:02 +0100271 validate(Accessor(_target), _reference);
Pablo Tellobf2fb952017-09-29 16:43:25 +0100272}
Pablo Tello6ff12a02017-11-02 16:09:35 +0000273
Gian Marcoe75a02b2017-11-08 12:24:09 +0000274FIXTURE_DATA_TEST_CASE(RunLarge, NEGEMMLowpQuantizeDownInt32ToUint8ScaleFixture, framework::DatasetMode::NIGHTLY, combine(datasets::LargeShapes(), quantize_down_int32_to_uint8_scale_cases))
275{
276 // Validate output
277 validate(Accessor(_target), _reference);
278}
279
Gian Marco6b77e912017-11-17 09:27:57 +0000280TEST_SUITE(BoundedReLu)
281FIXTURE_DATA_TEST_CASE(RunSmall, NEGEMMLowpQuantizeDownInt32ToUint8ScaleFixture, framework::DatasetMode::ALL, combine(datasets::SmallShapes(), quantize_down_int32_to_uint8_scale_relu_cases))
282{
283 // Validate output
284 validate(Accessor(_target), _reference);
285}
Gian Marcoe75a02b2017-11-08 12:24:09 +0000286
Gian Marco6b77e912017-11-17 09:27:57 +0000287FIXTURE_DATA_TEST_CASE(RunLarge, NEGEMMLowpQuantizeDownInt32ToUint8ScaleFixture, framework::DatasetMode::NIGHTLY, combine(datasets::LargeShapes(), quantize_down_int32_to_uint8_scale_relu_cases))
288{
289 // Validate output
290 validate(Accessor(_target), _reference);
291}
292TEST_SUITE_END() // BoundedReLu
293
Gian Marco6b77e912017-11-17 09:27:57 +0000294TEST_SUITE_END() // QuantizeDownInt32ToUint8Scale
Gian Marco58c57942017-11-28 09:10:03 +0000295
296TEST_SUITE(QuantizeDownInt32ToUint8ScaleByFixedPoint)
297
298const auto quantize_down_int32_to_uint8_scale_by_fixedpoint_cases = framework::dataset::make("result_fixedpoint_multiplier", 254601600, 254601602) * framework::dataset::make("result_shift", 1,
299 2)
300 * framework::dataset::make("result_offset_after_shift", 2, 3) * framework::dataset::make("min", 0) * framework::dataset::make("max", 0) * framework::dataset::make("addBias", { false, true });
301
302const auto quantize_down_int32_to_uint8_scale_by_fixedpoint_relu_cases = framework::dataset::make("result_fixedpoint_multiplier", 254601600, 254601602) * framework::dataset::make("result_shift", 1,
303 2)
304 * framework::dataset::make("result_offset_after_shift", 2, 3) * framework::dataset::make("min", 0, 2) * framework::dataset::make("max", 171, 174) * framework::dataset::make("addBias", { false, true });
305
306using NEGEMMLowpQuantizeDownInt32ToUint8ScaleByFixedPointFixture =
307 GEMMLowpQuantizeDownInt32ToUint8ScaleByFixedPointValidationFixture<Tensor, Accessor, NEGEMMLowpQuantizeDownInt32ToUint8ScaleByFixedPoint>;
308
Gian Marco7f0f7902017-12-07 09:26:56 +0000309// *INDENT-OFF*
310// clang-format off
311DATA_TEST_CASE(Validate, framework::DatasetMode::ALL, zip(zip(zip(zip(zip(
312 framework::dataset::make("InputAInfo", { TensorInfo(TensorShape(21U, 13U), 1, DataType::S32), // Input not a multiple of 16
313 TensorInfo(TensorShape(21U, 13U), 1, DataType::S32), // Invalid min and max
314 TensorInfo(TensorShape(20U, 13U), 1, DataType::S32), // Wrong output data type
315 }),
316 framework::dataset::make("InputBInfo",{ TensorInfo(TensorShape(21U), 1, DataType::S32),
317 TensorInfo(TensorShape(21U), 1, DataType::S32),
318 TensorInfo(TensorShape(20U), 1, DataType::S32),
319 })),
320 framework::dataset::make("OutputInfo",{ TensorInfo(TensorShape(21U, 13U), 1, DataType::QASYMM8),
321 TensorInfo(TensorShape(21U, 13U), 1, DataType::QASYMM8),
322 TensorInfo(TensorShape(20U, 13U), 1, DataType::S32),
323 })),
324 framework::dataset::make("Min",{ 0,
325 8,
326 13,
327 })),
328 framework::dataset::make("Max",{ 205,
329 300,
330 180,
331 })),
332 framework::dataset::make("Expected", { true, false, false })),
333 a_info, b_info, output_info, min, max, expected)
334{
335 // Lock tensors
336 Status status = NEGEMMLowpQuantizeDownInt32ToUint8ScaleByFixedPoint::validate(&a_info.clone()->set_is_resizable(false),
337 &b_info.clone()->set_is_resizable(false),
338 &output_info.clone()->set_is_resizable(false),
339 min,
340 max);
341 ARM_COMPUTE_EXPECT(bool(status) == expected, framework::LogLevel::ERRORS);
342}
343// clang-format on
344// *INDENT-ON*
345
Gian Marco58c57942017-11-28 09:10:03 +0000346DATA_TEST_CASE(Configuration, framework::DatasetMode::ALL, combine(framework::dataset::concat(datasets::SmallShapes(), datasets::LargeShapes()),
347 quantize_down_int32_to_uint8_scale_by_fixedpoint_cases),
348 shape, result_fixedpoint_multiplier, result_shift, result_offset_after_shift, min, max, add_bias)
349{
350 TensorShape shape_bias(shape[0]);
351
352 // Create tensors
353 Tensor in = create_tensor<Tensor>(shape, DataType::S32);
354 Tensor bias = create_tensor<Tensor>(shape_bias, DataType::S32);
355 Tensor out = create_tensor<Tensor>(shape, DataType::QASYMM8);
356
357 ARM_COMPUTE_EXPECT(in.info()->is_resizable(), framework::LogLevel::ERRORS);
358 ARM_COMPUTE_EXPECT(bias.info()->is_resizable(), framework::LogLevel::ERRORS);
359 ARM_COMPUTE_EXPECT(out.info()->is_resizable(), framework::LogLevel::ERRORS);
360
361 // Create and configure function
362 NEGEMMLowpQuantizeDownInt32ToUint8ScaleByFixedPoint output_stage;
363 output_stage.configure(&in, add_bias ? &bias : nullptr, &out, result_fixedpoint_multiplier, result_shift, result_offset_after_shift, min, max);
364
365 // Validate valid region input and output
366 const ValidRegion valid_region = shape_to_valid_region(shape);
367 validate(in.info()->valid_region(), valid_region);
368 validate(out.info()->valid_region(), valid_region);
369
370 // Validate valid region bias
371 if(add_bias)
372 {
373 const ValidRegion valid_region_bias = shape_to_valid_region(shape_bias);
374 validate(bias.info()->valid_region(), valid_region_bias);
375 }
376
377 // Validate padding
Gian Marco7f0f7902017-12-07 09:26:56 +0000378 const PaddingSize padding(0);
Gian Marco58c57942017-11-28 09:10:03 +0000379 validate(in.info()->padding(), padding);
380 validate(out.info()->padding(), padding);
381
382 if(add_bias)
383 {
384 validate(bias.info()->padding(), padding);
385 }
386}
387
388FIXTURE_DATA_TEST_CASE(RunSmall, NEGEMMLowpQuantizeDownInt32ToUint8ScaleByFixedPointFixture, framework::DatasetMode::ALL, combine(datasets::SmallShapes(),
389 quantize_down_int32_to_uint8_scale_by_fixedpoint_cases))
390{
391 // Validate output
392 validate(Accessor(_target), _reference);
393}
394
395FIXTURE_DATA_TEST_CASE(RunLarge, NEGEMMLowpQuantizeDownInt32ToUint8ScaleByFixedPointFixture, framework::DatasetMode::NIGHTLY, combine(datasets::LargeShapes(),
396 quantize_down_int32_to_uint8_scale_by_fixedpoint_cases))
397{
398 // Validate output
399 validate(Accessor(_target), _reference);
400}
401
402TEST_SUITE(BoundedReLu)
403FIXTURE_DATA_TEST_CASE(RunSmall, NEGEMMLowpQuantizeDownInt32ToUint8ScaleByFixedPointFixture, framework::DatasetMode::ALL, combine(datasets::SmallShapes(),
404 quantize_down_int32_to_uint8_scale_by_fixedpoint_relu_cases))
405{
406 // Validate output
407 validate(Accessor(_target), _reference);
408}
409
410FIXTURE_DATA_TEST_CASE(RunLarge, NEGEMMLowpQuantizeDownInt32ToUint8ScaleByFixedPointFixture, framework::DatasetMode::NIGHTLY, combine(datasets::LargeShapes(),
411 quantize_down_int32_to_uint8_scale_by_fixedpoint_relu_cases))
412{
413 // Validate output
414 validate(Accessor(_target), _reference);
415}
416TEST_SUITE_END() // BoundedReLu
417
418TEST_SUITE_END() // QuantizeDownInt32ToUint8ScaleByFixedPoint
Gian Marcoe75a02b2017-11-08 12:24:09 +0000419TEST_SUITE_END() // OutputStage
420
421TEST_SUITE_END() // GEMMLowp
422TEST_SUITE_END() // NEON
Pablo Tello299025a2017-09-29 11:30:12 +0100423} // namespace validation
424} // namespace test
425} // namespace arm_compute