blob: aea21fbd8e765a92bdde43b0067bc529542aa90c [file] [log] [blame]
Michele Di Giorgio980002b2018-08-08 09:25:51 +01001/*
Georgios Pinitas5fc8f842020-04-08 17:48:56 +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 */
24#include "arm_compute/core/CL/kernels/CLCol2ImKernel.h"
25#include "arm_compute/core/Types.h"
Michele Di Giorgio980002b2018-08-08 09:25:51 +010026
27#include "tests/CL/CLAccessor.h"
Georgios Pinitas5fc8f842020-04-08 17:48:56 +010028#include "tests/CL/Helper.h"
Michele Di Giorgio980002b2018-08-08 09:25:51 +010029#include "tests/framework/Asserts.h"
30#include "tests/framework/Macros.h"
31#include "tests/framework/datasets/Datasets.h"
32#include "tests/validation/Validation.h"
33#include "tests/validation/fixtures/Col2ImFixture.h"
34
35namespace arm_compute
36{
37namespace test
38{
39namespace validation
40{
41TEST_SUITE(CL)
42TEST_SUITE(Col2Im)
43
44using CLCol2Im = CLSynthetizeFunction<CLCol2ImKernel>;
45
Georgios Pinitas5fc8f842020-04-08 17:48:56 +010046/** Negative tests
47 *
48 * A series of validation tests on configurations which according to the API specification
49 * the function should fail against.
50 *
51 * Checks performed in order:
52 * - Pass unsupported data type for input
53 * - Pass NHWC as output data layout
54 * - Pass an invalid output shape
55 */
56TEST_CASE(Negative, framework::DatasetMode::PRECOMMIT)
Michele Di Giorgio980002b2018-08-08 09:25:51 +010057{
Georgios Pinitas5fc8f842020-04-08 17:48:56 +010058 // Unsupported data type
59 {
60 const auto input = TensorInfo(TensorShape(10U, 12U, 1U, 2U), 1, DataType::SIZET);
61 const auto output = TensorInfo(TensorShape(3U, 4U, 10U, 1U, 2U), 1, DataType::F32);
62 const auto conv_size = Size2D(3, 4);
63 const auto status = CLCol2ImKernel::validate(&input, &output, conv_size);
64 ARM_COMPUTE_EXPECT(bool(status) == false, framework::LogLevel::ERRORS);
65 }
66
67 // NHWC as output data layout
68 {
69 const auto input = TensorInfo(TensorShape(10U, 12U, 1U, 2U), 1, DataType::F32);
70 const auto output = TensorInfo(TensorShape(3U, 4U, 10U, 1U, 2U), 1, DataType::F32, DataLayout::NHWC);
71 const auto conv_size = Size2D(3, 4);
72 const auto status = CLCol2ImKernel::validate(&input, &output, conv_size);
73 ARM_COMPUTE_EXPECT(bool(status) == false, framework::LogLevel::ERRORS);
74 }
75
76 // Invalid output size
77 {
78 const auto input = TensorInfo(TensorShape(10U, 12U, 1U, 2U), 1, DataType::F32);
79 const auto output = TensorInfo(TensorShape(3U, 4U, 10U, 2U, 2U), 1, DataType::F32);
80 const auto conv_size = Size2D(3, 4);
81 const auto status = CLCol2ImKernel::validate(&input, &output, conv_size);
82 ARM_COMPUTE_EXPECT(bool(status) == false, framework::LogLevel::ERRORS);
83 }
Michele Di Giorgio980002b2018-08-08 09:25:51 +010084}
Michele Di Giorgio980002b2018-08-08 09:25:51 +010085
86template <typename T>
Giorgio Arena226e4b92018-08-23 12:00:02 +010087using CLCol2ImFixture = Col2ImValidationFixture<CLTensor, CLAccessor, CLCol2Im, T, true>;
Michele Di Giorgio980002b2018-08-08 09:25:51 +010088
Georgios Pinitas5fc8f842020-04-08 17:48:56 +010089/** Test kernel for single-precision floating point
90 *
91 * @note 8 elements processed per iteration
92 *
93 * Three main tests will be run:
94 * - Channels are multiple of elements processed
95 * - Channels larger and non multiple of elements used
96 * - Channels smaller and not multiple of elements used
97 *
98 * The above will be repeated with a different group size
99 *
100 * Kernel tested col2im
101 */
102FIXTURE_DATA_TEST_CASE(FP32,
103 CLCol2ImFixture<float>,
104 framework::DatasetMode::PRECOMMIT,
105 combine(combine(combine(combine(
106 framework::dataset::make("InputShape", { TensorShape(8U, 16U, 3U, 1U), TensorShape(17U, 16U, 3U, 1U), TensorShape(7U, 16U, 3U, 1U) }),
107 framework::dataset::make("ConvolvedWidth", 4)),
108 framework::dataset::make("ConvolvedHeight", 4)),
109 framework::dataset::make("Groups", { 1, 3 })),
110 framework::dataset::make("DataType", DataType::F32)))
Michele Di Giorgio980002b2018-08-08 09:25:51 +0100111{
112 // Validate output
113 validate(CLAccessor(_target), _reference);
114}
115
Georgios Pinitas5fc8f842020-04-08 17:48:56 +0100116/** Test kernel for half-precision floating point
117 *
118 * @note 8 elements processed per iteration
119 *
120 * One main tests will be run:
121 * - Channels larger and non multiple of elements used
122 *
123 * We just need to test the difference in the data type size.
124 * Any other issues can be identified by the main FP32 tests
125 *
126 * Kernel tested col2im
127 */
128FIXTURE_DATA_TEST_CASE(F16,
129 CLCol2ImFixture<half>,
130 framework::DatasetMode::PRECOMMIT,
131 combine(combine(combine(combine(
132 framework::dataset::make("InputShape", TensorShape(17U, 16U, 3U, 1U)),
133 framework::dataset::make("ConvolvedWidth", 4)),
134 framework::dataset::make("ConvolvedHeight", 4)),
135 framework::dataset::make("Groups", 3)),
136 framework::dataset::make("DataType", DataType::F16)))
Michele Di Giorgio980002b2018-08-08 09:25:51 +0100137{
138 // Validate output
139 validate(CLAccessor(_target), _reference);
140}
141
Georgios Pinitas5fc8f842020-04-08 17:48:56 +0100142/** Test kernel for unsigned asymmetric quantized type
143 *
144 * @note 8 elements processed per iteration
145 *
146 * One main tests will be run:
147 * - Channels larger and non multiple of elements used
148 *
149 * We just need to test the difference in the data type size.
150 * Any other issues can be identified by the main FP32 tests
151 *
152 * Kernel tested col2im
153 */
154FIXTURE_DATA_TEST_CASE(QASYMM8,
155 CLCol2ImFixture<uint8_t>,
156 framework::DatasetMode::PRECOMMIT,
157 combine(combine(combine(combine(
158 framework::dataset::make("InputShape", TensorShape(17U, 16U, 3U, 1U)),
159 framework::dataset::make("ConvolvedWidth", 4)),
160 framework::dataset::make("ConvolvedHeight", 4)),
161 framework::dataset::make("Groups", 3)),
162 framework::dataset::make("DataType", DataType::QASYMM8)))
Michele Di Giorgio980002b2018-08-08 09:25:51 +0100163{
164 // Validate output
165 validate(CLAccessor(_target), _reference);
166}
167
Georgios Pinitas5fc8f842020-04-08 17:48:56 +0100168TEST_SUITE_END() // CL
169TEST_SUITE_END() // Col2Im
Michele Di Giorgio980002b2018-08-08 09:25:51 +0100170} // namespace validation
171} // namespace test
172} // namespace arm_compute