blob: c46ad6a9d7ae2552d16723114aae7d696a8b4a09 [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"
Moritz Pflanzerd58cec02017-07-18 15:44:21 +010026#include "NEON/Accessor.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;
Anthony Barbier6ff3b192017-09-04 18:44:23 +010047using namespace arm_compute::test::validation;
48
49namespace
50{
Michele Di Giorgioab0a77e2017-06-21 15:36:24 +010051/** Compute Neon pixel-wise multiplication function.
Anthony Barbier6ff3b192017-09-04 18:44:23 +010052 *
53 * @param[in] shape Shape of the input and output tensors.
54 * @param[in] dt_in0 Data type of first input tensor.
55 * @param[in] dt_in1 Data type of second input tensor.
56 * @param[in] dt_out Data type of the output tensor.
57 * @param[in] scale Non-negative scale.
58 * @param[in] convert_policy Overflow policy of the operation.
59 * @param[in] rounding_policy Rounding policy of the operation.
Michele Di Giorgioab0a77e2017-06-21 15:36:24 +010060 * @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 +010061 *
62 * @return Computed output tensor.
63 */
64Tensor compute_pixel_wise_multiplication(const TensorShape &shape, DataType dt_in0, DataType dt_in1, DataType dt_out, float scale, ConvertPolicy convert_policy, RoundingPolicy rounding_policy,
65 int fixed_point_position = 0)
66{
67 // Create tensors
Moritz Pflanzer94450f12017-06-30 12:48:43 +010068 Tensor src1 = create_tensor<Tensor>(shape, dt_in0, 1, fixed_point_position);
69 Tensor src2 = create_tensor<Tensor>(shape, dt_in1, 1, fixed_point_position);
70 Tensor dst = create_tensor<Tensor>(shape, dt_out, 1, fixed_point_position);
Anthony Barbier6ff3b192017-09-04 18:44:23 +010071
72 // Create and configure function
73 NEPixelWiseMultiplication multiply;
74 multiply.configure(&src1, &src2, &dst, scale, convert_policy, rounding_policy);
75
76 // Allocate tensors
77 src1.allocator()->allocate();
78 src2.allocator()->allocate();
79 dst.allocator()->allocate();
80
81 BOOST_TEST(!src1.info()->is_resizable());
82 BOOST_TEST(!src2.info()->is_resizable());
83 BOOST_TEST(!dst.info()->is_resizable());
84
85 // Fill tensors
Moritz Pflanzerd58cec02017-07-18 15:44:21 +010086 library->fill_tensor_uniform(Accessor(src1), 0);
87 library->fill_tensor_uniform(Accessor(src2), 1);
Anthony Barbier6ff3b192017-09-04 18:44:23 +010088
89 // Compute function
90 multiply.run();
91
92 return dst;
93}
94
95void validate_configuration(const Tensor &src1, const Tensor &src2, Tensor &dst, TensorShape shape, float scale, ConvertPolicy convert_policy, RoundingPolicy rounding_policy)
96{
97 BOOST_TEST(src1.info()->is_resizable());
98 BOOST_TEST(src2.info()->is_resizable());
99 BOOST_TEST(dst.info()->is_resizable());
100
101 // Create and configure function
102 NEPixelWiseMultiplication multiply;
103 multiply.configure(&src1, &src2, &dst, scale, convert_policy, rounding_policy);
104
105 // Validate valid region
106 const ValidRegion valid_region = shape_to_valid_region(shape);
107 validate(src1.info()->valid_region(), valid_region);
108 validate(src2.info()->valid_region(), valid_region);
109 validate(dst.info()->valid_region(), valid_region);
110
111 // Validate padding
Moritz Pflanzer2509fba2017-06-23 14:15:03 +0100112 const PaddingSize padding = PaddingCalculator(shape.x(), 16).required_padding();
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100113 validate(src1.info()->padding(), padding);
114 validate(src2.info()->padding(), padding);
115 validate(dst.info()->padding(), padding);
116}
117} // namespace
118
119#ifndef DOXYGEN_SKIP_THIS
120BOOST_AUTO_TEST_SUITE(NEON)
121BOOST_AUTO_TEST_SUITE(PixelWiseMultiplication)
122
123BOOST_AUTO_TEST_SUITE(U8)
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100124BOOST_AUTO_TEST_SUITE(Scale255)
125BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit") * boost::unit_test::label("nightly"))
126BOOST_DATA_TEST_CASE(Configuration, (SmallShapes() + LargeShapes()) * (1.f / 255.f) * ConvertPolicies()
127 * RoundingPolicy::TO_NEAREST_UP,
128 shape, scale, convert_policy, rounding_policy)
129{
130 // Create tensors
Moritz Pflanzer94450f12017-06-30 12:48:43 +0100131 Tensor src1 = create_tensor<Tensor>(shape, DataType::U8);
132 Tensor src2 = create_tensor<Tensor>(shape, DataType::U8);
133 Tensor dst = create_tensor<Tensor>(shape, DataType::U8);
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100134
135 validate_configuration(src1, src2, dst, shape, scale, convert_policy, rounding_policy);
136}
137
138BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit"))
139BOOST_DATA_TEST_CASE(RunSmall, SmallShapes() * (1.f / 255.f) * ConvertPolicies() * RoundingPolicy::TO_NEAREST_UP,
140 shape, scale, convert_policy, rounding_policy)
141{
142 // Compute function
143 Tensor dst = compute_pixel_wise_multiplication(shape, DataType::U8, DataType::U8, DataType::U8, scale, convert_policy,
144 rounding_policy);
145
146 // Compute reference
147 RawTensor ref_dst = Reference::compute_reference_pixel_wise_multiplication(shape, DataType::U8, DataType::U8,
148 DataType::U8, scale, convert_policy, rounding_policy);
149
150 // Validate output
151 // Allow tolerance value of 1.f to counteract imprecision due to 32-bit float conversion
Moritz Pflanzerd58cec02017-07-18 15:44:21 +0100152 validate(Accessor(dst), ref_dst, 1.f, 0.f, std::numeric_limits<uint8_t>::max());
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100153}
154BOOST_TEST_DECORATOR(*boost::unit_test::label("nightly"))
155BOOST_DATA_TEST_CASE(RunLarge, LargeShapes() * (1.f / 255.f) * ConvertPolicies() * RoundingPolicy::TO_NEAREST_UP,
156 shape, scale, convert_policy, rounding_policy)
157{
158 // Compute function
159 Tensor dst = compute_pixel_wise_multiplication(shape, DataType::U8, DataType::U8, DataType::U8, scale, convert_policy,
160 rounding_policy);
161
162 // Compute reference
163 RawTensor ref_dst = Reference::compute_reference_pixel_wise_multiplication(shape, DataType::U8, DataType::U8,
164 DataType::U8, scale, convert_policy, rounding_policy);
165
166 // Validate output
167 // Allow tolerance value of 1.f to counteract imprecision due to 32-bit float conversion
Moritz Pflanzerd58cec02017-07-18 15:44:21 +0100168 validate(Accessor(dst), ref_dst, 1.f, 0.f, std::numeric_limits<uint8_t>::max());
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100169}
170BOOST_AUTO_TEST_SUITE_END()
171
172BOOST_AUTO_TEST_SUITE(ScaleOther)
173BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit") * boost::unit_test::label("nightly"))
174BOOST_DATA_TEST_CASE(Configuration, (SmallShapes() + LargeShapes()) * boost::unit_test::data::make({ 1.f, 1.f / 32768.f })
175 * ConvertPolicies()
176 * RoundingPolicy::TO_ZERO,
177 shape, scale, convert_policy, rounding_policy)
178{
179 // Create tensors
Moritz Pflanzer94450f12017-06-30 12:48:43 +0100180 Tensor src1 = create_tensor<Tensor>(shape, DataType::U8);
181 Tensor src2 = create_tensor<Tensor>(shape, DataType::U8);
182 Tensor dst = create_tensor<Tensor>(shape, DataType::U8);
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100183
184 validate_configuration(src1, src2, dst, shape, scale, convert_policy, rounding_policy);
185}
186
187BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit"))
188BOOST_DATA_TEST_CASE(RunSmall, SmallShapes() * boost::unit_test::data::make({ 1.f, 1.f / 32768.f }) * ConvertPolicies()
189 * RoundingPolicy::TO_ZERO,
190 shape, scale, convert_policy, rounding_policy)
191{
192 // Compute function
193 Tensor dst = compute_pixel_wise_multiplication(shape, DataType::U8, DataType::U8, DataType::U8, scale, convert_policy,
194 rounding_policy);
195
196 // Compute reference
197 RawTensor ref_dst = Reference::compute_reference_pixel_wise_multiplication(shape, DataType::U8, DataType::U8,
198 DataType::U8, scale, convert_policy, rounding_policy);
199
200 // Validate output
Moritz Pflanzerd58cec02017-07-18 15:44:21 +0100201 validate(Accessor(dst), ref_dst);
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100202}
203BOOST_TEST_DECORATOR(*boost::unit_test::label("nightly"))
204BOOST_DATA_TEST_CASE(RunLarge, LargeShapes() * boost::unit_test::data::make({ 1.f, 1.f / 32768.f }) * ConvertPolicies()
205 * RoundingPolicy::TO_ZERO,
206 shape, scale, convert_policy, rounding_policy)
207{
208 // Compute function
209 Tensor dst = compute_pixel_wise_multiplication(shape, DataType::U8, DataType::U8, DataType::U8, scale, convert_policy,
210 rounding_policy);
211
212 // Compute reference
213 RawTensor ref_dst = Reference::compute_reference_pixel_wise_multiplication(shape, DataType::U8, DataType::U8,
214 DataType::U8, scale, convert_policy, rounding_policy);
215
216 // Validate output
Moritz Pflanzerd58cec02017-07-18 15:44:21 +0100217 validate(Accessor(dst), ref_dst);
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100218}
219BOOST_AUTO_TEST_SUITE_END()
220BOOST_AUTO_TEST_SUITE_END()
221
222BOOST_AUTO_TEST_SUITE(S16)
223BOOST_AUTO_TEST_SUITE(Scale255)
224BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit") * boost::unit_test::label("nightly"))
225BOOST_DATA_TEST_CASE(Configuration, (SmallShapes() + LargeShapes()) * boost::unit_test::data::make({ DataType::U8, DataType::S16 }) * (1.f / 255.f) * ConvertPolicies()
226 * RoundingPolicy::TO_NEAREST_UP,
227 shape, dt, scale, convert_policy, rounding_policy)
228{
229 // Create tensors
Moritz Pflanzer94450f12017-06-30 12:48:43 +0100230 Tensor src1 = create_tensor<Tensor>(shape, dt);
231 Tensor src2 = create_tensor<Tensor>(shape, DataType::S16);
232 Tensor dst = create_tensor<Tensor>(shape, DataType::S16);
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100233
234 validate_configuration(src1, src2, dst, shape, scale, convert_policy, rounding_policy);
235}
236BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit"))
237BOOST_DATA_TEST_CASE(RunSmall, SmallShapes() * boost::unit_test::data::make({ DataType::U8, DataType::S16 }) * (1.f / 255.f) * ConvertPolicies()
238 * RoundingPolicy::TO_NEAREST_UP,
239 shape, dt, scale, convert_policy, rounding_policy)
240{
241 // Compute function
242 Tensor dst = compute_pixel_wise_multiplication(shape, dt, DataType::S16, DataType::S16, scale, convert_policy, rounding_policy);
243
244 // Compute reference
245 RawTensor ref_dst = Reference::compute_reference_pixel_wise_multiplication(shape, dt, DataType::S16, DataType::S16, scale, convert_policy, rounding_policy);
246
247 // Validate output
248 // Allow tolerance value of 2.f to counteract imprecision due to 32-bit float conversion
Moritz Pflanzerd58cec02017-07-18 15:44:21 +0100249 validate(Accessor(dst), ref_dst, 2.f, 0.f, std::numeric_limits<int16_t>::max());
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100250}
251BOOST_TEST_DECORATOR(*boost::unit_test::label("nightly"))
252BOOST_DATA_TEST_CASE(RunLarge, LargeShapes() * boost::unit_test::data::make({ DataType::U8, DataType::S16 }) * (1.f / 255.f) * ConvertPolicies()
253 * RoundingPolicy::TO_NEAREST_UP,
254 shape, dt, scale, convert_policy, rounding_policy)
255{
256 // Compute function
257 Tensor dst = compute_pixel_wise_multiplication(shape, dt, DataType::S16, DataType::S16, scale, convert_policy, rounding_policy);
258
259 // Compute reference
260 RawTensor ref_dst = Reference::compute_reference_pixel_wise_multiplication(shape, dt, DataType::S16, DataType::S16,
261 scale, convert_policy, rounding_policy);
262
263 // Validate output
264 // Allow tolerance value of 2.f to counteract imprecision due to 32-bit float conversion
Moritz Pflanzerd58cec02017-07-18 15:44:21 +0100265 validate(Accessor(dst), ref_dst, 2.f, 0.f, std::numeric_limits<int16_t>::max());
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100266}
267BOOST_AUTO_TEST_SUITE_END()
268
269BOOST_AUTO_TEST_SUITE(ScaleOther)
270BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit") * boost::unit_test::label("nightly"))
271BOOST_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 })
272 * ConvertPolicies()
273 * RoundingPolicy::TO_ZERO,
274 shape, dt, scale, convert_policy, rounding_policy)
275{
276 // Create tensors
Moritz Pflanzer94450f12017-06-30 12:48:43 +0100277 Tensor src1 = create_tensor<Tensor>(shape, dt);
278 Tensor src2 = create_tensor<Tensor>(shape, DataType::S16);
279 Tensor dst = create_tensor<Tensor>(shape, DataType::S16);
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100280
281 validate_configuration(src1, src2, dst, shape, scale, convert_policy, rounding_policy);
282}
283BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit"))
284BOOST_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()
285 * RoundingPolicy::TO_ZERO,
286 shape, dt, scale, convert_policy, rounding_policy)
287{
288 // Compute function
289 Tensor dst = compute_pixel_wise_multiplication(shape, dt, DataType::S16, DataType::S16, scale, convert_policy, rounding_policy);
290
291 // Compute reference
292 RawTensor ref_dst = Reference::compute_reference_pixel_wise_multiplication(shape, dt, DataType::S16, DataType::S16, scale, convert_policy, rounding_policy);
293
294 // Validate output
Moritz Pflanzerd58cec02017-07-18 15:44:21 +0100295 validate(Accessor(dst), ref_dst);
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100296}
297BOOST_TEST_DECORATOR(*boost::unit_test::label("nightly"))
298BOOST_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()
299 * RoundingPolicy::TO_ZERO,
300 shape, dt, scale, convert_policy, rounding_policy)
301{
302 // Compute function
303 Tensor dst = compute_pixel_wise_multiplication(shape, dt, DataType::S16, DataType::S16, scale, convert_policy, rounding_policy);
304
305 // Compute reference
306 RawTensor ref_dst = Reference::compute_reference_pixel_wise_multiplication(shape, dt, DataType::S16, DataType::S16,
307 scale, convert_policy, rounding_policy);
308
309 // Validate output
Moritz Pflanzerd58cec02017-07-18 15:44:21 +0100310 validate(Accessor(dst), ref_dst);
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100311}
312BOOST_AUTO_TEST_SUITE_END()
313BOOST_AUTO_TEST_SUITE_END()
314
Pablo Tellodf246182017-07-03 16:25:09 +0100315#ifdef ARM_COMPUTE_ENABLE_FP16
316BOOST_AUTO_TEST_SUITE(F16)
317BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit"))
318
319BOOST_DATA_TEST_CASE(RunSmall, SmallShapes() * (1.f / 255.f) * ConvertPolicies() * RoundingPolicy::TO_NEAREST_UP,
320 shape, scale, convert_policy, rounding_policy)
321{
322 // Compute function
323 Tensor dst = compute_pixel_wise_multiplication(shape, DataType::F16, DataType::F16, DataType::F16, scale, convert_policy, rounding_policy);
324
325 // Compute reference
326 RawTensor ref_dst = Reference::compute_reference_pixel_wise_multiplication(shape, DataType::F16, DataType::F16, DataType::F16, scale, convert_policy, rounding_policy);
327
328 // Validate output
329 // Allow tolerance value of 1.f to counteract imprecision due to 32-bit float conversion
Moritz Pflanzerd58cec02017-07-18 15:44:21 +0100330 validate(Accessor(dst), ref_dst, 1.f, 0.f, std::numeric_limits<int16_t>::max());
Pablo Tellodf246182017-07-03 16:25:09 +0100331}
332
333BOOST_AUTO_TEST_SUITE_END()
334#endif /* ARM_COMPUTE_ENABLE_FP16 */
335
Michele Di Giorgio81f0d152017-07-11 15:00:52 +0100336BOOST_AUTO_TEST_SUITE(F32)
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100337BOOST_AUTO_TEST_SUITE(Scale255)
338BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit") * boost::unit_test::label("nightly"))
339BOOST_DATA_TEST_CASE(Configuration, (SmallShapes() + LargeShapes()) * (1.f / 255.f) * ConvertPolicies()
340 * RoundingPolicy::TO_NEAREST_UP,
341 shape, scale, convert_policy, rounding_policy)
342{
343 // Create tensors
Moritz Pflanzer94450f12017-06-30 12:48:43 +0100344 Tensor src1 = create_tensor<Tensor>(shape, DataType::F32);
345 Tensor src2 = create_tensor<Tensor>(shape, DataType::F32);
346 Tensor dst = create_tensor<Tensor>(shape, DataType::F32);
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100347
348 validate_configuration(src1, src2, dst, shape, scale, convert_policy, rounding_policy);
349}
350BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit"))
351BOOST_DATA_TEST_CASE(RunSmall, SmallShapes() * (1.f / 255.f) * ConvertPolicies()
352 * RoundingPolicy::TO_NEAREST_UP,
353 shape, scale, convert_policy, rounding_policy)
354{
355 // Compute function
356 Tensor dst = compute_pixel_wise_multiplication(shape, DataType::F32, DataType::F32, DataType::F32, scale, convert_policy, rounding_policy);
357
358 // Compute reference
359 RawTensor ref_dst = Reference::compute_reference_pixel_wise_multiplication(shape, DataType::F32, DataType::F32, DataType::F32, scale, convert_policy, rounding_policy);
360
361 // Validate output
362 // Allow tolerance value of 1.f to counteract imprecision due to 32-bit float conversion
Moritz Pflanzerd58cec02017-07-18 15:44:21 +0100363 validate(Accessor(dst), ref_dst, 1.f, 0.f, std::numeric_limits<int16_t>::max());
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100364}
365BOOST_TEST_DECORATOR(*boost::unit_test::label("nightly"))
366BOOST_DATA_TEST_CASE(RunLarge, LargeShapes() * (1.f / 255.f) * ConvertPolicies()
367 * RoundingPolicy::TO_NEAREST_UP,
368 shape, scale, convert_policy, rounding_policy)
369{
370 // Compute function
371 Tensor dst = compute_pixel_wise_multiplication(shape, DataType::F32, DataType::F32, DataType::F32, scale, convert_policy, rounding_policy);
372
373 // Compute reference
374 RawTensor ref_dst = Reference::compute_reference_pixel_wise_multiplication(shape, DataType::F32, DataType::F32, DataType::F32,
375 scale, convert_policy, rounding_policy);
376
377 // Validate output
378 // Allow tolerance value of 1.f to counteract imprecision due to 32-bit float conversion
Moritz Pflanzerd58cec02017-07-18 15:44:21 +0100379 validate(Accessor(dst), ref_dst, 1.f, 0.f, std::numeric_limits<int16_t>::max());
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100380}
381BOOST_AUTO_TEST_SUITE_END()
382
383BOOST_AUTO_TEST_SUITE(ScaleOther)
384BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit") * boost::unit_test::label("nightly"))
385BOOST_DATA_TEST_CASE(Configuration, (SmallShapes() + LargeShapes()) * boost::unit_test::data::make({ 1.f, 1.f / 32768.f })
386 * ConvertPolicies()
387 * RoundingPolicy::TO_ZERO,
388 shape, scale, convert_policy, rounding_policy)
389{
390 // Create tensors
Moritz Pflanzer94450f12017-06-30 12:48:43 +0100391 Tensor src1 = create_tensor<Tensor>(shape, DataType::F32);
392 Tensor src2 = create_tensor<Tensor>(shape, DataType::F32);
393 Tensor dst = create_tensor<Tensor>(shape, DataType::F32);
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100394
395 validate_configuration(src1, src2, dst, shape, scale, convert_policy, rounding_policy);
396}
397BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit"))
398BOOST_DATA_TEST_CASE(RunSmall, SmallShapes() * boost::unit_test::data::make({ 1.f, 1.f / 32768.f }) * ConvertPolicies()
399 * RoundingPolicy::TO_ZERO,
400 shape, scale, convert_policy, rounding_policy)
401{
402 // Compute function
403 Tensor dst = compute_pixel_wise_multiplication(shape, DataType::F32, DataType::F32, DataType::F32, scale, convert_policy, rounding_policy);
404
405 // Compute reference
406 RawTensor ref_dst = Reference::compute_reference_pixel_wise_multiplication(shape, DataType::F32, DataType::F32, DataType::F32, scale, convert_policy, rounding_policy);
407
408 // Validate output
Moritz Pflanzerd58cec02017-07-18 15:44:21 +0100409 validate(Accessor(dst), ref_dst);
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100410}
411BOOST_TEST_DECORATOR(*boost::unit_test::label("nightly"))
412BOOST_DATA_TEST_CASE(RunLarge, LargeShapes() * boost::unit_test::data::make({ 1.f, 1.f / 32768.f }) * ConvertPolicies()
413 * RoundingPolicy::TO_ZERO,
414 shape, scale, convert_policy, rounding_policy)
415{
416 // Compute function
417 Tensor dst = compute_pixel_wise_multiplication(shape, DataType::F32, DataType::F32, DataType::F32, scale, convert_policy, rounding_policy);
418
419 // Compute reference
420 RawTensor ref_dst = Reference::compute_reference_pixel_wise_multiplication(shape, DataType::F32, DataType::F32, DataType::F32,
421 scale, convert_policy, rounding_policy);
422
423 // Validate output
Moritz Pflanzerd58cec02017-07-18 15:44:21 +0100424 validate(Accessor(dst), ref_dst);
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100425}
426BOOST_AUTO_TEST_SUITE_END()
427BOOST_AUTO_TEST_SUITE_END()
428
Michele Di Giorgioab0a77e2017-06-21 15:36:24 +0100429BOOST_AUTO_TEST_SUITE(Quantized)
Michele Di Giorgio81f0d152017-07-11 15:00:52 +0100430BOOST_AUTO_TEST_SUITE(QS8)
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100431BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit"))
432BOOST_DATA_TEST_CASE(RunSmall, SmallShapes() * DataType::QS8 *ConvertPolicies() * RoundingPolicy::TO_ZERO * boost::unit_test::data::xrange<int>(1, 7),
433 shape, dt, convert_policy, rounding_policy, fixed_point_position)
434{
435 // Compute function
436 Tensor dst = compute_pixel_wise_multiplication(shape, dt, dt, dt, 1.f, convert_policy, rounding_policy, fixed_point_position);
437
438 // Compute reference
439 RawTensor ref_dst = Reference::compute_reference_fixed_point_pixel_wise_multiplication(shape, dt, dt, dt, 1.f, fixed_point_position, convert_policy, rounding_policy);
440
441 // Validate output
Moritz Pflanzerd58cec02017-07-18 15:44:21 +0100442 validate(Accessor(dst), ref_dst);
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100443}
Michele Di Giorgio81f0d152017-07-11 15:00:52 +0100444
445BOOST_TEST_DECORATOR(*boost::unit_test::label("nightly"))
446BOOST_DATA_TEST_CASE(RunLarge, LargeShapes() * DataType::QS8 *ConvertPolicies() * RoundingPolicy::TO_ZERO * boost::unit_test::data::xrange<int>(1, 7),
447 shape, dt, convert_policy, rounding_policy, fixed_point_position)
448{
449 // Compute function
450 Tensor dst = compute_pixel_wise_multiplication(shape, dt, dt, dt, 1.f, convert_policy, rounding_policy);
451
452 // Compute reference
453 RawTensor ref_dst = Reference::compute_reference_pixel_wise_multiplication(shape, dt, dt, dt, 1.f, convert_policy, rounding_policy);
454
455 // Validate output
Moritz Pflanzerd58cec02017-07-18 15:44:21 +0100456 validate(Accessor(dst), ref_dst);
Michele Di Giorgio81f0d152017-07-11 15:00:52 +0100457}
458BOOST_AUTO_TEST_SUITE_END()
459
460BOOST_AUTO_TEST_SUITE(QS16)
461BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit"))
462BOOST_DATA_TEST_CASE(RunSmall, SmallShapes() * DataType::QS16 *ConvertPolicies() * RoundingPolicy::TO_ZERO * boost::unit_test::data::xrange<int>(1, 15),
463 shape, dt, convert_policy, rounding_policy, fixed_point_position)
464{
465 // Compute function
466 Tensor dst = compute_pixel_wise_multiplication(shape, dt, dt, dt, 1.f, convert_policy, rounding_policy, fixed_point_position);
467
468 // Compute reference
469 RawTensor ref_dst = Reference::compute_reference_fixed_point_pixel_wise_multiplication(shape, dt, dt, dt, 1.f, fixed_point_position, convert_policy, rounding_policy);
470
471 // Validate output
Moritz Pflanzerd58cec02017-07-18 15:44:21 +0100472 validate(Accessor(dst), ref_dst);
Michele Di Giorgio81f0d152017-07-11 15:00:52 +0100473}
474
475BOOST_TEST_DECORATOR(*boost::unit_test::label("nightly"))
476BOOST_DATA_TEST_CASE(RunLarge, LargeShapes() * DataType::QS16 *ConvertPolicies() * RoundingPolicy::TO_ZERO * boost::unit_test::data::xrange<int>(1, 15),
477 shape, dt, convert_policy, rounding_policy, fixed_point_position)
478{
479 // Compute function
480 Tensor dst = compute_pixel_wise_multiplication(shape, dt, dt, dt, 1.f, convert_policy, rounding_policy);
481
482 // Compute reference
483 RawTensor ref_dst = Reference::compute_reference_pixel_wise_multiplication(shape, dt, dt, dt, 1.f, convert_policy, rounding_policy);
484
485 // Validate output
Moritz Pflanzerd58cec02017-07-18 15:44:21 +0100486 validate(Accessor(dst), ref_dst);
Michele Di Giorgio81f0d152017-07-11 15:00:52 +0100487}
488BOOST_AUTO_TEST_SUITE_END()
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100489BOOST_AUTO_TEST_SUITE_END()
490
491BOOST_AUTO_TEST_SUITE_END()
492BOOST_AUTO_TEST_SUITE_END()
Anthony Barbierac69aa12017-07-03 17:39:37 +0100493#endif /* DOXYGEN_SKIP_THIS */