Giorgio Arena | 1f9ca1d | 2018-03-01 11:13:45 +0000 | [diff] [blame] | 1 | /* |
| 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, |
Gian Marco Iodice | 7e4b239 | 2018-02-22 16:17:20 +0000 | [diff] [blame] | 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
Giorgio Arena | 1f9ca1d | 2018-03-01 11:13:45 +0000 | [diff] [blame] | 22 | * SOFTWARE. |
| 23 | */ |
Gian Marco Iodice | 7e4b239 | 2018-02-22 16:17:20 +0000 | [diff] [blame] | 24 | #include "arm_compute/core/CL/kernels/CLWinogradFilterTransformKernel.h" |
Gian Marco Iodice | d2fab73 | 2018-03-02 11:18:12 +0000 | [diff] [blame] | 25 | #include "arm_compute/core/CL/kernels/CLWinogradOutputTransformKernel.h" |
Giorgio Arena | 1f9ca1d | 2018-03-01 11:13:45 +0000 | [diff] [blame] | 26 | #include "arm_compute/core/Types.h" |
| 27 | #include "arm_compute/core/utils/misc/ShapeCalculator.h" |
| 28 | #include "arm_compute/runtime/CL/CLTensor.h" |
| 29 | #include "arm_compute/runtime/CL/CLTensorAllocator.h" |
Gian Marco Iodice | d2fab73 | 2018-03-02 11:18:12 +0000 | [diff] [blame] | 30 | #include "arm_compute/runtime/CL/functions/CLWinogradConvolutionLayer.h" |
Giorgio Arena | 1f9ca1d | 2018-03-01 11:13:45 +0000 | [diff] [blame] | 31 | #include "arm_compute/runtime/CL/functions/CLWinogradInputTransform.h" |
| 32 | #include "tests/CL/CLAccessor.h" |
Gian Marco Iodice | 7e4b239 | 2018-02-22 16:17:20 +0000 | [diff] [blame] | 33 | #include "tests/CL/Helper.h" |
| 34 | #include "tests/PaddingCalculator.h" |
Gian Marco Iodice | d2fab73 | 2018-03-02 11:18:12 +0000 | [diff] [blame] | 35 | #include "tests/datasets/LargeConvolutionLayerDataset.h" |
Gian Marco Iodice | 7e4b239 | 2018-02-22 16:17:20 +0000 | [diff] [blame] | 36 | #include "tests/datasets/ShapeDatasets.h" |
Gian Marco Iodice | d2fab73 | 2018-03-02 11:18:12 +0000 | [diff] [blame] | 37 | #include "tests/datasets/SmallConvolutionLayerDataset.h" |
Giorgio Arena | 1f9ca1d | 2018-03-01 11:13:45 +0000 | [diff] [blame] | 38 | #include "tests/datasets/WinogradInputTransformDataset.h" |
Gian Marco Iodice | d2fab73 | 2018-03-02 11:18:12 +0000 | [diff] [blame] | 39 | #include "tests/datasets/WinogradOutputTransformDataset.h" |
Giorgio Arena | 1f9ca1d | 2018-03-01 11:13:45 +0000 | [diff] [blame] | 40 | #include "tests/framework/Asserts.h" |
| 41 | #include "tests/framework/Macros.h" |
| 42 | #include "tests/framework/datasets/Datasets.h" |
| 43 | #include "tests/validation/Validation.h" |
| 44 | #include "tests/validation/fixtures/WinogradLayerFixture.h" |
| 45 | |
| 46 | namespace arm_compute |
| 47 | { |
| 48 | namespace test |
| 49 | { |
| 50 | namespace validation |
| 51 | { |
Gian Marco Iodice | 7e4b239 | 2018-02-22 16:17:20 +0000 | [diff] [blame] | 52 | namespace |
| 53 | { |
Gian Marco Iodice | d2fab73 | 2018-03-02 11:18:12 +0000 | [diff] [blame] | 54 | constexpr AbsoluteTolerance<float> tolerance_f32(0.001f); |
Gian Marco Iodice | 7e4b239 | 2018-02-22 16:17:20 +0000 | [diff] [blame] | 55 | } // namespace |
| 56 | |
| 57 | using namespace arm_compute::misc::shape_calculator; |
| 58 | |
Giorgio Arena | 1f9ca1d | 2018-03-01 11:13:45 +0000 | [diff] [blame] | 59 | TEST_SUITE(CL) |
| 60 | TEST_SUITE(Winograd) |
| 61 | |
| 62 | TEST_SUITE(InputTransform) |
| 63 | |
| 64 | // *INDENT-OFF* |
| 65 | // clang-format off |
Gian Marco Iodice | 247f52c | 2018-03-22 11:24:56 +0000 | [diff] [blame^] | 66 | DATA_TEST_CASE(Validate, framework::DatasetMode::ALL, zip(zip(zip( |
Giorgio Arena | 1f9ca1d | 2018-03-01 11:13:45 +0000 | [diff] [blame] | 67 | framework::dataset::make("InputInfo",{ |
| 68 | TensorInfo(TensorShape(53U, 21U, 5U, 3U), 1, DataType::F16), // F16 not supported |
| 69 | TensorInfo(TensorShape(53U, 21U, 5U, 3U), 1, DataType::QASYMM8), // QASYMM8 not supported |
| 70 | TensorInfo(TensorShape(53U, 21U, 5U, 3U), 1, DataType::F32), // Kernel size not supported |
| 71 | TensorInfo(TensorShape(53U, 21U, 5U, 3U), 1, DataType::F32), // Strides not supported |
Gian Marco Iodice | d2fab73 | 2018-03-02 11:18:12 +0000 | [diff] [blame] | 72 | TensorInfo(TensorShape(53U, 33U, 4U), 1, DataType::F32), // Padding needed |
| 73 | TensorInfo(TensorShape(34U, 42U, 7U, 3U), 1, DataType::F32), // Padding needed |
| 74 | TensorInfo(TensorShape(31U, 37U, 37U), 1, DataType::F32) // Padding needed |
Giorgio Arena | 1f9ca1d | 2018-03-01 11:13:45 +0000 | [diff] [blame] | 75 | }), |
| 76 | framework::dataset::make("OutputInfo", { |
| 77 | TensorInfo(TensorShape(5U, 5U, 16U, 3U), 1, DataType::F16), |
| 78 | TensorInfo(TensorShape(5U, 5U, 16U, 3U), 1, DataType::QASYMM8), |
| 79 | TensorInfo(TensorShape(5U, 5U, 16U, 3U), 1, DataType::F32), |
| 80 | TensorInfo(TensorShape(5U, 1U, 16U, 3U), 1, DataType::F32), |
| 81 | TensorInfo(TensorShape(4U, 442U, 16U), 1, DataType::F32), |
| 82 | TensorInfo(TensorShape(7U, 320U, 16U, 3U), 1, DataType::F32), |
| 83 | TensorInfo(TensorShape(37U, 304U, 16U), 1, DataType::F32) |
| 84 | })), |
Gian Marco Iodice | 247f52c | 2018-03-22 11:24:56 +0000 | [diff] [blame^] | 85 | framework::dataset::make("WinogradInfo", { |
| 86 | WinogradInfo(Size2D(2, 2), Size2D(3, 3), Size2D(53U, 21U), PadStrideInfo(1, 1, 1, 0), DataLayout::NCHW), |
| 87 | WinogradInfo(Size2D(2, 2), Size2D(3, 3), Size2D(53U, 21U), PadStrideInfo(1, 1, 0, 0), DataLayout::NCHW), |
| 88 | WinogradInfo(Size2D(2, 2), Size2D(3, 3), Size2D(53U, 21U), PadStrideInfo(1, 1, 1, 1), DataLayout::NCHW), |
| 89 | WinogradInfo(Size2D(2, 2), Size2D(3, 3), Size2D(53U, 21U), PadStrideInfo(2, 1, 1, 1), DataLayout::NCHW), |
| 90 | WinogradInfo(Size2D(2, 2), Size2D(3, 3), Size2D(53U, 33U), PadStrideInfo(1, 1, 0, 1), DataLayout::NCHW), |
| 91 | WinogradInfo(Size2D(2, 2), Size2D(3, 3), Size2D(34U, 42U), PadStrideInfo(1, 1, 0, 0), DataLayout::NCHW), |
| 92 | WinogradInfo(Size2D(2, 2), Size2D(3, 3), Size2D(31U, 37U), PadStrideInfo(1, 1, 1, 1), DataLayout::NCHW) |
Giorgio Arena | 1f9ca1d | 2018-03-01 11:13:45 +0000 | [diff] [blame] | 93 | })), |
Gian Marco Iodice | d2fab73 | 2018-03-02 11:18:12 +0000 | [diff] [blame] | 94 | framework::dataset::make("Expected", { false, false, false, false, false, false, false })), |
Gian Marco Iodice | 247f52c | 2018-03-22 11:24:56 +0000 | [diff] [blame^] | 95 | input_info, output_info, winograd_info, expected) |
Giorgio Arena | 1f9ca1d | 2018-03-01 11:13:45 +0000 | [diff] [blame] | 96 | { |
Gian Marco Iodice | 247f52c | 2018-03-22 11:24:56 +0000 | [diff] [blame^] | 97 | ARM_COMPUTE_EXPECT(bool(CLWinogradInputTransform::validate(&input_info.clone()->set_is_resizable(false), &output_info.clone()->set_is_resizable(false), winograd_info)) == expected, framework::LogLevel::ERRORS); |
Giorgio Arena | 1f9ca1d | 2018-03-01 11:13:45 +0000 | [diff] [blame] | 98 | } |
| 99 | // clang-format on |
| 100 | // *INDENT-ON* |
| 101 | |
| 102 | using CLWinogradInputTransformFixture = WinogradInputTransformValidationFixture<CLTensor, CLAccessor, CLWinogradInputTransform, float>; |
| 103 | |
Gian Marco Iodice | 247f52c | 2018-03-22 11:24:56 +0000 | [diff] [blame^] | 104 | DATA_TEST_CASE(Configuration, framework::DatasetMode::ALL, combine(combine(framework::dataset::concat(datasets::SmallWinogradInputTransformDataset(), datasets::LargeWinogradInputTransformDataset()), |
| 105 | framework::dataset::make("DataLayout", { DataLayout::NCHW })), |
Giorgio Arena | 1f9ca1d | 2018-03-01 11:13:45 +0000 | [diff] [blame] | 106 | framework::dataset::make("DataType", { DataType::F32 })), |
Gian Marco Iodice | 247f52c | 2018-03-22 11:24:56 +0000 | [diff] [blame^] | 107 | shape_in, winograd_info, data_layout, data_type) |
Giorgio Arena | 1f9ca1d | 2018-03-01 11:13:45 +0000 | [diff] [blame] | 108 | { |
Gian Marco Iodice | 247f52c | 2018-03-22 11:24:56 +0000 | [diff] [blame^] | 109 | TensorShape shape_out = compute_winograd_input_transform_shape(TensorInfo(shape_in, 1, data_type), winograd_info); |
Giorgio Arena | 1f9ca1d | 2018-03-01 11:13:45 +0000 | [diff] [blame] | 110 | |
| 111 | // Create tensors |
Gian Marco Iodice | 247f52c | 2018-03-22 11:24:56 +0000 | [diff] [blame^] | 112 | CLTensor in = create_tensor<CLTensor>(shape_in, data_type, 1, 0, QuantizationInfo(), data_layout); |
Giorgio Arena | 1f9ca1d | 2018-03-01 11:13:45 +0000 | [diff] [blame] | 113 | CLTensor out = create_tensor<CLTensor>(shape_out, data_type); |
| 114 | |
| 115 | ARM_COMPUTE_EXPECT(in.info()->is_resizable(), framework::LogLevel::ERRORS); |
| 116 | ARM_COMPUTE_EXPECT(out.info()->is_resizable(), framework::LogLevel::ERRORS); |
| 117 | |
| 118 | // Create and configure function |
| 119 | CLWinogradInputTransform winograd_input_transform; |
| 120 | |
| 121 | // Configure the function |
Gian Marco Iodice | 247f52c | 2018-03-22 11:24:56 +0000 | [diff] [blame^] | 122 | winograd_input_transform.configure(&in, &out, winograd_info); |
Giorgio Arena | 1f9ca1d | 2018-03-01 11:13:45 +0000 | [diff] [blame] | 123 | } |
| 124 | |
Gian Marco Iodice | 247f52c | 2018-03-22 11:24:56 +0000 | [diff] [blame^] | 125 | FIXTURE_DATA_TEST_CASE(RunSmall, CLWinogradInputTransformFixture, framework::DatasetMode::PRECOMMIT, combine(combine(datasets::SmallWinogradInputTransformDataset(), |
| 126 | framework::dataset::make("DataLayout", { DataLayout::NCHW })), |
| 127 | framework::dataset::make("DataType", { DataType::F32 }))) |
Giorgio Arena | 1f9ca1d | 2018-03-01 11:13:45 +0000 | [diff] [blame] | 128 | { |
| 129 | validate(CLAccessor(_target), _reference); |
| 130 | } |
| 131 | |
Gian Marco Iodice | 247f52c | 2018-03-22 11:24:56 +0000 | [diff] [blame^] | 132 | FIXTURE_DATA_TEST_CASE(RunLarge, CLWinogradInputTransformFixture, framework::DatasetMode::NIGHTLY, combine(combine(datasets::LargeWinogradInputTransformDataset(), |
| 133 | framework::dataset::make("DataLayout", { DataLayout::NCHW })), |
| 134 | framework::dataset::make("DataType", { DataType::F32 }))) |
Giorgio Arena | 1f9ca1d | 2018-03-01 11:13:45 +0000 | [diff] [blame] | 135 | { |
| 136 | validate(CLAccessor(_target), _reference); |
| 137 | } |
Gian Marco Iodice | 7e4b239 | 2018-02-22 16:17:20 +0000 | [diff] [blame] | 138 | TEST_SUITE_END() // InputTransform |
Giorgio Arena | 1f9ca1d | 2018-03-01 11:13:45 +0000 | [diff] [blame] | 139 | |
Gian Marco Iodice | 7e4b239 | 2018-02-22 16:17:20 +0000 | [diff] [blame] | 140 | TEST_SUITE(FilterTransform) |
| 141 | // *INDENT-OFF* |
| 142 | // clang-format off |
Giorgio Arena | 2d9de0a | 2018-03-15 17:58:20 +0000 | [diff] [blame] | 143 | DATA_TEST_CASE(Validate, framework::DatasetMode::ALL, zip(zip(zip( |
Gian Marco Iodice | 7e4b239 | 2018-02-22 16:17:20 +0000 | [diff] [blame] | 144 | framework::dataset::make("InputInfo",{ |
| 145 | TensorInfo(TensorShape(3U, 3U, 5U, 3U), 1, DataType::F16), // F16 not supported |
| 146 | TensorInfo(TensorShape(3U, 3U, 5U, 3U), 1, DataType::QASYMM8), // QASYMM8 not supported |
| 147 | TensorInfo(TensorShape(5U, 5U, 5U, 3U), 1, DataType::F32), // Kernel size not supported |
Giorgio Arena | 2d9de0a | 2018-03-15 17:58:20 +0000 | [diff] [blame] | 148 | TensorInfo(TensorShape(3U, 3U), 1, DataType::F32), // Output tile not supported |
Gian Marco Iodice | 7e4b239 | 2018-02-22 16:17:20 +0000 | [diff] [blame] | 149 | TensorInfo(TensorShape(3U, 3U, 5U, 3U), 1, DataType::F32), // valid |
| 150 | TensorInfo(TensorShape(3U, 3U, 37U, 2U), 1, DataType::F32), // valid |
| 151 | TensorInfo(TensorShape(3U, 3U, 37U, 22U), 1, DataType::F32) // valid |
| 152 | }), |
| 153 | framework::dataset::make("OutputInfo", { |
| 154 | TensorInfo(TensorShape(3U, 5U, 16U), 1, DataType::F16), |
| 155 | TensorInfo(TensorShape(3U, 5U, 16U), 1, DataType::QASYMM8), |
| 156 | TensorInfo(TensorShape(3U, 5U, 16U), 1, DataType::F32), |
| 157 | TensorInfo(TensorShape(1U, 1U, 16U), 1, DataType::F32), |
| 158 | TensorInfo(TensorShape(3U, 5U, 16U), 1, DataType::F32), |
| 159 | TensorInfo(TensorShape(2U, 37U, 16U), 1, DataType::F32), |
Giorgio Arena | 2d9de0a | 2018-03-15 17:58:20 +0000 | [diff] [blame] | 160 | TensorInfo(TensorShape(22U, 37U, 36U), 1, DataType::F32) |
Gian Marco Iodice | 7e4b239 | 2018-02-22 16:17:20 +0000 | [diff] [blame] | 161 | })), |
Gian Marco Iodice | 247f52c | 2018-03-22 11:24:56 +0000 | [diff] [blame^] | 162 | framework::dataset::make("WinogradInfo", { |
| 163 | WinogradInfo(Size2D(2U, 2U), Size2D(3U, 3U), Size2D() /* Not needed */, PadStrideInfo() /* Not needed */, DataLayout::NCHW /* Not needed */ ), |
| 164 | WinogradInfo(Size2D(2U, 2U), Size2D(3U, 3U), Size2D() /* Not needed */, PadStrideInfo() /* Not needed */, DataLayout::NCHW /* Not needed */ ), |
| 165 | WinogradInfo(Size2D(2U, 2U), Size2D(3U, 3U), Size2D() /* Not needed */, PadStrideInfo() /* Not needed */, DataLayout::NCHW /* Not needed */ ), |
| 166 | WinogradInfo(Size2D(3U, 3U), Size2D(3U, 3U), Size2D() /* Not needed */, PadStrideInfo() /* Not needed */, DataLayout::NCHW /* Not needed */ ), |
| 167 | WinogradInfo(Size2D(2U, 2U), Size2D(3U, 3U), Size2D() /* Not needed */, PadStrideInfo() /* Not needed */, DataLayout::NCHW /* Not needed */ ), |
| 168 | WinogradInfo(Size2D(2U, 2U), Size2D(3U, 3U), Size2D() /* Not needed */, PadStrideInfo() /* Not needed */, DataLayout::NCHW /* Not needed */ ), |
| 169 | WinogradInfo(Size2D(4U, 4U), Size2D(3U, 3U), Size2D() /* Not needed */, PadStrideInfo() /* Not needed */, DataLayout::NCHW /* Not needed */ ) |
| 170 | })), |
Giorgio Arena | 2d9de0a | 2018-03-15 17:58:20 +0000 | [diff] [blame] | 171 | framework::dataset::make("Expected", { false, false, false, false, true, true, true })), |
Gian Marco Iodice | 247f52c | 2018-03-22 11:24:56 +0000 | [diff] [blame^] | 172 | input_info, output_info, winograd_info, expected) |
Gian Marco Iodice | 7e4b239 | 2018-02-22 16:17:20 +0000 | [diff] [blame] | 173 | { |
Gian Marco Iodice | 247f52c | 2018-03-22 11:24:56 +0000 | [diff] [blame^] | 174 | ARM_COMPUTE_EXPECT(bool(CLWinogradFilterTransformKernel::validate(&input_info.clone()->set_is_resizable(false), &output_info.clone()->set_is_resizable(false), winograd_info)) == expected, framework::LogLevel::ERRORS); |
Gian Marco Iodice | 7e4b239 | 2018-02-22 16:17:20 +0000 | [diff] [blame] | 175 | } |
| 176 | // clang-format on |
| 177 | // *INDENT-ON* |
Giorgio Arena | 1f9ca1d | 2018-03-01 11:13:45 +0000 | [diff] [blame] | 178 | |
Gian Marco Iodice | 7e4b239 | 2018-02-22 16:17:20 +0000 | [diff] [blame] | 179 | using CLWinogradFilterTransform = CLSynthetizeFunctionWithZeroConstantBorder<CLWinogradFilterTransformKernel, 0>; |
| 180 | using CLWinogradFilterTransformFixture = WinogradFilterTransformValidationFixture<CLTensor, CLAccessor, CLWinogradFilterTransform, float>; |
| 181 | |
Gian Marco Iodice | 247f52c | 2018-03-22 11:24:56 +0000 | [diff] [blame^] | 182 | DATA_TEST_CASE(Configuration, framework::DatasetMode::ALL, combine(combine(combine(framework::dataset::concat(datasets::Small3x3Shapes(), datasets::Large3x3Shapes()), |
| 183 | framework::dataset::make("OutputTile", { Size2D(2U, 2U), Size2D(4U, 4U) })), |
| 184 | framework::dataset::make("DataLayout", { DataLayout::NCHW })), |
Gian Marco Iodice | 7e4b239 | 2018-02-22 16:17:20 +0000 | [diff] [blame] | 185 | framework::dataset::make("DataType", { DataType::F32 })), |
Gian Marco Iodice | 247f52c | 2018-03-22 11:24:56 +0000 | [diff] [blame^] | 186 | shape_a, output_tile, data_layout, data_type) |
Gian Marco Iodice | 7e4b239 | 2018-02-22 16:17:20 +0000 | [diff] [blame] | 187 | { |
Gian Marco Iodice | 247f52c | 2018-03-22 11:24:56 +0000 | [diff] [blame^] | 188 | WinogradInfo winograd_info(output_tile, Size2D(shape_a[0], shape_a[1]), Size2D() /* Not needed */, PadStrideInfo() /* Not needed */, DataLayout::NCHW /* Not needed */); |
Gian Marco Iodice | 7e4b239 | 2018-02-22 16:17:20 +0000 | [diff] [blame] | 189 | |
Gian Marco Iodice | 247f52c | 2018-03-22 11:24:56 +0000 | [diff] [blame^] | 190 | TensorShape shape_b = compute_winograd_filter_transform_shape(TensorInfo(shape_a, 1, data_type), winograd_info); |
Gian Marco Iodice | 7e4b239 | 2018-02-22 16:17:20 +0000 | [diff] [blame] | 191 | |
| 192 | // Create tensors |
Gian Marco Iodice | 247f52c | 2018-03-22 11:24:56 +0000 | [diff] [blame^] | 193 | CLTensor a = create_tensor<CLTensor>(shape_a, data_type, 1, 0, QuantizationInfo(), data_layout); |
| 194 | CLTensor b = create_tensor<CLTensor>(shape_b, data_type, 1, 0, QuantizationInfo(), data_layout); |
Gian Marco Iodice | 7e4b239 | 2018-02-22 16:17:20 +0000 | [diff] [blame] | 195 | |
| 196 | ARM_COMPUTE_EXPECT(a.info()->is_resizable(), framework::LogLevel::ERRORS); |
| 197 | ARM_COMPUTE_EXPECT(b.info()->is_resizable(), framework::LogLevel::ERRORS); |
| 198 | |
| 199 | // Create and configure function |
| 200 | CLWinogradFilterTransform winograd_filter_transform; |
Gian Marco Iodice | 247f52c | 2018-03-22 11:24:56 +0000 | [diff] [blame^] | 201 | winograd_filter_transform.configure(&a, &b, winograd_info); |
Gian Marco Iodice | 7e4b239 | 2018-02-22 16:17:20 +0000 | [diff] [blame] | 202 | } |
| 203 | |
Gian Marco Iodice | 247f52c | 2018-03-22 11:24:56 +0000 | [diff] [blame^] | 204 | FIXTURE_DATA_TEST_CASE(RunSmall, CLWinogradFilterTransformFixture, framework::DatasetMode::ALL, combine(combine(combine(datasets::Small3x3Shapes(), |
| 205 | framework::dataset::make("OutputTile", { Size2D(2U, 2U), Size2D(4U, 4U) })), |
| 206 | framework::dataset::make("DataLayout", { DataLayout::NCHW })), |
Giorgio Arena | 2d9de0a | 2018-03-15 17:58:20 +0000 | [diff] [blame] | 207 | framework::dataset::make("DataType", { DataType::F32 }))) |
Gian Marco Iodice | 7e4b239 | 2018-02-22 16:17:20 +0000 | [diff] [blame] | 208 | { |
| 209 | // Validate output |
| 210 | validate(CLAccessor(_target), _reference, tolerance_f32); |
| 211 | } |
| 212 | |
Gian Marco Iodice | 247f52c | 2018-03-22 11:24:56 +0000 | [diff] [blame^] | 213 | FIXTURE_DATA_TEST_CASE(RunLarge, CLWinogradFilterTransformFixture, framework::DatasetMode::NIGHTLY, combine(combine(combine(datasets::Large3x3Shapes(), |
Giorgio Arena | 2d9de0a | 2018-03-15 17:58:20 +0000 | [diff] [blame] | 214 | framework::dataset::make("OutputTile", { Size2D(2U, 2U), Size2D(4U, 4U) })), |
Gian Marco Iodice | 247f52c | 2018-03-22 11:24:56 +0000 | [diff] [blame^] | 215 | framework::dataset::make("DataLayout", { DataLayout::NCHW })), |
Giorgio Arena | 2d9de0a | 2018-03-15 17:58:20 +0000 | [diff] [blame] | 216 | framework::dataset::make("DataType", { DataType::F32 }))) |
Gian Marco Iodice | 7e4b239 | 2018-02-22 16:17:20 +0000 | [diff] [blame] | 217 | { |
| 218 | // Validate output |
| 219 | validate(CLAccessor(_target), _reference, tolerance_f32); |
| 220 | } |
Gian Marco Iodice | d2fab73 | 2018-03-02 11:18:12 +0000 | [diff] [blame] | 221 | |
Gian Marco Iodice | 7e4b239 | 2018-02-22 16:17:20 +0000 | [diff] [blame] | 222 | TEST_SUITE_END() // FilterTransform |
| 223 | |
Gian Marco Iodice | d2fab73 | 2018-03-02 11:18:12 +0000 | [diff] [blame] | 224 | TEST_SUITE(OutputTransform) |
| 225 | // *INDENT-OFF* |
| 226 | // clang-format off |
Gian Marco Iodice | 247f52c | 2018-03-22 11:24:56 +0000 | [diff] [blame^] | 227 | DATA_TEST_CASE(Validate, framework::DatasetMode::ALL, zip(zip(zip(zip( |
Gian Marco Iodice | d2fab73 | 2018-03-02 11:18:12 +0000 | [diff] [blame] | 228 | framework::dataset::make("InputInfo",{ |
Gian Marco Iodice | 247f52c | 2018-03-22 11:24:56 +0000 | [diff] [blame^] | 229 | TensorInfo(TensorShape(512U, 49U, 16U, 5U), 1, DataType::F16), // F16 not supported |
| 230 | TensorInfo(TensorShape(512U, 49U, 16U, 5U), 1, DataType::QASYMM8), // QASYMM8 not supported |
| 231 | TensorInfo(TensorShape(512U, 49U, 16U, 5U), 1, DataType::F32), // Kernel size not supported |
| 232 | TensorInfo(TensorShape(512U, 49U, 16U, 5U), 1, DataType::F32), // Valid |
| 233 | TensorInfo(TensorShape(13U, 108U, 16U, 4U), 1, DataType::F32), // Padding needed |
| 234 | TensorInfo(TensorShape(7U, 20U, 16U, 7U), 1, DataType::F32), // Valid |
| 235 | TensorInfo(TensorShape(7U, 20U, 16U, 7U), 1, DataType::F32) // Wrong WinogradInfo |
Gian Marco Iodice | d2fab73 | 2018-03-02 11:18:12 +0000 | [diff] [blame] | 236 | }), |
| 237 | framework::dataset::make("BiasInfo", { |
Gian Marco Iodice | 247f52c | 2018-03-22 11:24:56 +0000 | [diff] [blame^] | 238 | TensorInfo(TensorShape(512U), 1, DataType::F16), |
| 239 | TensorInfo(TensorShape(512U), 1, DataType::QASYMM8), |
| 240 | TensorInfo(TensorShape(512U), 1, DataType::F32), |
Gian Marco Iodice | d2fab73 | 2018-03-02 11:18:12 +0000 | [diff] [blame] | 241 | TensorInfo(TensorShape(512U), 1, DataType::F32), |
| 242 | TensorInfo(TensorShape(13U), 1, DataType::F32), |
| 243 | TensorInfo(TensorShape(7U), 1, DataType::F32), |
Gian Marco Iodice | 247f52c | 2018-03-22 11:24:56 +0000 | [diff] [blame^] | 244 | TensorInfo(TensorShape(7U), 1, DataType::F32) |
Gian Marco Iodice | d2fab73 | 2018-03-02 11:18:12 +0000 | [diff] [blame] | 245 | })), |
| 246 | framework::dataset::make("OutputInfo", { |
Gian Marco Iodice | 247f52c | 2018-03-22 11:24:56 +0000 | [diff] [blame^] | 247 | TensorInfo(TensorShape(14U, 14U, 512U, 5U), 1, DataType::F16), |
| 248 | TensorInfo(TensorShape(14U, 14U, 512U, 5U), 1, DataType::QASYMM8), |
| 249 | TensorInfo(TensorShape(14U, 14U, 512U, 5U), 1, DataType::F32), |
| 250 | TensorInfo(TensorShape(14U, 14U, 512U, 5U), 1, DataType::F32), |
| 251 | TensorInfo(TensorShape(17U, 23U, 13U, 4U), 1, DataType::F32), |
| 252 | TensorInfo(TensorShape(8U, 10U, 7U, 7U), 1, DataType::F32), |
| 253 | TensorInfo(TensorShape(7U, 9U, 7U, 7U), 1, DataType::F32) |
Gian Marco Iodice | d2fab73 | 2018-03-02 11:18:12 +0000 | [diff] [blame] | 254 | })), |
Gian Marco Iodice | 247f52c | 2018-03-22 11:24:56 +0000 | [diff] [blame^] | 255 | framework::dataset::make("WinogradInfo", { |
| 256 | WinogradInfo(Size2D(2U, 2U), Size2D(3U, 3U), Size2D(14U, 14U), PadStrideInfo(1, 1, 1, 1), DataLayout::NCHW), |
| 257 | WinogradInfo(Size2D(2U, 2U), Size2D(3U, 3U), Size2D(14U, 14U), PadStrideInfo(1, 1, 1, 1), DataLayout::NCHW), |
| 258 | WinogradInfo(Size2D(2U, 2U), Size2D(5U, 5U), Size2D(14U, 14U), PadStrideInfo(1, 1, 1, 1), DataLayout::NCHW), |
| 259 | WinogradInfo(Size2D(2U, 2U), Size2D(3U, 3U), Size2D(14U, 14U), PadStrideInfo(1, 1, 1, 1), DataLayout::NCHW), |
| 260 | WinogradInfo(Size2D(2U, 2U), Size2D(3U, 3U), Size2D(17U, 23U), PadStrideInfo(1, 1, 1, 1), DataLayout::NCHW), |
| 261 | WinogradInfo(Size2D(2U, 2U), Size2D(3U, 3U), Size2D(8U, 10U), PadStrideInfo(1, 1, 1, 1), DataLayout::NCHW), |
| 262 | WinogradInfo(Size2D(2U, 3U), Size2D(3U, 3U), Size2D(8U, 10U), PadStrideInfo(1, 1, 0, 0), DataLayout::NCHW), |
Gian Marco Iodice | d2fab73 | 2018-03-02 11:18:12 +0000 | [diff] [blame] | 263 | })), |
| 264 | framework::dataset::make("Expected", { false, false, false, true, false, true, false })), |
Gian Marco Iodice | 247f52c | 2018-03-22 11:24:56 +0000 | [diff] [blame^] | 265 | input_info, bias_info, output_info, winograd_info, expected) |
Gian Marco Iodice | d2fab73 | 2018-03-02 11:18:12 +0000 | [diff] [blame] | 266 | { |
Gian Marco Iodice | 247f52c | 2018-03-22 11:24:56 +0000 | [diff] [blame^] | 267 | ARM_COMPUTE_EXPECT(bool(CLWinogradOutputTransformKernel::validate(&input_info.clone()->set_is_resizable(false), &bias_info.clone()->set_is_resizable(false), &output_info.clone()->set_is_resizable(false), winograd_info)) == expected, framework::LogLevel::ERRORS); |
Gian Marco Iodice | d2fab73 | 2018-03-02 11:18:12 +0000 | [diff] [blame] | 268 | } |
| 269 | // clang-format on |
| 270 | // *INDENT-ON* |
| 271 | |
| 272 | using CLWinogradOutputTransform = CLSynthetizeFunctionWithZeroConstantBorder<CLWinogradOutputTransformKernel, 0>; |
| 273 | using CLWinogradOutputTransformFixture = WinogradOutputTransformValidationFixture<CLTensor, CLAccessor, CLWinogradOutputTransform, float>; |
| 274 | |
| 275 | DATA_TEST_CASE(Configuration, framework::DatasetMode::ALL, combine(framework::dataset::concat(datasets::SmallWinogradOutputTransformDataset(), datasets::LargeWinogradOutputTransformDataset()), |
| 276 | framework::dataset::make("DataType", { DataType::F32 })), |
Gian Marco Iodice | 247f52c | 2018-03-22 11:24:56 +0000 | [diff] [blame^] | 277 | shape_a, winograd_info, data_type) |
Gian Marco Iodice | d2fab73 | 2018-03-02 11:18:12 +0000 | [diff] [blame] | 278 | { |
Gian Marco Iodice | 247f52c | 2018-03-22 11:24:56 +0000 | [diff] [blame^] | 279 | TensorShape shape_b = compute_winograd_output_transform_shape(TensorInfo(shape_a, 1, data_type), winograd_info); |
Gian Marco Iodice | d2fab73 | 2018-03-02 11:18:12 +0000 | [diff] [blame] | 280 | |
| 281 | // Create tensors |
| 282 | CLTensor a = create_tensor<CLTensor>(shape_a, data_type); |
| 283 | CLTensor b = create_tensor<CLTensor>(shape_b, data_type); |
| 284 | |
| 285 | ARM_COMPUTE_EXPECT(a.info()->is_resizable(), framework::LogLevel::ERRORS); |
| 286 | ARM_COMPUTE_EXPECT(b.info()->is_resizable(), framework::LogLevel::ERRORS); |
| 287 | |
| 288 | // Create and configure function |
| 289 | CLWinogradOutputTransform winograd_output_transform; |
Gian Marco Iodice | 247f52c | 2018-03-22 11:24:56 +0000 | [diff] [blame^] | 290 | winograd_output_transform.configure(&a, nullptr, &b, winograd_info); |
Gian Marco Iodice | d2fab73 | 2018-03-02 11:18:12 +0000 | [diff] [blame] | 291 | } |
| 292 | |
| 293 | FIXTURE_DATA_TEST_CASE(RunSmall, CLWinogradOutputTransformFixture, framework::DatasetMode::ALL, combine(datasets::SmallWinogradOutputTransformDataset(), framework::dataset::make("DataType", { DataType::F32 }))) |
| 294 | { |
| 295 | // Validate output |
| 296 | validate(CLAccessor(_target), _reference, tolerance_f32); |
| 297 | } |
| 298 | |
| 299 | FIXTURE_DATA_TEST_CASE(RunLarge, CLWinogradOutputTransformFixture, framework::DatasetMode::NIGHTLY, combine(datasets::LargeWinogradOutputTransformDataset(), framework::dataset::make("DataType", { DataType::F32 }))) |
| 300 | { |
| 301 | // Validate output |
| 302 | validate(CLAccessor(_target), _reference, tolerance_f32); |
| 303 | } |
| 304 | |
| 305 | TEST_SUITE_END() // OutputTransform |
| 306 | |
| 307 | TEST_SUITE(ConvolutionLayer) |
| 308 | // *INDENT-OFF* |
| 309 | // clang-format off |
| 310 | DATA_TEST_CASE(Validate, framework::DatasetMode::ALL, zip(zip(zip(zip(zip( |
| 311 | framework::dataset::make("InputInfo", { |
| 312 | TensorInfo(TensorShape(17U, 31U, 2U), 1, DataType::F16), // FP16 not supported |
| 313 | TensorInfo(TensorShape(17U, 31U, 2U), 1, DataType::F32), // Datatype mismatch |
| 314 | TensorInfo(TensorShape(23U, 27U, 5U, 4U), 1, DataType::F32), // Stride y not supported |
| 315 | TensorInfo(TensorShape(16U, 16U, 8U), 1, DataType::F32), // Padding needed |
| 316 | TensorInfo(TensorShape(33U, 27U, 7U, 4U), 1, DataType::F32) // Kernel size not supported |
| 317 | }), |
| 318 | framework::dataset::make("WeightsInfo", { |
| 319 | TensorInfo(TensorShape(3U, 3U, 2U, 19U), 1, DataType::F32), |
| 320 | TensorInfo(TensorShape(3U, 3U, 2U, 19U), 1, DataType::QASYMM8), |
| 321 | TensorInfo(TensorShape(3U, 3U, 5U, 21U), 1, DataType::F32), |
| 322 | TensorInfo(TensorShape(3U, 3U, 8U, 16U), 1, DataType::F32), |
| 323 | TensorInfo(TensorShape(5U, 5U, 7U, 16U), 1, DataType::F16) |
| 324 | })), |
| 325 | framework::dataset::make("BiasesInfo", { |
| 326 | TensorInfo(TensorShape(19U), 1, DataType::F32), |
| 327 | TensorInfo(TensorShape(19U), 1, DataType::F32), |
| 328 | TensorInfo(TensorShape(21U), 1, DataType::F32), |
| 329 | TensorInfo(TensorShape(16U), 1, DataType::F32), |
| 330 | TensorInfo(TensorShape(16U), 1, DataType::F32) |
| 331 | })), |
| 332 | framework::dataset::make("OutputInfo", { |
| 333 | TensorInfo(TensorShape(17U, 31U, 19U), 1, DataType::F32), |
| 334 | TensorInfo(TensorShape(15U, 15U, 19U), 1, DataType::F32), |
| 335 | TensorInfo(TensorShape(21U, 25U, 21U, 4U), 1, DataType::F32), |
| 336 | TensorInfo(TensorShape(16U, 16U, 16U), 1, DataType::F32), |
| 337 | TensorInfo(TensorShape(11U, 12U, 16U, 4U), 1, DataType::F32) |
| 338 | })), |
| 339 | framework::dataset::make("ConvInfo", { |
| 340 | PadStrideInfo(1, 1, 1, 1), |
| 341 | PadStrideInfo(1, 1, 1, 1), |
| 342 | PadStrideInfo(1, 2, 0, 0), |
| 343 | PadStrideInfo(1, 1, 1, 1), |
| 344 | PadStrideInfo(1, 1, 1, 0) |
| 345 | })), |
| 346 | framework::dataset::make("Expected", { false, false, false, false, false })), |
| 347 | input_info, weights_info, bias_info, output_info, conv_info, expected) |
| 348 | { |
| 349 | ARM_COMPUTE_EXPECT(bool(CLWinogradConvolutionLayer::validate(&input_info.clone()->set_is_resizable(false), &weights_info.clone()->set_is_resizable(false), &bias_info.clone()->set_is_resizable(false), &output_info.clone()->set_is_resizable(false), conv_info)) == expected, framework::LogLevel::ERRORS); |
| 350 | } |
| 351 | // clang-format on |
| 352 | // *INDENT-ON* |
| 353 | |
| 354 | using CLWinogradConvolutionLayerFixture = WinogradConvolutionLayerValidationFixture<CLTensor, CLAccessor, CLWinogradConvolutionLayer, float>; |
Isabella Gottardi | 3f217ec | 2018-02-12 14:59:19 +0000 | [diff] [blame] | 355 | FIXTURE_DATA_TEST_CASE(RunSmall, CLWinogradConvolutionLayerFixture, framework::DatasetMode::PRECOMMIT, combine(combine(datasets::SmallWinogradConvolutionLayer3x3Dataset(), |
| 356 | framework::dataset::make("DataType", { DataType::F32 })), |
| 357 | framework::dataset::make("ActivationLayerInfo", { ActivationLayerInfo() }))) |
Gian Marco Iodice | d2fab73 | 2018-03-02 11:18:12 +0000 | [diff] [blame] | 358 | { |
| 359 | // Validate output |
| 360 | validate(CLAccessor(_target), _reference, tolerance_f32); |
| 361 | } |
| 362 | |
Isabella Gottardi | 3f217ec | 2018-02-12 14:59:19 +0000 | [diff] [blame] | 363 | FIXTURE_DATA_TEST_CASE(RunLarge, CLWinogradConvolutionLayerFixture, framework::DatasetMode::NIGHTLY, combine(combine(datasets::LargeWinogradConvolutionLayer3x3Dataset(), |
| 364 | framework::dataset::make("DataType", { DataType::F32 })), |
| 365 | framework::dataset::make("ActivationLayerInfo", { ActivationLayerInfo() }))) |
Gian Marco Iodice | d2fab73 | 2018-03-02 11:18:12 +0000 | [diff] [blame] | 366 | { |
| 367 | // Validate output |
| 368 | validate(CLAccessor(_target), _reference, tolerance_f32); |
| 369 | } |
| 370 | TEST_SUITE_END() // ConvolutionLayer |
| 371 | |
Gian Marco Iodice | 7e4b239 | 2018-02-22 16:17:20 +0000 | [diff] [blame] | 372 | TEST_SUITE_END() // Winograd |
| 373 | TEST_SUITE_END() // CL |
Giorgio Arena | 1f9ca1d | 2018-03-01 11:13:45 +0000 | [diff] [blame] | 374 | } // namespace validation |
| 375 | } // namespace test |
| 376 | } // namespace arm_compute |