blob: 664b3f4ef85c290028728e80d25df5aa95d848db [file] [log] [blame]
Giorgio Arena1f9ca1d2018-03-01 11:13:45 +00001/*
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 CONCLCTION 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/core/utils/misc/ShapeCalculator.h"
26#include "arm_compute/runtime/CL/CLTensor.h"
27#include "arm_compute/runtime/CL/CLTensorAllocator.h"
28#include "arm_compute/runtime/CL/functions/CLWinogradInputTransform.h"
29#include "tests/CL/CLAccessor.h"
30#include "tests/datasets/WinogradInputTransformDataset.h"
31#include "tests/framework/Asserts.h"
32#include "tests/framework/Macros.h"
33#include "tests/framework/datasets/Datasets.h"
34#include "tests/validation/Validation.h"
35#include "tests/validation/fixtures/WinogradLayerFixture.h"
36
37namespace arm_compute
38{
39namespace test
40{
41namespace validation
42{
43TEST_SUITE(CL)
44TEST_SUITE(Winograd)
45
46TEST_SUITE(InputTransform)
47
48// *INDENT-OFF*
49// clang-format off
50DATA_TEST_CASE(Validate, framework::DatasetMode::ALL, zip(zip(zip(zip(
51 framework::dataset::make("InputInfo",{
52 TensorInfo(TensorShape(53U, 21U, 5U, 3U), 1, DataType::F16), // F16 not supported
53 TensorInfo(TensorShape(53U, 21U, 5U, 3U), 1, DataType::QASYMM8), // QASYMM8 not supported
54 TensorInfo(TensorShape(53U, 21U, 5U, 3U), 1, DataType::F32), // Kernel size not supported
55 TensorInfo(TensorShape(53U, 21U, 5U, 3U), 1, DataType::F32), // Strides not supported
56 TensorInfo(TensorShape(53U, 33U, 4U), 1, DataType::F32), // valid
57 TensorInfo(TensorShape(34U, 42U, 7U, 3U), 1, DataType::F32), // valid
58 TensorInfo(TensorShape(31U, 37U, 37U), 1, DataType::F32) // valid
59 }),
60 framework::dataset::make("OutputInfo", {
61 TensorInfo(TensorShape(5U, 5U, 16U, 3U), 1, DataType::F16),
62 TensorInfo(TensorShape(5U, 5U, 16U, 3U), 1, DataType::QASYMM8),
63 TensorInfo(TensorShape(5U, 5U, 16U, 3U), 1, DataType::F32),
64 TensorInfo(TensorShape(5U, 1U, 16U, 3U), 1, DataType::F32),
65 TensorInfo(TensorShape(4U, 442U, 16U), 1, DataType::F32),
66 TensorInfo(TensorShape(7U, 320U, 16U, 3U), 1, DataType::F32),
67 TensorInfo(TensorShape(37U, 304U, 16U), 1, DataType::F32)
68 })),
69 framework::dataset::make("PadStrideInfo", {
70 PadStrideInfo(1, 1, 1, 0),
71 PadStrideInfo(1, 1, 0, 0),
72 PadStrideInfo(1, 1, 1, 1),
73 PadStrideInfo(2, 1, 1, 1),
74 PadStrideInfo(1, 1, 0, 1),
75 PadStrideInfo(1, 1, 0, 0),
76 PadStrideInfo(1, 1, 1, 1)
77 })),
78 framework::dataset::make("KernelDims", {
79 Size2D(3U, 3U),
80 Size2D(3U, 3U),
81 Size2D(5U, 5U),
82 Size2D(3U, 3U),
83 Size2D(3U, 3U),
84 Size2D(3U, 3U),
85 Size2D(3U, 3U)
86 })),
87 framework::dataset::make("Expected", { false, false, false, false, true, true, true })),
88 input_info, output_info, conv_info, kernel_dims, expected)
89{
90 ARM_COMPUTE_EXPECT(bool(CLWinogradInputTransform::validate(&input_info.clone()->set_is_resizable(false), &output_info.clone()->set_is_resizable(false), conv_info, kernel_dims)) == expected, framework::LogLevel::ERRORS);
91}
92// clang-format on
93// *INDENT-ON*
94
95using CLWinogradInputTransformFixture = WinogradInputTransformValidationFixture<CLTensor, CLAccessor, CLWinogradInputTransform, float>;
96
97DATA_TEST_CASE(Configuration, framework::DatasetMode::ALL, combine(framework::dataset::concat(datasets::SmallWinogradInputTransformDataset(), datasets::LargeWinogradInputTransformDataset()),
98 framework::dataset::make("DataType", { DataType::F32 })),
99 shape_in, conv_info, kernel_dims, is_nchw_format, data_type)
100{
101 ARM_COMPUTE_UNUSED(is_nchw_format);
102
103 TensorShape shape_out = compute_winograd_input_transform_shape(TensorInfo(shape_in, 1, data_type), conv_info, kernel_dims);
104
105 // Create tensors
106 CLTensor in = create_tensor<CLTensor>(shape_in, data_type);
107 CLTensor out = create_tensor<CLTensor>(shape_out, data_type);
108
109 ARM_COMPUTE_EXPECT(in.info()->is_resizable(), framework::LogLevel::ERRORS);
110 ARM_COMPUTE_EXPECT(out.info()->is_resizable(), framework::LogLevel::ERRORS);
111
112 // Create and configure function
113 CLWinogradInputTransform winograd_input_transform;
114
115 // Configure the function
116 winograd_input_transform.configure(&in, &out, conv_info, kernel_dims);
117}
118
119FIXTURE_DATA_TEST_CASE(RunSmall, CLWinogradInputTransformFixture, framework::DatasetMode::PRECOMMIT, combine(datasets::SmallWinogradInputTransformDataset(), framework::dataset::make("DataType", { DataType::F32 })))
120{
121 validate(CLAccessor(_target), _reference);
122}
123
124FIXTURE_DATA_TEST_CASE(RunLarge, CLWinogradInputTransformFixture, framework::DatasetMode::NIGHTLY, combine(datasets::LargeWinogradInputTransformDataset(), framework::dataset::make("DataType", { DataType::F32 })))
125{
126 validate(CLAccessor(_target), _reference);
127}
128
129TEST_SUITE_END()
130
131TEST_SUITE_END()
132TEST_SUITE_END()
133} // namespace validation
134} // namespace test
135} // namespace arm_compute