blob: b651bf8918ed738d408ef1139d057122f63d31b4 [file] [log] [blame]
Michele Di Giorgio980002b2018-08-08 09:25:51 +01001/*
Michele Di Giorgiod9eaf612020-07-08 11:12:57 +01002 * Copyright (c) 2018-2020 Arm Limited.
Michele Di Giorgio980002b2018-08-08 09:25:51 +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 */
Michele Di Giorgio980002b2018-08-08 09:25:51 +010024#include "arm_compute/core/Types.h"
Sang-Hoon Parkbef7fa22020-10-21 15:58:54 +010025#include "src/core/CL/kernels/CLCol2ImKernel.h"
Michele Di Giorgio980002b2018-08-08 09:25:51 +010026#include "tests/CL/CLAccessor.h"
Georgios Pinitas5fc8f842020-04-08 17:48:56 +010027#include "tests/CL/Helper.h"
Michele Di Giorgio980002b2018-08-08 09:25:51 +010028#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/Col2ImFixture.h"
33
34namespace arm_compute
35{
36namespace test
37{
38namespace validation
39{
40TEST_SUITE(CL)
41TEST_SUITE(Col2Im)
42
43using CLCol2Im = CLSynthetizeFunction<CLCol2ImKernel>;
44
Georgios Pinitas5fc8f842020-04-08 17:48:56 +010045/** Negative tests
46 *
47 * A series of validation tests on configurations which according to the API specification
48 * the function should fail against.
49 *
50 * Checks performed in order:
51 * - Pass unsupported data type for input
52 * - Pass NHWC as output data layout
53 * - Pass an invalid output shape
54 */
Georgios Pinitasc1c366d2020-03-30 18:09:24 +010055TEST_CASE(Negative, framework::DatasetMode::ALL)
Michele Di Giorgio980002b2018-08-08 09:25:51 +010056{
Georgios Pinitas5fc8f842020-04-08 17:48:56 +010057 // Unsupported data type
58 {
59 const auto input = TensorInfo(TensorShape(10U, 12U, 1U, 2U), 1, DataType::SIZET);
60 const auto output = TensorInfo(TensorShape(3U, 4U, 10U, 1U, 2U), 1, DataType::F32);
61 const auto conv_size = Size2D(3, 4);
62 const auto status = CLCol2ImKernel::validate(&input, &output, conv_size);
63 ARM_COMPUTE_EXPECT(bool(status) == false, framework::LogLevel::ERRORS);
64 }
65
66 // NHWC as output data layout
67 {
68 const auto input = TensorInfo(TensorShape(10U, 12U, 1U, 2U), 1, DataType::F32);
69 const auto output = TensorInfo(TensorShape(3U, 4U, 10U, 1U, 2U), 1, DataType::F32, DataLayout::NHWC);
70 const auto conv_size = Size2D(3, 4);
71 const auto status = CLCol2ImKernel::validate(&input, &output, conv_size);
72 ARM_COMPUTE_EXPECT(bool(status) == false, framework::LogLevel::ERRORS);
73 }
74
75 // Invalid output size
76 {
77 const auto input = TensorInfo(TensorShape(10U, 12U, 1U, 2U), 1, DataType::F32);
78 const auto output = TensorInfo(TensorShape(3U, 4U, 10U, 2U, 2U), 1, DataType::F32);
79 const auto conv_size = Size2D(3, 4);
80 const auto status = CLCol2ImKernel::validate(&input, &output, conv_size);
81 ARM_COMPUTE_EXPECT(bool(status) == false, framework::LogLevel::ERRORS);
82 }
Michele Di Giorgio980002b2018-08-08 09:25:51 +010083}
Michele Di Giorgio980002b2018-08-08 09:25:51 +010084
85template <typename T>
Giorgio Arena226e4b92018-08-23 12:00:02 +010086using CLCol2ImFixture = Col2ImValidationFixture<CLTensor, CLAccessor, CLCol2Im, T, true>;
Michele Di Giorgio980002b2018-08-08 09:25:51 +010087
Georgios Pinitas5fc8f842020-04-08 17:48:56 +010088/** Test kernel for single-precision floating point
89 *
90 * @note 8 elements processed per iteration
91 *
92 * Three main tests will be run:
93 * - Channels are multiple of elements processed
94 * - Channels larger and non multiple of elements used
95 * - Channels smaller and not multiple of elements used
96 *
97 * The above will be repeated with a different group size
98 *
99 * Kernel tested col2im
100 */
101FIXTURE_DATA_TEST_CASE(FP32,
102 CLCol2ImFixture<float>,
Georgios Pinitasc1c366d2020-03-30 18:09:24 +0100103 framework::DatasetMode::ALL,
Georgios Pinitas5fc8f842020-04-08 17:48:56 +0100104 combine(combine(combine(combine(
105 framework::dataset::make("InputShape", { TensorShape(8U, 16U, 3U, 1U), TensorShape(17U, 16U, 3U, 1U), TensorShape(7U, 16U, 3U, 1U) }),
106 framework::dataset::make("ConvolvedWidth", 4)),
107 framework::dataset::make("ConvolvedHeight", 4)),
108 framework::dataset::make("Groups", { 1, 3 })),
109 framework::dataset::make("DataType", DataType::F32)))
Michele Di Giorgio980002b2018-08-08 09:25:51 +0100110{
111 // Validate output
112 validate(CLAccessor(_target), _reference);
113}
114
Georgios Pinitas5fc8f842020-04-08 17:48:56 +0100115/** Test kernel for half-precision floating point
116 *
117 * @note 8 elements processed per iteration
118 *
119 * One main tests will be run:
120 * - Channels larger and non multiple of elements used
121 *
122 * We just need to test the difference in the data type size.
123 * Any other issues can be identified by the main FP32 tests
124 *
125 * Kernel tested col2im
126 */
127FIXTURE_DATA_TEST_CASE(F16,
128 CLCol2ImFixture<half>,
Georgios Pinitasc1c366d2020-03-30 18:09:24 +0100129 framework::DatasetMode::ALL,
Georgios Pinitas5fc8f842020-04-08 17:48:56 +0100130 combine(combine(combine(combine(
131 framework::dataset::make("InputShape", TensorShape(17U, 16U, 3U, 1U)),
132 framework::dataset::make("ConvolvedWidth", 4)),
133 framework::dataset::make("ConvolvedHeight", 4)),
134 framework::dataset::make("Groups", 3)),
135 framework::dataset::make("DataType", DataType::F16)))
Michele Di Giorgio980002b2018-08-08 09:25:51 +0100136{
137 // Validate output
138 validate(CLAccessor(_target), _reference);
139}
140
Georgios Pinitas5fc8f842020-04-08 17:48:56 +0100141/** Test kernel for unsigned asymmetric quantized type
142 *
143 * @note 8 elements processed per iteration
144 *
145 * One main tests will be run:
146 * - Channels larger and non multiple of elements used
147 *
148 * We just need to test the difference in the data type size.
149 * Any other issues can be identified by the main FP32 tests
150 *
151 * Kernel tested col2im
152 */
153FIXTURE_DATA_TEST_CASE(QASYMM8,
154 CLCol2ImFixture<uint8_t>,
Georgios Pinitasc1c366d2020-03-30 18:09:24 +0100155 framework::DatasetMode::ALL,
Georgios Pinitas5fc8f842020-04-08 17:48:56 +0100156 combine(combine(combine(combine(
157 framework::dataset::make("InputShape", TensorShape(17U, 16U, 3U, 1U)),
158 framework::dataset::make("ConvolvedWidth", 4)),
159 framework::dataset::make("ConvolvedHeight", 4)),
160 framework::dataset::make("Groups", 3)),
161 framework::dataset::make("DataType", DataType::QASYMM8)))
Michele Di Giorgio980002b2018-08-08 09:25:51 +0100162{
163 // Validate output
164 validate(CLAccessor(_target), _reference);
165}
166
Georgios Pinitas5fc8f842020-04-08 17:48:56 +0100167TEST_SUITE_END() // CL
168TEST_SUITE_END() // Col2Im
Michele Di Giorgio980002b2018-08-08 09:25:51 +0100169} // namespace validation
170} // namespace test
171} // namespace arm_compute