blob: 14fb7e25184a51e36c5806d5eabd46e2ddc27742 [file] [log] [blame]
giuros0114c4e0f2019-03-26 17:44:40 +00001/*
2 * Copyright (c) 2019 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 */
24#include "arm_compute/core/Types.h"
25#include "arm_compute/runtime/NEON/functions/NEFFT1D.h"
26#include "arm_compute/runtime/Tensor.h"
27#include "tests/NEON/Accessor.h"
28#include "tests/framework/Asserts.h"
29#include "tests/framework/Macros.h"
30#include "tests/framework/datasets/Datasets.h"
31#include "tests/validation/Validation.h"
32#include "tests/validation/fixtures/FFTFixture.h"
33
34namespace arm_compute
35{
36namespace test
37{
38namespace validation
39{
40namespace
41{
42const auto data_types = framework::dataset::make("DataType", { DataType::F32 });
43const auto shapes_1d = framework::dataset::make("TensorShape", { TensorShape(2U, 2U, 3U), TensorShape(3U, 2U, 3U),
44 TensorShape(4U, 2U, 3U), TensorShape(5U, 2U, 3U),
45 TensorShape(7U, 2U, 3U), TensorShape(8U, 2U, 3U),
46 TensorShape(9U, 2U, 3U), TensorShape(25U, 2U, 3U),
47 TensorShape(49U, 2U, 3U), TensorShape(64U, 2U, 3U),
48 TensorShape(16U, 2U, 3U), TensorShape(32U, 2U, 3U),
49 TensorShape(96U, 2U, 2U)
50 });
51
52const auto ActivationFunctionsSmallDataset = framework::dataset::make("ActivationInfo",
53{
54 ActivationLayerInfo(),
55 ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::LU_BOUNDED_RELU, 0.5f)
56});
57
58RelativeTolerance<float> tolerance_f32(0.1f); /**< Relative tolerance value for FP32 */
59constexpr float tolerance_num = 0.07f; /**< Tolerance number */
60
61} // namespace
62TEST_SUITE(NEON)
63TEST_SUITE(FFT1D)
64
65DATA_TEST_CASE(Configuration, framework::DatasetMode::ALL, combine(shapes_1d, data_types),
66 shape, data_type)
67{
68 // Create tensors
69 Tensor src = create_tensor<Tensor>(shape, data_type, 2);
70 Tensor dst = create_tensor<Tensor>(shape, data_type, 2);
71
72 ARM_COMPUTE_EXPECT(src.info()->is_resizable(), framework::LogLevel::ERRORS);
73 ARM_COMPUTE_EXPECT(dst.info()->is_resizable(), framework::LogLevel::ERRORS);
74
75 // Create and configure function
76 NEFFT1D fft1d;
77 fft1d.configure(&src, &dst, FFT1DInfo());
78
79 // Validate valid region
80 const ValidRegion valid_region = shape_to_valid_region(shape);
81 validate(src.info()->valid_region(), valid_region);
82 validate(dst.info()->valid_region(), valid_region);
83
84 // Validate padding
85 validate(src.info()->padding(), PaddingSize());
86 validate(dst.info()->padding(), PaddingSize());
87}
88
89// *INDENT-OFF*
90// clang-format off
91DATA_TEST_CASE(Validate, framework::DatasetMode::ALL, zip(zip(zip(
92 framework::dataset::make("InputInfo", { TensorInfo(TensorShape(32U, 13U, 2U), 2, DataType::F32), // Mismatching data types
93 TensorInfo(TensorShape(32U, 13U, 2U), 2, DataType::F32), // Mismatching shapes
94 TensorInfo(TensorShape(32U, 13U, 2U), 3, DataType::F32), // Invalid channels
95 TensorInfo(TensorShape(32U, 13U, 2U), 2, DataType::F32), // Unsupported axis
96 TensorInfo(TensorShape(11U, 13U, 2U), 2, DataType::F32), // Undecomposable FFT
97 TensorInfo(TensorShape(25U, 13U, 2U), 2, DataType::F32),
98 }),
99 framework::dataset::make("OutputInfo",{ TensorInfo(TensorShape(32U, 13U, 2U), 2, DataType::F16),
100 TensorInfo(TensorShape(16U, 13U, 2U), 2, DataType::F32),
101 TensorInfo(TensorShape(32U, 13U, 2U), 2, DataType::F32),
102 TensorInfo(TensorShape(32U, 13U, 2U), 2, DataType::F32),
103 TensorInfo(TensorShape(11U, 13U, 2U), 2, DataType::F32),
104 TensorInfo(TensorShape(25U, 13U, 2U), 2, DataType::F32),
105 })),
106 framework::dataset::make("Axis", { 0, 0, 0, 2, 0, 0 })),
107 framework::dataset::make("Expected", { false, false, false, false, false, true })),
108 input_info, output_info, axis, expected)
109{
110 FFT1DInfo desc;
111 desc.axis = axis;
112 const Status s = NEFFT1D::validate(&input_info.clone()->set_is_resizable(false), &output_info.clone()->set_is_resizable(false), desc);
113 ARM_COMPUTE_EXPECT(bool(s) == expected, framework::LogLevel::ERRORS);
114}
115// clang-format on
116// *INDENT-ON*
117
118template <typename T>
119using NEFFT1DFixture = FFTValidationFixture<Tensor, Accessor, NEFFT1D, FFT1DInfo, T>;
120
121TEST_SUITE(Float)
122TEST_SUITE(FP32)
123FIXTURE_DATA_TEST_CASE(RunSmall, NEFFT1DFixture<float>, framework::DatasetMode::ALL, combine(shapes_1d, framework::dataset::make("DataType", DataType::F32)))
124{
125 // Validate output
126 validate(Accessor(_target), _reference, tolerance_f32, tolerance_num);
127}
128TEST_SUITE_END() // FP32
129TEST_SUITE_END() // Float
130
131TEST_SUITE_END() // FFT1D
132TEST_SUITE_END() // NEON
133} // namespace validation
134} // namespace test
135} // namespace arm_compute