blob: 5cff90c112c75c4bd604326177c7ed491a39d4b7 [file] [log] [blame]
Anthony Barbier6ff3b192017-09-04 18:44:23 +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 */
Moritz Pflanzerfb5aabb2017-07-18 14:39:55 +010024#include "AssetsLibrary.h"
Anthony Barbier6ff3b192017-09-04 18:44:23 +010025#include "Globals.h"
Anthony Barbier6ff3b192017-09-04 18:44:23 +010026#include "NEON/NEAccessor.h"
Moritz Pflanzer5b512292017-06-21 15:54:07 +010027#include "PaddingCalculator.h"
Anthony Barbier6ff3b192017-09-04 18:44:23 +010028#include "TypePrinter.h"
29#include "Utils.h"
30#include "validation/Datasets.h"
31#include "validation/Reference.h"
32#include "validation/Validation.h"
33
34#include "arm_compute/core/Helpers.h"
35#include "arm_compute/core/Types.h"
36#include "arm_compute/runtime/NEON/functions/NEPixelWiseMultiplication.h"
37#include "arm_compute/runtime/Tensor.h"
38#include "arm_compute/runtime/TensorAllocator.h"
39
40#include "boost_wrapper.h"
41
42#include <random>
43#include <string>
44
45using namespace arm_compute;
46using namespace arm_compute::test;
47using namespace arm_compute::test::neon;
48using namespace arm_compute::test::validation;
49
50namespace
51{
Michele Di Giorgioab0a77e2017-06-21 15:36:24 +010052/** Compute Neon pixel-wise multiplication function.
Anthony Barbier6ff3b192017-09-04 18:44:23 +010053 *
54 * @param[in] shape Shape of the input and output tensors.
55 * @param[in] dt_in0 Data type of first input tensor.
56 * @param[in] dt_in1 Data type of second input tensor.
57 * @param[in] dt_out Data type of the output tensor.
58 * @param[in] scale Non-negative scale.
59 * @param[in] convert_policy Overflow policy of the operation.
60 * @param[in] rounding_policy Rounding policy of the operation.
Michele Di Giorgioab0a77e2017-06-21 15:36:24 +010061 * @param[in] fixed_point_position (Optional) Fixed point position that expresses the number of bits for the fractional part of the number.
Anthony Barbier6ff3b192017-09-04 18:44:23 +010062 *
63 * @return Computed output tensor.
64 */
65Tensor compute_pixel_wise_multiplication(const TensorShape &shape, DataType dt_in0, DataType dt_in1, DataType dt_out, float scale, ConvertPolicy convert_policy, RoundingPolicy rounding_policy,
66 int fixed_point_position = 0)
67{
68 // Create tensors
Moritz Pflanzer94450f12017-06-30 12:48:43 +010069 Tensor src1 = create_tensor<Tensor>(shape, dt_in0, 1, fixed_point_position);
70 Tensor src2 = create_tensor<Tensor>(shape, dt_in1, 1, fixed_point_position);
71 Tensor dst = create_tensor<Tensor>(shape, dt_out, 1, fixed_point_position);
Anthony Barbier6ff3b192017-09-04 18:44:23 +010072
73 // Create and configure function
74 NEPixelWiseMultiplication multiply;
75 multiply.configure(&src1, &src2, &dst, scale, convert_policy, rounding_policy);
76
77 // Allocate tensors
78 src1.allocator()->allocate();
79 src2.allocator()->allocate();
80 dst.allocator()->allocate();
81
82 BOOST_TEST(!src1.info()->is_resizable());
83 BOOST_TEST(!src2.info()->is_resizable());
84 BOOST_TEST(!dst.info()->is_resizable());
85
86 // Fill tensors
87 library->fill_tensor_uniform(NEAccessor(src1), 0);
88 library->fill_tensor_uniform(NEAccessor(src2), 1);
89
90 // Compute function
91 multiply.run();
92
93 return dst;
94}
95
96void validate_configuration(const Tensor &src1, const Tensor &src2, Tensor &dst, TensorShape shape, float scale, ConvertPolicy convert_policy, RoundingPolicy rounding_policy)
97{
98 BOOST_TEST(src1.info()->is_resizable());
99 BOOST_TEST(src2.info()->is_resizable());
100 BOOST_TEST(dst.info()->is_resizable());
101
102 // Create and configure function
103 NEPixelWiseMultiplication multiply;
104 multiply.configure(&src1, &src2, &dst, scale, convert_policy, rounding_policy);
105
106 // Validate valid region
107 const ValidRegion valid_region = shape_to_valid_region(shape);
108 validate(src1.info()->valid_region(), valid_region);
109 validate(src2.info()->valid_region(), valid_region);
110 validate(dst.info()->valid_region(), valid_region);
111
112 // Validate padding
Moritz Pflanzer2509fba2017-06-23 14:15:03 +0100113 const PaddingSize padding = PaddingCalculator(shape.x(), 16).required_padding();
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100114 validate(src1.info()->padding(), padding);
115 validate(src2.info()->padding(), padding);
116 validate(dst.info()->padding(), padding);
117}
118} // namespace
119
120#ifndef DOXYGEN_SKIP_THIS
121BOOST_AUTO_TEST_SUITE(NEON)
122BOOST_AUTO_TEST_SUITE(PixelWiseMultiplication)
123
124BOOST_AUTO_TEST_SUITE(U8)
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100125BOOST_AUTO_TEST_SUITE(Scale255)
126BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit") * boost::unit_test::label("nightly"))
127BOOST_DATA_TEST_CASE(Configuration, (SmallShapes() + LargeShapes()) * (1.f / 255.f) * ConvertPolicies()
128 * RoundingPolicy::TO_NEAREST_UP,
129 shape, scale, convert_policy, rounding_policy)
130{
131 // Create tensors
Moritz Pflanzer94450f12017-06-30 12:48:43 +0100132 Tensor src1 = create_tensor<Tensor>(shape, DataType::U8);
133 Tensor src2 = create_tensor<Tensor>(shape, DataType::U8);
134 Tensor dst = create_tensor<Tensor>(shape, DataType::U8);
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100135
136 validate_configuration(src1, src2, dst, shape, scale, convert_policy, rounding_policy);
137}
138
139BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit"))
140BOOST_DATA_TEST_CASE(RunSmall, SmallShapes() * (1.f / 255.f) * ConvertPolicies() * RoundingPolicy::TO_NEAREST_UP,
141 shape, scale, convert_policy, rounding_policy)
142{
143 // Compute function
144 Tensor dst = compute_pixel_wise_multiplication(shape, DataType::U8, DataType::U8, DataType::U8, scale, convert_policy,
145 rounding_policy);
146
147 // Compute reference
148 RawTensor ref_dst = Reference::compute_reference_pixel_wise_multiplication(shape, DataType::U8, DataType::U8,
149 DataType::U8, scale, convert_policy, rounding_policy);
150
151 // Validate output
152 // Allow tolerance value of 1.f to counteract imprecision due to 32-bit float conversion
153 validate(NEAccessor(dst), ref_dst, 1.f, 0.f, std::numeric_limits<uint8_t>::max());
154}
155BOOST_TEST_DECORATOR(*boost::unit_test::label("nightly"))
156BOOST_DATA_TEST_CASE(RunLarge, LargeShapes() * (1.f / 255.f) * ConvertPolicies() * RoundingPolicy::TO_NEAREST_UP,
157 shape, scale, convert_policy, rounding_policy)
158{
159 // Compute function
160 Tensor dst = compute_pixel_wise_multiplication(shape, DataType::U8, DataType::U8, DataType::U8, scale, convert_policy,
161 rounding_policy);
162
163 // Compute reference
164 RawTensor ref_dst = Reference::compute_reference_pixel_wise_multiplication(shape, DataType::U8, DataType::U8,
165 DataType::U8, scale, convert_policy, rounding_policy);
166
167 // Validate output
168 // Allow tolerance value of 1.f to counteract imprecision due to 32-bit float conversion
169 validate(NEAccessor(dst), ref_dst, 1.f, 0.f, std::numeric_limits<uint8_t>::max());
170}
171BOOST_AUTO_TEST_SUITE_END()
172
173BOOST_AUTO_TEST_SUITE(ScaleOther)
174BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit") * boost::unit_test::label("nightly"))
175BOOST_DATA_TEST_CASE(Configuration, (SmallShapes() + LargeShapes()) * boost::unit_test::data::make({ 1.f, 1.f / 32768.f })
176 * ConvertPolicies()
177 * RoundingPolicy::TO_ZERO,
178 shape, scale, convert_policy, rounding_policy)
179{
180 // Create tensors
Moritz Pflanzer94450f12017-06-30 12:48:43 +0100181 Tensor src1 = create_tensor<Tensor>(shape, DataType::U8);
182 Tensor src2 = create_tensor<Tensor>(shape, DataType::U8);
183 Tensor dst = create_tensor<Tensor>(shape, DataType::U8);
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100184
185 validate_configuration(src1, src2, dst, shape, scale, convert_policy, rounding_policy);
186}
187
188BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit"))
189BOOST_DATA_TEST_CASE(RunSmall, SmallShapes() * boost::unit_test::data::make({ 1.f, 1.f / 32768.f }) * ConvertPolicies()
190 * RoundingPolicy::TO_ZERO,
191 shape, scale, convert_policy, rounding_policy)
192{
193 // Compute function
194 Tensor dst = compute_pixel_wise_multiplication(shape, DataType::U8, DataType::U8, DataType::U8, scale, convert_policy,
195 rounding_policy);
196
197 // Compute reference
198 RawTensor ref_dst = Reference::compute_reference_pixel_wise_multiplication(shape, DataType::U8, DataType::U8,
199 DataType::U8, scale, convert_policy, rounding_policy);
200
201 // Validate output
202 validate(NEAccessor(dst), ref_dst);
203}
204BOOST_TEST_DECORATOR(*boost::unit_test::label("nightly"))
205BOOST_DATA_TEST_CASE(RunLarge, LargeShapes() * boost::unit_test::data::make({ 1.f, 1.f / 32768.f }) * ConvertPolicies()
206 * RoundingPolicy::TO_ZERO,
207 shape, scale, convert_policy, rounding_policy)
208{
209 // Compute function
210 Tensor dst = compute_pixel_wise_multiplication(shape, DataType::U8, DataType::U8, DataType::U8, scale, convert_policy,
211 rounding_policy);
212
213 // Compute reference
214 RawTensor ref_dst = Reference::compute_reference_pixel_wise_multiplication(shape, DataType::U8, DataType::U8,
215 DataType::U8, scale, convert_policy, rounding_policy);
216
217 // Validate output
218 validate(NEAccessor(dst), ref_dst);
219}
220BOOST_AUTO_TEST_SUITE_END()
221BOOST_AUTO_TEST_SUITE_END()
222
223BOOST_AUTO_TEST_SUITE(S16)
224BOOST_AUTO_TEST_SUITE(Scale255)
225BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit") * boost::unit_test::label("nightly"))
226BOOST_DATA_TEST_CASE(Configuration, (SmallShapes() + LargeShapes()) * boost::unit_test::data::make({ DataType::U8, DataType::S16 }) * (1.f / 255.f) * ConvertPolicies()
227 * RoundingPolicy::TO_NEAREST_UP,
228 shape, dt, scale, convert_policy, rounding_policy)
229{
230 // Create tensors
Moritz Pflanzer94450f12017-06-30 12:48:43 +0100231 Tensor src1 = create_tensor<Tensor>(shape, dt);
232 Tensor src2 = create_tensor<Tensor>(shape, DataType::S16);
233 Tensor dst = create_tensor<Tensor>(shape, DataType::S16);
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100234
235 validate_configuration(src1, src2, dst, shape, scale, convert_policy, rounding_policy);
236}
237BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit"))
238BOOST_DATA_TEST_CASE(RunSmall, SmallShapes() * boost::unit_test::data::make({ DataType::U8, DataType::S16 }) * (1.f / 255.f) * ConvertPolicies()
239 * RoundingPolicy::TO_NEAREST_UP,
240 shape, dt, scale, convert_policy, rounding_policy)
241{
242 // Compute function
243 Tensor dst = compute_pixel_wise_multiplication(shape, dt, DataType::S16, DataType::S16, scale, convert_policy, rounding_policy);
244
245 // Compute reference
246 RawTensor ref_dst = Reference::compute_reference_pixel_wise_multiplication(shape, dt, DataType::S16, DataType::S16, scale, convert_policy, rounding_policy);
247
248 // Validate output
249 // Allow tolerance value of 2.f to counteract imprecision due to 32-bit float conversion
250 validate(NEAccessor(dst), ref_dst, 2.f, 0.f, std::numeric_limits<int16_t>::max());
251}
252BOOST_TEST_DECORATOR(*boost::unit_test::label("nightly"))
253BOOST_DATA_TEST_CASE(RunLarge, LargeShapes() * boost::unit_test::data::make({ DataType::U8, DataType::S16 }) * (1.f / 255.f) * ConvertPolicies()
254 * RoundingPolicy::TO_NEAREST_UP,
255 shape, dt, scale, convert_policy, rounding_policy)
256{
257 // Compute function
258 Tensor dst = compute_pixel_wise_multiplication(shape, dt, DataType::S16, DataType::S16, scale, convert_policy, rounding_policy);
259
260 // Compute reference
261 RawTensor ref_dst = Reference::compute_reference_pixel_wise_multiplication(shape, dt, DataType::S16, DataType::S16,
262 scale, convert_policy, rounding_policy);
263
264 // Validate output
265 // Allow tolerance value of 2.f to counteract imprecision due to 32-bit float conversion
266 validate(NEAccessor(dst), ref_dst, 2.f, 0.f, std::numeric_limits<int16_t>::max());
267}
268BOOST_AUTO_TEST_SUITE_END()
269
270BOOST_AUTO_TEST_SUITE(ScaleOther)
271BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit") * boost::unit_test::label("nightly"))
272BOOST_DATA_TEST_CASE(Configuration, (SmallShapes() + LargeShapes()) * boost::unit_test::data::make({ DataType::U8, DataType::S16 }) * boost::unit_test::data::make({ 1.f, 1.f / 32768.f })
273 * ConvertPolicies()
274 * RoundingPolicy::TO_ZERO,
275 shape, dt, scale, convert_policy, rounding_policy)
276{
277 // Create tensors
Moritz Pflanzer94450f12017-06-30 12:48:43 +0100278 Tensor src1 = create_tensor<Tensor>(shape, dt);
279 Tensor src2 = create_tensor<Tensor>(shape, DataType::S16);
280 Tensor dst = create_tensor<Tensor>(shape, DataType::S16);
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100281
282 validate_configuration(src1, src2, dst, shape, scale, convert_policy, rounding_policy);
283}
284BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit"))
285BOOST_DATA_TEST_CASE(RunSmall, SmallShapes() * boost::unit_test::data::make({ DataType::U8, DataType::S16 }) * boost::unit_test::data::make({ 1.f, 1.f / 32768.f }) * ConvertPolicies()
286 * RoundingPolicy::TO_ZERO,
287 shape, dt, scale, convert_policy, rounding_policy)
288{
289 // Compute function
290 Tensor dst = compute_pixel_wise_multiplication(shape, dt, DataType::S16, DataType::S16, scale, convert_policy, rounding_policy);
291
292 // Compute reference
293 RawTensor ref_dst = Reference::compute_reference_pixel_wise_multiplication(shape, dt, DataType::S16, DataType::S16, scale, convert_policy, rounding_policy);
294
295 // Validate output
296 validate(NEAccessor(dst), ref_dst);
297}
298BOOST_TEST_DECORATOR(*boost::unit_test::label("nightly"))
299BOOST_DATA_TEST_CASE(RunLarge, LargeShapes() * boost::unit_test::data::make({ DataType::U8, DataType::S16 }) * boost::unit_test::data::make({ 1.f, 1.f / 32768.f }) * ConvertPolicies()
300 * RoundingPolicy::TO_ZERO,
301 shape, dt, scale, convert_policy, rounding_policy)
302{
303 // Compute function
304 Tensor dst = compute_pixel_wise_multiplication(shape, dt, DataType::S16, DataType::S16, scale, convert_policy, rounding_policy);
305
306 // Compute reference
307 RawTensor ref_dst = Reference::compute_reference_pixel_wise_multiplication(shape, dt, DataType::S16, DataType::S16,
308 scale, convert_policy, rounding_policy);
309
310 // Validate output
311 validate(NEAccessor(dst), ref_dst);
312}
313BOOST_AUTO_TEST_SUITE_END()
314BOOST_AUTO_TEST_SUITE_END()
315
Pablo Tellodf246182017-07-03 16:25:09 +0100316#ifdef ARM_COMPUTE_ENABLE_FP16
317BOOST_AUTO_TEST_SUITE(F16)
318BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit"))
319
320BOOST_DATA_TEST_CASE(RunSmall, SmallShapes() * (1.f / 255.f) * ConvertPolicies() * RoundingPolicy::TO_NEAREST_UP,
321 shape, scale, convert_policy, rounding_policy)
322{
323 // Compute function
324 Tensor dst = compute_pixel_wise_multiplication(shape, DataType::F16, DataType::F16, DataType::F16, scale, convert_policy, rounding_policy);
325
326 // Compute reference
327 RawTensor ref_dst = Reference::compute_reference_pixel_wise_multiplication(shape, DataType::F16, DataType::F16, DataType::F16, scale, convert_policy, rounding_policy);
328
329 // Validate output
330 // Allow tolerance value of 1.f to counteract imprecision due to 32-bit float conversion
331 validate(NEAccessor(dst), ref_dst, 1.f, 0.f, std::numeric_limits<int16_t>::max());
332}
333
334BOOST_AUTO_TEST_SUITE_END()
335#endif /* ARM_COMPUTE_ENABLE_FP16 */
336
Michele Di Giorgio81f0d152017-07-11 15:00:52 +0100337BOOST_AUTO_TEST_SUITE(F32)
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100338BOOST_AUTO_TEST_SUITE(Scale255)
339BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit") * boost::unit_test::label("nightly"))
340BOOST_DATA_TEST_CASE(Configuration, (SmallShapes() + LargeShapes()) * (1.f / 255.f) * ConvertPolicies()
341 * RoundingPolicy::TO_NEAREST_UP,
342 shape, scale, convert_policy, rounding_policy)
343{
344 // Create tensors
Moritz Pflanzer94450f12017-06-30 12:48:43 +0100345 Tensor src1 = create_tensor<Tensor>(shape, DataType::F32);
346 Tensor src2 = create_tensor<Tensor>(shape, DataType::F32);
347 Tensor dst = create_tensor<Tensor>(shape, DataType::F32);
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100348
349 validate_configuration(src1, src2, dst, shape, scale, convert_policy, rounding_policy);
350}
351BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit"))
352BOOST_DATA_TEST_CASE(RunSmall, SmallShapes() * (1.f / 255.f) * ConvertPolicies()
353 * RoundingPolicy::TO_NEAREST_UP,
354 shape, scale, convert_policy, rounding_policy)
355{
356 // Compute function
357 Tensor dst = compute_pixel_wise_multiplication(shape, DataType::F32, DataType::F32, DataType::F32, scale, convert_policy, rounding_policy);
358
359 // Compute reference
360 RawTensor ref_dst = Reference::compute_reference_pixel_wise_multiplication(shape, DataType::F32, DataType::F32, DataType::F32, scale, convert_policy, rounding_policy);
361
362 // Validate output
363 // Allow tolerance value of 1.f to counteract imprecision due to 32-bit float conversion
364 validate(NEAccessor(dst), ref_dst, 1.f, 0.f, std::numeric_limits<int16_t>::max());
365}
366BOOST_TEST_DECORATOR(*boost::unit_test::label("nightly"))
367BOOST_DATA_TEST_CASE(RunLarge, LargeShapes() * (1.f / 255.f) * ConvertPolicies()
368 * RoundingPolicy::TO_NEAREST_UP,
369 shape, scale, convert_policy, rounding_policy)
370{
371 // Compute function
372 Tensor dst = compute_pixel_wise_multiplication(shape, DataType::F32, DataType::F32, DataType::F32, scale, convert_policy, rounding_policy);
373
374 // Compute reference
375 RawTensor ref_dst = Reference::compute_reference_pixel_wise_multiplication(shape, DataType::F32, DataType::F32, DataType::F32,
376 scale, convert_policy, rounding_policy);
377
378 // Validate output
379 // Allow tolerance value of 1.f to counteract imprecision due to 32-bit float conversion
380 validate(NEAccessor(dst), ref_dst, 1.f, 0.f, std::numeric_limits<int16_t>::max());
381}
382BOOST_AUTO_TEST_SUITE_END()
383
384BOOST_AUTO_TEST_SUITE(ScaleOther)
385BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit") * boost::unit_test::label("nightly"))
386BOOST_DATA_TEST_CASE(Configuration, (SmallShapes() + LargeShapes()) * boost::unit_test::data::make({ 1.f, 1.f / 32768.f })
387 * ConvertPolicies()
388 * RoundingPolicy::TO_ZERO,
389 shape, scale, convert_policy, rounding_policy)
390{
391 // Create tensors
Moritz Pflanzer94450f12017-06-30 12:48:43 +0100392 Tensor src1 = create_tensor<Tensor>(shape, DataType::F32);
393 Tensor src2 = create_tensor<Tensor>(shape, DataType::F32);
394 Tensor dst = create_tensor<Tensor>(shape, DataType::F32);
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100395
396 validate_configuration(src1, src2, dst, shape, scale, convert_policy, rounding_policy);
397}
398BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit"))
399BOOST_DATA_TEST_CASE(RunSmall, SmallShapes() * boost::unit_test::data::make({ 1.f, 1.f / 32768.f }) * ConvertPolicies()
400 * RoundingPolicy::TO_ZERO,
401 shape, scale, convert_policy, rounding_policy)
402{
403 // Compute function
404 Tensor dst = compute_pixel_wise_multiplication(shape, DataType::F32, DataType::F32, DataType::F32, scale, convert_policy, rounding_policy);
405
406 // Compute reference
407 RawTensor ref_dst = Reference::compute_reference_pixel_wise_multiplication(shape, DataType::F32, DataType::F32, DataType::F32, scale, convert_policy, rounding_policy);
408
409 // Validate output
410 validate(NEAccessor(dst), ref_dst);
411}
412BOOST_TEST_DECORATOR(*boost::unit_test::label("nightly"))
413BOOST_DATA_TEST_CASE(RunLarge, LargeShapes() * boost::unit_test::data::make({ 1.f, 1.f / 32768.f }) * ConvertPolicies()
414 * RoundingPolicy::TO_ZERO,
415 shape, scale, convert_policy, rounding_policy)
416{
417 // Compute function
418 Tensor dst = compute_pixel_wise_multiplication(shape, DataType::F32, DataType::F32, DataType::F32, scale, convert_policy, rounding_policy);
419
420 // Compute reference
421 RawTensor ref_dst = Reference::compute_reference_pixel_wise_multiplication(shape, DataType::F32, DataType::F32, DataType::F32,
422 scale, convert_policy, rounding_policy);
423
424 // Validate output
425 validate(NEAccessor(dst), ref_dst);
426}
427BOOST_AUTO_TEST_SUITE_END()
428BOOST_AUTO_TEST_SUITE_END()
429
Michele Di Giorgioab0a77e2017-06-21 15:36:24 +0100430BOOST_AUTO_TEST_SUITE(Quantized)
Michele Di Giorgio81f0d152017-07-11 15:00:52 +0100431BOOST_AUTO_TEST_SUITE(QS8)
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100432BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit"))
433BOOST_DATA_TEST_CASE(RunSmall, SmallShapes() * DataType::QS8 *ConvertPolicies() * RoundingPolicy::TO_ZERO * boost::unit_test::data::xrange<int>(1, 7),
434 shape, dt, convert_policy, rounding_policy, fixed_point_position)
435{
436 // Compute function
437 Tensor dst = compute_pixel_wise_multiplication(shape, dt, dt, dt, 1.f, convert_policy, rounding_policy, fixed_point_position);
438
439 // Compute reference
440 RawTensor ref_dst = Reference::compute_reference_fixed_point_pixel_wise_multiplication(shape, dt, dt, dt, 1.f, fixed_point_position, convert_policy, rounding_policy);
441
442 // Validate output
443 validate(NEAccessor(dst), ref_dst);
444}
Michele Di Giorgio81f0d152017-07-11 15:00:52 +0100445
446BOOST_TEST_DECORATOR(*boost::unit_test::label("nightly"))
447BOOST_DATA_TEST_CASE(RunLarge, LargeShapes() * DataType::QS8 *ConvertPolicies() * RoundingPolicy::TO_ZERO * boost::unit_test::data::xrange<int>(1, 7),
448 shape, dt, convert_policy, rounding_policy, fixed_point_position)
449{
450 // Compute function
451 Tensor dst = compute_pixel_wise_multiplication(shape, dt, dt, dt, 1.f, convert_policy, rounding_policy);
452
453 // Compute reference
454 RawTensor ref_dst = Reference::compute_reference_pixel_wise_multiplication(shape, dt, dt, dt, 1.f, convert_policy, rounding_policy);
455
456 // Validate output
457 validate(NEAccessor(dst), ref_dst);
458}
459BOOST_AUTO_TEST_SUITE_END()
460
461BOOST_AUTO_TEST_SUITE(QS16)
462BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit"))
463BOOST_DATA_TEST_CASE(RunSmall, SmallShapes() * DataType::QS16 *ConvertPolicies() * RoundingPolicy::TO_ZERO * boost::unit_test::data::xrange<int>(1, 15),
464 shape, dt, convert_policy, rounding_policy, fixed_point_position)
465{
466 // Compute function
467 Tensor dst = compute_pixel_wise_multiplication(shape, dt, dt, dt, 1.f, convert_policy, rounding_policy, fixed_point_position);
468
469 // Compute reference
470 RawTensor ref_dst = Reference::compute_reference_fixed_point_pixel_wise_multiplication(shape, dt, dt, dt, 1.f, fixed_point_position, convert_policy, rounding_policy);
471
472 // Validate output
473 validate(NEAccessor(dst), ref_dst);
474}
475
476BOOST_TEST_DECORATOR(*boost::unit_test::label("nightly"))
477BOOST_DATA_TEST_CASE(RunLarge, LargeShapes() * DataType::QS16 *ConvertPolicies() * RoundingPolicy::TO_ZERO * boost::unit_test::data::xrange<int>(1, 15),
478 shape, dt, convert_policy, rounding_policy, fixed_point_position)
479{
480 // Compute function
481 Tensor dst = compute_pixel_wise_multiplication(shape, dt, dt, dt, 1.f, convert_policy, rounding_policy);
482
483 // Compute reference
484 RawTensor ref_dst = Reference::compute_reference_pixel_wise_multiplication(shape, dt, dt, dt, 1.f, convert_policy, rounding_policy);
485
486 // Validate output
487 validate(NEAccessor(dst), ref_dst);
488}
489BOOST_AUTO_TEST_SUITE_END()
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100490BOOST_AUTO_TEST_SUITE_END()
491
492BOOST_AUTO_TEST_SUITE_END()
493BOOST_AUTO_TEST_SUITE_END()
Anthony Barbierac69aa12017-07-03 17:39:37 +0100494#endif /* DOXYGEN_SKIP_THIS */