Compute Library
 21.02
PixelWiseMultiplication.cpp
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2017-2020 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 PixelWiseMultiplicationPolicySTNUDataset = combine(
62 
63 const auto PixelWiseMultiplicationPolicySTZDataset = combine(
65  framework::dataset::make("RoundingPolicy", { RoundingPolicy::TO_ZERO }));
66 
67 /** Tests for in-place computation
68  * With current interface storing TensorInfo with quantization information
69  * in the kernel, it is difficult to have different tensor metadata
70  * (e.g., quantization information, data type, different shape for broadcasting)
71  * when an input is used as the output of the computation.
72  * So, the following dataset for in-place computation is used only when
73  * the exact same input and output Tensor object makes sense
74  * (i.e., all the tensor metadata is the same) whereas if output is
75  * expected to have either different quantization information, data type
76  * or different shape we are not testing in-place computation.
77  */
78 const auto InPlaceDataSet = framework::dataset::make("InPlace", { false, true });
79 
80 #define DEFAULT_VALIDATE validate(Accessor(_target), _reference);
81 #define VALIDATE(TYPE, TOLERANCE) validate(Accessor(_target), _reference, AbsoluteTolerance<TYPE>(TOLERANCE), 0.f);
82 #define WRAP_VALIDATE(TYPE, TOLERANCE) validate_wrap(Accessor(_target), _reference, AbsoluteTolerance<TYPE>(TOLERANCE), 0.f);
83 
84 // *INDENT-OFF*
85 // clang-format off
86 #define PIXEL_WISE_MULTIPLICATION_FIXTURE_DATA_TEST_CASE(TEST_NAME, FIXTURE, MODE, SHAPES, DT1, DT2, DT3, SCALE, RP, INPLACE_DATASET, VALIDATE) \
87  FIXTURE_DATA_TEST_CASE(TEST_NAME, NEPixelWiseMultiplication##FIXTURE, framework::DatasetMode::MODE, \
88  combine(combine(combine(combine(combine(combine(combine( \
89  datasets::SHAPES, \
90  framework::dataset::make("DataType1", DataType::DT1)), \
91  framework::dataset::make("DataType2", DataType::DT2)), \
92  framework::dataset::make("DataType3", DataType::DT3)), \
93  framework::dataset::make("Scale", std::move(SCALE))), \
94  datasets::ConvertPolicies()), \
95  framework::dataset::make("RoundingPolicy", RoundingPolicy::RP)), \
96  (INPLACE_DATASET))) \
97  { \
98  VALIDATE \
99  }
100 
101 // *INDENT-ON*
102 // clang-format on
103 } // namespace
104 
105 using NEPixelWiseMultiplicationQASYMM8Fixture = PixelWiseMultiplicationValidationQuantizedFixture<Tensor, Accessor, NEPixelWiseMultiplication, uint8_t, uint8_t>;
106 using NEPixelWiseMultiplicationQASYMM8SignedFixture = PixelWiseMultiplicationValidationQuantizedFixture<Tensor, Accessor, NEPixelWiseMultiplication, int8_t, int8_t>;
107 using NEPixelWiseMultiplicationQSYMM16Fixture = PixelWiseMultiplicationValidationQuantizedFixture<Tensor, Accessor, NEPixelWiseMultiplication, int16_t, int16_t>;
108 using NEPixelWiseMultiplicationQSYMM16ToS32Fixture = PixelWiseMultiplicationValidationQuantizedFixture<Tensor, Accessor, NEPixelWiseMultiplication, int16_t, int16_t, int32_t>;
109 template <typename T>
110 using NEPixelWiseMultiplicationToU8Fixture = PixelWiseMultiplicationValidationFixture<Tensor, Accessor, NEPixelWiseMultiplication, T, uint8_t>;
111 template <typename T>
112 using NEPixelWiseMultiplicationToS16Fixture = PixelWiseMultiplicationValidationFixture<Tensor, Accessor, NEPixelWiseMultiplication, T, int16_t>;
113 template <typename T>
114 using NEPixelWiseMultiplicationToS32Fixture = PixelWiseMultiplicationValidationFixture<Tensor, Accessor, NEPixelWiseMultiplication, T, int32_t>;
115 template <typename T>
116 using NEPixelWiseMultiplicationToF16Fixture = PixelWiseMultiplicationValidationFixture<Tensor, Accessor, NEPixelWiseMultiplication, T, half_float::half>;
117 template <typename T>
118 using NEPixelWiseMultiplicationToF32Fixture = PixelWiseMultiplicationValidationFixture<Tensor, Accessor, NEPixelWiseMultiplication, T, float>;
119 using NEPixelWiseMultiplicationU8U8ToS16Fixture = PixelWiseMultiplicationValidationFixture<Tensor, Accessor, NEPixelWiseMultiplication, uint8_t, uint8_t, int16_t>;
120 template <typename T>
121 using NEPixelWiseMultiplicationBroadcastFixture = PixelWiseMultiplicationBroadcastValidationFixture<Tensor, Accessor, NEPixelWiseMultiplication, T, T>;
122 using NEPixelWiseMultiplicationBroadcastQASYMM8Fixture = PixelWiseMultiplicationBroadcastValidationQuantizedFixture<Tensor, Accessor, NEPixelWiseMultiplication, uint8_t, uint8_t>;
123 using NEPixelWiseMultiplicationBroadcastQASYMM8SignedFixture = PixelWiseMultiplicationBroadcastValidationQuantizedFixture<Tensor, Accessor, NEPixelWiseMultiplication, int8_t, int8_t>;
124 
125 TEST_SUITE(NEON)
126 TEST_SUITE(PixelWiseMultiplication)
127 
128 // *INDENT-OFF*
129 // clang-format off
130 DATA_TEST_CASE(Validate, framework::DatasetMode::ALL, zip(zip(zip(zip(zip(
131  framework::dataset::make("Input1Info", { TensorInfo(TensorShape(32U, 13U, 2U), 1, DataType::U8), //1 Ok
132  TensorInfo(TensorShape(32U, 13U, 2U), 1, DataType::U8), //2 Ok
133  TensorInfo(TensorShape(27U, 13U, 2U), 1, DataType::U8), //3 Window shrink
134  TensorInfo(TensorShape(32U, 13U, 2U), 1, DataType::U8), //4 Invalid scale
135  TensorInfo(TensorShape(32U, 13U, 2U), 1, DataType::U8), //5 Invalid data type combination
136  TensorInfo(TensorShape(32U, 13U, 2U), 1, DataType::F32), //6 Mismatching shapes
137  TensorInfo(TensorShape(32U, 13U, 2U), 1, DataType::F32), //7 Mismatching data type
138  TensorInfo(TensorShape(32U, 13U, 2U), 1, DataType::QASYMM8), //8 Mismatching data type
139  TensorInfo(TensorShape(32U, 13U, 2U), 1, DataType::QASYMM8_SIGNED), //9 Ok
140  TensorInfo(TensorShape(32U, 13U, 2U), 1, DataType::QASYMM8_SIGNED), //10 Mismatching data type
141  TensorInfo(TensorShape(32U, 13U, 2U), 1, DataType::QASYMM8), //11 Mismatching data type
142  TensorInfo(TensorShape(32U, 13U, 2U), 1, DataType::QASYMM8), //12 Ok
143  TensorInfo(TensorShape(32U, 13U, 2U), 1, DataType::QASYMM8_SIGNED), //13 Quantized cannot do WRAP
144  TensorInfo(TensorShape(32U, 13U, 2U), 1, DataType::S32), //14 S32 does not support scale255
145  }),
146  framework::dataset::make("Input2Info",{ TensorInfo(TensorShape(32U, 13U, 2U), 1, DataType::U8),
147  TensorInfo(TensorShape(32U, 13U, 2U), 1, DataType::U8),
148  TensorInfo(TensorShape(27U, 13U, 2U), 1, DataType::U8),
149  TensorInfo(TensorShape(32U, 13U, 2U), 1, DataType::U8),
150  TensorInfo(TensorShape(32U, 13U, 2U), 1, DataType::S16),
151  TensorInfo(TensorShape(48U, 11U, 2U), 1, DataType::F32),
152  TensorInfo(TensorShape(32U, 13U, 2U), 1, DataType::U8),
153  TensorInfo(TensorShape(32U, 13U, 2U), 1, DataType::U8),
159  TensorInfo(TensorShape(32U, 13U, 2U), 1, DataType::S32),
160  })),
161  framework::dataset::make("OutputInfo",{ TensorInfo(TensorShape(32U, 13U, 2U), 1, DataType::S16),
162  TensorInfo(TensorShape(32U, 13U, 2U), 1, DataType::U8),
163  TensorInfo(TensorShape(27U, 13U, 2U), 1, DataType::U8),
164  TensorInfo(TensorShape(32U, 13U, 2U), 1, DataType::U8),
165  TensorInfo(TensorShape(32U, 13U, 2U), 1, DataType::U8),
166  TensorInfo(TensorShape(48U, 11U, 2U), 1, DataType::F32),
167  TensorInfo(TensorShape(32U, 13U, 2U), 1, DataType::F32),
168  TensorInfo(TensorShape(32U, 13U, 2U), 1, DataType::U8),
174  TensorInfo(TensorShape(32U, 13U, 2U), 1, DataType::S32),
175  })),
176  framework::dataset::make("Scale",{ scale_unity,
177  scale_unity,
178  scale_unity,
179  -1.f,
180  scale_unity,
181  scale_unity,
182  scale_unity,
183  scale_unity,
184  scale_unity,
185  scale_unity,
186  scale_unity,
187  scale_unity,
188  scale_unity,
189  scale_255})),
190  framework::dataset::make("OverflowPolicy",{
205  })),
206 
207  framework::dataset::make("Expected", { true, true, true, false, false, false, false, false, true , false, false, true, false, false})),
208  input1_info, input2_info, output_info, scale, policy, expected)
209 {
210  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));
212 }
213 // clang-format on
214 // *INDENT-ON*
215 
216 TEST_SUITE(InPlaceValidate)
218 {
219  const auto random_shape = TensorShape{ 9, 9 };
220  const auto single_tensor_info = TensorInfo{ random_shape, 1, DataType::F32 };
221 
222  Status result = NEPixelWiseMultiplication::validate(&single_tensor_info, &single_tensor_info, &single_tensor_info, scale_unity, ConvertPolicy::WRAP, RoundingPolicy::TO_ZERO);
223  ARM_COMPUTE_EXPECT(bool(result) == true, framework::LogLevel::ERRORS);
224 }
225 
226 TEST_CASE(ValidBroadCast, framework::DatasetMode::ALL)
227 {
228  const auto larger_shape = TensorShape{ 27U, 13U, 2U };
229  const auto smaller_shape = TensorShape{ 1U, 13U, 2U };
230 
231  const auto larger_tensor_info = TensorInfo{ larger_shape, 1, DataType::F32 };
232  const auto smaller_tensor_info = TensorInfo{ smaller_shape, 1, DataType::F32 };
233 
234  Status result = NEPixelWiseMultiplication::validate(&larger_tensor_info, &smaller_tensor_info, &larger_tensor_info, scale_unity, ConvertPolicy::WRAP, RoundingPolicy::TO_ZERO);
235  ARM_COMPUTE_EXPECT(bool(result) == true, framework::LogLevel::ERRORS);
236 }
237 
238 TEST_CASE(InvalidBroadcastOutput, framework::DatasetMode::ALL)
239 {
240  const auto larger_shape = TensorShape{ 27U, 13U, 2U };
241  const auto smaller_shape = TensorShape{ 1U, 13U, 2U };
242 
243  const auto larger_tensor_info = TensorInfo{ larger_shape, 1, DataType::F32 };
244  const auto smaller_tensor_info = TensorInfo{ smaller_shape, 1, DataType::F32 };
245 
246  Status result = NEPixelWiseMultiplication::validate(&larger_tensor_info, &smaller_tensor_info, &smaller_tensor_info, scale_unity, ConvertPolicy::WRAP, RoundingPolicy::TO_ZERO);
247  ARM_COMPUTE_EXPECT(bool(result) == false, framework::LogLevel::ERRORS);
248 }
249 
250 TEST_CASE(InvalidBroadcastBoth, framework::DatasetMode::ALL)
251 {
252  const auto shape0 = TensorShape{ 9U, 9U };
253  const auto shape1 = TensorShape{ 9U, 1U, 2U };
254 
255  const auto info0 = TensorInfo{ shape0, 1, DataType::F32 };
256  const auto info1 = TensorInfo{ shape1, 1, DataType::F32 };
257 
258  Status result{};
259 
260  result = NEPixelWiseMultiplication::validate(&info0, &info1, &info0, scale_unity, ConvertPolicy::WRAP, RoundingPolicy::TO_ZERO);
261  ARM_COMPUTE_EXPECT(bool(result) == false, framework::LogLevel::ERRORS);
262 
263  result = NEPixelWiseMultiplication::validate(&info0, &info1, &info1, scale_unity, ConvertPolicy::WRAP, RoundingPolicy::TO_ZERO);
264  ARM_COMPUTE_EXPECT(bool(result) == false, framework::LogLevel::ERRORS);
265 }
266 TEST_SUITE_END() // InPlaceValidate
267 
268 TEST_SUITE(Quantized)
270 TEST_SUITE(ScaleUnity)
272  framework::dataset::make("DataTypeIn1", DataType::QASYMM8_SIGNED)),
273  framework::dataset::make("DataTypeIn2", DataType::QASYMM8_SIGNED)),
274  framework::dataset::make("DataTypeOut", DataType::QASYMM8_SIGNED)),
275  framework::dataset::make("Scale", { scale_unity })),
276  PixelWiseMultiplicationPolicySTZDataset),
277  PixelWiseMultiplicationQASYMM8QuantDataset),
278  InPlaceDataSet))
279 {
280  // Validate output
281  validate(Accessor(_target), _reference, tolerance_qasymm8);
282 }
283 TEST_SUITE_END() // ScaleUnity
284 TEST_SUITE_END() // QASYMM8_SIGNED
285 
287 TEST_SUITE(Scale255)
289  framework::dataset::make("DataTypeIn1", DataType::QASYMM8)),
290  framework::dataset::make("DataTypeIn2", DataType::QASYMM8)),
291  framework::dataset::make("DataTypeOut", DataType::QASYMM8)),
292  framework::dataset::make("Scale", { scale_255 })),
293  PixelWiseMultiplicationPolicySTNUDataset),
294  PixelWiseMultiplicationQASYMM8QuantDataset),
295  InPlaceDataSet))
296 {
297  // Validate output
298  validate(Accessor(_target), _reference, tolerance_qasymm8);
299 }
300 TEST_SUITE_END() // Scale255
301 TEST_SUITE(ScaleUnity)
303  framework::dataset::make("DataTypeIn1", DataType::QASYMM8)),
304  framework::dataset::make("DataTypeIn2", DataType::QASYMM8)),
305  framework::dataset::make("DataTypeOut", DataType::QASYMM8)),
306  framework::dataset::make("Scale", { scale_unity })),
307  PixelWiseMultiplicationPolicySTZDataset),
308  PixelWiseMultiplicationQASYMM8QuantDataset),
309  InPlaceDataSet))
310 {
311  // Validate output
312  validate(Accessor(_target), _reference, tolerance_qasymm8);
313 }
314 TEST_SUITE_END() // ScaleUnity
315 TEST_SUITE(ScaleOther)
317  framework::dataset::make("DataTypeIn1", DataType::QASYMM8)),
318  framework::dataset::make("DataTypeIn2", DataType::QASYMM8)),
319  framework::dataset::make("DataTypeOut", DataType::QASYMM8)),
320  framework::dataset::make("Scale", { scale_other })),
321  PixelWiseMultiplicationPolicySTZDataset),
322  PixelWiseMultiplicationQASYMM8QuantDataset),
323  InPlaceDataSet))
324 {
325  // Validate output
326  validate(Accessor(_target), _reference, tolerance_qasymm8);
327 }
328 TEST_SUITE_END() // ScaleOther
329 TEST_SUITE(Broadcast)
331  combine(combine(combine(combine(combine(combine(combine(datasets::SmallShapesBroadcast(),
335  framework::dataset::make("Scale", { scale_other })),
336  PixelWiseMultiplicationPolicySTZDataset),
337  PixelWiseMultiplicationQASYMM8QuantDataset),
338  framework::dataset::make("InPlace", { false })))
339 {
340  // Validate output
341  validate(Accessor(_target), _reference, tolerance_qasymm8);
342 }
343 TEST_SUITE_END() // Broadcast
344 TEST_SUITE_END() // QASYMM8
346 TEST_SUITE(Scale255)
348  framework::dataset::make("DataTypeIn1", DataType::QSYMM16)),
349  framework::dataset::make("DataTypeIn2", DataType::QSYMM16)),
350  framework::dataset::make("DataTypeOut", DataType::QSYMM16)),
351  framework::dataset::make("Scale", { scale_255 })),
352  PixelWiseMultiplicationPolicySTNUDataset),
353  PixelWiseMultiplicationQSYMM16QuantDataset),
354  InPlaceDataSet))
355 {
356  // Validate output
357  validate(Accessor(_target), _reference, tolerance_qsymm16);
358 }
359 TEST_SUITE_END() // Scale255
360 TEST_SUITE(ScaleUnity)
362  framework::dataset::make("DataTypeIn1", DataType::QSYMM16)),
363  framework::dataset::make("DataTypeIn2", DataType::QSYMM16)),
364  framework::dataset::make("DataTypeOut", DataType::QSYMM16)),
365  framework::dataset::make("Scale", { scale_unity })),
366  PixelWiseMultiplicationPolicySTZDataset),
367  PixelWiseMultiplicationQSYMM16QuantDataset),
368  InPlaceDataSet))
369 {
370  // Validate output
371  validate(Accessor(_target), _reference, tolerance_qsymm16);
372 }
373 TEST_SUITE_END() // ScaleUnity
374 TEST_SUITE(ScaleOther)
376  framework::dataset::make("DataTypeIn1", DataType::QSYMM16)),
377  framework::dataset::make("DataTypeIn2", DataType::QSYMM16)),
378  framework::dataset::make("DataTypeOut", DataType::QSYMM16)),
379  framework::dataset::make("Scale", { scale_other })),
380  PixelWiseMultiplicationPolicySTZDataset),
381  PixelWiseMultiplicationQSYMM16QuantDataset),
382  InPlaceDataSet))
383 {
384  // Validate output
385  validate(Accessor(_target), _reference, tolerance_qsymm16);
386 }
387 TEST_SUITE_END() // ScaleOther
388 TEST_SUITE_END() // QSYMM16
389 TEST_SUITE(QSYMM16toS32)
391  framework::dataset::make("DataTypeIn1", DataType::QSYMM16)),
392  framework::dataset::make("DataTypeIn2", DataType::QSYMM16)),
393  framework::dataset::make("DataTypeOut", DataType::S32)),
394  framework::dataset::make("Scale", { scale_unity })),
395  PixelWiseMultiplicationPolicySTZDataset),
396  PixelWiseMultiplicationQSYMM16QuantDataset),
397  framework::dataset::make("InPlace", { false })))
398 {
399  // Validate output
400  validate(Accessor(_target), _reference);
401 }
402 TEST_SUITE_END() // QSYMM16toS32
403 TEST_SUITE_END() // Quantized
404 
405 TEST_SUITE(U8U8toS16)
406 
408  framework::dataset::make("DataTypeIn1", DataType::U8)),
409  framework::dataset::make("DataTypeIn2", DataType::U8)),
410  framework::dataset::make("DataTypeOut", DataType::S16)),
411  framework::dataset::make("Scale", { scale_255 })),
412  datasets::ConvertPolicies()),
414  framework::dataset::make("InPlace", { false })))
415 {
416  // Validate output
417  validate_wrap(Accessor(_target), _reference, AbsoluteTolerance<int16_t>(1), 0.f);
418 }
419 
421  framework::dataset::make("DataTypeIn1", DataType::U8)),
422  framework::dataset::make("DataTypeIn2", DataType::U8)),
423  framework::dataset::make("DataTypeOut", DataType::S16)),
424  framework::dataset::make("Scale", { scale_other })),
425  datasets::ConvertPolicies()),
427  framework::dataset::make("InPlace", { false })))
428 {
429  // Validate output
430  validate(Accessor(_target), _reference);
431 }
432 
433 TEST_SUITE_END() // U8U8toS16
434 
435 TEST_SUITE(U8toU8)
436 
437 TEST_SUITE(Scale255)
438 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))
439 TEST_SUITE_END() // Scale255
440 
441 TEST_SUITE(ScaleUnity)
442 PIXEL_WISE_MULTIPLICATION_FIXTURE_DATA_TEST_CASE(RunSmall, ToU8Fixture<uint8_t>, ALL, SmallShapes(), U8, U8, U8, scale_unity, TO_ZERO, InPlaceDataSet, DEFAULT_VALIDATE)
443 TEST_SUITE_END() // ScaleUnity
444 
445 TEST_SUITE(ScaleOther)
446 PIXEL_WISE_MULTIPLICATION_FIXTURE_DATA_TEST_CASE(RunSmall, ToU8Fixture<uint8_t>, ALL, SmallShapes(), U8, U8, U8, scale_other, TO_ZERO, InPlaceDataSet, DEFAULT_VALIDATE)
447 TEST_SUITE_END() // ScaleOther
448 
449 TEST_SUITE_END() // U8toU8
450 
451 TEST_SUITE(U8toS16)
452 
453 TEST_SUITE(Scale255)
454 PIXEL_WISE_MULTIPLICATION_FIXTURE_DATA_TEST_CASE(RunSmall, ToS16Fixture<uint8_t>, ALL, SmallShapes(), U8, S16, S16, scale_255, TO_NEAREST_UP, framework::dataset::make("InPlace", { false }),
455  WRAP_VALIDATE(int16_t, 2))
456 TEST_SUITE_END() // Scale255
457 
458 TEST_SUITE(ScaleUnity)
459 PIXEL_WISE_MULTIPLICATION_FIXTURE_DATA_TEST_CASE(RunSmall, ToS16Fixture<uint8_t>, ALL, SmallShapes(), U8, S16, S16, scale_unity, TO_ZERO, framework::dataset::make("InPlace", { false }),
461 TEST_SUITE_END() // ScaleUnity
462 
463 TEST_SUITE(ScaleOther)
464 PIXEL_WISE_MULTIPLICATION_FIXTURE_DATA_TEST_CASE(RunSmall, ToS16Fixture<uint8_t>, ALL, SmallShapes(), U8, S16, S16, scale_other, TO_ZERO, framework::dataset::make("InPlace", { false }),
466 TEST_SUITE_END() // ScaleOther
467 
468 TEST_SUITE_END() // U8toS16
469 
470 TEST_SUITE(S16toS16)
471 
472 TEST_SUITE(Scale255)
473 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))
474 TEST_SUITE_END() // Scale255
475 
476 TEST_SUITE(ScaleUnity)
477 PIXEL_WISE_MULTIPLICATION_FIXTURE_DATA_TEST_CASE(RunSmall, ToS16Fixture<int16_t>, ALL, SmallShapes(), S16, S16, S16, scale_unity, TO_ZERO, InPlaceDataSet, DEFAULT_VALIDATE)
478 TEST_SUITE_END() // ScaleUnity
479 
480 TEST_SUITE(ScaleOther)
481 PIXEL_WISE_MULTIPLICATION_FIXTURE_DATA_TEST_CASE(RunSmall, ToS16Fixture<int16_t>, ALL, SmallShapes(), S16, S16, S16, scale_other, TO_ZERO, InPlaceDataSet, DEFAULT_VALIDATE)
482 TEST_SUITE_END() // ScaleOther
483 
484 TEST_SUITE_END() // S16toS16
485 
486 TEST_SUITE(S32toS32)
487 
488 TEST_SUITE(ScaleUnity)
489 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))
490 TEST_SUITE_END() // ScaleUnity
491 
492 TEST_SUITE(ScaleOther)
493 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))
494 TEST_SUITE_END() // ScaleOther
495 
496 TEST_SUITE(Broadcast)
497 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 }),
498  WRAP_VALIDATE(int32_t, 1))
499 TEST_SUITE_END() // Broadcast
500 
501 TEST_SUITE_END() // S32toS32
502 
503 #ifdef __ARM_FEATURE_FP16_VECTOR_ARITHMETIC
504 TEST_SUITE(F16toF16)
505 
506 TEST_SUITE(Scale255)
507 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))
508 TEST_SUITE_END() // Scale255
509 
510 TEST_SUITE_END() // F16toF16
511 #endif /* __ARM_FEATURE_FP16_VECTOR_ARITHMETIC */
512 
513 TEST_SUITE(F32toF32)
514 
515 TEST_SUITE(Scale255)
516 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))
517 TEST_SUITE_END() // Scale255
518 
519 TEST_SUITE(ScaleUnity)
520 PIXEL_WISE_MULTIPLICATION_FIXTURE_DATA_TEST_CASE(RunSmall, ToF32Fixture<float>, ALL, SmallShapes(), F32, F32, F32, scale_unity, TO_ZERO, InPlaceDataSet, DEFAULT_VALIDATE)
521 TEST_SUITE_END() // ScaleUnity
522 
523 TEST_SUITE(ScaleOther)
524 PIXEL_WISE_MULTIPLICATION_FIXTURE_DATA_TEST_CASE(RunSmall, ToF32Fixture<float>, ALL, SmallShapes(), F32, F32, F32, scale_other, TO_ZERO, InPlaceDataSet, DEFAULT_VALIDATE)
525 TEST_SUITE_END() // ScaleOther
526 
527 TEST_SUITE_END() // F32toF32
528 
529 TEST_SUITE(Broadcast)
530 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 }),
531  VALIDATE(float, 1.f))
532 TEST_SUITE_END() // Broadcast
533 
536 } // namespace validation
537 } // namespace test
538 } // 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:50
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-2021 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
TEST_SUITE(U8_to_S8) FIXTURE_DATA_TEST_CASE(RunSmall
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:45
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}))
DataType
Available data types.
Definition: Types.h:77
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:374