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