Compute Library
 22.11
PixelWiseMultiplication.cpp
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2017-2021 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  */
26 #include "tests/NEON/Accessor.h"
28 #include "tests/datasets/ConvertPolicyDataset.h"
29 #include "tests/datasets/ShapeDatasets.h"
30 #include "tests/framework/Macros.h"
32 #include "tests/validation/fixtures/PixelWiseMultiplicationFixture.h"
33 
34 namespace arm_compute
35 {
36 namespace test
37 {
38 namespace validation
39 {
40 namespace
41 {
42 const float scale_unity = 1.f;
43 const float scale_255 = 1.f / 255.f;
44 const float scale_other = 1.f / 32768.f;
45 
46 constexpr AbsoluteTolerance<float> tolerance_qasymm8(1); /**< Tolerance value for comparing reference's output against implementation's output for 8-bit quantized asymmetric data types */
47 constexpr AbsoluteTolerance<float> tolerance_qsymm16(1); /**< Tolerance value for comparing reference's output against implementation's output for 16-bit quantized symmetric data types */
48 
49 const auto PixelWiseMultiplicationQSYMM16QuantDataset = combine(combine(
50  framework::dataset::make("Src0QInfo", { QuantizationInfo(1.f / 32768.f, 0) }),
51  framework::dataset::make("Src1QInfo", { QuantizationInfo(2.f / 32768.f, 0) })),
52  framework::dataset::make("OutQInfo", { QuantizationInfo(5.f / 32768.f, 0) }));
53 
54 const auto PixelWiseMultiplicationQASYMM8QuantDataset = combine(combine(
55  framework::dataset::make("Src0QInfo", { QuantizationInfo(5.f / 32768.f, 0) }),
56  framework::dataset::make("Src1QInfo", { QuantizationInfo(2.f / 32768.f, 0) })),
57  framework::dataset::make("OutQInfo", { QuantizationInfo(1.f / 32768.f, 0) }));
58 
59 const auto PixelWiseMultiplicationQASYMM8QuantInPlaceDataset = combine(combine(
60  framework::dataset::make("Src0QInfo", { QuantizationInfo(5.f / 32768.f, 10) }),
61  framework::dataset::make("Src1QInfo", { QuantizationInfo(5.f / 32768.f, 10) })),
62  framework::dataset::make("OutQInfo", { QuantizationInfo(5.f / 32768.f, 10) }));
63 
64 const auto PixelWiseMultiplicationPolicySTNUDataset = combine(
67 
68 const auto PixelWiseMultiplicationPolicySTZDataset = combine(
70  framework::dataset::make("RoundingPolicy", { RoundingPolicy::TO_ZERO }));
71 
72 /** Tests for in-place computation
73  * With current interface storing TensorInfo with quantization information
74  * in the kernel, it is difficult to have different tensor metadata
75  * (e.g., quantization information, data type, different shape for broadcasting)
76  * when an input is used as the output of the computation.
77  * So, the following dataset for in-place computation is used only when
78  * the exact same input and output Tensor object makes sense
79  * (i.e., all the tensor metadata is the same) whereas if output is
80  * expected to have either different quantization information, data type
81  * or different shape we are not testing in-place computation.
82  */
83 const auto InPlaceDataSet = framework::dataset::make("InPlace", { false, true });
84 const auto OutOfPlaceDataSet = framework::dataset::make("InPlace", { false });
85 
86 #define DEFAULT_VALIDATE validate(Accessor(_target), _reference);
87 #define VALIDATE(TYPE, TOLERANCE) validate(Accessor(_target), _reference, AbsoluteTolerance<TYPE>(TOLERANCE), 0.f);
88 #define WRAP_VALIDATE(TYPE, TOLERANCE) validate_wrap(Accessor(_target), _reference, AbsoluteTolerance<TYPE>(TOLERANCE), 0.f);
89 
90 // *INDENT-OFF*
91 // clang-format off
92 #define PIXEL_WISE_MULTIPLICATION_FIXTURE_DATA_TEST_CASE(TEST_NAME, FIXTURE, MODE, SHAPES, DT1, DT2, DT3, SCALE, RP, INPLACE_DATASET, VALIDATE) \
93  FIXTURE_DATA_TEST_CASE(TEST_NAME, NEPixelWiseMultiplication##FIXTURE, framework::DatasetMode::MODE, \
94  combine(combine(combine(combine(combine(combine(combine( \
95  datasets::SHAPES, \
96  framework::dataset::make("DataType1", DataType::DT1)), \
97  framework::dataset::make("DataType2", DataType::DT2)), \
98  framework::dataset::make("DataType3", DataType::DT3)), \
99  framework::dataset::make("Scale", std::move(SCALE))), \
100  datasets::ConvertPolicies()), \
101  framework::dataset::make("RoundingPolicy", RoundingPolicy::RP)), \
102  (INPLACE_DATASET))) \
103  { \
104  VALIDATE \
105  }
106 
107 // *INDENT-ON*
108 // clang-format on
109 } // namespace
110 
111 using NEPixelWiseMultiplicationQASYMM8Fixture = PixelWiseMultiplicationValidationQuantizedFixture<Tensor, Accessor, NEPixelWiseMultiplication, uint8_t, uint8_t>;
112 using NEPixelWiseMultiplicationQASYMM8SignedFixture = PixelWiseMultiplicationValidationQuantizedFixture<Tensor, Accessor, NEPixelWiseMultiplication, int8_t, int8_t>;
113 using NEPixelWiseMultiplicationQSYMM16Fixture = PixelWiseMultiplicationValidationQuantizedFixture<Tensor, Accessor, NEPixelWiseMultiplication, int16_t, int16_t>;
114 using NEPixelWiseMultiplicationQSYMM16ToS32Fixture = PixelWiseMultiplicationValidationQuantizedFixture<Tensor, Accessor, NEPixelWiseMultiplication, int16_t, int16_t, int32_t>;
115 template <typename T>
116 using NEPixelWiseMultiplicationToU8Fixture = PixelWiseMultiplicationValidationFixture<Tensor, Accessor, NEPixelWiseMultiplication, T, uint8_t>;
117 template <typename T>
118 using NEPixelWiseMultiplicationToS16Fixture = PixelWiseMultiplicationValidationFixture<Tensor, Accessor, NEPixelWiseMultiplication, T, int16_t>;
119 template <typename T>
120 using NEPixelWiseMultiplicationToS32Fixture = PixelWiseMultiplicationValidationFixture<Tensor, Accessor, NEPixelWiseMultiplication, T, int32_t>;
121 template <typename T>
122 using NEPixelWiseMultiplicationToF16Fixture = PixelWiseMultiplicationValidationFixture<Tensor, Accessor, NEPixelWiseMultiplication, T, half_float::half>;
123 template <typename T>
124 using NEPixelWiseMultiplicationToF32Fixture = PixelWiseMultiplicationValidationFixture<Tensor, Accessor, NEPixelWiseMultiplication, T, float>;
125 using NEPixelWiseMultiplicationU8U8ToS16Fixture = PixelWiseMultiplicationValidationFixture<Tensor, Accessor, NEPixelWiseMultiplication, uint8_t, uint8_t, int16_t>;
126 template <typename T>
127 using NEPixelWiseMultiplicationBroadcastFixture = PixelWiseMultiplicationBroadcastValidationFixture<Tensor, Accessor, NEPixelWiseMultiplication, T, T>;
128 using NEPixelWiseMultiplicationBroadcastQASYMM8Fixture = PixelWiseMultiplicationBroadcastValidationQuantizedFixture<Tensor, Accessor, NEPixelWiseMultiplication, uint8_t, uint8_t>;
129 using NEPixelWiseMultiplicationBroadcastQASYMM8SignedFixture = PixelWiseMultiplicationBroadcastValidationQuantizedFixture<Tensor, Accessor, NEPixelWiseMultiplication, int8_t, int8_t>;
130 
131 TEST_SUITE(NEON)
132 TEST_SUITE(PixelWiseMultiplication)
133 
134 // *INDENT-OFF*
135 // clang-format off
136 DATA_TEST_CASE(Validate, framework::DatasetMode::ALL, zip(zip(zip(zip(zip(
137  framework::dataset::make("Input1Info", { TensorInfo(TensorShape(32U, 13U, 2U), 1, DataType::U8), //1 Ok
138  TensorInfo(TensorShape(32U, 13U, 2U), 1, DataType::U8), //2 Ok
139  TensorInfo(TensorShape(27U, 13U, 2U), 1, DataType::U8), //3 Window shrink
140  TensorInfo(TensorShape(32U, 13U, 2U), 1, DataType::U8), //4 Invalid scale
141  TensorInfo(TensorShape(32U, 13U, 2U), 1, DataType::U8), //5 Invalid data type combination
142  TensorInfo(TensorShape(32U, 13U, 2U), 1, DataType::F32), //6 Mismatching shapes
143  TensorInfo(TensorShape(32U, 13U, 2U), 1, DataType::F32), //7 Mismatching data type
144  TensorInfo(TensorShape(32U, 13U, 2U), 1, DataType::QASYMM8), //8 Mismatching data type
145  TensorInfo(TensorShape(32U, 13U, 2U), 1, DataType::QASYMM8_SIGNED), //9 Ok
146  TensorInfo(TensorShape(32U, 13U, 2U), 1, DataType::QASYMM8_SIGNED), //10 Mismatching data type
147  TensorInfo(TensorShape(32U, 13U, 2U), 1, DataType::QASYMM8), //11 Mismatching data type
148  TensorInfo(TensorShape(32U, 13U, 2U), 1, DataType::QASYMM8), //12 Ok
149  TensorInfo(TensorShape(32U, 13U, 2U), 1, DataType::QASYMM8_SIGNED), //13 Quantized cannot do WRAP
150  TensorInfo(TensorShape(32U, 13U, 2U), 1, DataType::S32), //14 S32 does not support scale255
151  }),
152  framework::dataset::make("Input2Info",{ TensorInfo(TensorShape(32U, 13U, 2U), 1, DataType::U8),
153  TensorInfo(TensorShape(32U, 13U, 2U), 1, DataType::U8),
154  TensorInfo(TensorShape(27U, 13U, 2U), 1, DataType::U8),
155  TensorInfo(TensorShape(32U, 13U, 2U), 1, DataType::U8),
156  TensorInfo(TensorShape(32U, 13U, 2U), 1, DataType::S16),
157  TensorInfo(TensorShape(48U, 11U, 2U), 1, DataType::F32),
158  TensorInfo(TensorShape(32U, 13U, 2U), 1, DataType::U8),
159  TensorInfo(TensorShape(32U, 13U, 2U), 1, DataType::U8),
165  TensorInfo(TensorShape(32U, 13U, 2U), 1, DataType::S32),
166  })),
167  framework::dataset::make("OutputInfo",{ TensorInfo(TensorShape(32U, 13U, 2U), 1, DataType::S16),
168  TensorInfo(TensorShape(32U, 13U, 2U), 1, DataType::U8),
169  TensorInfo(TensorShape(27U, 13U, 2U), 1, DataType::U8),
170  TensorInfo(TensorShape(32U, 13U, 2U), 1, DataType::U8),
171  TensorInfo(TensorShape(32U, 13U, 2U), 1, DataType::U8),
172  TensorInfo(TensorShape(48U, 11U, 2U), 1, DataType::F32),
173  TensorInfo(TensorShape(32U, 13U, 2U), 1, DataType::F32),
174  TensorInfo(TensorShape(32U, 13U, 2U), 1, DataType::U8),
180  TensorInfo(TensorShape(32U, 13U, 2U), 1, DataType::S32),
181  })),
182  framework::dataset::make("Scale",{ scale_unity,
183  scale_unity,
184  scale_unity,
185  -1.f,
186  scale_unity,
187  scale_unity,
188  scale_unity,
189  scale_unity,
190  scale_unity,
191  scale_unity,
192  scale_unity,
193  scale_unity,
194  scale_unity,
195  scale_255})),
196  framework::dataset::make("OverflowPolicy",{
211  })),
212 
213  framework::dataset::make("Expected", { true, true, true, false, false, false, false, false, true , false, false, true, false, false})),
215 {
216  bool has_error = bool(NEPixelWiseMultiplication::validate(&input1_info.clone()->set_is_resizable(false), &input2_info.clone()->set_is_resizable(false), &output_info.clone()->set_is_resizable(false), scale, policy, RoundingPolicy::TO_ZERO));
218 }
219 // clang-format on
220 // *INDENT-ON*
221 
222 TEST_SUITE(InPlaceValidate)
224 {
225  const auto random_shape = TensorShape{ 9, 9 };
226  const auto single_tensor_info = TensorInfo{ random_shape, 1, DataType::F32 };
227 
228  Status result = NEPixelWiseMultiplication::validate(&single_tensor_info, &single_tensor_info, &single_tensor_info, scale_unity, ConvertPolicy::WRAP, RoundingPolicy::TO_ZERO);
229  ARM_COMPUTE_EXPECT(bool(result) == true, framework::LogLevel::ERRORS);
230 }
231 
232 TEST_CASE(ValidBroadCast, framework::DatasetMode::ALL)
233 {
234  const auto larger_shape = TensorShape{ 27U, 13U, 2U };
235  const auto smaller_shape = TensorShape{ 1U, 13U, 2U };
236 
237  const auto larger_tensor_info = TensorInfo{ larger_shape, 1, DataType::F32 };
238  const auto smaller_tensor_info = TensorInfo{ smaller_shape, 1, DataType::F32 };
239 
240  Status result = NEPixelWiseMultiplication::validate(&larger_tensor_info, &smaller_tensor_info, &larger_tensor_info, scale_unity, ConvertPolicy::WRAP, RoundingPolicy::TO_ZERO);
241  ARM_COMPUTE_EXPECT(bool(result) == true, framework::LogLevel::ERRORS);
242 }
243 
244 TEST_CASE(InvalidBroadcastOutput, framework::DatasetMode::ALL)
245 {
246  const auto larger_shape = TensorShape{ 27U, 13U, 2U };
247  const auto smaller_shape = TensorShape{ 1U, 13U, 2U };
248 
249  const auto larger_tensor_info = TensorInfo{ larger_shape, 1, DataType::F32 };
250  const auto smaller_tensor_info = TensorInfo{ smaller_shape, 1, DataType::F32 };
251 
252  Status result = NEPixelWiseMultiplication::validate(&larger_tensor_info, &smaller_tensor_info, &smaller_tensor_info, scale_unity, ConvertPolicy::WRAP, RoundingPolicy::TO_ZERO);
253  ARM_COMPUTE_EXPECT(bool(result) == false, framework::LogLevel::ERRORS);
254 }
255 
256 TEST_CASE(InvalidBroadcastBoth, framework::DatasetMode::ALL)
257 {
258  const auto shape0 = TensorShape{ 9U, 9U };
259  const auto shape1 = TensorShape{ 9U, 1U, 2U };
260 
261  const auto info0 = TensorInfo{ shape0, 1, DataType::F32 };
262  const auto info1 = TensorInfo{ shape1, 1, DataType::F32 };
263 
264  Status result{};
265 
266  result = NEPixelWiseMultiplication::validate(&info0, &info1, &info0, scale_unity, ConvertPolicy::WRAP, RoundingPolicy::TO_ZERO);
267  ARM_COMPUTE_EXPECT(bool(result) == false, framework::LogLevel::ERRORS);
268 
269  result = NEPixelWiseMultiplication::validate(&info0, &info1, &info1, scale_unity, ConvertPolicy::WRAP, RoundingPolicy::TO_ZERO);
270  ARM_COMPUTE_EXPECT(bool(result) == false, framework::LogLevel::ERRORS);
271 }
272 TEST_SUITE_END() // InPlaceValidate
273 
274 TEST_SUITE(Quantized)
276 TEST_SUITE(ScaleUnity)
278  framework::dataset::make("DataTypeIn1", DataType::QASYMM8_SIGNED)),
279  framework::dataset::make("DataTypeIn2", DataType::QASYMM8_SIGNED)),
280  framework::dataset::make("DataTypeOut", DataType::QASYMM8_SIGNED)),
281  framework::dataset::make("Scale", { scale_unity })),
282  PixelWiseMultiplicationPolicySTZDataset),
283  PixelWiseMultiplicationQASYMM8QuantDataset),
284  OutOfPlaceDataSet))
285 {
286  // Validate output
287  validate(Accessor(_target), _reference, tolerance_qasymm8);
288 }
293  framework::dataset::make("Scale", { scale_unity })),
294  PixelWiseMultiplicationPolicySTZDataset),
295  PixelWiseMultiplicationQASYMM8QuantInPlaceDataset),
296  InPlaceDataSet))
297 {
298  // Validate output
299  validate(Accessor(_target), _reference, tolerance_qasymm8);
300 }
301 TEST_SUITE_END() // ScaleUnity
302 TEST_SUITE_END() // QASYMM8_SIGNED
303 
305 TEST_SUITE(Scale255)
307  framework::dataset::make("DataTypeIn1", DataType::QASYMM8)),
308  framework::dataset::make("DataTypeIn2", DataType::QASYMM8)),
309  framework::dataset::make("DataTypeOut", DataType::QASYMM8)),
310  framework::dataset::make("Scale", { scale_255 })),
311  PixelWiseMultiplicationPolicySTNUDataset),
312  PixelWiseMultiplicationQASYMM8QuantDataset),
313  OutOfPlaceDataSet))
314 {
315  // Validate output
316  validate(Accessor(_target), _reference, tolerance_qasymm8);
317 }
318 TEST_SUITE_END() // Scale255
319 TEST_SUITE(ScaleUnity)
321  framework::dataset::make("DataTypeIn1", DataType::QASYMM8)),
322  framework::dataset::make("DataTypeIn2", DataType::QASYMM8)),
323  framework::dataset::make("DataTypeOut", DataType::QASYMM8)),
324  framework::dataset::make("Scale", { scale_unity })),
325  PixelWiseMultiplicationPolicySTZDataset),
326  PixelWiseMultiplicationQASYMM8QuantDataset),
327  OutOfPlaceDataSet))
328 {
329  // Validate output
330  validate(Accessor(_target), _reference, tolerance_qasymm8);
331 }
332 TEST_SUITE_END() // ScaleUnity
333 TEST_SUITE(ScaleOther)
335  framework::dataset::make("DataTypeIn1", DataType::QASYMM8)),
336  framework::dataset::make("DataTypeIn2", DataType::QASYMM8)),
337  framework::dataset::make("DataTypeOut", DataType::QASYMM8)),
338  framework::dataset::make("Scale", { scale_other })),
339  PixelWiseMultiplicationPolicySTZDataset),
340  PixelWiseMultiplicationQASYMM8QuantDataset),
341  OutOfPlaceDataSet))
342 {
343  // Validate output
344  validate(Accessor(_target), _reference, tolerance_qasymm8);
345 }
346 TEST_SUITE_END() // ScaleOther
347 TEST_SUITE(Broadcast)
349  combine(combine(combine(combine(combine(combine(combine(datasets::SmallShapesBroadcast(),
353  framework::dataset::make("Scale", { scale_other })),
354  PixelWiseMultiplicationPolicySTZDataset),
355  PixelWiseMultiplicationQASYMM8QuantDataset),
356  OutOfPlaceDataSet))
357 {
358  // Validate output
359  validate(Accessor(_target), _reference, tolerance_qasymm8);
360 }
362  combine(combine(combine(combine(combine(combine(combine(datasets::TinyShapesBroadcastInplace(),
366  framework::dataset::make("Scale", { scale_other })),
367  PixelWiseMultiplicationPolicySTZDataset),
368  PixelWiseMultiplicationQASYMM8QuantInPlaceDataset),
369  InPlaceDataSet))
370 {
371  // Validate output
372  validate(Accessor(_target), _reference, tolerance_qasymm8);
373 }
374 TEST_SUITE_END() // Broadcast
375 TEST_SUITE_END() // QASYMM8
377 TEST_SUITE(Scale255)
379  framework::dataset::make("DataTypeIn1", DataType::QSYMM16)),
380  framework::dataset::make("DataTypeIn2", DataType::QSYMM16)),
381  framework::dataset::make("DataTypeOut", DataType::QSYMM16)),
382  framework::dataset::make("Scale", { scale_255 })),
383  PixelWiseMultiplicationPolicySTNUDataset),
384  PixelWiseMultiplicationQSYMM16QuantDataset),
385  OutOfPlaceDataSet))
386 {
387  // Validate output
388  validate(Accessor(_target), _reference, tolerance_qsymm16);
389 }
390 TEST_SUITE_END() // Scale255
391 TEST_SUITE(ScaleUnity)
393  framework::dataset::make("DataTypeIn1", DataType::QSYMM16)),
394  framework::dataset::make("DataTypeIn2", DataType::QSYMM16)),
395  framework::dataset::make("DataTypeOut", DataType::QSYMM16)),
396  framework::dataset::make("Scale", { scale_unity })),
397  PixelWiseMultiplicationPolicySTZDataset),
398  PixelWiseMultiplicationQSYMM16QuantDataset),
399  OutOfPlaceDataSet))
400 {
401  // Validate output
402  validate(Accessor(_target), _reference, tolerance_qsymm16);
403 }
404 TEST_SUITE_END() // ScaleUnity
405 TEST_SUITE(ScaleOther)
407  framework::dataset::make("DataTypeIn1", DataType::QSYMM16)),
408  framework::dataset::make("DataTypeIn2", DataType::QSYMM16)),
409  framework::dataset::make("DataTypeOut", DataType::QSYMM16)),
410  framework::dataset::make("Scale", { scale_other })),
411  PixelWiseMultiplicationPolicySTZDataset),
412  PixelWiseMultiplicationQSYMM16QuantDataset),
413  OutOfPlaceDataSet))
414 {
415  // Validate output
416  validate(Accessor(_target), _reference, tolerance_qsymm16);
417 }
418 TEST_SUITE_END() // ScaleOther
419 TEST_SUITE_END() // QSYMM16
420 TEST_SUITE(QSYMM16toS32)
422  framework::dataset::make("DataTypeIn1", DataType::QSYMM16)),
423  framework::dataset::make("DataTypeIn2", DataType::QSYMM16)),
424  framework::dataset::make("DataTypeOut", DataType::S32)),
425  framework::dataset::make("Scale", { scale_unity })),
426  PixelWiseMultiplicationPolicySTZDataset),
427  PixelWiseMultiplicationQSYMM16QuantDataset),
428  OutOfPlaceDataSet))
429 {
430  // Validate output
431  validate(Accessor(_target), _reference);
432 }
433 TEST_SUITE_END() // QSYMM16toS32
434 TEST_SUITE_END() // Quantized
435 
436 TEST_SUITE(U8U8toS16)
437 
439  framework::dataset::make("DataTypeIn1", DataType::U8)),
440  framework::dataset::make("DataTypeIn2", DataType::U8)),
441  framework::dataset::make("DataTypeOut", DataType::S16)),
442  framework::dataset::make("Scale", { scale_255 })),
443  datasets::ConvertPolicies()),
445  OutOfPlaceDataSet))
446 {
447  // Validate output
448  validate_wrap(Accessor(_target), _reference, AbsoluteTolerance<int16_t>(1), 0.f);
449 }
450 
452  framework::dataset::make("DataTypeIn1", DataType::U8)),
453  framework::dataset::make("DataTypeIn2", DataType::U8)),
454  framework::dataset::make("DataTypeOut", DataType::S16)),
455  framework::dataset::make("Scale", { scale_other })),
456  datasets::ConvertPolicies()),
458  framework::dataset::make("InPlace", { false })))
459 {
460  // Validate output
461  validate(Accessor(_target), _reference);
462 }
463 
464 TEST_SUITE_END() // U8U8toS16
465 
466 TEST_SUITE(U8toU8)
467 
468 TEST_SUITE(Scale255)
469 PIXEL_WISE_MULTIPLICATION_FIXTURE_DATA_TEST_CASE(RunSmall, ToU8Fixture<uint8_t>, ALL, SmallShapes(), U8, U8, U8, scale_255, TO_NEAREST_UP, InPlaceDataSet, WRAP_VALIDATE(uint8_t, 1))
470 TEST_SUITE_END() // Scale255
471 
472 TEST_SUITE(ScaleUnity)
473 PIXEL_WISE_MULTIPLICATION_FIXTURE_DATA_TEST_CASE(RunSmall, ToU8Fixture<uint8_t>, ALL, SmallShapes(), U8, U8, U8, scale_unity, TO_ZERO, InPlaceDataSet, DEFAULT_VALIDATE)
474 TEST_SUITE_END() // ScaleUnity
475 
476 TEST_SUITE(ScaleOther)
477 PIXEL_WISE_MULTIPLICATION_FIXTURE_DATA_TEST_CASE(RunSmall, ToU8Fixture<uint8_t>, ALL, SmallShapes(), U8, U8, U8, scale_other, TO_ZERO, InPlaceDataSet, DEFAULT_VALIDATE)
478 TEST_SUITE_END() // ScaleOther
479 
480 TEST_SUITE_END() // U8toU8
481 
482 TEST_SUITE(U8toS16)
483 
484 TEST_SUITE(Scale255)
485 PIXEL_WISE_MULTIPLICATION_FIXTURE_DATA_TEST_CASE(RunSmall, ToS16Fixture<uint8_t>, ALL, SmallShapes(), U8, S16, S16, scale_255, TO_NEAREST_UP, OutOfPlaceDataSet,
486  WRAP_VALIDATE(int16_t, 2))
487 TEST_SUITE_END() // Scale255
488 
489 TEST_SUITE(ScaleUnity)
490 PIXEL_WISE_MULTIPLICATION_FIXTURE_DATA_TEST_CASE(RunSmall, ToS16Fixture<uint8_t>, ALL, SmallShapes(), U8, S16, S16, scale_unity, TO_ZERO, OutOfPlaceDataSet,
492 TEST_SUITE_END() // ScaleUnity
493 
494 TEST_SUITE(ScaleOther)
495 PIXEL_WISE_MULTIPLICATION_FIXTURE_DATA_TEST_CASE(RunSmall, ToS16Fixture<uint8_t>, ALL, SmallShapes(), U8, S16, S16, scale_other, TO_ZERO, OutOfPlaceDataSet,
497 TEST_SUITE_END() // ScaleOther
498 
499 TEST_SUITE_END() // U8toS16
500 
501 TEST_SUITE(S16toS16)
502 
503 TEST_SUITE(Scale255)
504 PIXEL_WISE_MULTIPLICATION_FIXTURE_DATA_TEST_CASE(RunSmall, ToS16Fixture<int16_t>, ALL, SmallShapes(), S16, S16, S16, scale_255, TO_NEAREST_UP, InPlaceDataSet, WRAP_VALIDATE(int16_t, 2))
505 TEST_SUITE_END() // Scale255
506 
507 TEST_SUITE(ScaleUnity)
508 PIXEL_WISE_MULTIPLICATION_FIXTURE_DATA_TEST_CASE(RunSmall, ToS16Fixture<int16_t>, ALL, SmallShapes(), S16, S16, S16, scale_unity, TO_ZERO, InPlaceDataSet, DEFAULT_VALIDATE)
509 TEST_SUITE_END() // ScaleUnity
510 
511 TEST_SUITE(ScaleOther)
512 PIXEL_WISE_MULTIPLICATION_FIXTURE_DATA_TEST_CASE(RunSmall, ToS16Fixture<int16_t>, ALL, SmallShapes(), S16, S16, S16, scale_other, TO_ZERO, InPlaceDataSet, DEFAULT_VALIDATE)
513 TEST_SUITE_END() // ScaleOther
514 
515 TEST_SUITE_END() // S16toS16
516 
517 TEST_SUITE(S32toS32)
518 
519 TEST_SUITE(ScaleUnity)
520 PIXEL_WISE_MULTIPLICATION_FIXTURE_DATA_TEST_CASE(RunSmall, ToS32Fixture<int32_t>, ALL, SmallShapes(), S32, S32, S32, scale_unity, TO_ZERO, InPlaceDataSet, WRAP_VALIDATE(int32_t, 1))
521 TEST_SUITE_END() // ScaleUnity
522 
523 TEST_SUITE(ScaleOther)
524 PIXEL_WISE_MULTIPLICATION_FIXTURE_DATA_TEST_CASE(RunSmall, ToS32Fixture<int32_t>, ALL, SmallShapes(), S32, S32, S32, scale_other, TO_ZERO, InPlaceDataSet, WRAP_VALIDATE(int32_t, 1))
525 TEST_SUITE_END() // ScaleOther
526 
527 TEST_SUITE(Broadcast)
528 PIXEL_WISE_MULTIPLICATION_FIXTURE_DATA_TEST_CASE(RunSmall, BroadcastFixture<int32_t>, ALL, SmallShapesBroadcast(), S32, S32, S32, scale_unity, TO_ZERO, framework::dataset::make("InPlace", { false }),
529  WRAP_VALIDATE(int32_t, 1))
530 TEST_SUITE_END() // Broadcast
531 
532 TEST_SUITE_END() // S32toS32
533 
534 #ifdef __ARM_FEATURE_FP16_VECTOR_ARITHMETIC
535 TEST_SUITE(F16toF16)
536 
537 TEST_SUITE(Scale255)
538 PIXEL_WISE_MULTIPLICATION_FIXTURE_DATA_TEST_CASE(RunSmall, ToF16Fixture<half_float::half>, ALL, SmallShapes(), F16, F16, F16, scale_255, TO_NEAREST_UP, InPlaceDataSet, VALIDATE(float, 1.f))
539 TEST_SUITE_END() // Scale255
540 
541 TEST_SUITE_END() // F16toF16
542 #endif /* __ARM_FEATURE_FP16_VECTOR_ARITHMETIC */
543 
544 TEST_SUITE(F32toF32)
545 
546 TEST_SUITE(Scale255)
547 PIXEL_WISE_MULTIPLICATION_FIXTURE_DATA_TEST_CASE(RunSmall, ToF32Fixture<float>, ALL, SmallShapes(), F32, F32, F32, scale_255, TO_NEAREST_UP, InPlaceDataSet, VALIDATE(float, 1.f))
548 TEST_SUITE_END() // Scale255
549 
550 TEST_SUITE(ScaleUnity)
551 PIXEL_WISE_MULTIPLICATION_FIXTURE_DATA_TEST_CASE(RunSmall, ToF32Fixture<float>, ALL, SmallShapes(), F32, F32, F32, scale_unity, TO_ZERO, InPlaceDataSet, DEFAULT_VALIDATE)
552 TEST_SUITE_END() // ScaleUnity
553 
554 TEST_SUITE(ScaleOther)
555 PIXEL_WISE_MULTIPLICATION_FIXTURE_DATA_TEST_CASE(RunSmall, ToF32Fixture<float>, ALL, SmallShapes(), F32, F32, F32, scale_other, TO_ZERO, InPlaceDataSet, DEFAULT_VALIDATE)
556 TEST_SUITE_END() // ScaleOther
557 
558 TEST_SUITE_END() // F32toF32
559 
560 TEST_SUITE(Broadcast)
561 PIXEL_WISE_MULTIPLICATION_FIXTURE_DATA_TEST_CASE(RunSmall, BroadcastFixture<float>, ALL, SmallShapesBroadcast(), F32, F32, F32, scale_255, TO_NEAREST_UP, framework::dataset::make("InPlace", { false }),
562  VALIDATE(float, 1.f))
563 TEST_SUITE_END() // Broadcast
564 
567 } // namespace validation
568 } // namespace test
569 } // namespace arm_compute
#define VALIDATE(TYPE, TOLERANCE)
PixelWiseMultiplicationValidationQuantizedFixture< Tensor, Accessor, NEPixelWiseMultiplication, int8_t, int8_t > NEPixelWiseMultiplicationQASYMM8SignedFixture
PixelWiseMultiplicationValidationFixture< Tensor, Accessor, NEPixelWiseMultiplication, T, float > NEPixelWiseMultiplicationToF32Fixture
Shape of a tensor.
Definition: TensorShape.h:39
Class reprensenting an absolute tolerance value.
Definition: Validation.h:61
quantized, symmetric fixed-point 16-bit number
Rounds to nearest value; half rounds away from zero.
PixelWiseMultiplicationBroadcastValidationQuantizedFixture< Tensor, Accessor, NEPixelWiseMultiplication, uint8_t, uint8_t > NEPixelWiseMultiplicationBroadcastQASYMM8Fixture
1 channel, 1 U8 per channel
PixelWiseMultiplicationValidationQuantizedFixture< Tensor, Accessor, NEPixelWiseMultiplication, int16_t, int16_t, int32_t > NEPixelWiseMultiplicationQSYMM16ToS32Fixture
#define PIXEL_WISE_MULTIPLICATION_FIXTURE_DATA_TEST_CASE(TEST_NAME, FIXTURE, MODE, SHAPES, DT1, DT2, DT3, SCALE, RP, INPLACE_DATASET, VALIDATE)
1 channel, 1 F32 per channel
ARM_COMPUTE_EXPECT(has_error==expected, framework::LogLevel::ERRORS)
#define WRAP_VALIDATE(TYPE, TOLERANCE)
PixelWiseMultiplicationBroadcastValidationFixture< Tensor, Accessor, NEPixelWiseMultiplication, T, T > NEPixelWiseMultiplicationBroadcastFixture
std::enable_if< is_container< T >::value, ContainerDataset< T > >::type make(std::string name, T &&values)
Helper function to create a ContainerDataset.
Status class.
Definition: Error.h:52
Copyright (c) 2017-2022 Arm Limited.
1 channel, 1 S32 per channel
PixelWiseMultiplicationValidationFixture< Tensor, Accessor, NEPixelWiseMultiplication, T, half_float::half > NEPixelWiseMultiplicationToF16Fixture
DATA_TEST_CASE(Validate, framework::DatasetMode::ALL, zip(zip(zip(framework::dataset::make("InputInfo", { TensorInfo(TensorShape(27U, 13U, 2U), 1, DataType::F32), TensorInfo(TensorShape(27U, 13U, 2U), 1, DataType::F32), TensorInfo(TensorShape(32U, 13U, 2U), 1, DataType::F32), TensorInfo(TensorShape(32U, 13U, 2U), 1, DataType::QASYMM8), TensorInfo(TensorShape(27U, 13U, 2U), 1, DataType::QASYMM8), TensorInfo(TensorShape(27U, 13U, 2U), 1, DataType::F32), TensorInfo(TensorShape(32U, 13U, 2U), 1, DataType::QSYMM16), TensorInfo(TensorShape(32U, 13U, 2U), 1, DataType::QSYMM16), TensorInfo(TensorShape(32U, 13U, 2U), 1, DataType::QSYMM16), }), framework::dataset::make("OutputInfo",{ TensorInfo(TensorShape(27U, 13U, 2U), 1, DataType::F16), TensorInfo(TensorShape(27U, 13U, 2U), 1, DataType::F32), TensorInfo(TensorShape(32U, 13U, 2U), 1, DataType::F32), TensorInfo(TensorShape(32U, 13U, 2U), 1, DataType::QASYMM8), TensorInfo(TensorShape(27U, 13U, 2U), 1, DataType::QASYMM8), TensorInfo(TensorShape(30U, 11U, 2U), 1, DataType::F32), TensorInfo(TensorShape(32U, 13U, 2U), 1, DataType::QSYMM16, QuantizationInfo(1.f/32768.f, 0)), TensorInfo(TensorShape(32U, 13U, 2U), 1, DataType::QSYMM16, QuantizationInfo(1.f/32768.f, 0)), TensorInfo(TensorShape(32U, 13U, 2U), 1, DataType::QSYMM16, QuantizationInfo(1.f/32768.f, 0)), })), framework::dataset::make("ActivationInfo", { ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU), ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU), ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU), ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::LU_BOUNDED_RELU), ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::TANH), ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU), ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::TANH), ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::LOGISTIC), ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::SQRT), })), framework::dataset::make("Expected", { false, true, true, true, false, false, true, true, false })), input_info, output_info, act_info, expected)
PixelWiseMultiplicationBroadcastValidationQuantizedFixture< Tensor, Accessor, NEPixelWiseMultiplication, int8_t, int8_t > NEPixelWiseMultiplicationBroadcastQASYMM8SignedFixture
Accessor implementation for Tensor objects.
Definition: Accessor.h:35
DatasetMode
Possible dataset modes.
Definition: DatasetModes.h:40
PixelWiseMultiplicationValidationQuantizedFixture< Tensor, Accessor, NEPixelWiseMultiplication, int16_t, int16_t > NEPixelWiseMultiplicationQSYMM16Fixture
TEST_SUITE_END() FIXTURE_DATA_TEST_CASE(RunSmall
[CLActivationLayer Test snippet]
PixelWiseMultiplicationValidationFixture< Tensor, Accessor, NEPixelWiseMultiplication, T, int32_t > NEPixelWiseMultiplicationToS32Fixture
quantized, asymmetric fixed-point 8-bit number unsigned
validate(CLAccessor(output_state), expected_output)
PixelWiseMultiplicationValidationFixture< Tensor, Accessor, NEPixelWiseMultiplication, T, uint8_t > NEPixelWiseMultiplicationToU8Fixture
1 channel, 1 S16 per channel
PixelWiseMultiplicationValidationFixture< Tensor, Accessor, NEPixelWiseMultiplication, T, int16_t > NEPixelWiseMultiplicationToS16Fixture
FIXTURE_DATA_TEST_CASE(RunSmall, CLAbsLayerFixture< half >, framework::DatasetMode::PRECOMMIT, combine(datasets::SmallShapes(), framework::dataset::make("DataType", DataType::F16)))
Definition: AbsLayer.cpp:50
static Status validate(const ITensorInfo *input1, const ITensorInfo *input2, const ITensorInfo *output, float scale, ConvertPolicy overflow_policy, RoundingPolicy rounding_policy, const ActivationLayerInfo &act_info=ActivationLayerInfo())
Static function to check if given info will lead to a valid configuration of NEPixelWiseMultiplicatio...
#define DEFAULT_VALIDATE
Store the tensor&#39;s metadata.
Definition: TensorInfo.h:43
PixelWiseMultiplicationValidationQuantizedFixture< Tensor, Accessor, NEPixelWiseMultiplication, uint8_t, uint8_t > NEPixelWiseMultiplicationQASYMM8Fixture
TEST_CASE(FusedActivation, framework::DatasetMode::ALL)
Validate fused activation expecting the following behaviours:
quantized, asymmetric fixed-point 8-bit number signed
PixelWiseMultiplicationValidationFixture< Tensor, Accessor, NEPixelWiseMultiplication, uint8_t, uint8_t, int16_t > NEPixelWiseMultiplicationU8U8ToS16Fixture
zip(zip(framework::dataset::make("Weights", { TensorInfo(TensorShape(32U, 13U, 2U, 2U), 1, DataType::F32), TensorInfo(TensorShape(32U, 13U, 2U, 2U), 1, DataType::F32), TensorInfo(TensorShape(32U, 13U, 2U, 1U), 1, DataType::F32), }), framework::dataset::make("MVBGInfo",{ TensorInfo(TensorShape(2U), 1, DataType::F32), TensorInfo(TensorShape(2U), 1, DataType::F16), TensorInfo(TensorShape(5U), 1, DataType::F32), })), framework::dataset::make("Expected", { true, false, false}))
TEST_SUITE(QASYMM8_to_F32) FIXTURE_DATA_TEST_CASE(RunSmall
DataType
Available data types.
Definition: Types.h:79
Truncates the least significant values that are lost in operations.
combine(datasets::SmallShapes(), framework::dataset::make("DataType", DataType::F32)))
Definition: AbsLayer.cpp:65
void validate_wrap(const IAccessor &tensor, const SimpleTensor< T > &reference, U tolerance_value, float tolerance_number)
Definition: Validation.h:373