blob: 1458c9fdc384f9b6ff4c5f203ef7095d0b85ec97 [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;
Gian Marco Iodice4b908652018-10-18 10:21:02 +010098 gemmlowp_mm.configure(&a, &b, nullptr, &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),
Gian Marco Iodice4b908652018-10-18 10:21:02 +0100128 nullptr,
Georgios Pinitas631c41a2017-12-06 11:53:03 +0000129 &output_info.clone()->set_is_resizable(false));
130 ARM_COMPUTE_EXPECT(bool(status) == expected, framework::LogLevel::ERRORS);
Georgios Pinitasa3b1b462017-11-16 19:24:39 +0000131}
132// clang-format on
133// *INDENT-ON*
134
Gian Marcoe75a02b2017-11-08 12:24:09 +0000135FIXTURE_DATA_TEST_CASE(RunSmall, NEGEMMLowpMatrixMultiplyCoreFixture, framework::DatasetMode::ALL, datasets::SmallGEMMLowpDataset())
Pablo Tello299025a2017-09-29 11:30:12 +0100136{
137 // Validate output
Gian Marcofa4cacd2017-10-18 17:05:02 +0100138 validate(Accessor(_target), _reference);
139}
140
Gian Marcoe75a02b2017-11-08 12:24:09 +0000141FIXTURE_DATA_TEST_CASE(RunLarge, NEGEMMLowpMatrixMultiplyCoreFixture, framework::DatasetMode::NIGHTLY, datasets::LargeGEMMLowpDataset())
Gian Marcofa4cacd2017-10-18 17:05:02 +0100142{
143 // Validate output
144 validate(Accessor(_target), _reference);
Pablo Tello299025a2017-09-29 11:30:12 +0100145}
Pablo Tello299025a2017-09-29 11:30:12 +0100146
Gian Marcoe75a02b2017-11-08 12:24:09 +0000147TEST_SUITE_END() // MatrixMultiplyCore
148
149TEST_SUITE(OutputStage)
150
151TEST_SUITE(QuantizeDownInt32ToUint8Scale)
152
Gian Marco05288a22017-11-21 10:57:50 +0000153const 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 +0000154 3)
155 * framework::dataset::make("min", 0) * framework::dataset::make("max", 0) * framework::dataset::make("addBias", { false, true });
156
Gian Marco05288a22017-11-21 10:57:50 +0000157const 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 +0000158 2)
159 * 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 });
160
Gian Marcoe75a02b2017-11-08 12:24:09 +0000161using NEGEMMLowpQuantizeDownInt32ToUint8ScaleFixture = GEMMLowpQuantizeDownInt32ToUint8ScaleValidationFixture<Tensor, Accessor, NEGEMMLowpQuantizeDownInt32ToUint8Scale>;
162
Gian Marco7f0f7902017-12-07 09:26:56 +0000163// *INDENT-OFF*
164// clang-format off
165DATA_TEST_CASE(Validate, framework::DatasetMode::ALL, zip(zip(zip(zip(zip(
166 framework::dataset::make("InputAInfo", { TensorInfo(TensorShape(21U, 13U), 1, DataType::S32), // Input not a multiple of 16
167 TensorInfo(TensorShape(21U, 13U), 1, DataType::S32), // Invalid min and max
168 TensorInfo(TensorShape(20U, 13U), 1, DataType::S32), // Wrong output data type
169 }),
170 framework::dataset::make("InputBInfo",{ TensorInfo(TensorShape(21U), 1, DataType::S32),
171 TensorInfo(TensorShape(21U), 1, DataType::S32),
172 TensorInfo(TensorShape(20U), 1, DataType::S32),
173 })),
174 framework::dataset::make("OutputInfo",{ TensorInfo(TensorShape(21U, 13U), 1, DataType::QASYMM8),
175 TensorInfo(TensorShape(21U, 13U), 1, DataType::QASYMM8),
176 TensorInfo(TensorShape(20U, 13U), 1, DataType::S32),
177 })),
178 framework::dataset::make("Min",{ 0,
179 8,
180 13,
181 })),
182 framework::dataset::make("Max",{ 205,
183 300,
184 180,
185 })),
186 framework::dataset::make("Expected", { true, false, false })),
187 a_info, b_info, output_info, min, max, expected)
188{
189 // Lock tensors
190 Status status = NEGEMMLowpQuantizeDownInt32ToUint8Scale::validate(&a_info.clone()->set_is_resizable(false),
191 &b_info.clone()->set_is_resizable(false),
192 &output_info.clone()->set_is_resizable(false),
193 min,
194 max);
195 ARM_COMPUTE_EXPECT(bool(status) == expected, framework::LogLevel::ERRORS);
196}
197// clang-format on
198// *INDENT-ON*
199
Gian Marcoe75a02b2017-11-08 12:24:09 +0000200DATA_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 +0000201 shape, result_offset, result_mult_int, result_shift, min, max, add_bias)
Gian Marcoe75a02b2017-11-08 12:24:09 +0000202{
Gian Marco6b77e912017-11-17 09:27:57 +0000203 TensorShape shape_bias(shape[0]);
204
Gian Marcoe75a02b2017-11-08 12:24:09 +0000205 // Create tensors
Gian Marco6b77e912017-11-17 09:27:57 +0000206 Tensor in = create_tensor<Tensor>(shape, DataType::S32);
207 Tensor bias = create_tensor<Tensor>(shape_bias, DataType::S32);
208 Tensor out = create_tensor<Tensor>(shape, DataType::QASYMM8);
Gian Marcoe75a02b2017-11-08 12:24:09 +0000209
210 ARM_COMPUTE_EXPECT(in.info()->is_resizable(), framework::LogLevel::ERRORS);
Gian Marco6b77e912017-11-17 09:27:57 +0000211 ARM_COMPUTE_EXPECT(bias.info()->is_resizable(), framework::LogLevel::ERRORS);
Gian Marcoe75a02b2017-11-08 12:24:09 +0000212 ARM_COMPUTE_EXPECT(out.info()->is_resizable(), framework::LogLevel::ERRORS);
213
214 // Create and configure function
215 NEGEMMLowpQuantizeDownInt32ToUint8Scale output_stage;
Gian Marco6b77e912017-11-17 09:27:57 +0000216 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 +0000217
Gian Marco6b77e912017-11-17 09:27:57 +0000218 // Validate valid region input and output
Gian Marcoe75a02b2017-11-08 12:24:09 +0000219 const ValidRegion valid_region = shape_to_valid_region(shape);
220 validate(in.info()->valid_region(), valid_region);
221 validate(out.info()->valid_region(), valid_region);
222
Gian Marco6b77e912017-11-17 09:27:57 +0000223 // Validate valid region bias
224 if(add_bias)
225 {
226 const ValidRegion valid_region_bias = shape_to_valid_region(shape_bias);
227 validate(bias.info()->valid_region(), valid_region_bias);
228 }
229
Gian Marcoe75a02b2017-11-08 12:24:09 +0000230 // Validate padding
Gian Marco7f0f7902017-12-07 09:26:56 +0000231 const PaddingSize padding(0);
Gian Marcoe75a02b2017-11-08 12:24:09 +0000232 validate(in.info()->padding(), padding);
233 validate(out.info()->padding(), padding);
Gian Marco6b77e912017-11-17 09:27:57 +0000234
235 if(add_bias)
236 {
237 validate(bias.info()->padding(), padding);
238 }
Gian Marcoe75a02b2017-11-08 12:24:09 +0000239}
240
241FIXTURE_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 +0100242{
243 // Validate output
Gian Marcofa4cacd2017-10-18 17:05:02 +0100244 validate(Accessor(_target), _reference);
Pablo Tellobf2fb952017-09-29 16:43:25 +0100245}
Pablo Tello6ff12a02017-11-02 16:09:35 +0000246
Gian Marcoe75a02b2017-11-08 12:24:09 +0000247FIXTURE_DATA_TEST_CASE(RunLarge, NEGEMMLowpQuantizeDownInt32ToUint8ScaleFixture, framework::DatasetMode::NIGHTLY, combine(datasets::LargeShapes(), quantize_down_int32_to_uint8_scale_cases))
248{
249 // Validate output
250 validate(Accessor(_target), _reference);
251}
252
Gian Marco6b77e912017-11-17 09:27:57 +0000253TEST_SUITE(BoundedReLu)
254FIXTURE_DATA_TEST_CASE(RunSmall, NEGEMMLowpQuantizeDownInt32ToUint8ScaleFixture, framework::DatasetMode::ALL, combine(datasets::SmallShapes(), quantize_down_int32_to_uint8_scale_relu_cases))
255{
256 // Validate output
257 validate(Accessor(_target), _reference);
258}
Gian Marcoe75a02b2017-11-08 12:24:09 +0000259
Gian Marco6b77e912017-11-17 09:27:57 +0000260FIXTURE_DATA_TEST_CASE(RunLarge, NEGEMMLowpQuantizeDownInt32ToUint8ScaleFixture, framework::DatasetMode::NIGHTLY, combine(datasets::LargeShapes(), quantize_down_int32_to_uint8_scale_relu_cases))
261{
262 // Validate output
263 validate(Accessor(_target), _reference);
264}
265TEST_SUITE_END() // BoundedReLu
266
Gian Marco6b77e912017-11-17 09:27:57 +0000267TEST_SUITE_END() // QuantizeDownInt32ToUint8Scale
Gian Marco58c57942017-11-28 09:10:03 +0000268
269TEST_SUITE(QuantizeDownInt32ToUint8ScaleByFixedPoint)
270
271const auto quantize_down_int32_to_uint8_scale_by_fixedpoint_cases = framework::dataset::make("result_fixedpoint_multiplier", 254601600, 254601602) * framework::dataset::make("result_shift", 1,
272 2)
273 * 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 });
274
275const 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,
276 2)
277 * 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 });
278
279using NEGEMMLowpQuantizeDownInt32ToUint8ScaleByFixedPointFixture =
280 GEMMLowpQuantizeDownInt32ToUint8ScaleByFixedPointValidationFixture<Tensor, Accessor, NEGEMMLowpQuantizeDownInt32ToUint8ScaleByFixedPoint>;
281
Gian Marco7f0f7902017-12-07 09:26:56 +0000282// *INDENT-OFF*
283// clang-format off
284DATA_TEST_CASE(Validate, framework::DatasetMode::ALL, zip(zip(zip(zip(zip(
285 framework::dataset::make("InputAInfo", { TensorInfo(TensorShape(21U, 13U), 1, DataType::S32), // Input not a multiple of 16
286 TensorInfo(TensorShape(21U, 13U), 1, DataType::S32), // Invalid min and max
287 TensorInfo(TensorShape(20U, 13U), 1, DataType::S32), // Wrong output data type
288 }),
289 framework::dataset::make("InputBInfo",{ TensorInfo(TensorShape(21U), 1, DataType::S32),
290 TensorInfo(TensorShape(21U), 1, DataType::S32),
291 TensorInfo(TensorShape(20U), 1, DataType::S32),
292 })),
293 framework::dataset::make("OutputInfo",{ TensorInfo(TensorShape(21U, 13U), 1, DataType::QASYMM8),
294 TensorInfo(TensorShape(21U, 13U), 1, DataType::QASYMM8),
295 TensorInfo(TensorShape(20U, 13U), 1, DataType::S32),
296 })),
297 framework::dataset::make("Min",{ 0,
298 8,
299 13,
300 })),
301 framework::dataset::make("Max",{ 205,
302 300,
303 180,
304 })),
305 framework::dataset::make("Expected", { true, false, false })),
306 a_info, b_info, output_info, min, max, expected)
307{
308 // Lock tensors
309 Status status = NEGEMMLowpQuantizeDownInt32ToUint8ScaleByFixedPoint::validate(&a_info.clone()->set_is_resizable(false),
310 &b_info.clone()->set_is_resizable(false),
311 &output_info.clone()->set_is_resizable(false),
312 min,
313 max);
314 ARM_COMPUTE_EXPECT(bool(status) == expected, framework::LogLevel::ERRORS);
315}
316// clang-format on
317// *INDENT-ON*
318
Gian Marco58c57942017-11-28 09:10:03 +0000319DATA_TEST_CASE(Configuration, framework::DatasetMode::ALL, combine(framework::dataset::concat(datasets::SmallShapes(), datasets::LargeShapes()),
320 quantize_down_int32_to_uint8_scale_by_fixedpoint_cases),
321 shape, result_fixedpoint_multiplier, result_shift, result_offset_after_shift, min, max, add_bias)
322{
323 TensorShape shape_bias(shape[0]);
324
325 // Create tensors
326 Tensor in = create_tensor<Tensor>(shape, DataType::S32);
327 Tensor bias = create_tensor<Tensor>(shape_bias, DataType::S32);
328 Tensor out = create_tensor<Tensor>(shape, DataType::QASYMM8);
329
330 ARM_COMPUTE_EXPECT(in.info()->is_resizable(), framework::LogLevel::ERRORS);
331 ARM_COMPUTE_EXPECT(bias.info()->is_resizable(), framework::LogLevel::ERRORS);
332 ARM_COMPUTE_EXPECT(out.info()->is_resizable(), framework::LogLevel::ERRORS);
333
334 // Create and configure function
335 NEGEMMLowpQuantizeDownInt32ToUint8ScaleByFixedPoint output_stage;
336 output_stage.configure(&in, add_bias ? &bias : nullptr, &out, result_fixedpoint_multiplier, result_shift, result_offset_after_shift, min, max);
337
338 // Validate valid region input and output
339 const ValidRegion valid_region = shape_to_valid_region(shape);
340 validate(in.info()->valid_region(), valid_region);
341 validate(out.info()->valid_region(), valid_region);
342
343 // Validate valid region bias
344 if(add_bias)
345 {
346 const ValidRegion valid_region_bias = shape_to_valid_region(shape_bias);
347 validate(bias.info()->valid_region(), valid_region_bias);
348 }
349
350 // Validate padding
Gian Marco7f0f7902017-12-07 09:26:56 +0000351 const PaddingSize padding(0);
Gian Marco58c57942017-11-28 09:10:03 +0000352 validate(in.info()->padding(), padding);
353 validate(out.info()->padding(), padding);
354
355 if(add_bias)
356 {
357 validate(bias.info()->padding(), padding);
358 }
359}
360
361FIXTURE_DATA_TEST_CASE(RunSmall, NEGEMMLowpQuantizeDownInt32ToUint8ScaleByFixedPointFixture, framework::DatasetMode::ALL, combine(datasets::SmallShapes(),
362 quantize_down_int32_to_uint8_scale_by_fixedpoint_cases))
363{
364 // Validate output
365 validate(Accessor(_target), _reference);
366}
367
368FIXTURE_DATA_TEST_CASE(RunLarge, NEGEMMLowpQuantizeDownInt32ToUint8ScaleByFixedPointFixture, framework::DatasetMode::NIGHTLY, combine(datasets::LargeShapes(),
369 quantize_down_int32_to_uint8_scale_by_fixedpoint_cases))
370{
371 // Validate output
372 validate(Accessor(_target), _reference);
373}
374
375TEST_SUITE(BoundedReLu)
376FIXTURE_DATA_TEST_CASE(RunSmall, NEGEMMLowpQuantizeDownInt32ToUint8ScaleByFixedPointFixture, framework::DatasetMode::ALL, combine(datasets::SmallShapes(),
377 quantize_down_int32_to_uint8_scale_by_fixedpoint_relu_cases))
378{
379 // Validate output
380 validate(Accessor(_target), _reference);
381}
382
383FIXTURE_DATA_TEST_CASE(RunLarge, NEGEMMLowpQuantizeDownInt32ToUint8ScaleByFixedPointFixture, framework::DatasetMode::NIGHTLY, combine(datasets::LargeShapes(),
384 quantize_down_int32_to_uint8_scale_by_fixedpoint_relu_cases))
385{
386 // Validate output
387 validate(Accessor(_target), _reference);
388}
389TEST_SUITE_END() // BoundedReLu
390
391TEST_SUITE_END() // QuantizeDownInt32ToUint8ScaleByFixedPoint
Gian Marcoe75a02b2017-11-08 12:24:09 +0000392TEST_SUITE_END() // OutputStage
393
394TEST_SUITE_END() // GEMMLowp
395TEST_SUITE_END() // NEON
Pablo Tello299025a2017-09-29 11:30:12 +0100396} // namespace validation
397} // namespace test
398} // namespace arm_compute