blob: 9eba3c85c16cb2ab3672e495503efe1b8ce7cc1e [file] [log] [blame]
Pablo Tello299025a2017-09-29 11:30:12 +01001/*
Pablo Telloeb82fd22018-02-23 13:43:50 +00002 * Copyright (c) 2017-2018 ARM Limited.
Pablo Tello299025a2017-09-29 11:30:12 +01003 *
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 */
24#include "arm_compute/core/Types.h"
Pablo Tello181e6512017-11-15 13:28:27 +000025#include "arm_compute/runtime/NEON/functions/NEGEMMLowpAssemblyMatrixMultiplyCore.h"
Gian Marcoe75a02b2017-11-08 12:24:09 +000026#include "arm_compute/runtime/NEON/functions/NEGEMMLowpMatrixMultiplyCore.h"
27#include "arm_compute/runtime/NEON/functions/NEGEMMLowpOutputStage.h"
Pablo Tello299025a2017-09-29 11:30:12 +010028#include "arm_compute/runtime/Tensor.h"
29#include "arm_compute/runtime/TensorAllocator.h"
30#include "tests/NEON/Accessor.h"
Gian Marco Iodiceab182122017-10-09 15:05:40 +010031#include "tests/NEON/Helper.h"
Gian Marcoe75a02b2017-11-08 12:24:09 +000032#include "tests/PaddingCalculator.h"
Gian Marcofa4cacd2017-10-18 17:05:02 +010033#include "tests/datasets/LargeGEMMLowpDataset.h"
Gian Marcoe75a02b2017-11-08 12:24:09 +000034#include "tests/datasets/ShapeDatasets.h"
Gian Marcofa4cacd2017-10-18 17:05:02 +010035#include "tests/datasets/SmallGEMMLowpDataset.h"
Pablo Tello299025a2017-09-29 11:30:12 +010036#include "tests/framework/Asserts.h"
37#include "tests/framework/Macros.h"
38#include "tests/framework/datasets/Datasets.h"
39#include "tests/validation/Validation.h"
Pablo Tello181e6512017-11-15 13:28:27 +000040#include "tests/validation/fixtures/GEMMLowpAssemblyFixture.h"
Pablo Tello299025a2017-09-29 11:30:12 +010041#include "tests/validation/fixtures/GEMMLowpFixture.h"
42
43namespace arm_compute
44{
45namespace test
46{
47namespace validation
48{
49namespace
50{
Pablo Tello181e6512017-11-15 13:28:27 +000051const 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 +010052} // namespace
53
54TEST_SUITE(NEON)
Pablo Tello181e6512017-11-15 13:28:27 +000055TEST_SUITE(ASSEMBLY_MATRIX_MULTIPLY)
Michalis Spyrouf3dfa272017-11-21 17:52:12 +000056
57using NEGEMMAssemblyFixture_S8 = GEMMLowpAssemblyFixture<Tensor, Accessor, NEGEMMLowpAssemblyMatrixMultiplyCore, int8_t>;
58using NEGEMMAssemblyFixture_U8 = GEMMLowpAssemblyFixture<Tensor, Accessor, NEGEMMLowpAssemblyMatrixMultiplyCore, uint8_t>;
59
60TEST_SUITE(S8)
61FIXTURE_DATA_TEST_CASE(RunSmall, NEGEMMAssemblyFixture_S8, framework::DatasetMode::PRECOMMIT, data_matrix_multiply)
Pablo Tello181e6512017-11-15 13:28:27 +000062{
63 // Validate output
64 validate(Accessor(_target), _reference);
65}
66TEST_SUITE_END()
67
Michalis Spyrouf3dfa272017-11-21 17:52:12 +000068TEST_SUITE(U8)
69FIXTURE_DATA_TEST_CASE(RunSmall, NEGEMMAssemblyFixture_U8, framework::DatasetMode::PRECOMMIT, data_matrix_multiply)
70{
71 // Validate output
72 validate(Accessor(_target), _reference);
73}
74TEST_SUITE_END()
75TEST_SUITE_END()
76
Pablo Tello299025a2017-09-29 11:30:12 +010077TEST_SUITE(GEMMLowp)
Gian Marcoe75a02b2017-11-08 12:24:09 +000078TEST_SUITE(MatrixMultiplyCore)
79using NEGEMMLowpMatrixMultiplyCoreFixture = GEMMLowpMatrixMultiplyCoreValidationFixture<Tensor, Accessor, NEGEMMLowpMatrixMultiplyCore>;
Gian Marcofa4cacd2017-10-18 17:05:02 +010080
Gian Marcoe75a02b2017-11-08 12:24:09 +000081DATA_TEST_CASE(Configuration, framework::DatasetMode::ALL, framework::dataset::concat(datasets::SmallGEMMLowpDataset(), datasets::LargeGEMMLowpDataset()),
82 shape_a, shape_b, shape_c, a_offset, b_offset)
Gian Marcofa4cacd2017-10-18 17:05:02 +010083{
84 // Create tensors
Gian Marcoe75a02b2017-11-08 12:24:09 +000085 Tensor a = create_tensor<Tensor>(shape_a, DataType::QASYMM8);
86 Tensor b = create_tensor<Tensor>(shape_b, DataType::QASYMM8);
87 Tensor c = create_tensor<Tensor>(shape_c, DataType::S32);
88
89 a.info()->set_quantization_info(QuantizationInfo(1.0f / 255, a_offset));
90 b.info()->set_quantization_info(QuantizationInfo(1.0f / 255, b_offset));
Gian Marcofa4cacd2017-10-18 17:05:02 +010091
92 ARM_COMPUTE_EXPECT(a.info()->is_resizable(), framework::LogLevel::ERRORS);
93 ARM_COMPUTE_EXPECT(b.info()->is_resizable(), framework::LogLevel::ERRORS);
94 ARM_COMPUTE_EXPECT(c.info()->is_resizable(), framework::LogLevel::ERRORS);
95
96 // Create and configure function
Gian Marcoe75a02b2017-11-08 12:24:09 +000097 NEGEMMLowpMatrixMultiplyCore gemmlowp_mm;
98 gemmlowp_mm.configure(&a, &b, &c);
Gian Marcofa4cacd2017-10-18 17:05:02 +010099}
100
Georgios Pinitasa3b1b462017-11-16 19:24:39 +0000101// *INDENT-OFF*
102// clang-format off
103DATA_TEST_CASE(Validate, framework::DatasetMode::ALL, zip(zip(zip(
104 framework::dataset::make("InputAInfo", { TensorInfo(TensorShape(21U, 13U), 1, DataType::QASYMM8, QuantizationInfo(1.f/255, 10)), // Input not a multiple of 4
Vidhya Sudhan Loganathan7485d5a2018-07-04 09:34:00 +0100105 TensorInfo(TensorShape(21U, 13U), 1, DataType::S32), // Mismatching data type
Georgios Pinitasa3b1b462017-11-16 19:24:39 +0000106 TensorInfo(TensorShape(20U, 13U), 1, DataType::QASYMM8, QuantizationInfo(1.f/255, 10)), // Invalid dimensions
107 TensorInfo(TensorShape(21U, 13U), 1, DataType::QASYMM8, QuantizationInfo(1.f/255, 10)), // Invalid dimensions
108 TensorInfo(TensorShape(16U, 32U), 1, DataType::QASYMM8, QuantizationInfo(1.f/255, 10)),
109 }),
110 framework::dataset::make("InputBInfo",{ TensorInfo(TensorShape(33U, 21U), 1, DataType::QASYMM8, QuantizationInfo(1.f/256, 10)),
111 TensorInfo(TensorShape(33U, 21U), 1, DataType::QASYMM8, QuantizationInfo(1.f/256, 10)),
112 TensorInfo(TensorShape(33U, 21U), 1, DataType::QASYMM8, QuantizationInfo(1.f/256, 10)),
113 TensorInfo(TensorShape(33U, 21U), 1, DataType::QASYMM8, QuantizationInfo(1.f/256, 10)),
114 TensorInfo(TensorShape(64U, 16U), 1, DataType::QASYMM8, QuantizationInfo(1.f/256, 10)),
115 })),
116 framework::dataset::make("OutputInfo",{ TensorInfo(TensorShape(33U, 13U), 1, DataType::S32),
117 TensorInfo(TensorShape(33U, 13U), 1, DataType::S32),
118 TensorInfo(TensorShape(33U, 13U), 1, DataType::S32),
119 TensorInfo(TensorShape(8U, 11U), 1, DataType::S32),
120 TensorInfo(TensorShape(64U, 32U), 1, DataType::S32),
121 })),
Georgios Pinitas631c41a2017-12-06 11:53:03 +0000122 framework::dataset::make("Expected", { false, false, false, false, true })),
Georgios Pinitasa3b1b462017-11-16 19:24:39 +0000123 a_info, b_info, output_info, expected)
124{
125 // Lock tensors
Georgios Pinitas631c41a2017-12-06 11:53:03 +0000126 Status status = NEGEMMLowpMatrixMultiplyCore::validate(&a_info.clone()->set_is_resizable(false),
127 &b_info.clone()->set_is_resizable(false),
128 &output_info.clone()->set_is_resizable(false));
129 ARM_COMPUTE_EXPECT(bool(status) == expected, framework::LogLevel::ERRORS);
Georgios Pinitasa3b1b462017-11-16 19:24:39 +0000130}
131// clang-format on
132// *INDENT-ON*
133
Gian Marcoe75a02b2017-11-08 12:24:09 +0000134FIXTURE_DATA_TEST_CASE(RunSmall, NEGEMMLowpMatrixMultiplyCoreFixture, framework::DatasetMode::ALL, datasets::SmallGEMMLowpDataset())
Pablo Tello299025a2017-09-29 11:30:12 +0100135{
136 // Validate output
Gian Marcofa4cacd2017-10-18 17:05:02 +0100137 validate(Accessor(_target), _reference);
138}
139
Gian Marcoe75a02b2017-11-08 12:24:09 +0000140FIXTURE_DATA_TEST_CASE(RunLarge, NEGEMMLowpMatrixMultiplyCoreFixture, framework::DatasetMode::NIGHTLY, datasets::LargeGEMMLowpDataset())
Gian Marcofa4cacd2017-10-18 17:05:02 +0100141{
142 // Validate output
143 validate(Accessor(_target), _reference);
Pablo Tello299025a2017-09-29 11:30:12 +0100144}
Pablo Tello299025a2017-09-29 11:30:12 +0100145
Gian Marcoe75a02b2017-11-08 12:24:09 +0000146TEST_SUITE_END() // MatrixMultiplyCore
147
148TEST_SUITE(OutputStage)
149
150TEST_SUITE(QuantizeDownInt32ToUint8Scale)
151
Gian Marco05288a22017-11-21 10:57:50 +0000152const 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 +0000153 3)
154 * framework::dataset::make("min", 0) * framework::dataset::make("max", 0) * framework::dataset::make("addBias", { false, true });
155
Gian Marco05288a22017-11-21 10:57:50 +0000156const 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 +0000157 2)
158 * 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 });
159
Gian Marcoe75a02b2017-11-08 12:24:09 +0000160using NEGEMMLowpQuantizeDownInt32ToUint8ScaleFixture = GEMMLowpQuantizeDownInt32ToUint8ScaleValidationFixture<Tensor, Accessor, NEGEMMLowpQuantizeDownInt32ToUint8Scale>;
161
Gian Marco7f0f7902017-12-07 09:26:56 +0000162// *INDENT-OFF*
163// clang-format off
164DATA_TEST_CASE(Validate, framework::DatasetMode::ALL, zip(zip(zip(zip(zip(
165 framework::dataset::make("InputAInfo", { TensorInfo(TensorShape(21U, 13U), 1, DataType::S32), // Input not a multiple of 16
166 TensorInfo(TensorShape(21U, 13U), 1, DataType::S32), // Invalid min and max
167 TensorInfo(TensorShape(20U, 13U), 1, DataType::S32), // Wrong output data type
168 }),
169 framework::dataset::make("InputBInfo",{ TensorInfo(TensorShape(21U), 1, DataType::S32),
170 TensorInfo(TensorShape(21U), 1, DataType::S32),
171 TensorInfo(TensorShape(20U), 1, DataType::S32),
172 })),
173 framework::dataset::make("OutputInfo",{ TensorInfo(TensorShape(21U, 13U), 1, DataType::QASYMM8),
174 TensorInfo(TensorShape(21U, 13U), 1, DataType::QASYMM8),
175 TensorInfo(TensorShape(20U, 13U), 1, DataType::S32),
176 })),
177 framework::dataset::make("Min",{ 0,
178 8,
179 13,
180 })),
181 framework::dataset::make("Max",{ 205,
182 300,
183 180,
184 })),
185 framework::dataset::make("Expected", { true, false, false })),
186 a_info, b_info, output_info, min, max, expected)
187{
188 // Lock tensors
189 Status status = NEGEMMLowpQuantizeDownInt32ToUint8Scale::validate(&a_info.clone()->set_is_resizable(false),
190 &b_info.clone()->set_is_resizable(false),
191 &output_info.clone()->set_is_resizable(false),
192 min,
193 max);
194 ARM_COMPUTE_EXPECT(bool(status) == expected, framework::LogLevel::ERRORS);
195}
196// clang-format on
197// *INDENT-ON*
198
Gian Marcoe75a02b2017-11-08 12:24:09 +0000199DATA_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 +0000200 shape, result_offset, result_mult_int, result_shift, min, max, add_bias)
Gian Marcoe75a02b2017-11-08 12:24:09 +0000201{
Gian Marco6b77e912017-11-17 09:27:57 +0000202 TensorShape shape_bias(shape[0]);
203
Gian Marcoe75a02b2017-11-08 12:24:09 +0000204 // Create tensors
Gian Marco6b77e912017-11-17 09:27:57 +0000205 Tensor in = create_tensor<Tensor>(shape, DataType::S32);
206 Tensor bias = create_tensor<Tensor>(shape_bias, DataType::S32);
207 Tensor out = create_tensor<Tensor>(shape, DataType::QASYMM8);
Gian Marcoe75a02b2017-11-08 12:24:09 +0000208
209 ARM_COMPUTE_EXPECT(in.info()->is_resizable(), framework::LogLevel::ERRORS);
Gian Marco6b77e912017-11-17 09:27:57 +0000210 ARM_COMPUTE_EXPECT(bias.info()->is_resizable(), framework::LogLevel::ERRORS);
Gian Marcoe75a02b2017-11-08 12:24:09 +0000211 ARM_COMPUTE_EXPECT(out.info()->is_resizable(), framework::LogLevel::ERRORS);
212
213 // Create and configure function
214 NEGEMMLowpQuantizeDownInt32ToUint8Scale output_stage;
Gian Marco6b77e912017-11-17 09:27:57 +0000215 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 +0000216
Gian Marco6b77e912017-11-17 09:27:57 +0000217 // Validate valid region input and output
Gian Marcoe75a02b2017-11-08 12:24:09 +0000218 const ValidRegion valid_region = shape_to_valid_region(shape);
219 validate(in.info()->valid_region(), valid_region);
220 validate(out.info()->valid_region(), valid_region);
221
Gian Marco6b77e912017-11-17 09:27:57 +0000222 // Validate valid region bias
223 if(add_bias)
224 {
225 const ValidRegion valid_region_bias = shape_to_valid_region(shape_bias);
226 validate(bias.info()->valid_region(), valid_region_bias);
227 }
228
Gian Marcoe75a02b2017-11-08 12:24:09 +0000229 // Validate padding
Gian Marco7f0f7902017-12-07 09:26:56 +0000230 const PaddingSize padding(0);
Gian Marcoe75a02b2017-11-08 12:24:09 +0000231 validate(in.info()->padding(), padding);
232 validate(out.info()->padding(), padding);
Gian Marco6b77e912017-11-17 09:27:57 +0000233
234 if(add_bias)
235 {
236 validate(bias.info()->padding(), padding);
237 }
Gian Marcoe75a02b2017-11-08 12:24:09 +0000238}
239
240FIXTURE_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 +0100241{
242 // Validate output
Gian Marcofa4cacd2017-10-18 17:05:02 +0100243 validate(Accessor(_target), _reference);
Pablo Tellobf2fb952017-09-29 16:43:25 +0100244}
Pablo Tello6ff12a02017-11-02 16:09:35 +0000245
Gian Marcoe75a02b2017-11-08 12:24:09 +0000246FIXTURE_DATA_TEST_CASE(RunLarge, NEGEMMLowpQuantizeDownInt32ToUint8ScaleFixture, framework::DatasetMode::NIGHTLY, combine(datasets::LargeShapes(), quantize_down_int32_to_uint8_scale_cases))
247{
248 // Validate output
249 validate(Accessor(_target), _reference);
250}
251
Gian Marco6b77e912017-11-17 09:27:57 +0000252TEST_SUITE(BoundedReLu)
253FIXTURE_DATA_TEST_CASE(RunSmall, NEGEMMLowpQuantizeDownInt32ToUint8ScaleFixture, framework::DatasetMode::ALL, combine(datasets::SmallShapes(), quantize_down_int32_to_uint8_scale_relu_cases))
254{
255 // Validate output
256 validate(Accessor(_target), _reference);
257}
Gian Marcoe75a02b2017-11-08 12:24:09 +0000258
Gian Marco6b77e912017-11-17 09:27:57 +0000259FIXTURE_DATA_TEST_CASE(RunLarge, NEGEMMLowpQuantizeDownInt32ToUint8ScaleFixture, framework::DatasetMode::NIGHTLY, combine(datasets::LargeShapes(), quantize_down_int32_to_uint8_scale_relu_cases))
260{
261 // Validate output
262 validate(Accessor(_target), _reference);
263}
264TEST_SUITE_END() // BoundedReLu
265
Gian Marco6b77e912017-11-17 09:27:57 +0000266TEST_SUITE_END() // QuantizeDownInt32ToUint8Scale
Gian Marco58c57942017-11-28 09:10:03 +0000267
268TEST_SUITE(QuantizeDownInt32ToUint8ScaleByFixedPoint)
269
270const auto quantize_down_int32_to_uint8_scale_by_fixedpoint_cases = framework::dataset::make("result_fixedpoint_multiplier", 254601600, 254601602) * framework::dataset::make("result_shift", 1,
271 2)
272 * 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 });
273
274const 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,
275 2)
276 * 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 });
277
278using NEGEMMLowpQuantizeDownInt32ToUint8ScaleByFixedPointFixture =
279 GEMMLowpQuantizeDownInt32ToUint8ScaleByFixedPointValidationFixture<Tensor, Accessor, NEGEMMLowpQuantizeDownInt32ToUint8ScaleByFixedPoint>;
280
Gian Marco7f0f7902017-12-07 09:26:56 +0000281// *INDENT-OFF*
282// clang-format off
283DATA_TEST_CASE(Validate, framework::DatasetMode::ALL, zip(zip(zip(zip(zip(
284 framework::dataset::make("InputAInfo", { TensorInfo(TensorShape(21U, 13U), 1, DataType::S32), // Input not a multiple of 16
285 TensorInfo(TensorShape(21U, 13U), 1, DataType::S32), // Invalid min and max
286 TensorInfo(TensorShape(20U, 13U), 1, DataType::S32), // Wrong output data type
287 }),
288 framework::dataset::make("InputBInfo",{ TensorInfo(TensorShape(21U), 1, DataType::S32),
289 TensorInfo(TensorShape(21U), 1, DataType::S32),
290 TensorInfo(TensorShape(20U), 1, DataType::S32),
291 })),
292 framework::dataset::make("OutputInfo",{ TensorInfo(TensorShape(21U, 13U), 1, DataType::QASYMM8),
293 TensorInfo(TensorShape(21U, 13U), 1, DataType::QASYMM8),
294 TensorInfo(TensorShape(20U, 13U), 1, DataType::S32),
295 })),
296 framework::dataset::make("Min",{ 0,
297 8,
298 13,
299 })),
300 framework::dataset::make("Max",{ 205,
301 300,
302 180,
303 })),
304 framework::dataset::make("Expected", { true, false, false })),
305 a_info, b_info, output_info, min, max, expected)
306{
307 // Lock tensors
308 Status status = NEGEMMLowpQuantizeDownInt32ToUint8ScaleByFixedPoint::validate(&a_info.clone()->set_is_resizable(false),
309 &b_info.clone()->set_is_resizable(false),
310 &output_info.clone()->set_is_resizable(false),
311 min,
312 max);
313 ARM_COMPUTE_EXPECT(bool(status) == expected, framework::LogLevel::ERRORS);
314}
315// clang-format on
316// *INDENT-ON*
317
Gian Marco58c57942017-11-28 09:10:03 +0000318DATA_TEST_CASE(Configuration, framework::DatasetMode::ALL, combine(framework::dataset::concat(datasets::SmallShapes(), datasets::LargeShapes()),
319 quantize_down_int32_to_uint8_scale_by_fixedpoint_cases),
320 shape, result_fixedpoint_multiplier, result_shift, result_offset_after_shift, min, max, add_bias)
321{
322 TensorShape shape_bias(shape[0]);
323
324 // Create tensors
325 Tensor in = create_tensor<Tensor>(shape, DataType::S32);
326 Tensor bias = create_tensor<Tensor>(shape_bias, DataType::S32);
327 Tensor out = create_tensor<Tensor>(shape, DataType::QASYMM8);
328
329 ARM_COMPUTE_EXPECT(in.info()->is_resizable(), framework::LogLevel::ERRORS);
330 ARM_COMPUTE_EXPECT(bias.info()->is_resizable(), framework::LogLevel::ERRORS);
331 ARM_COMPUTE_EXPECT(out.info()->is_resizable(), framework::LogLevel::ERRORS);
332
333 // Create and configure function
334 NEGEMMLowpQuantizeDownInt32ToUint8ScaleByFixedPoint output_stage;
335 output_stage.configure(&in, add_bias ? &bias : nullptr, &out, result_fixedpoint_multiplier, result_shift, result_offset_after_shift, min, max);
336
337 // Validate valid region input and output
338 const ValidRegion valid_region = shape_to_valid_region(shape);
339 validate(in.info()->valid_region(), valid_region);
340 validate(out.info()->valid_region(), valid_region);
341
342 // Validate valid region bias
343 if(add_bias)
344 {
345 const ValidRegion valid_region_bias = shape_to_valid_region(shape_bias);
346 validate(bias.info()->valid_region(), valid_region_bias);
347 }
348
349 // Validate padding
Gian Marco7f0f7902017-12-07 09:26:56 +0000350 const PaddingSize padding(0);
Gian Marco58c57942017-11-28 09:10:03 +0000351 validate(in.info()->padding(), padding);
352 validate(out.info()->padding(), padding);
353
354 if(add_bias)
355 {
356 validate(bias.info()->padding(), padding);
357 }
358}
359
360FIXTURE_DATA_TEST_CASE(RunSmall, NEGEMMLowpQuantizeDownInt32ToUint8ScaleByFixedPointFixture, framework::DatasetMode::ALL, combine(datasets::SmallShapes(),
361 quantize_down_int32_to_uint8_scale_by_fixedpoint_cases))
362{
363 // Validate output
364 validate(Accessor(_target), _reference);
365}
366
367FIXTURE_DATA_TEST_CASE(RunLarge, NEGEMMLowpQuantizeDownInt32ToUint8ScaleByFixedPointFixture, framework::DatasetMode::NIGHTLY, combine(datasets::LargeShapes(),
368 quantize_down_int32_to_uint8_scale_by_fixedpoint_cases))
369{
370 // Validate output
371 validate(Accessor(_target), _reference);
372}
373
374TEST_SUITE(BoundedReLu)
375FIXTURE_DATA_TEST_CASE(RunSmall, NEGEMMLowpQuantizeDownInt32ToUint8ScaleByFixedPointFixture, framework::DatasetMode::ALL, combine(datasets::SmallShapes(),
376 quantize_down_int32_to_uint8_scale_by_fixedpoint_relu_cases))
377{
378 // Validate output
379 validate(Accessor(_target), _reference);
380}
381
382FIXTURE_DATA_TEST_CASE(RunLarge, NEGEMMLowpQuantizeDownInt32ToUint8ScaleByFixedPointFixture, framework::DatasetMode::NIGHTLY, combine(datasets::LargeShapes(),
383 quantize_down_int32_to_uint8_scale_by_fixedpoint_relu_cases))
384{
385 // Validate output
386 validate(Accessor(_target), _reference);
387}
388TEST_SUITE_END() // BoundedReLu
389
390TEST_SUITE_END() // QuantizeDownInt32ToUint8ScaleByFixedPoint
Gian Marcoe75a02b2017-11-08 12:24:09 +0000391TEST_SUITE_END() // OutputStage
392
393TEST_SUITE_END() // GEMMLowp
394TEST_SUITE_END() // NEON
Pablo Tello299025a2017-09-29 11:30:12 +0100395} // namespace validation
396} // namespace test
397} // namespace arm_compute