blob: 0d29532c29fa3be423e34c7ea74417e49c6d2604 [file] [log] [blame]
Georgios Pinitas0bc78492019-03-18 20:07:37 +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/CL/CLTensor.h"
26#include "arm_compute/runtime/CL/functions/CLFFT1D.h"
27#include "tests/CL/CLAccessor.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 = 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} // namespace
52TEST_SUITE(CL)
53TEST_SUITE(FFT1D)
54
55DATA_TEST_CASE(Configuration, framework::DatasetMode::ALL, combine(shapes, data_types),
56 shape, data_type)
57{
58 // Create tensors
59 CLTensor src = create_tensor<CLTensor>(shape, data_type, 2);
60 CLTensor dst = create_tensor<CLTensor>(shape, data_type, 2);
61
62 ARM_COMPUTE_EXPECT(src.info()->is_resizable(), framework::LogLevel::ERRORS);
63 ARM_COMPUTE_EXPECT(dst.info()->is_resizable(), framework::LogLevel::ERRORS);
64
65 // Create and configure function
66 CLFFT1D fft1d;
67 fft1d.configure(&src, &dst, FFT1DInfo());
68
69 // Validate valid region
70 const ValidRegion valid_region = shape_to_valid_region(shape);
71 validate(src.info()->valid_region(), valid_region);
72 validate(dst.info()->valid_region(), valid_region);
73
74 // Validate padding
75 validate(src.info()->padding(), PaddingSize());
76 validate(dst.info()->padding(), PaddingSize());
77}
78
79// *INDENT-OFF*
80// clang-format off
81DATA_TEST_CASE(Validate, framework::DatasetMode::ALL, zip(zip(zip(
82 framework::dataset::make("InputInfo", { TensorInfo(TensorShape(32U, 13U, 2U), 2, DataType::F32), // Mismatching data types
83 TensorInfo(TensorShape(32U, 13U, 2U), 2, DataType::F32), // Mismatching shapes
84 TensorInfo(TensorShape(32U, 13U, 2U), 1, DataType::F32), // Invalid channels
85 TensorInfo(TensorShape(32U, 13U, 2U), 2, DataType::F32), // Unsupported axis
86 TensorInfo(TensorShape(11U, 13U, 2U), 2, DataType::F32), // Undecomposable FFT
87 TensorInfo(TensorShape(25U, 13U, 2U), 2, DataType::F32),
88 }),
89 framework::dataset::make("OutputInfo",{ TensorInfo(TensorShape(32U, 13U, 2U), 2, DataType::F16),
90 TensorInfo(TensorShape(16U, 13U, 2U), 2, DataType::F32),
91 TensorInfo(TensorShape(32U, 13U, 2U), 1, DataType::F32),
92 TensorInfo(TensorShape(32U, 13U, 2U), 2, DataType::F32),
93 TensorInfo(TensorShape(11U, 13U, 2U), 2, DataType::F32),
94 TensorInfo(TensorShape(25U, 13U, 2U), 2, DataType::F32),
95 })),
96 framework::dataset::make("Axis", { 0, 0, 0, 1, 0, 0 })),
97 framework::dataset::make("Expected", { false, false, false, false, false, true })),
98 input_info, output_info, axis, expected)
99{
100 FFT1DInfo desc;
101 desc.axis = axis;
102 const Status s = CLFFT1D::validate(&input_info.clone()->set_is_resizable(false), &output_info.clone()->set_is_resizable(false), desc);
103 ARM_COMPUTE_EXPECT(bool(s) == expected, framework::LogLevel::ERRORS);
104}
105// clang-format on
106// *INDENT-ON*
107
108template <typename T>
109using CLFFT1DFixture = FFTValidationFixture<CLTensor, CLAccessor, CLFFT1D, T>;
110
111TEST_SUITE(Float)
112TEST_SUITE(FP32)
113FIXTURE_DATA_TEST_CASE(RunSmall, CLFFT1DFixture<float>, framework::DatasetMode::ALL, combine(shapes, framework::dataset::make("DataType", DataType::F32)))
114{
115 // Validate output
116 validate(CLAccessor(_target), _reference, RelativeTolerance<float>(0.1f), 0.05f);
117}
118TEST_SUITE_END() // FP32
119TEST_SUITE_END() // Float
120
121TEST_SUITE_END() // FFT1D
122TEST_SUITE_END() // CL
123} // namespace validation
124} // namespace test
125} // namespace arm_compute