blob: 9c2d7ae268b6df02c7f97a6a5dbfafb874d66837 [file] [log] [blame]
Manuel Bottinied753262019-05-15 15:30:47 +01001/*
Viet-Hoa Dofd472f02023-03-15 14:05:06 +00002 * Copyright (c) 2019-2021, 2023 Arm Limited.
Manuel Bottinied753262019-05-15 15:30:47 +01003 *
4 * SPDX-License-Identifier: MIT
5 *
6 * Permission is hereby granted, free of charge, to any person obtaining a copy
7 * of this software and associated documentation files (the "Software"), to
8 * deal in the Software without restriction, including without limitation the
9 * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
10 * sell copies of the Software, and to permit persons to whom the Software is
11 * furnished to do so, subject to the following conditions:
12 *
13 * The above copyright notice and this permission notice shall be included in all
14 * copies or substantial portions of the Software.
15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 * SOFTWARE.
23 */
24#include "arm_compute/core/Types.h"
25#include "arm_compute/runtime/NEON/functions/NEElementwiseUnaryLayer.h"
26#include "arm_compute/runtime/Tensor.h"
27#include "arm_compute/runtime/TensorAllocator.h"
28#include "tests/NEON/Accessor.h"
29#include "tests/PaddingCalculator.h"
30#include "tests/datasets/ShapeDatasets.h"
31#include "tests/framework/Asserts.h"
32#include "tests/framework/Macros.h"
33#include "tests/framework/datasets/Datasets.h"
34#include "tests/validation/Validation.h"
Jakub Sujakee301b32021-06-04 09:46:08 +010035#include "tests/validation/fixtures/ElementwiseUnaryFixture.h"
Manuel Bottinied753262019-05-15 15:30:47 +010036
37namespace arm_compute
38{
39namespace test
40{
41namespace validation
42{
43namespace
44{
45AbsoluteTolerance<float> tolerance_fp32(0.00001f);
46#ifdef __ARM_FEATURE_FP16_VECTOR_ARITHMETIC
47AbsoluteTolerance<float> tolerance_fp16(0.0005f);
48#endif // __ARM_FEATURE_FP16_VECTOR_ARITHMETIC
Viet-Hoa Dofd472f02023-03-15 14:05:06 +000049constexpr AbsoluteTolerance<uint8_t> tolerance_qasymm8(0);
50constexpr AbsoluteTolerance<int8_t> tolerance_qasymm8_signed(0);
Manuel Bottinied753262019-05-15 15:30:47 +010051} // namespace
52TEST_SUITE(NEON)
53TEST_SUITE(SinLayer)
54
Manuel Bottinied753262019-05-15 15:30:47 +010055template <typename T>
56using NESinLayerFixture = SinValidationFixture<Tensor, Accessor, NESinLayer, T>;
57
Viet-Hoa Dofd472f02023-03-15 14:05:06 +000058template <typename T>
59using NESinLayerQuantizedFixture = SinQuantizedValidationFixture<Tensor, Accessor, NESinLayer, T>;
60
Manuel Bottinied753262019-05-15 15:30:47 +010061TEST_SUITE(Float)
62#ifdef __ARM_FEATURE_FP16_VECTOR_ARITHMETIC
63TEST_SUITE(FP16)
64FIXTURE_DATA_TEST_CASE(RunSmall, NESinLayerFixture<half>, framework::DatasetMode::PRECOMMIT, combine(datasets::SmallShapes(), framework::dataset::make("DataType",
65 DataType::F16)))
66{
67 // Validate output
68 validate(Accessor(_target), _reference, tolerance_fp16);
69}
70FIXTURE_DATA_TEST_CASE(RunLarge, NESinLayerFixture<half>, framework::DatasetMode::NIGHTLY, combine(datasets::LargeShapes(), framework::dataset::make("DataType",
71 DataType::F16)))
72{
73 // Validate output
74 validate(Accessor(_target), _reference, tolerance_fp16);
75}
76
77TEST_SUITE_END() // FP16
78#endif // __ARM_FEATURE_FP16_VECTOR_ARITHMETIC
79
80TEST_SUITE(FP32)
81FIXTURE_DATA_TEST_CASE(RunSmall, NESinLayerFixture<float>, framework::DatasetMode::ALL, combine(datasets::SmallShapes(), framework::dataset::make("DataType",
82 DataType::F32)))
83{
84 // Validate output
85 validate(Accessor(_target), _reference, tolerance_fp32);
86}
87
88FIXTURE_DATA_TEST_CASE(RunLarge, NESinLayerFixture<float>, framework::DatasetMode::NIGHTLY, combine(datasets::LargeShapes(), framework::dataset::make("DataType",
89 DataType::F32)))
90{
91 // Validate output
92 validate(Accessor(_target), _reference, tolerance_fp32);
93}
94TEST_SUITE_END() // FP32
95TEST_SUITE_END() // Float
96
Viet-Hoa Dofd472f02023-03-15 14:05:06 +000097TEST_SUITE(Quantized)
98TEST_SUITE(QASYMM8)
99FIXTURE_DATA_TEST_CASE(RunSmall, NESinLayerQuantizedFixture<uint8_t>, framework::DatasetMode::ALL, combine(combine(combine(
100 datasets::SmallShapes(),
101 framework::dataset::make("DataType", DataType::QASYMM8)),
102 framework::dataset::make("InputQInfo", { QuantizationInfo(0.2, -3) })),
103 framework::dataset::make("OutputQInfo", { QuantizationInfo(200, 10) })))
104{
105 // Validate output
106 validate(Accessor(_target), _reference, tolerance_qasymm8);
107}
108TEST_SUITE_END() // QASYMM8
109
110TEST_SUITE(QASYMM8_SIGNED)
111FIXTURE_DATA_TEST_CASE(RunSmall, NESinLayerQuantizedFixture<int8_t>, framework::DatasetMode::ALL, combine(combine(combine(
112 datasets::SmallShapes(),
113 framework::dataset::make("DataType", DataType::QASYMM8_SIGNED)),
114 framework::dataset::make("InputQInfo", { QuantizationInfo(0.07, 6) })),
115 framework::dataset::make("OutputQInfo", { QuantizationInfo(123, -7) })))
116{
117 // Validate output
118 validate(Accessor(_target), _reference, tolerance_qasymm8_signed);
119}
120TEST_SUITE_END() // QASYMM8_SIGNED
121
122TEST_SUITE_END() // Quantized
Manuel Bottinied753262019-05-15 15:30:47 +0100123TEST_SUITE_END() // SinLayer
Sheri Zhangac6499a2021-02-10 15:32:38 +0000124TEST_SUITE_END() // Neon
Manuel Bottinied753262019-05-15 15:30:47 +0100125} // namespace validation
126} // namespace test
127} // namespace arm_compute