blob: 9422fcc49b32b682545c9d48e2104925cae84052 [file] [log] [blame]
Pablo Tello4a626a72018-04-04 10:01:14 +01001/*
2 * Copyright (c) 2018 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/CL/kernels/CLIm2ColKernel.h"
25#include "arm_compute/core/Types.h"
26#include "tests/CL/Helper.h"
27
28#include "tests/CL/CLAccessor.h"
29#include "tests/datasets/ShapeDatasets.h"
30#include "tests/framework/Asserts.h"
31#include "tests/framework/Macros.h"
32#include "tests/framework/datasets/Datasets.h"
33#include "tests/validation/Validation.h"
34#include "tests/validation/fixtures/Im2ColFixture.h"
35
36namespace arm_compute
37{
38namespace test
39{
40namespace validation
41{
42namespace
43{
44const auto conv_filter_sizes = framework::dataset::make("KernelDims", { Size2D(3U, 3U), Size2D(3U, 1U), Size2D(1U, 5U), Size2D(5U, 5U), Size2D(7U, 7U) });
45const auto padstrides = framework::dataset::make("PadStride", { PadStrideInfo(1U, 1U, 0U, 0U), PadStrideInfo(1U, 1U, 1U, 1U), PadStrideInfo(2U, 2U, 0U, 2U) });
46const auto conv_args = combine(combine(combine(conv_filter_sizes, padstrides),
47 framework::dataset::make("QuantizationInfo", QuantizationInfo(0.5f, 10))),
48 framework::dataset::make("DataLayout", { DataLayout::NCHW, DataLayout::NHWC }));
49
50} // namespace
51TEST_SUITE(CL)
52TEST_SUITE(Im2Col)
53
54using CLIm2Col = CLSynthetizeFunction<CLIm2ColKernel>;
55
56// *INDENT-OFF*
57// clang-format off
58DATA_TEST_CASE(Validate, framework::DatasetMode::ALL, zip(zip(zip(
59 framework::dataset::make("InputInfo", { TensorInfo(TensorShape(10U, 12U, 2U), 1, DataType::U8), // Unsupported data type
60 TensorInfo(TensorShape(10U, 12U, 2U), 1, DataType::F32), // Mismatching data type
Pablo Tello4a626a72018-04-04 10:01:14 +010061 TensorInfo(TensorShape(10U, 12U, 2U), 1, DataType::QASYMM8), // Bias not supported with QASYMM8
62 TensorInfo(TensorShape(10U, 12U, 2U), 1, DataType::QASYMM8), // Mismatching shapes
63 TensorInfo(TensorShape(10U, 12U, 2U, 2U), 1, DataType::QASYMM8),
64 }),
65 framework::dataset::make("OutputInfo",{ TensorInfo(TensorShape(3U, 4U, 10U, 2U), 1, DataType::F16),
66 TensorInfo(TensorShape(3U, 4U, 10U, 2U), 1, DataType::F16),
Pablo Tello4a626a72018-04-04 10:01:14 +010067 TensorInfo(TensorShape(3U, 3U, 10U, 2U), 1, DataType::QASYMM8),
68 TensorInfo(TensorShape(3U, 4U, 10U, 2U), 1, DataType::QASYMM8),
69 TensorInfo(TensorShape(18U, 80U, 1U, 2U), 1, DataType::QASYMM8),
70 })),
Vidhya Sudhan Loganathan0fc25452018-06-18 14:40:56 +010071 framework::dataset::make("HasBias", { true, true, true, false, false })),
72 framework::dataset::make("Expected", { false, false, false, true, true })),
Pablo Tello4a626a72018-04-04 10:01:14 +010073 input_info, output_info, has_bias, expected)
74{
75
76 bool status = bool(CLIm2Col::validate(&input_info, &output_info, Size2D(3U, 3U), PadStrideInfo(), has_bias));
77 ARM_COMPUTE_EXPECT(status == expected, framework::LogLevel::ERRORS);
78}
79// clang-format on
80// *INDENT-ON*
81
82template <typename T>
Gian Marco Iodice597a8562018-08-01 15:06:06 +010083using CLIm2ColFixture = Im2ColValidationFixture<CLTensor, CLAccessor, CLIm2Col, T, true>;
Pablo Tello4a626a72018-04-04 10:01:14 +010084TEST_SUITE(Float)
85TEST_SUITE(FP32)
86FIXTURE_DATA_TEST_CASE(RunSmall, CLIm2ColFixture<float>, framework::DatasetMode::ALL, combine(combine(datasets::SmallShapes(), framework::dataset::make("DataType", DataType::F32)),
87 conv_args))
88{
89 // Validate output
90 validate(CLAccessor(_target), _reference);
91}
92TEST_SUITE_END()
93
94FIXTURE_DATA_TEST_CASE(RunLarge, CLIm2ColFixture<float>, framework::DatasetMode::NIGHTLY, combine(combine(datasets::LargeShapes(), framework::dataset::make("DataType", DataType::F32)),
95 conv_args))
96{
97 // Validate output
98 validate(CLAccessor(_target), _reference);
99}
100
101#ifdef __ARM_FEATURE_FP16_VECTOR_ARITHMETIC
102
103TEST_SUITE(FP16)
104FIXTURE_DATA_TEST_CASE(RunSmall, CLIm2ColFixture<half>, framework::DatasetMode::ALL, combine(combine(datasets::SmallShapes(), framework::dataset::make("DataType", DataType::F16)),
105 conv_args))
106{
107 // Validate output
108 validate(CLAccessor(_target), _reference);
109}
110FIXTURE_DATA_TEST_CASE(RunLarge, CLIm2ColFixture<half>, framework::DatasetMode::NIGHTLY, combine(combine(datasets::LargeShapes(), framework::dataset::make("DataType", DataType::F16)),
111 conv_args))
112{
113 // Validate output
114 validate(CLAccessor(_target), _reference);
115}
116TEST_SUITE_END()
117
118#endif /* __ARM_FEATURE_FP16_VECTOR_ARITHMETIC */
119
120TEST_SUITE_END()
121
122TEST_SUITE(QASYMM8)
123FIXTURE_DATA_TEST_CASE(RunSmall, CLIm2ColFixture<uint8_t>, framework::DatasetMode::ALL, combine(combine(datasets::SmallShapes(), framework::dataset::make("DataType", DataType::QASYMM8)),
124 conv_args))
125{
126 // Validate output
127 validate(CLAccessor(_target), _reference);
128}
129FIXTURE_DATA_TEST_CASE(RunLarge, CLIm2ColFixture<uint8_t>, framework::DatasetMode::NIGHTLY, combine(combine(datasets::LargeShapes(), framework::dataset::make("DataType", DataType::QASYMM8)),
130 conv_args))
131{
132 // Validate output
133 validate(CLAccessor(_target), _reference);
134}
135TEST_SUITE_END()
136
137TEST_SUITE_END()
138TEST_SUITE_END()
139} // namespace validation
140} // namespace test
141} // namespace arm_compute