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" |
Gian Marco Iodice | f1c2bf0 | 2018-06-13 14:05:54 +0100 | [diff] [blame] | 26 | #include "arm_compute/core/Helpers.h" |
Giorgio Arena | 1f9ca1d | 2018-03-01 11:13:45 +0000 | [diff] [blame] | 27 | #include "arm_compute/core/Types.h" |
| 28 | #include "arm_compute/core/utils/misc/ShapeCalculator.h" |
| 29 | #include "arm_compute/runtime/CL/CLTensor.h" |
| 30 | #include "arm_compute/runtime/CL/CLTensorAllocator.h" |
Gian Marco Iodice | d2fab73 | 2018-03-02 11:18:12 +0000 | [diff] [blame] | 31 | #include "arm_compute/runtime/CL/functions/CLWinogradConvolutionLayer.h" |
Giorgio Arena | 1f9ca1d | 2018-03-01 11:13:45 +0000 | [diff] [blame] | 32 | #include "arm_compute/runtime/CL/functions/CLWinogradInputTransform.h" |
| 33 | #include "tests/CL/CLAccessor.h" |
Gian Marco Iodice | 7e4b239 | 2018-02-22 16:17:20 +0000 | [diff] [blame] | 34 | #include "tests/CL/Helper.h" |
| 35 | #include "tests/PaddingCalculator.h" |
Gian Marco Iodice | d2fab73 | 2018-03-02 11:18:12 +0000 | [diff] [blame] | 36 | #include "tests/datasets/LargeConvolutionLayerDataset.h" |
Gian Marco Iodice | 7e4b239 | 2018-02-22 16:17:20 +0000 | [diff] [blame] | 37 | #include "tests/datasets/ShapeDatasets.h" |
Gian Marco Iodice | d2fab73 | 2018-03-02 11:18:12 +0000 | [diff] [blame] | 38 | #include "tests/datasets/SmallConvolutionLayerDataset.h" |
Giorgio Arena | 1f9ca1d | 2018-03-01 11:13:45 +0000 | [diff] [blame] | 39 | #include "tests/datasets/WinogradInputTransformDataset.h" |
Gian Marco Iodice | d2fab73 | 2018-03-02 11:18:12 +0000 | [diff] [blame] | 40 | #include "tests/datasets/WinogradOutputTransformDataset.h" |
Giorgio Arena | 1f9ca1d | 2018-03-01 11:13:45 +0000 | [diff] [blame] | 41 | #include "tests/framework/Asserts.h" |
| 42 | #include "tests/framework/Macros.h" |
| 43 | #include "tests/framework/datasets/Datasets.h" |
| 44 | #include "tests/validation/Validation.h" |
Georgios Pinitas | 9fb1159 | 2018-04-26 20:34:58 +0100 | [diff] [blame] | 45 | #include "tests/validation/fixtures/WinogradConvolutionLayerFixture.h" |
Giorgio Arena | 1f9ca1d | 2018-03-01 11:13:45 +0000 | [diff] [blame] | 46 | |
| 47 | namespace arm_compute |
| 48 | { |
| 49 | namespace test |
| 50 | { |
| 51 | namespace validation |
| 52 | { |
Gian Marco Iodice | 7e4b239 | 2018-02-22 16:17:20 +0000 | [diff] [blame] | 53 | namespace |
| 54 | { |
Gian Marco Iodice | f1c2bf0 | 2018-06-13 14:05:54 +0100 | [diff] [blame] | 55 | // *INDENT-OFF* |
| 56 | // clang-format off |
Gian Marco Iodice | 6cf188c | 2018-05-04 16:36:50 +0100 | [diff] [blame] | 57 | constexpr AbsoluteTolerance<float> tolerance_f32(0.001f); |
Gian Marco Iodice | 4497e81 | 2018-05-08 16:36:52 +0100 | [diff] [blame] | 58 | constexpr AbsoluteTolerance<float> tolerance_convolution_layer_f32(0.1f); |
Gian Marco Iodice | f1c2bf0 | 2018-06-13 14:05:54 +0100 | [diff] [blame] | 59 | |
| 60 | // Input transform |
| 61 | const auto SmallWinogradInputTransformDatasetNCHW = |
| 62 | framework::dataset::concat(datasets::SmallWinogradInputTransformDataset2x2_3x3(), |
| 63 | framework::dataset::concat(datasets::SmallWinogradInputTransformDataset2x1_3x1(), |
| 64 | framework::dataset::concat(datasets::SmallWinogradInputTransformDataset1x2_1x3(), |
| 65 | framework::dataset::concat(datasets::SmallWinogradInputTransformDataset4x4_3x3(), |
| 66 | framework::dataset::concat(datasets::SmallWinogradInputTransformDataset4x1_3x1(), |
| 67 | framework::dataset::concat(datasets::SmallWinogradInputTransformDataset1x4_1x3(), |
| 68 | datasets::SmallWinogradInputTransformDataset4x4_5x5())))))); |
| 69 | |
| 70 | const auto SmallWinogradInputTransformDatasetNHWC = framework::dataset::concat(datasets::SmallWinogradInputTransformDataset4x4_3x3(), |
| 71 | datasets::SmallWinogradInputTransformDataset4x4_5x5()); |
| 72 | |
| 73 | const auto LargeWinogradInputTransformDatasetNCHW = |
| 74 | framework::dataset::concat(datasets::LargeWinogradInputTransformDataset2x2_3x3(), |
| 75 | framework::dataset::concat(datasets::LargeWinogradInputTransformDataset2x1_3x1(), |
| 76 | framework::dataset::concat(datasets::LargeWinogradInputTransformDataset1x2_1x3(), |
| 77 | framework::dataset::concat(datasets::LargeWinogradInputTransformDataset4x4_3x3(), |
| 78 | framework::dataset::concat(datasets::LargeWinogradInputTransformDataset4x1_3x1(), |
| 79 | framework::dataset::concat(datasets::LargeWinogradInputTransformDataset1x4_1x3(), |
| 80 | datasets::LargeWinogradInputTransformDataset4x4_5x5())))))); |
| 81 | |
| 82 | const auto LargeWinogradInputTransformDatasetNHWC = |
| 83 | framework::dataset::concat(datasets::LargeWinogradInputTransformDataset4x4_3x3(), |
| 84 | datasets::LargeWinogradInputTransformDataset4x4_5x5()); |
| 85 | |
| 86 | // Filter transform |
| 87 | const auto SmallWinogradFilterTransformDatasetNCHW = |
| 88 | framework::dataset::concat(combine(datasets::Small3x3Shapes(), framework::dataset::make("OutputTile", { Size2D(2U, 2U), Size2D(4U, 4U) })), |
| 89 | framework::dataset::concat(combine(datasets::Small3x1Shapes(), framework::dataset::make("OutputTile", { Size2D(2U, 1U), Size2D(4U, 1U) })), |
| 90 | framework::dataset::concat(combine(datasets::Small1x3Shapes(), framework::dataset::make("OutputTile", { Size2D(1U, 2U), Size2D(1U, 4U) })), |
| 91 | combine(datasets::Small5x5Shapes(), framework::dataset::make("OutputTile", { Size2D(4U, 4U) }))))); |
| 92 | |
| 93 | const auto SmallWinogradFilterTransformDatasetNHWC = |
| 94 | framework::dataset::concat(combine(datasets::Small3x3Shapes(), framework::dataset::make("OutputTile", { Size2D(4U, 4U) })), |
| 95 | combine(datasets::Small5x5Shapes(), framework::dataset::make("OutputTile", { Size2D(4U, 4U) }))); |
| 96 | |
| 97 | const auto LargeWinogradFilterTransformDatasetNCHW = |
| 98 | framework::dataset::concat(combine(datasets::Large3x3Shapes(), framework::dataset::make("OutputTile", { Size2D(2U, 2U), Size2D(4U, 4U) })), |
| 99 | framework::dataset::concat(combine(datasets::Large3x1Shapes(), framework::dataset::make("OutputTile", { Size2D(2U, 1U), Size2D(4U, 1U) })), |
| 100 | framework::dataset::concat(combine(datasets::Large1x3Shapes(), framework::dataset::make("OutputTile", { Size2D(1U, 2U), Size2D(1U, 4U) })), |
| 101 | combine(datasets::Large5x5Shapes(), framework::dataset::make("OutputTile", { Size2D(4U, 4U) }))))); |
| 102 | |
| 103 | const auto LargeWinogradFilterTransformDatasetNHWC = |
| 104 | framework::dataset::concat(combine(datasets::Large3x3Shapes(), framework::dataset::make("OutputTile", { Size2D(4U, 4U) })), |
| 105 | combine(datasets::Large5x5Shapes(), framework::dataset::make("OutputTile", { Size2D(4U, 4U) }))); |
| 106 | |
| 107 | // Output transform |
| 108 | const auto SmallWinogradOutputTransformDatasetNCHW = datasets::SmallWinogradOutputTransformDatasetNCHW(); |
| 109 | |
| 110 | const auto SmallWinogradOutputTransformDatasetNHWC = datasets::SmallWinogradOutputTransformDatasetNHWC(); |
| 111 | |
| 112 | const auto LargeWinogradOutputTransformDatasetNCHW = datasets::LargeWinogradOutputTransformDatasetNCHW(); |
| 113 | |
| 114 | const auto LargeWinogradOutputTransformDatasetNHWC = datasets::LargeWinogradOutputTransformDatasetNHWC(); |
Gian Marco Iodice | 7e4b239 | 2018-02-22 16:17:20 +0000 | [diff] [blame] | 115 | } // namespace |
| 116 | |
| 117 | using namespace arm_compute::misc::shape_calculator; |
| 118 | |
Giorgio Arena | 1f9ca1d | 2018-03-01 11:13:45 +0000 | [diff] [blame] | 119 | TEST_SUITE(CL) |
| 120 | TEST_SUITE(Winograd) |
| 121 | |
| 122 | TEST_SUITE(InputTransform) |
Gian Marco Iodice | 247f52c | 2018-03-22 11:24:56 +0000 | [diff] [blame] | 123 | DATA_TEST_CASE(Validate, framework::DatasetMode::ALL, zip(zip(zip( |
Giorgio Arena | 1f9ca1d | 2018-03-01 11:13:45 +0000 | [diff] [blame] | 124 | framework::dataset::make("InputInfo",{ |
| 125 | TensorInfo(TensorShape(53U, 21U, 5U, 3U), 1, DataType::F16), // F16 not supported |
| 126 | TensorInfo(TensorShape(53U, 21U, 5U, 3U), 1, DataType::QASYMM8), // QASYMM8 not supported |
| 127 | TensorInfo(TensorShape(53U, 21U, 5U, 3U), 1, DataType::F32), // Kernel size not supported |
| 128 | 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] | 129 | TensorInfo(TensorShape(53U, 33U, 4U), 1, DataType::F32), // Padding needed |
| 130 | TensorInfo(TensorShape(34U, 42U, 7U, 3U), 1, DataType::F32), // Padding needed |
| 131 | TensorInfo(TensorShape(31U, 37U, 37U), 1, DataType::F32) // Padding needed |
Giorgio Arena | 1f9ca1d | 2018-03-01 11:13:45 +0000 | [diff] [blame] | 132 | }), |
| 133 | framework::dataset::make("OutputInfo", { |
| 134 | TensorInfo(TensorShape(5U, 5U, 16U, 3U), 1, DataType::F16), |
| 135 | TensorInfo(TensorShape(5U, 5U, 16U, 3U), 1, DataType::QASYMM8), |
| 136 | TensorInfo(TensorShape(5U, 5U, 16U, 3U), 1, DataType::F32), |
| 137 | TensorInfo(TensorShape(5U, 1U, 16U, 3U), 1, DataType::F32), |
| 138 | TensorInfo(TensorShape(4U, 442U, 16U), 1, DataType::F32), |
| 139 | TensorInfo(TensorShape(7U, 320U, 16U, 3U), 1, DataType::F32), |
| 140 | TensorInfo(TensorShape(37U, 304U, 16U), 1, DataType::F32) |
| 141 | })), |
Gian Marco Iodice | 247f52c | 2018-03-22 11:24:56 +0000 | [diff] [blame] | 142 | framework::dataset::make("WinogradInfo", { |
| 143 | WinogradInfo(Size2D(2, 2), Size2D(3, 3), Size2D(53U, 21U), PadStrideInfo(1, 1, 1, 0), DataLayout::NCHW), |
| 144 | WinogradInfo(Size2D(2, 2), Size2D(3, 3), Size2D(53U, 21U), PadStrideInfo(1, 1, 0, 0), DataLayout::NCHW), |
| 145 | WinogradInfo(Size2D(2, 2), Size2D(3, 3), Size2D(53U, 21U), PadStrideInfo(1, 1, 1, 1), DataLayout::NCHW), |
| 146 | WinogradInfo(Size2D(2, 2), Size2D(3, 3), Size2D(53U, 21U), PadStrideInfo(2, 1, 1, 1), DataLayout::NCHW), |
| 147 | WinogradInfo(Size2D(2, 2), Size2D(3, 3), Size2D(53U, 33U), PadStrideInfo(1, 1, 0, 1), DataLayout::NCHW), |
| 148 | WinogradInfo(Size2D(2, 2), Size2D(3, 3), Size2D(34U, 42U), PadStrideInfo(1, 1, 0, 0), DataLayout::NCHW), |
| 149 | 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] | 150 | })), |
Gian Marco Iodice | d2fab73 | 2018-03-02 11:18:12 +0000 | [diff] [blame] | 151 | framework::dataset::make("Expected", { false, false, false, false, false, false, false })), |
Gian Marco Iodice | 247f52c | 2018-03-22 11:24:56 +0000 | [diff] [blame] | 152 | input_info, output_info, winograd_info, expected) |
Giorgio Arena | 1f9ca1d | 2018-03-01 11:13:45 +0000 | [diff] [blame] | 153 | { |
Gian Marco Iodice | 247f52c | 2018-03-22 11:24:56 +0000 | [diff] [blame] | 154 | 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] | 155 | } |
Giorgio Arena | 1f9ca1d | 2018-03-01 11:13:45 +0000 | [diff] [blame] | 156 | |
| 157 | using CLWinogradInputTransformFixture = WinogradInputTransformValidationFixture<CLTensor, CLAccessor, CLWinogradInputTransform, float>; |
| 158 | |
Gian Marco Iodice | f1c2bf0 | 2018-06-13 14:05:54 +0100 | [diff] [blame] | 159 | TEST_SUITE(NCHW) |
| 160 | DATA_TEST_CASE(Configuration, framework::DatasetMode::ALL, combine(combine(framework::dataset::concat(SmallWinogradInputTransformDatasetNCHW, |
| 161 | LargeWinogradInputTransformDatasetNCHW), |
Gian Marco Iodice | 247f52c | 2018-03-22 11:24:56 +0000 | [diff] [blame] | 162 | framework::dataset::make("DataLayout", { DataLayout::NCHW })), |
Gian Marco Iodice | f1c2bf0 | 2018-06-13 14:05:54 +0100 | [diff] [blame] | 163 | framework::dataset::make("DataType", { DataType::F32 })), |
Gian Marco Iodice | 247f52c | 2018-03-22 11:24:56 +0000 | [diff] [blame] | 164 | shape_in, winograd_info, data_layout, data_type) |
Giorgio Arena | 1f9ca1d | 2018-03-01 11:13:45 +0000 | [diff] [blame] | 165 | { |
Gian Marco Iodice | f1c2bf0 | 2018-06-13 14:05:54 +0100 | [diff] [blame] | 166 | TensorInfo tensor_info_in(shape_in, 1, data_type); |
| 167 | tensor_info_in.set_data_layout(data_layout); |
| 168 | |
| 169 | TensorShape shape_out = compute_winograd_input_transform_shape(tensor_info_in, winograd_info); |
Giorgio Arena | 1f9ca1d | 2018-03-01 11:13:45 +0000 | [diff] [blame] | 170 | |
| 171 | // Create tensors |
Vidhya Sudhan Loganathan | 014333d | 2018-07-02 09:13:49 +0100 | [diff] [blame^] | 172 | CLTensor in = create_tensor<CLTensor>(shape_in, data_type, 1, QuantizationInfo(), data_layout); |
Giorgio Arena | 1f9ca1d | 2018-03-01 11:13:45 +0000 | [diff] [blame] | 173 | CLTensor out = create_tensor<CLTensor>(shape_out, data_type); |
| 174 | |
| 175 | ARM_COMPUTE_EXPECT(in.info()->is_resizable(), framework::LogLevel::ERRORS); |
| 176 | ARM_COMPUTE_EXPECT(out.info()->is_resizable(), framework::LogLevel::ERRORS); |
| 177 | |
| 178 | // Create and configure function |
| 179 | CLWinogradInputTransform winograd_input_transform; |
| 180 | |
| 181 | // Configure the function |
Gian Marco Iodice | 247f52c | 2018-03-22 11:24:56 +0000 | [diff] [blame] | 182 | winograd_input_transform.configure(&in, &out, winograd_info); |
Giorgio Arena | 1f9ca1d | 2018-03-01 11:13:45 +0000 | [diff] [blame] | 183 | } |
| 184 | |
Gian Marco Iodice | f1c2bf0 | 2018-06-13 14:05:54 +0100 | [diff] [blame] | 185 | FIXTURE_DATA_TEST_CASE(RunSmall, CLWinogradInputTransformFixture, framework::DatasetMode::PRECOMMIT, combine(combine(SmallWinogradInputTransformDatasetNCHW, |
| 186 | framework::dataset::make("DataLayout", { DataLayout::NCHW })), |
| 187 | framework::dataset::make("DataType", { DataType::F32 }))) |
Giorgio Arena | 1f9ca1d | 2018-03-01 11:13:45 +0000 | [diff] [blame] | 188 | { |
Giorgio Arena | fe5ef38 | 2018-04-17 10:14:10 +0100 | [diff] [blame] | 189 | validate(CLAccessor(_target), _reference, tolerance_f32); |
Giorgio Arena | 1f9ca1d | 2018-03-01 11:13:45 +0000 | [diff] [blame] | 190 | } |
| 191 | |
Gian Marco Iodice | f1c2bf0 | 2018-06-13 14:05:54 +0100 | [diff] [blame] | 192 | FIXTURE_DATA_TEST_CASE(RunLarge, CLWinogradInputTransformFixture, framework::DatasetMode::NIGHTLY, combine(combine(LargeWinogradInputTransformDatasetNCHW, |
| 193 | framework::dataset::make("DataLayout", { DataLayout::NCHW })), |
| 194 | framework::dataset::make("DataType", { DataType::F32 }))) |
Giorgio Arena | 1f9ca1d | 2018-03-01 11:13:45 +0000 | [diff] [blame] | 195 | { |
Giorgio Arena | fe5ef38 | 2018-04-17 10:14:10 +0100 | [diff] [blame] | 196 | validate(CLAccessor(_target), _reference, tolerance_f32); |
Giorgio Arena | 1f9ca1d | 2018-03-01 11:13:45 +0000 | [diff] [blame] | 197 | } |
Gian Marco Iodice | f1c2bf0 | 2018-06-13 14:05:54 +0100 | [diff] [blame] | 198 | TEST_SUITE_END() // NCHW |
| 199 | |
| 200 | TEST_SUITE(NHWC) |
| 201 | DATA_TEST_CASE(Configuration, framework::DatasetMode::ALL, combine(combine(framework::dataset::concat(SmallWinogradInputTransformDatasetNHWC, |
| 202 | LargeWinogradInputTransformDatasetNHWC), |
| 203 | framework::dataset::make("DataLayout", { DataLayout::NHWC })), |
| 204 | framework::dataset::make("DataType", { DataType::F32 })), |
| 205 | shape_in, winograd_info, data_layout, data_type) |
| 206 | { |
| 207 | TensorShape shape_in_nhwc(shape_in); |
| 208 | |
| 209 | // Convert the shape to NHWC |
| 210 | permute(shape_in_nhwc, PermutationVector(2U, 0U, 1U)); |
| 211 | |
| 212 | // TensorInfo |
| 213 | TensorInfo tensor_info_in(shape_in_nhwc, 1, data_type); |
| 214 | tensor_info_in.set_data_layout(data_layout); |
| 215 | |
| 216 | TensorShape shape_out = compute_winograd_input_transform_shape(tensor_info_in, winograd_info); |
| 217 | |
| 218 | // Create tensors |
Vidhya Sudhan Loganathan | 014333d | 2018-07-02 09:13:49 +0100 | [diff] [blame^] | 219 | CLTensor in = create_tensor<CLTensor>(shape_in_nhwc, data_type, 1, QuantizationInfo(), data_layout); |
Gian Marco Iodice | f1c2bf0 | 2018-06-13 14:05:54 +0100 | [diff] [blame] | 220 | CLTensor out = create_tensor<CLTensor>(shape_out, data_type); |
| 221 | |
| 222 | ARM_COMPUTE_EXPECT(in.info()->is_resizable(), framework::LogLevel::ERRORS); |
| 223 | ARM_COMPUTE_EXPECT(out.info()->is_resizable(), framework::LogLevel::ERRORS); |
| 224 | |
| 225 | // Create and configure function |
| 226 | CLWinogradInputTransform winograd_input_transform; |
| 227 | |
| 228 | // Configure the function |
| 229 | winograd_input_transform.configure(&in, &out, winograd_info); |
| 230 | } |
| 231 | |
| 232 | FIXTURE_DATA_TEST_CASE(RunSmall, CLWinogradInputTransformFixture, framework::DatasetMode::PRECOMMIT, combine(combine(SmallWinogradInputTransformDatasetNHWC, |
| 233 | framework::dataset::make("DataLayout", { DataLayout::NHWC })), |
| 234 | framework::dataset::make("DataType", { DataType::F32 }))) |
| 235 | { |
| 236 | validate(CLAccessor(_target), _reference, tolerance_f32); |
| 237 | } |
| 238 | |
| 239 | FIXTURE_DATA_TEST_CASE(RunLarge, CLWinogradInputTransformFixture, framework::DatasetMode::NIGHTLY, combine(combine(LargeWinogradInputTransformDatasetNHWC, |
| 240 | framework::dataset::make("DataLayout", { DataLayout::NHWC })), |
| 241 | framework::dataset::make("DataType", { DataType::F32 }))) |
| 242 | { |
| 243 | validate(CLAccessor(_target), _reference, tolerance_f32); |
| 244 | } |
| 245 | TEST_SUITE_END() // NHWC |
Gian Marco Iodice | 7e4b239 | 2018-02-22 16:17:20 +0000 | [diff] [blame] | 246 | TEST_SUITE_END() // InputTransform |
Giorgio Arena | 1f9ca1d | 2018-03-01 11:13:45 +0000 | [diff] [blame] | 247 | |
Gian Marco Iodice | 7e4b239 | 2018-02-22 16:17:20 +0000 | [diff] [blame] | 248 | TEST_SUITE(FilterTransform) |
Giorgio Arena | 2d9de0a | 2018-03-15 17:58:20 +0000 | [diff] [blame] | 249 | DATA_TEST_CASE(Validate, framework::DatasetMode::ALL, zip(zip(zip( |
Gian Marco Iodice | 7e4b239 | 2018-02-22 16:17:20 +0000 | [diff] [blame] | 250 | framework::dataset::make("InputInfo",{ |
| 251 | TensorInfo(TensorShape(3U, 3U, 5U, 3U), 1, DataType::F16), // F16 not supported |
| 252 | TensorInfo(TensorShape(3U, 3U, 5U, 3U), 1, DataType::QASYMM8), // QASYMM8 not supported |
| 253 | 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] | 254 | TensorInfo(TensorShape(3U, 3U), 1, DataType::F32), // Output tile not supported |
Gian Marco Iodice | 7e4b239 | 2018-02-22 16:17:20 +0000 | [diff] [blame] | 255 | TensorInfo(TensorShape(3U, 3U, 5U, 3U), 1, DataType::F32), // valid |
| 256 | TensorInfo(TensorShape(3U, 3U, 37U, 2U), 1, DataType::F32), // valid |
| 257 | TensorInfo(TensorShape(3U, 3U, 37U, 22U), 1, DataType::F32) // valid |
| 258 | }), |
| 259 | framework::dataset::make("OutputInfo", { |
| 260 | TensorInfo(TensorShape(3U, 5U, 16U), 1, DataType::F16), |
| 261 | TensorInfo(TensorShape(3U, 5U, 16U), 1, DataType::QASYMM8), |
| 262 | TensorInfo(TensorShape(3U, 5U, 16U), 1, DataType::F32), |
| 263 | TensorInfo(TensorShape(1U, 1U, 16U), 1, DataType::F32), |
| 264 | TensorInfo(TensorShape(3U, 5U, 16U), 1, DataType::F32), |
| 265 | TensorInfo(TensorShape(2U, 37U, 16U), 1, DataType::F32), |
Giorgio Arena | 2d9de0a | 2018-03-15 17:58:20 +0000 | [diff] [blame] | 266 | TensorInfo(TensorShape(22U, 37U, 36U), 1, DataType::F32) |
Gian Marco Iodice | 7e4b239 | 2018-02-22 16:17:20 +0000 | [diff] [blame] | 267 | })), |
Gian Marco Iodice | 247f52c | 2018-03-22 11:24:56 +0000 | [diff] [blame] | 268 | framework::dataset::make("WinogradInfo", { |
| 269 | WinogradInfo(Size2D(2U, 2U), Size2D(3U, 3U), Size2D() /* Not needed */, PadStrideInfo() /* Not needed */, DataLayout::NCHW /* Not needed */ ), |
| 270 | WinogradInfo(Size2D(2U, 2U), Size2D(3U, 3U), Size2D() /* Not needed */, PadStrideInfo() /* Not needed */, DataLayout::NCHW /* Not needed */ ), |
| 271 | WinogradInfo(Size2D(2U, 2U), Size2D(3U, 3U), Size2D() /* Not needed */, PadStrideInfo() /* Not needed */, DataLayout::NCHW /* Not needed */ ), |
| 272 | WinogradInfo(Size2D(3U, 3U), Size2D(3U, 3U), Size2D() /* Not needed */, PadStrideInfo() /* Not needed */, DataLayout::NCHW /* Not needed */ ), |
| 273 | WinogradInfo(Size2D(2U, 2U), Size2D(3U, 3U), Size2D() /* Not needed */, PadStrideInfo() /* Not needed */, DataLayout::NCHW /* Not needed */ ), |
| 274 | WinogradInfo(Size2D(2U, 2U), Size2D(3U, 3U), Size2D() /* Not needed */, PadStrideInfo() /* Not needed */, DataLayout::NCHW /* Not needed */ ), |
| 275 | WinogradInfo(Size2D(4U, 4U), Size2D(3U, 3U), Size2D() /* Not needed */, PadStrideInfo() /* Not needed */, DataLayout::NCHW /* Not needed */ ) |
| 276 | })), |
Giorgio Arena | 2d9de0a | 2018-03-15 17:58:20 +0000 | [diff] [blame] | 277 | framework::dataset::make("Expected", { false, false, false, false, true, true, true })), |
Gian Marco Iodice | 247f52c | 2018-03-22 11:24:56 +0000 | [diff] [blame] | 278 | input_info, output_info, winograd_info, expected) |
Gian Marco Iodice | 7e4b239 | 2018-02-22 16:17:20 +0000 | [diff] [blame] | 279 | { |
Gian Marco Iodice | 247f52c | 2018-03-22 11:24:56 +0000 | [diff] [blame] | 280 | 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] | 281 | } |
Giorgio Arena | 1f9ca1d | 2018-03-01 11:13:45 +0000 | [diff] [blame] | 282 | |
Gian Marco Iodice | 7e4b239 | 2018-02-22 16:17:20 +0000 | [diff] [blame] | 283 | using CLWinogradFilterTransform = CLSynthetizeFunctionWithZeroConstantBorder<CLWinogradFilterTransformKernel, 0>; |
| 284 | using CLWinogradFilterTransformFixture = WinogradFilterTransformValidationFixture<CLTensor, CLAccessor, CLWinogradFilterTransform, float>; |
| 285 | |
Gian Marco Iodice | f1c2bf0 | 2018-06-13 14:05:54 +0100 | [diff] [blame] | 286 | TEST_SUITE(NCHW) |
| 287 | DATA_TEST_CASE(Configuration, framework::DatasetMode::ALL, |
| 288 | combine(combine(framework::dataset::concat(SmallWinogradFilterTransformDatasetNCHW, |
| 289 | LargeWinogradFilterTransformDatasetNCHW), |
| 290 | framework::dataset::make("DataLayout", { DataLayout::NCHW })), |
| 291 | framework::dataset::make("DataType", { DataType::F32 })), |
Gian Marco Iodice | 247f52c | 2018-03-22 11:24:56 +0000 | [diff] [blame] | 292 | shape_a, output_tile, data_layout, data_type) |
Gian Marco Iodice | 7e4b239 | 2018-02-22 16:17:20 +0000 | [diff] [blame] | 293 | { |
Gian Marco Iodice | f1c2bf0 | 2018-06-13 14:05:54 +0100 | [diff] [blame] | 294 | WinogradInfo winograd_info(output_tile, Size2D(shape_a[0], shape_a[1]), Size2D() /* Not needed */, PadStrideInfo() /* Not needed */, data_layout /* Not needed */); |
Gian Marco Iodice | 7e4b239 | 2018-02-22 16:17:20 +0000 | [diff] [blame] | 295 | |
Gian Marco Iodice | 247f52c | 2018-03-22 11:24:56 +0000 | [diff] [blame] | 296 | 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] | 297 | |
| 298 | // Create tensors |
Vidhya Sudhan Loganathan | 014333d | 2018-07-02 09:13:49 +0100 | [diff] [blame^] | 299 | CLTensor a = create_tensor<CLTensor>(shape_a, data_type, 1, QuantizationInfo(), data_layout); |
| 300 | CLTensor b = create_tensor<CLTensor>(shape_b, data_type, 1, QuantizationInfo(), data_layout); |
Gian Marco Iodice | 7e4b239 | 2018-02-22 16:17:20 +0000 | [diff] [blame] | 301 | |
| 302 | ARM_COMPUTE_EXPECT(a.info()->is_resizable(), framework::LogLevel::ERRORS); |
| 303 | ARM_COMPUTE_EXPECT(b.info()->is_resizable(), framework::LogLevel::ERRORS); |
| 304 | |
| 305 | // Create and configure function |
| 306 | CLWinogradFilterTransform winograd_filter_transform; |
Gian Marco Iodice | 247f52c | 2018-03-22 11:24:56 +0000 | [diff] [blame] | 307 | winograd_filter_transform.configure(&a, &b, winograd_info); |
Gian Marco Iodice | 7e4b239 | 2018-02-22 16:17:20 +0000 | [diff] [blame] | 308 | } |
| 309 | |
Gian Marco Iodice | f1c2bf0 | 2018-06-13 14:05:54 +0100 | [diff] [blame] | 310 | FIXTURE_DATA_TEST_CASE(RunSmall, CLWinogradFilterTransformFixture, framework::DatasetMode::PRECOMMIT, |
| 311 | combine(combine(SmallWinogradFilterTransformDatasetNCHW, |
| 312 | framework::dataset::make("DataLayout", { DataLayout::NCHW })), |
| 313 | framework::dataset::make("DataType", { DataType::F32 }))) |
Gian Marco Iodice | 7e4b239 | 2018-02-22 16:17:20 +0000 | [diff] [blame] | 314 | { |
| 315 | // Validate output |
| 316 | validate(CLAccessor(_target), _reference, tolerance_f32); |
| 317 | } |
| 318 | |
Giorgio Arena | 9373c8b | 2018-04-11 19:07:17 +0100 | [diff] [blame] | 319 | FIXTURE_DATA_TEST_CASE(RunLarge, CLWinogradFilterTransformFixture, framework::DatasetMode::NIGHTLY, |
Gian Marco Iodice | f1c2bf0 | 2018-06-13 14:05:54 +0100 | [diff] [blame] | 320 | combine(combine(LargeWinogradFilterTransformDatasetNCHW, |
| 321 | framework::dataset::make("DataLayout", { DataLayout::NCHW })), |
| 322 | framework::dataset::make("DataType", { DataType::F32 }))) |
| 323 | { |
| 324 | // Validate output |
| 325 | validate(CLAccessor(_target), _reference, tolerance_f32); |
| 326 | } |
| 327 | TEST_SUITE_END() // NCHW |
| 328 | |
| 329 | TEST_SUITE(NHWC) |
| 330 | DATA_TEST_CASE(Configuration, framework::DatasetMode::ALL, |
| 331 | combine(combine(framework::dataset::concat(SmallWinogradFilterTransformDatasetNHWC, |
| 332 | LargeWinogradFilterTransformDatasetNHWC), |
| 333 | framework::dataset::make("DataLayout", { DataLayout::NHWC })), |
| 334 | framework::dataset::make("DataType", { DataType::F32 })), |
| 335 | shape_in, output_tile, data_layout, data_type) |
| 336 | { |
| 337 | TensorShape shape_in_nhwc(shape_in); |
| 338 | |
| 339 | // Convert the shape to NHWC |
| 340 | permute(shape_in_nhwc, PermutationVector(2U, 0U, 1U)); |
| 341 | |
| 342 | // TensorInfo |
| 343 | TensorInfo tensor_info_in(shape_in_nhwc, 1, data_type); |
| 344 | tensor_info_in.set_data_layout(data_layout); |
| 345 | |
| 346 | WinogradInfo winograd_info(output_tile, Size2D(shape_in[0], shape_in[1]), Size2D() /* Not needed */, PadStrideInfo() /* Not needed */, data_layout /* Not needed */); |
| 347 | |
| 348 | TensorShape shape_b = compute_winograd_filter_transform_shape(tensor_info_in, winograd_info); |
| 349 | |
| 350 | // Create tensors |
Vidhya Sudhan Loganathan | 014333d | 2018-07-02 09:13:49 +0100 | [diff] [blame^] | 351 | CLTensor a = create_tensor<CLTensor>(shape_in_nhwc, data_type, 1, QuantizationInfo(), data_layout); |
| 352 | CLTensor b = create_tensor<CLTensor>(shape_b, data_type, 1, QuantizationInfo(), data_layout); |
Gian Marco Iodice | f1c2bf0 | 2018-06-13 14:05:54 +0100 | [diff] [blame] | 353 | |
| 354 | ARM_COMPUTE_EXPECT(a.info()->is_resizable(), framework::LogLevel::ERRORS); |
| 355 | ARM_COMPUTE_EXPECT(b.info()->is_resizable(), framework::LogLevel::ERRORS); |
| 356 | |
| 357 | // Create and configure function |
| 358 | CLWinogradFilterTransform winograd_filter_transform; |
| 359 | winograd_filter_transform.configure(&a, &b, winograd_info); |
| 360 | } |
| 361 | |
| 362 | FIXTURE_DATA_TEST_CASE(RunSmall, CLWinogradFilterTransformFixture, framework::DatasetMode::PRECOMMIT, |
| 363 | combine(combine(SmallWinogradFilterTransformDatasetNHWC, |
| 364 | framework::dataset::make("DataLayout", { DataLayout::NHWC })), |
| 365 | framework::dataset::make("DataType", { DataType::F32 }))) |
Gian Marco Iodice | 7e4b239 | 2018-02-22 16:17:20 +0000 | [diff] [blame] | 366 | { |
| 367 | // Validate output |
| 368 | validate(CLAccessor(_target), _reference, tolerance_f32); |
| 369 | } |
Gian Marco Iodice | d2fab73 | 2018-03-02 11:18:12 +0000 | [diff] [blame] | 370 | |
Gian Marco Iodice | f1c2bf0 | 2018-06-13 14:05:54 +0100 | [diff] [blame] | 371 | FIXTURE_DATA_TEST_CASE(RunLarge, CLWinogradFilterTransformFixture, framework::DatasetMode::NIGHTLY, |
| 372 | combine(combine(LargeWinogradFilterTransformDatasetNHWC, |
| 373 | framework::dataset::make("DataLayout", { DataLayout::NHWC })), |
| 374 | framework::dataset::make("DataType", { DataType::F32 }))) |
| 375 | { |
| 376 | // Validate output |
| 377 | validate(CLAccessor(_target), _reference, tolerance_f32); |
| 378 | } |
| 379 | TEST_SUITE_END() // NHWC |
Gian Marco Iodice | 7e4b239 | 2018-02-22 16:17:20 +0000 | [diff] [blame] | 380 | TEST_SUITE_END() // FilterTransform |
| 381 | |
Gian Marco Iodice | d2fab73 | 2018-03-02 11:18:12 +0000 | [diff] [blame] | 382 | TEST_SUITE(OutputTransform) |
Gian Marco Iodice | 247f52c | 2018-03-22 11:24:56 +0000 | [diff] [blame] | 383 | DATA_TEST_CASE(Validate, framework::DatasetMode::ALL, zip(zip(zip(zip( |
Gian Marco Iodice | d2fab73 | 2018-03-02 11:18:12 +0000 | [diff] [blame] | 384 | framework::dataset::make("InputInfo",{ |
Gian Marco Iodice | 247f52c | 2018-03-22 11:24:56 +0000 | [diff] [blame] | 385 | TensorInfo(TensorShape(512U, 49U, 16U, 5U), 1, DataType::F16), // F16 not supported |
| 386 | TensorInfo(TensorShape(512U, 49U, 16U, 5U), 1, DataType::QASYMM8), // QASYMM8 not supported |
| 387 | TensorInfo(TensorShape(512U, 49U, 16U, 5U), 1, DataType::F32), // Kernel size not supported |
| 388 | TensorInfo(TensorShape(512U, 49U, 16U, 5U), 1, DataType::F32), // Valid |
| 389 | TensorInfo(TensorShape(13U, 108U, 16U, 4U), 1, DataType::F32), // Padding needed |
| 390 | TensorInfo(TensorShape(7U, 20U, 16U, 7U), 1, DataType::F32), // Valid |
Gian Marco Iodice | e52a300 | 2018-04-11 15:59:10 +0100 | [diff] [blame] | 391 | TensorInfo(TensorShape(7U, 20U, 16U, 7U), 1, DataType::F32), // Wrong WinogradInfo |
| 392 | TensorInfo(TensorShape(7U, 256U, 36U, 3U), 1, DataType::F32), // Valid |
| 393 | 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] | 394 | }), |
| 395 | framework::dataset::make("BiasInfo", { |
Gian Marco Iodice | 247f52c | 2018-03-22 11:24:56 +0000 | [diff] [blame] | 396 | TensorInfo(TensorShape(512U), 1, DataType::F16), |
| 397 | TensorInfo(TensorShape(512U), 1, DataType::QASYMM8), |
| 398 | TensorInfo(TensorShape(512U), 1, DataType::F32), |
Gian Marco Iodice | d2fab73 | 2018-03-02 11:18:12 +0000 | [diff] [blame] | 399 | TensorInfo(TensorShape(512U), 1, DataType::F32), |
| 400 | TensorInfo(TensorShape(13U), 1, DataType::F32), |
| 401 | TensorInfo(TensorShape(7U), 1, DataType::F32), |
Gian Marco Iodice | e52a300 | 2018-04-11 15:59:10 +0100 | [diff] [blame] | 402 | TensorInfo(TensorShape(7U), 1, DataType::F32), |
| 403 | TensorInfo(TensorShape(7U), 1, DataType::F32), |
Gian Marco Iodice | 247f52c | 2018-03-22 11:24:56 +0000 | [diff] [blame] | 404 | TensorInfo(TensorShape(7U), 1, DataType::F32) |
Gian Marco Iodice | d2fab73 | 2018-03-02 11:18:12 +0000 | [diff] [blame] | 405 | })), |
| 406 | framework::dataset::make("OutputInfo", { |
Gian Marco Iodice | 247f52c | 2018-03-22 11:24:56 +0000 | [diff] [blame] | 407 | TensorInfo(TensorShape(14U, 14U, 512U, 5U), 1, DataType::F16), |
| 408 | TensorInfo(TensorShape(14U, 14U, 512U, 5U), 1, DataType::QASYMM8), |
| 409 | TensorInfo(TensorShape(14U, 14U, 512U, 5U), 1, DataType::F32), |
| 410 | TensorInfo(TensorShape(14U, 14U, 512U, 5U), 1, DataType::F32), |
| 411 | TensorInfo(TensorShape(17U, 23U, 13U, 4U), 1, DataType::F32), |
| 412 | TensorInfo(TensorShape(8U, 10U, 7U, 7U), 1, DataType::F32), |
Gian Marco Iodice | e52a300 | 2018-04-11 15:59:10 +0100 | [diff] [blame] | 413 | TensorInfo(TensorShape(7U, 9U, 7U, 7U), 1, DataType::F32), |
| 414 | TensorInfo(TensorShape(64U, 64U, 7U, 3U), 1, DataType::F32), |
| 415 | TensorInfo(TensorShape(64U, 64U, 7U, 3U), 1, DataType::F32) |
Gian Marco Iodice | d2fab73 | 2018-03-02 11:18:12 +0000 | [diff] [blame] | 416 | })), |
Gian Marco Iodice | 247f52c | 2018-03-22 11:24:56 +0000 | [diff] [blame] | 417 | framework::dataset::make("WinogradInfo", { |
| 418 | WinogradInfo(Size2D(2U, 2U), Size2D(3U, 3U), Size2D(14U, 14U), PadStrideInfo(1, 1, 1, 1), DataLayout::NCHW), |
| 419 | WinogradInfo(Size2D(2U, 2U), Size2D(3U, 3U), Size2D(14U, 14U), PadStrideInfo(1, 1, 1, 1), DataLayout::NCHW), |
| 420 | WinogradInfo(Size2D(2U, 2U), Size2D(5U, 5U), Size2D(14U, 14U), PadStrideInfo(1, 1, 1, 1), DataLayout::NCHW), |
| 421 | WinogradInfo(Size2D(2U, 2U), Size2D(3U, 3U), Size2D(14U, 14U), PadStrideInfo(1, 1, 1, 1), DataLayout::NCHW), |
| 422 | WinogradInfo(Size2D(2U, 2U), Size2D(3U, 3U), Size2D(17U, 23U), PadStrideInfo(1, 1, 1, 1), DataLayout::NCHW), |
| 423 | WinogradInfo(Size2D(2U, 2U), Size2D(3U, 3U), Size2D(8U, 10U), PadStrideInfo(1, 1, 1, 1), DataLayout::NCHW), |
| 424 | 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] | 425 | WinogradInfo(Size2D(4U, 4U), Size2D(3U, 3U), Size2D(64U, 64U), PadStrideInfo(1, 1, 1, 1), DataLayout::NCHW), |
| 426 | 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] | 427 | })), |
Gian Marco Iodice | e52a300 | 2018-04-11 15:59:10 +0100 | [diff] [blame] | 428 | 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] | 429 | input_info, bias_info, output_info, winograd_info, expected) |
Gian Marco Iodice | d2fab73 | 2018-03-02 11:18:12 +0000 | [diff] [blame] | 430 | { |
Gian Marco Iodice | 247f52c | 2018-03-22 11:24:56 +0000 | [diff] [blame] | 431 | 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] | 432 | } |
Gian Marco Iodice | d2fab73 | 2018-03-02 11:18:12 +0000 | [diff] [blame] | 433 | |
| 434 | using CLWinogradOutputTransform = CLSynthetizeFunctionWithZeroConstantBorder<CLWinogradOutputTransformKernel, 0>; |
| 435 | using CLWinogradOutputTransformFixture = WinogradOutputTransformValidationFixture<CLTensor, CLAccessor, CLWinogradOutputTransform, float>; |
| 436 | |
Gian Marco Iodice | f1c2bf0 | 2018-06-13 14:05:54 +0100 | [diff] [blame] | 437 | TEST_SUITE(NCHW) |
| 438 | DATA_TEST_CASE(Configuration, framework::DatasetMode::ALL, combine(framework::dataset::concat(SmallWinogradOutputTransformDatasetNCHW, |
| 439 | LargeWinogradOutputTransformDatasetNCHW), |
| 440 | framework::dataset::make("DataType", { DataType::F32 })), |
Gian Marco Iodice | 247f52c | 2018-03-22 11:24:56 +0000 | [diff] [blame] | 441 | shape_a, winograd_info, data_type) |
Gian Marco Iodice | d2fab73 | 2018-03-02 11:18:12 +0000 | [diff] [blame] | 442 | { |
Gian Marco Iodice | 247f52c | 2018-03-22 11:24:56 +0000 | [diff] [blame] | 443 | 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] | 444 | |
| 445 | // Create tensors |
| 446 | CLTensor a = create_tensor<CLTensor>(shape_a, data_type); |
Vidhya Sudhan Loganathan | 014333d | 2018-07-02 09:13:49 +0100 | [diff] [blame^] | 447 | CLTensor b = create_tensor<CLTensor>(shape_b, data_type, 1, QuantizationInfo(), winograd_info.output_data_layout); |
Gian Marco Iodice | d2fab73 | 2018-03-02 11:18:12 +0000 | [diff] [blame] | 448 | |
| 449 | ARM_COMPUTE_EXPECT(a.info()->is_resizable(), framework::LogLevel::ERRORS); |
| 450 | ARM_COMPUTE_EXPECT(b.info()->is_resizable(), framework::LogLevel::ERRORS); |
| 451 | |
| 452 | // Create and configure function |
| 453 | CLWinogradOutputTransform winograd_output_transform; |
Gian Marco Iodice | 247f52c | 2018-03-22 11:24:56 +0000 | [diff] [blame] | 454 | winograd_output_transform.configure(&a, nullptr, &b, winograd_info); |
Gian Marco Iodice | d2fab73 | 2018-03-02 11:18:12 +0000 | [diff] [blame] | 455 | } |
| 456 | |
Gian Marco Iodice | f1c2bf0 | 2018-06-13 14:05:54 +0100 | [diff] [blame] | 457 | FIXTURE_DATA_TEST_CASE(RunSmall, CLWinogradOutputTransformFixture, framework::DatasetMode::ALL, |
| 458 | combine(SmallWinogradOutputTransformDatasetNCHW, |
| 459 | framework::dataset::make("DataType", { DataType::F32 }))) |
Gian Marco Iodice | d2fab73 | 2018-03-02 11:18:12 +0000 | [diff] [blame] | 460 | { |
| 461 | // Validate output |
| 462 | validate(CLAccessor(_target), _reference, tolerance_f32); |
| 463 | } |
| 464 | |
Gian Marco Iodice | f1c2bf0 | 2018-06-13 14:05:54 +0100 | [diff] [blame] | 465 | FIXTURE_DATA_TEST_CASE(RunLarge, CLWinogradOutputTransformFixture, framework::DatasetMode::NIGHTLY, |
| 466 | combine(LargeWinogradOutputTransformDatasetNCHW, |
| 467 | framework::dataset::make("DataType", { DataType::F32 }))) |
| 468 | { |
| 469 | // Validate output |
| 470 | validate(CLAccessor(_target), _reference, tolerance_f32); |
| 471 | } |
| 472 | TEST_SUITE_END() // NCHW |
| 473 | |
| 474 | TEST_SUITE(NHWC) |
| 475 | DATA_TEST_CASE(Configuration, framework::DatasetMode::ALL, combine(framework::dataset::concat(SmallWinogradOutputTransformDatasetNHWC, |
| 476 | LargeWinogradOutputTransformDatasetNHWC), |
| 477 | framework::dataset::make("DataType", { DataType::F32 })), |
| 478 | shape_a, winograd_info, data_type) |
| 479 | { |
| 480 | TensorShape shape_b = compute_winograd_output_transform_shape(TensorInfo(shape_a, 1, data_type), winograd_info); |
| 481 | |
| 482 | // Create tensors |
| 483 | CLTensor a = create_tensor<CLTensor>(shape_a, data_type); |
Vidhya Sudhan Loganathan | 014333d | 2018-07-02 09:13:49 +0100 | [diff] [blame^] | 484 | CLTensor b = create_tensor<CLTensor>(shape_b, data_type, 1, QuantizationInfo(), winograd_info.output_data_layout); |
Gian Marco Iodice | f1c2bf0 | 2018-06-13 14:05:54 +0100 | [diff] [blame] | 485 | |
| 486 | ARM_COMPUTE_EXPECT(a.info()->is_resizable(), framework::LogLevel::ERRORS); |
| 487 | ARM_COMPUTE_EXPECT(b.info()->is_resizable(), framework::LogLevel::ERRORS); |
| 488 | |
| 489 | // Create and configure function |
| 490 | CLWinogradOutputTransform winograd_output_transform; |
| 491 | winograd_output_transform.configure(&a, nullptr, &b, winograd_info); |
| 492 | } |
| 493 | |
| 494 | FIXTURE_DATA_TEST_CASE(RunSmall, CLWinogradOutputTransformFixture, framework::DatasetMode::ALL, |
| 495 | combine(SmallWinogradOutputTransformDatasetNHWC, |
| 496 | framework::dataset::make("DataType", { DataType::F32 }))) |
Gian Marco Iodice | d2fab73 | 2018-03-02 11:18:12 +0000 | [diff] [blame] | 497 | { |
| 498 | // Validate output |
| 499 | validate(CLAccessor(_target), _reference, tolerance_f32); |
| 500 | } |
| 501 | |
Gian Marco Iodice | f1c2bf0 | 2018-06-13 14:05:54 +0100 | [diff] [blame] | 502 | FIXTURE_DATA_TEST_CASE(RunLarge, CLWinogradOutputTransformFixture, framework::DatasetMode::NIGHTLY, |
| 503 | combine(LargeWinogradOutputTransformDatasetNHWC, |
| 504 | framework::dataset::make("DataType", { DataType::F32 }))) |
| 505 | { |
| 506 | // Validate output |
| 507 | validate(CLAccessor(_target), _reference, tolerance_f32); |
| 508 | } |
| 509 | TEST_SUITE_END() // NHWC |
Gian Marco Iodice | d2fab73 | 2018-03-02 11:18:12 +0000 | [diff] [blame] | 510 | TEST_SUITE_END() // OutputTransform |
| 511 | |
| 512 | TEST_SUITE(ConvolutionLayer) |
Gian Marco Iodice | d2fab73 | 2018-03-02 11:18:12 +0000 | [diff] [blame] | 513 | DATA_TEST_CASE(Validate, framework::DatasetMode::ALL, zip(zip(zip(zip(zip( |
| 514 | framework::dataset::make("InputInfo", { |
| 515 | TensorInfo(TensorShape(17U, 31U, 2U), 1, DataType::F16), // FP16 not supported |
| 516 | TensorInfo(TensorShape(17U, 31U, 2U), 1, DataType::F32), // Datatype mismatch |
| 517 | TensorInfo(TensorShape(23U, 27U, 5U, 4U), 1, DataType::F32), // Stride y not supported |
| 518 | TensorInfo(TensorShape(16U, 16U, 8U), 1, DataType::F32), // Padding needed |
| 519 | TensorInfo(TensorShape(33U, 27U, 7U, 4U), 1, DataType::F32) // Kernel size not supported |
| 520 | }), |
| 521 | framework::dataset::make("WeightsInfo", { |
| 522 | TensorInfo(TensorShape(3U, 3U, 2U, 19U), 1, DataType::F32), |
| 523 | TensorInfo(TensorShape(3U, 3U, 2U, 19U), 1, DataType::QASYMM8), |
| 524 | TensorInfo(TensorShape(3U, 3U, 5U, 21U), 1, DataType::F32), |
| 525 | TensorInfo(TensorShape(3U, 3U, 8U, 16U), 1, DataType::F32), |
| 526 | TensorInfo(TensorShape(5U, 5U, 7U, 16U), 1, DataType::F16) |
| 527 | })), |
| 528 | framework::dataset::make("BiasesInfo", { |
| 529 | TensorInfo(TensorShape(19U), 1, DataType::F32), |
| 530 | TensorInfo(TensorShape(19U), 1, DataType::F32), |
| 531 | TensorInfo(TensorShape(21U), 1, DataType::F32), |
| 532 | TensorInfo(TensorShape(16U), 1, DataType::F32), |
| 533 | TensorInfo(TensorShape(16U), 1, DataType::F32) |
| 534 | })), |
| 535 | framework::dataset::make("OutputInfo", { |
| 536 | TensorInfo(TensorShape(17U, 31U, 19U), 1, DataType::F32), |
| 537 | TensorInfo(TensorShape(15U, 15U, 19U), 1, DataType::F32), |
| 538 | TensorInfo(TensorShape(21U, 25U, 21U, 4U), 1, DataType::F32), |
| 539 | TensorInfo(TensorShape(16U, 16U, 16U), 1, DataType::F32), |
| 540 | TensorInfo(TensorShape(11U, 12U, 16U, 4U), 1, DataType::F32) |
| 541 | })), |
| 542 | framework::dataset::make("ConvInfo", { |
| 543 | PadStrideInfo(1, 1, 1, 1), |
| 544 | PadStrideInfo(1, 1, 1, 1), |
| 545 | PadStrideInfo(1, 2, 0, 0), |
| 546 | PadStrideInfo(1, 1, 1, 1), |
| 547 | PadStrideInfo(1, 1, 1, 0) |
| 548 | })), |
| 549 | framework::dataset::make("Expected", { false, false, false, false, false })), |
| 550 | input_info, weights_info, bias_info, output_info, conv_info, expected) |
| 551 | { |
| 552 | 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); |
| 553 | } |
Gian Marco Iodice | d2fab73 | 2018-03-02 11:18:12 +0000 | [diff] [blame] | 554 | |
Gian Marco Iodice | 2213d4b | 2018-04-27 10:39:06 +0100 | [diff] [blame] | 555 | using CLWinogradConvolutionLayerFastMathFixture = WinogradConvolutionLayerFastMathValidationFixture<CLTensor, CLAccessor, CLWinogradConvolutionLayer, float>; |
Gian Marco Iodice | 6cf188c | 2018-05-04 16:36:50 +0100 | [diff] [blame] | 556 | TEST_SUITE(Conv3x3) |
Gian Marco Iodice | 2213d4b | 2018-04-27 10:39:06 +0100 | [diff] [blame] | 557 | FIXTURE_DATA_TEST_CASE(RunSmall, CLWinogradConvolutionLayerFastMathFixture, framework::DatasetMode::PRECOMMIT, |
Pablo Tello | 7282d56 | 2018-06-14 15:35:49 +0100 | [diff] [blame] | 558 | combine(combine(combine(datasets::SmallWinogradConvolutionLayer3x3Dataset(), |
| 559 | framework::dataset::make("DataType", { DataType::F32 })), |
Gian Marco Iodice | f1c2bf0 | 2018-06-13 14:05:54 +0100 | [diff] [blame] | 560 | framework::dataset::make("ActivationLayerInfo", { ActivationLayerInfo() })), |
| 561 | framework::dataset::make("DataLayout", { DataLayout::NCHW }))) |
Gian Marco Iodice | 2213d4b | 2018-04-27 10:39:06 +0100 | [diff] [blame] | 562 | { |
| 563 | // Validate output |
Gian Marco Iodice | 4497e81 | 2018-05-08 16:36:52 +0100 | [diff] [blame] | 564 | validate(CLAccessor(_target), _reference, tolerance_convolution_layer_f32); |
Gian Marco Iodice | 2213d4b | 2018-04-27 10:39:06 +0100 | [diff] [blame] | 565 | } |
| 566 | |
| 567 | FIXTURE_DATA_TEST_CASE(RunLarge, CLWinogradConvolutionLayerFastMathFixture, framework::DatasetMode::NIGHTLY, |
Pablo Tello | 7282d56 | 2018-06-14 15:35:49 +0100 | [diff] [blame] | 568 | combine(combine(combine(datasets::LargeWinogradConvolutionLayer3x3Dataset(), |
| 569 | framework::dataset::make("DataType", { DataType::F32 })), |
Gian Marco Iodice | f1c2bf0 | 2018-06-13 14:05:54 +0100 | [diff] [blame] | 570 | framework::dataset::make("ActivationLayerInfo", { ActivationLayerInfo() })), |
| 571 | framework::dataset::make("DataLayout", { DataLayout::NCHW }))) |
Gian Marco Iodice | 2213d4b | 2018-04-27 10:39:06 +0100 | [diff] [blame] | 572 | { |
| 573 | // Validate output |
Gian Marco Iodice | 4497e81 | 2018-05-08 16:36:52 +0100 | [diff] [blame] | 574 | validate(CLAccessor(_target), _reference, tolerance_convolution_layer_f32); |
Gian Marco Iodice | 2213d4b | 2018-04-27 10:39:06 +0100 | [diff] [blame] | 575 | } |
Gian Marco Iodice | 6cf188c | 2018-05-04 16:36:50 +0100 | [diff] [blame] | 576 | TEST_SUITE_END() // Conv3x3 |
| 577 | |
Gian Marco Iodice | f1c2bf0 | 2018-06-13 14:05:54 +0100 | [diff] [blame] | 578 | TEST_SUITE(Conv3x1) |
| 579 | FIXTURE_DATA_TEST_CASE(RunSmall, CLWinogradConvolutionLayerFastMathFixture, framework::DatasetMode::PRECOMMIT, |
| 580 | combine(combine(combine(datasets::SmallWinogradConvolutionLayer3x1Dataset(), |
| 581 | framework::dataset::make("DataType", { DataType::F32 })), |
| 582 | framework::dataset::make("ActivationLayerInfo", { ActivationLayerInfo() })), |
| 583 | framework::dataset::make("DataLayout", { DataLayout::NCHW }))) |
| 584 | { |
| 585 | // Validate output |
| 586 | validate(CLAccessor(_target), _reference, tolerance_convolution_layer_f32); |
| 587 | } |
| 588 | |
| 589 | FIXTURE_DATA_TEST_CASE(RunLarge, CLWinogradConvolutionLayerFastMathFixture, framework::DatasetMode::NIGHTLY, |
| 590 | combine(combine(combine(datasets::LargeWinogradConvolutionLayer3x1Dataset(), |
| 591 | framework::dataset::make("DataType", { DataType::F32 })), |
| 592 | framework::dataset::make("ActivationLayerInfo", { ActivationLayerInfo() })), |
| 593 | framework::dataset::make("DataLayout", { DataLayout::NCHW }))) |
| 594 | { |
| 595 | // Validate output |
| 596 | validate(CLAccessor(_target), _reference, tolerance_convolution_layer_f32); |
| 597 | } |
| 598 | TEST_SUITE_END() // Conv3x1 |
| 599 | |
| 600 | TEST_SUITE(Conv1x3) |
| 601 | FIXTURE_DATA_TEST_CASE(RunSmall, CLWinogradConvolutionLayerFastMathFixture, framework::DatasetMode::PRECOMMIT, |
| 602 | combine(combine(combine(datasets::SmallWinogradConvolutionLayer1x3Dataset(), |
| 603 | framework::dataset::make("DataType", { DataType::F32 })), |
| 604 | framework::dataset::make("ActivationLayerInfo", { ActivationLayerInfo() })), |
| 605 | framework::dataset::make("DataLayout", { DataLayout::NCHW }))) |
| 606 | { |
| 607 | // Validate output |
| 608 | validate(CLAccessor(_target), _reference, tolerance_convolution_layer_f32); |
| 609 | } |
| 610 | |
| 611 | FIXTURE_DATA_TEST_CASE(RunLarge, CLWinogradConvolutionLayerFastMathFixture, framework::DatasetMode::NIGHTLY, |
| 612 | combine(combine(combine(datasets::LargeWinogradConvolutionLayer1x3Dataset(), |
| 613 | framework::dataset::make("DataType", { DataType::F32 })), |
| 614 | framework::dataset::make("ActivationLayerInfo", { ActivationLayerInfo() })), |
| 615 | framework::dataset::make("DataLayout", { DataLayout::NCHW }))) |
| 616 | { |
| 617 | // Validate output |
| 618 | validate(CLAccessor(_target), _reference, tolerance_convolution_layer_f32); |
| 619 | } |
| 620 | TEST_SUITE_END() // Conv1x3 |
| 621 | |
Gian Marco Iodice | 6cf188c | 2018-05-04 16:36:50 +0100 | [diff] [blame] | 622 | TEST_SUITE(Conv5x5) |
| 623 | FIXTURE_DATA_TEST_CASE(RunSmall, CLWinogradConvolutionLayerFastMathFixture, framework::DatasetMode::PRECOMMIT, |
Pablo Tello | 7282d56 | 2018-06-14 15:35:49 +0100 | [diff] [blame] | 624 | combine(combine(combine(datasets::SmallWinogradConvolutionLayer5x5Dataset(), |
| 625 | framework::dataset::make("DataType", { DataType::F32 })), |
Gian Marco Iodice | f1c2bf0 | 2018-06-13 14:05:54 +0100 | [diff] [blame] | 626 | framework::dataset::make("ActivationLayerInfo", { ActivationLayerInfo() })), |
| 627 | framework::dataset::make("DataLayout", { DataLayout::NCHW }))) |
Pablo Tello | 7282d56 | 2018-06-14 15:35:49 +0100 | [diff] [blame] | 628 | |
Gian Marco Iodice | 6cf188c | 2018-05-04 16:36:50 +0100 | [diff] [blame] | 629 | { |
| 630 | // Validate output |
Gian Marco Iodice | 4497e81 | 2018-05-08 16:36:52 +0100 | [diff] [blame] | 631 | validate(CLAccessor(_target), _reference, tolerance_convolution_layer_f32); |
Gian Marco Iodice | 6cf188c | 2018-05-04 16:36:50 +0100 | [diff] [blame] | 632 | } |
| 633 | |
| 634 | FIXTURE_DATA_TEST_CASE(RunLarge, CLWinogradConvolutionLayerFastMathFixture, framework::DatasetMode::NIGHTLY, |
Pablo Tello | 7282d56 | 2018-06-14 15:35:49 +0100 | [diff] [blame] | 635 | combine(combine(combine(datasets::LargeWinogradConvolutionLayer5x5Dataset(), |
| 636 | framework::dataset::make("DataType", { DataType::F32 })), |
Gian Marco Iodice | f1c2bf0 | 2018-06-13 14:05:54 +0100 | [diff] [blame] | 637 | framework::dataset::make("ActivationLayerInfo", { ActivationLayerInfo() })), |
| 638 | framework::dataset::make("DataLayout", { DataLayout::NCHW }))) |
Pablo Tello | 7282d56 | 2018-06-14 15:35:49 +0100 | [diff] [blame] | 639 | |
Gian Marco Iodice | 6cf188c | 2018-05-04 16:36:50 +0100 | [diff] [blame] | 640 | { |
| 641 | // Validate output |
Gian Marco Iodice | 4497e81 | 2018-05-08 16:36:52 +0100 | [diff] [blame] | 642 | validate(CLAccessor(_target), _reference, tolerance_convolution_layer_f32); |
Gian Marco Iodice | 6cf188c | 2018-05-04 16:36:50 +0100 | [diff] [blame] | 643 | } |
| 644 | TEST_SUITE_END() // Conv5x5 |
Gian Marco Iodice | 2213d4b | 2018-04-27 10:39:06 +0100 | [diff] [blame] | 645 | |
Gian Marco Iodice | d2fab73 | 2018-03-02 11:18:12 +0000 | [diff] [blame] | 646 | TEST_SUITE_END() // ConvolutionLayer |
Gian Marco Iodice | 7e4b239 | 2018-02-22 16:17:20 +0000 | [diff] [blame] | 647 | TEST_SUITE_END() // Winograd |
| 648 | TEST_SUITE_END() // CL |
Giorgio Arena | 1f9ca1d | 2018-03-01 11:13:45 +0000 | [diff] [blame] | 649 | } // namespace validation |
| 650 | } // namespace test |
| 651 | } // namespace arm_compute |