Pablo Tello | 8951933 | 2017-11-17 11:52:36 +0000 | [diff] [blame] | 1 | /* |
Georgios Pinitas | 9fb1159 | 2018-04-26 20:34:58 +0100 | [diff] [blame] | 2 | * Copyright (c) 2018 ARM Limited. |
Pablo Tello | 8951933 | 2017-11-17 11:52:36 +0000 | [diff] [blame] | 3 | * |
| 4 | * SPDX-License-Identifier: MIT |
| 5 | * |
| 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy |
| 7 | * of this software and associated documentation files (the "Software"), to |
| 8 | * deal in the Software without restriction, including without limitation the |
| 9 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or |
| 10 | * sell copies of the Software, and to permit persons to whom the Software is |
| 11 | * furnished to do so, subject to the following conditions: |
| 12 | * |
| 13 | * The above copyright notice and this permission notice shall be included in all |
| 14 | * copies or substantial portions of the Software. |
| 15 | * |
| 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
| 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
| 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
| 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
| 22 | * SOFTWARE. |
| 23 | */ |
| 24 | #ifndef ARM_COMPUTE_TEST_WINOGRAD_LAYER_FIXTURE |
| 25 | #define ARM_COMPUTE_TEST_WINOGRAD_LAYER_FIXTURE |
| 26 | |
| 27 | #include "arm_compute/core/TensorShape.h" |
| 28 | #include "arm_compute/core/Types.h" |
Giorgio Arena | 1f9ca1d | 2018-03-01 11:13:45 +0000 | [diff] [blame] | 29 | #include "arm_compute/core/utils/misc/ShapeCalculator.h" |
Pablo Tello | 8951933 | 2017-11-17 11:52:36 +0000 | [diff] [blame] | 30 | #include "tests/AssetsLibrary.h" |
| 31 | #include "tests/Globals.h" |
| 32 | #include "tests/IAccessor.h" |
| 33 | #include "tests/framework/Asserts.h" |
| 34 | #include "tests/framework/Fixture.h" |
Pablo Tello | 8951933 | 2017-11-17 11:52:36 +0000 | [diff] [blame] | 35 | #include "tests/validation/Helpers.h" |
Isabella Gottardi | 3f217ec | 2018-02-12 14:59:19 +0000 | [diff] [blame] | 36 | #include "tests/validation/reference/ActivationLayer.h" |
Georgios Pinitas | 5a7e776 | 2017-12-01 16:27:29 +0000 | [diff] [blame] | 37 | #include "tests/validation/reference/ConvolutionLayer.h" |
Gian Marco Iodice | 2213d4b | 2018-04-27 10:39:06 +0100 | [diff] [blame] | 38 | #include "tests/validation/reference/GEMM.h" |
Giorgio Arena | 3695f9a | 2018-04-23 17:41:22 +0100 | [diff] [blame] | 39 | #include "tests/validation/reference/Permute.h" |
Georgios Pinitas | 5a7e776 | 2017-12-01 16:27:29 +0000 | [diff] [blame] | 40 | #include "tests/validation/reference/Utils.h" |
Giorgio Arena | 1f9ca1d | 2018-03-01 11:13:45 +0000 | [diff] [blame] | 41 | #include "tests/validation/reference/Winograd.h" |
Vidhya Sudhan Loganathan | a25d16c | 2018-11-16 11:33:12 +0000 | [diff] [blame] | 42 | #include "utils/Utils.h" |
Pablo Tello | 8951933 | 2017-11-17 11:52:36 +0000 | [diff] [blame] | 43 | |
| 44 | #include <random> |
| 45 | |
| 46 | namespace arm_compute |
| 47 | { |
Pablo Tello | 8951933 | 2017-11-17 11:52:36 +0000 | [diff] [blame] | 48 | namespace test |
| 49 | { |
| 50 | namespace validation |
| 51 | { |
Giorgio Arena | 1f9ca1d | 2018-03-01 11:13:45 +0000 | [diff] [blame] | 52 | using namespace arm_compute::misc::shape_calculator; |
| 53 | |
Andrew Mundy | 4d9379a | 2018-03-15 16:47:03 +0000 | [diff] [blame] | 54 | template <typename TensorType, typename AccessorType, typename FunctionType, typename T, bool use_bias = true> |
Gian Marco Iodice | d2fab73 | 2018-03-02 11:18:12 +0000 | [diff] [blame] | 55 | class WinogradConvolutionLayerValidationFixture : public framework::Fixture |
Pablo Tello | 8951933 | 2017-11-17 11:52:36 +0000 | [diff] [blame] | 56 | { |
| 57 | public: |
| 58 | template <typename...> |
Pablo Tello | 7df2786 | 2018-05-30 11:44:26 +0100 | [diff] [blame] | 59 | void setup(TensorShape input_shape, TensorShape weights_shape, TensorShape bias_shape, TensorShape output_shape, PadStrideInfo info, Size2D dilation, |
| 60 | DataType data_type, ActivationLayerInfo act_info) |
Pablo Tello | 8951933 | 2017-11-17 11:52:36 +0000 | [diff] [blame] | 61 | { |
Alex Gilday | 7da29b6 | 2018-03-23 14:16:00 +0000 | [diff] [blame] | 62 | ARM_COMPUTE_UNUSED(dilation); |
| 63 | |
Isabella Gottardi | 3f217ec | 2018-02-12 14:59:19 +0000 | [diff] [blame] | 64 | _target = compute_target(input_shape, weights_shape, bias_shape, output_shape, info, data_type, act_info); |
| 65 | _reference = compute_reference(input_shape, weights_shape, bias_shape, output_shape, info, data_type, act_info); |
Pablo Tello | 8951933 | 2017-11-17 11:52:36 +0000 | [diff] [blame] | 66 | } |
| 67 | |
| 68 | protected: |
| 69 | template <typename U> |
| 70 | void fill(U &&tensor, int i, float min, float max) |
| 71 | { |
| 72 | switch(tensor.data_type()) |
| 73 | { |
Vidhya Sudhan Loganathan | 71ecf39 | 2018-08-31 16:10:16 +0100 | [diff] [blame] | 74 | case DataType::F16: |
Pablo Tello | 8951933 | 2017-11-17 11:52:36 +0000 | [diff] [blame] | 75 | case DataType::F32: |
| 76 | { |
| 77 | std::uniform_real_distribution<> distribution(min, max); |
| 78 | library->fill(tensor, distribution, i); |
| 79 | break; |
| 80 | } |
| 81 | default: |
| 82 | { |
| 83 | ARM_COMPUTE_ERROR("Not supported"); |
| 84 | library->fill_tensor_uniform(tensor, i); |
| 85 | break; |
| 86 | } |
| 87 | } |
| 88 | } |
| 89 | |
Pablo Tello | 7df2786 | 2018-05-30 11:44:26 +0100 | [diff] [blame] | 90 | TensorType compute_target(TensorShape input_shape, TensorShape weights_shape, TensorShape bias_shape, TensorShape output_shape, const PadStrideInfo &info, |
Isabella Gottardi | 3f217ec | 2018-02-12 14:59:19 +0000 | [diff] [blame] | 91 | DataType data_type, ActivationLayerInfo act_info) |
Pablo Tello | 8951933 | 2017-11-17 11:52:36 +0000 | [diff] [blame] | 92 | { |
| 93 | // Create tensors |
Gian Marco Iodice | d2fab73 | 2018-03-02 11:18:12 +0000 | [diff] [blame] | 94 | TensorType src = create_tensor<TensorType>(input_shape, data_type, 1); |
| 95 | TensorType weights = create_tensor<TensorType>(weights_shape, data_type, 1); |
| 96 | TensorType bias = create_tensor<TensorType>(bias_shape, data_type, 1); |
| 97 | TensorType dst = create_tensor<TensorType>(output_shape, data_type, 1); |
Pablo Tello | 8951933 | 2017-11-17 11:52:36 +0000 | [diff] [blame] | 98 | |
| 99 | // Create and configure function |
| 100 | FunctionType conv; |
Vidhya Sudhan Loganathan | 84ce1f9 | 2018-04-25 13:00:09 +0100 | [diff] [blame] | 101 | ARM_COMPUTE_EXPECT(static_cast<bool>(conv.validate(src.info(), weights.info(), (use_bias) ? bias.info() : nullptr, dst.info(), info, act_info)), framework::LogLevel::ERRORS); |
Andrew Mundy | 4d9379a | 2018-03-15 16:47:03 +0000 | [diff] [blame] | 102 | conv.configure(&src, &weights, (use_bias) ? &bias : nullptr, &dst, info, act_info); |
Pablo Tello | 8951933 | 2017-11-17 11:52:36 +0000 | [diff] [blame] | 103 | |
| 104 | ARM_COMPUTE_EXPECT(src.info()->is_resizable(), framework::LogLevel::ERRORS); |
| 105 | ARM_COMPUTE_EXPECT(weights.info()->is_resizable(), framework::LogLevel::ERRORS); |
| 106 | ARM_COMPUTE_EXPECT(bias.info()->is_resizable(), framework::LogLevel::ERRORS); |
| 107 | ARM_COMPUTE_EXPECT(dst.info()->is_resizable(), framework::LogLevel::ERRORS); |
| 108 | |
| 109 | // Allocate tensors |
| 110 | src.allocator()->allocate(); |
| 111 | weights.allocator()->allocate(); |
Pablo Tello | 8951933 | 2017-11-17 11:52:36 +0000 | [diff] [blame] | 112 | dst.allocator()->allocate(); |
Pablo Tello | d6ca478 | 2018-01-23 09:36:04 +0000 | [diff] [blame] | 113 | bias.allocator()->allocate(); |
Pablo Tello | 8951933 | 2017-11-17 11:52:36 +0000 | [diff] [blame] | 114 | |
| 115 | ARM_COMPUTE_EXPECT(!src.info()->is_resizable(), framework::LogLevel::ERRORS); |
| 116 | ARM_COMPUTE_EXPECT(!weights.info()->is_resizable(), framework::LogLevel::ERRORS); |
| 117 | ARM_COMPUTE_EXPECT(!bias.info()->is_resizable(), framework::LogLevel::ERRORS); |
| 118 | ARM_COMPUTE_EXPECT(!dst.info()->is_resizable(), framework::LogLevel::ERRORS); |
| 119 | |
| 120 | // Fill tensors |
| 121 | fill(AccessorType(src), 0, -1.f, 1.f); |
| 122 | fill(AccessorType(weights), 1, -1.f, 1.f); |
Pablo Tello | d6ca478 | 2018-01-23 09:36:04 +0000 | [diff] [blame] | 123 | fill(AccessorType(bias), 2, -1.f, 1.f); |
Pablo Tello | 8951933 | 2017-11-17 11:52:36 +0000 | [diff] [blame] | 124 | |
Gian Marco Iodice | d2fab73 | 2018-03-02 11:18:12 +0000 | [diff] [blame] | 125 | // Compute Winograd Convolution function |
Pablo Tello | 8951933 | 2017-11-17 11:52:36 +0000 | [diff] [blame] | 126 | conv.run(); |
| 127 | |
| 128 | return dst; |
| 129 | } |
| 130 | |
Gian Marco Iodice | d2fab73 | 2018-03-02 11:18:12 +0000 | [diff] [blame] | 131 | SimpleTensor<T> compute_reference(const TensorShape &input_shape, const TensorShape &weights_shape, const TensorShape &bias_shape, const TensorShape &output_shape, const PadStrideInfo &info, |
Isabella Gottardi | 3f217ec | 2018-02-12 14:59:19 +0000 | [diff] [blame] | 132 | DataType data_type, ActivationLayerInfo act_info) |
Pablo Tello | 8951933 | 2017-11-17 11:52:36 +0000 | [diff] [blame] | 133 | { |
| 134 | // Create reference |
Gian Marco Iodice | d2fab73 | 2018-03-02 11:18:12 +0000 | [diff] [blame] | 135 | SimpleTensor<T> src{ input_shape, data_type, 1 }; |
| 136 | SimpleTensor<T> weights{ weights_shape, data_type, 1 }; |
| 137 | SimpleTensor<T> bias{ bias_shape, data_type, 1 }; |
Pablo Tello | 8951933 | 2017-11-17 11:52:36 +0000 | [diff] [blame] | 138 | |
| 139 | // Fill reference |
| 140 | fill(src, 0, -1.f, 1.f); |
| 141 | fill(weights, 1, -1.f, 1.f); |
Andrew Mundy | 4d9379a | 2018-03-15 16:47:03 +0000 | [diff] [blame] | 142 | if(use_bias) |
| 143 | { |
| 144 | fill(bias, 2, -1.f, 1.f); |
| 145 | } |
| 146 | else |
| 147 | { |
| 148 | fill(bias, 2, 0.f, 0.f); |
| 149 | } |
Pablo Tello | 8951933 | 2017-11-17 11:52:36 +0000 | [diff] [blame] | 150 | |
Gian Marco Iodice | 247f52c | 2018-03-22 11:24:56 +0000 | [diff] [blame] | 151 | SimpleTensor<T> conv_out = reference::convolution_layer<T>(src, weights, bias, output_shape, info); |
| 152 | |
| 153 | return (act_info.enabled()) ? reference::activation_layer<T>(conv_out, act_info) : conv_out; |
Pablo Tello | 8951933 | 2017-11-17 11:52:36 +0000 | [diff] [blame] | 154 | } |
| 155 | |
| 156 | TensorType _target{}; |
| 157 | SimpleTensor<T> _reference{}; |
Pablo Tello | 8951933 | 2017-11-17 11:52:36 +0000 | [diff] [blame] | 158 | }; |
| 159 | |
Vidhya Sudhan Loganathan | a25d16c | 2018-11-16 11:33:12 +0000 | [diff] [blame] | 160 | template <typename TensorType, typename AccessorType, typename FunctionType, typename T, typename T1 = T, bool use_bias = true> |
Gian Marco Iodice | 2213d4b | 2018-04-27 10:39:06 +0100 | [diff] [blame] | 161 | class WinogradConvolutionLayerFastMathValidationFixture : public framework::Fixture |
| 162 | { |
| 163 | public: |
| 164 | template <typename...> |
Pablo Tello | 7282d56 | 2018-06-14 15:35:49 +0100 | [diff] [blame] | 165 | void setup(TensorShape input_shape, TensorShape weights_shape, TensorShape bias_shape, TensorShape output_shape, PadStrideInfo info, Size2D dilation, |
| 166 | DataType data_type, ActivationLayerInfo act_info, const DataLayout &data_layout) |
| 167 | |
Gian Marco Iodice | 2213d4b | 2018-04-27 10:39:06 +0100 | [diff] [blame] | 168 | { |
| 169 | ARM_COMPUTE_UNUSED(dilation); |
Pablo Tello | 7282d56 | 2018-06-14 15:35:49 +0100 | [diff] [blame] | 170 | _target = compute_target(input_shape, weights_shape, bias_shape, output_shape, info, data_type, act_info, data_layout); |
Gian Marco Iodice | 2213d4b | 2018-04-27 10:39:06 +0100 | [diff] [blame] | 171 | _reference = compute_reference(input_shape, weights_shape, bias_shape, output_shape, info, data_type, act_info); |
| 172 | } |
| 173 | |
| 174 | protected: |
| 175 | template <typename U> |
| 176 | void fill(U &&tensor, int i, float min, float max) |
| 177 | { |
| 178 | switch(tensor.data_type()) |
| 179 | { |
Vidhya Sudhan Loganathan | 71ecf39 | 2018-08-31 16:10:16 +0100 | [diff] [blame] | 180 | case DataType::F16: |
Vidhya Sudhan Loganathan | a25d16c | 2018-11-16 11:33:12 +0000 | [diff] [blame] | 181 | { |
| 182 | arm_compute::utils::uniform_real_distribution_fp16 distribution((half)min, (half)max); |
| 183 | library->fill(tensor, distribution, i); |
| 184 | break; |
| 185 | } |
Gian Marco Iodice | 2213d4b | 2018-04-27 10:39:06 +0100 | [diff] [blame] | 186 | case DataType::F32: |
| 187 | { |
| 188 | std::uniform_real_distribution<> distribution(min, max); |
| 189 | library->fill(tensor, distribution, i); |
| 190 | break; |
| 191 | } |
| 192 | default: |
| 193 | { |
| 194 | ARM_COMPUTE_ERROR("Not supported"); |
| 195 | library->fill_tensor_uniform(tensor, i); |
| 196 | break; |
| 197 | } |
| 198 | } |
| 199 | } |
| 200 | |
Pablo Tello | 7282d56 | 2018-06-14 15:35:49 +0100 | [diff] [blame] | 201 | TensorType compute_target(TensorShape input_shape, TensorShape weights_shape, TensorShape bias_shape, TensorShape output_shape, const PadStrideInfo &info, |
| 202 | DataType data_type, ActivationLayerInfo act_info, const DataLayout data_layout) |
Gian Marco Iodice | 2213d4b | 2018-04-27 10:39:06 +0100 | [diff] [blame] | 203 | { |
Pablo Tello | 7282d56 | 2018-06-14 15:35:49 +0100 | [diff] [blame] | 204 | if(data_layout == DataLayout::NHWC) |
| 205 | { |
| 206 | permute(input_shape, PermutationVector(2U, 0U, 1U)); |
| 207 | permute(weights_shape, PermutationVector(2U, 0U, 1U)); |
| 208 | permute(output_shape, PermutationVector(2U, 0U, 1U)); |
| 209 | } |
| 210 | |
Gian Marco Iodice | 2213d4b | 2018-04-27 10:39:06 +0100 | [diff] [blame] | 211 | // Create tensors |
Vidhya Sudhan Loganathan | 014333d | 2018-07-02 09:13:49 +0100 | [diff] [blame] | 212 | TensorType src = create_tensor<TensorType>(input_shape, data_type, 1, QuantizationInfo(), data_layout); |
| 213 | TensorType weights = create_tensor<TensorType>(weights_shape, data_type, 1, QuantizationInfo(), data_layout); |
| 214 | TensorType bias = create_tensor<TensorType>(bias_shape, data_type, 1, QuantizationInfo(), data_layout); |
| 215 | TensorType dst = create_tensor<TensorType>(output_shape, data_type, 1, QuantizationInfo(), data_layout); |
Gian Marco Iodice | 2213d4b | 2018-04-27 10:39:06 +0100 | [diff] [blame] | 216 | |
| 217 | // Create and configure function |
| 218 | FunctionType conv; |
Giorgio Arena | a3221e6 | 2018-05-03 15:57:48 +0100 | [diff] [blame] | 219 | ARM_COMPUTE_EXPECT(static_cast<bool>(conv.validate(src.info(), weights.info(), (use_bias) ? bias.info() : nullptr, dst.info(), info, act_info, true /* Enable fast math */)), |
| 220 | framework::LogLevel::ERRORS); |
| 221 | conv.configure(&src, &weights, (use_bias) ? &bias : nullptr, &dst, info, act_info, true /* Enable fast math */); |
Gian Marco Iodice | 2213d4b | 2018-04-27 10:39:06 +0100 | [diff] [blame] | 222 | |
| 223 | ARM_COMPUTE_EXPECT(src.info()->is_resizable(), framework::LogLevel::ERRORS); |
| 224 | ARM_COMPUTE_EXPECT(weights.info()->is_resizable(), framework::LogLevel::ERRORS); |
| 225 | ARM_COMPUTE_EXPECT(bias.info()->is_resizable(), framework::LogLevel::ERRORS); |
| 226 | ARM_COMPUTE_EXPECT(dst.info()->is_resizable(), framework::LogLevel::ERRORS); |
| 227 | |
| 228 | // Allocate tensors |
| 229 | src.allocator()->allocate(); |
| 230 | weights.allocator()->allocate(); |
| 231 | dst.allocator()->allocate(); |
| 232 | bias.allocator()->allocate(); |
| 233 | |
| 234 | ARM_COMPUTE_EXPECT(!src.info()->is_resizable(), framework::LogLevel::ERRORS); |
| 235 | ARM_COMPUTE_EXPECT(!weights.info()->is_resizable(), framework::LogLevel::ERRORS); |
| 236 | ARM_COMPUTE_EXPECT(!bias.info()->is_resizable(), framework::LogLevel::ERRORS); |
| 237 | ARM_COMPUTE_EXPECT(!dst.info()->is_resizable(), framework::LogLevel::ERRORS); |
| 238 | |
| 239 | // Fill tensors |
| 240 | fill(AccessorType(src), 0, -1.f, 1.f); |
| 241 | fill(AccessorType(weights), 1, -1.f, 1.f); |
| 242 | fill(AccessorType(bias), 2, -1.f, 1.f); |
| 243 | |
| 244 | // Compute Winograd Convolution function |
| 245 | conv.run(); |
| 246 | |
| 247 | return dst; |
| 248 | } |
| 249 | |
| 250 | SimpleTensor<T> compute_reference(const TensorShape &input_shape, const TensorShape &weights_shape, const TensorShape &bias_shape, const TensorShape &output_shape, const PadStrideInfo &info, |
| 251 | DataType data_type, ActivationLayerInfo act_info) |
| 252 | { |
| 253 | // Create reference |
Vidhya Sudhan Loganathan | a25d16c | 2018-11-16 11:33:12 +0000 | [diff] [blame] | 254 | SimpleTensor<T> src_t{ input_shape, data_type, 1 }; |
| 255 | SimpleTensor<T> weights_t{ weights_shape, data_type, 1 }; |
| 256 | SimpleTensor<T> bias_t{ bias_shape, data_type, 1 }; |
Gian Marco Iodice | 2213d4b | 2018-04-27 10:39:06 +0100 | [diff] [blame] | 257 | |
| 258 | // Fill reference |
Vidhya Sudhan Loganathan | a25d16c | 2018-11-16 11:33:12 +0000 | [diff] [blame] | 259 | fill(src_t, 0, -1.f, 1.f); |
| 260 | SimpleTensor<T1> src_t1(copy_tensor<T1, T>(src_t)); |
| 261 | |
| 262 | fill(weights_t, 1, -1.f, 1.f); |
| 263 | SimpleTensor<T1> weights_t1(copy_tensor<T1, T>(weights_t)); |
Giorgio Arena | a3221e6 | 2018-05-03 15:57:48 +0100 | [diff] [blame] | 264 | if(use_bias) |
| 265 | { |
Vidhya Sudhan Loganathan | a25d16c | 2018-11-16 11:33:12 +0000 | [diff] [blame] | 266 | fill(bias_t, 2, -1.f, 1.f); |
Giorgio Arena | a3221e6 | 2018-05-03 15:57:48 +0100 | [diff] [blame] | 267 | } |
| 268 | else |
| 269 | { |
Vidhya Sudhan Loganathan | a25d16c | 2018-11-16 11:33:12 +0000 | [diff] [blame] | 270 | fill(bias_t, 2, 0.f, 0.f); |
Giorgio Arena | a3221e6 | 2018-05-03 15:57:48 +0100 | [diff] [blame] | 271 | } |
Vidhya Sudhan Loganathan | a25d16c | 2018-11-16 11:33:12 +0000 | [diff] [blame] | 272 | SimpleTensor<T1> bias_t1(copy_tensor<T1, T>(bias_t)); |
Gian Marco Iodice | 2213d4b | 2018-04-27 10:39:06 +0100 | [diff] [blame] | 273 | |
Gian Marco Iodice | f1c2bf0 | 2018-06-13 14:05:54 +0100 | [diff] [blame] | 274 | // Set output tile |
| 275 | Size2D output_tile(4U, 4U); |
Pablo Tello | 96e922e | 2018-09-26 11:25:15 +0100 | [diff] [blame] | 276 | if(weights_shape[0] == 7 && weights_shape[1] == 1) |
| 277 | { |
| 278 | output_tile.width = 2; |
| 279 | output_tile.height = 1; |
| 280 | } |
| 281 | else if(weights_shape[0] == 1 && weights_shape[1] == 7) |
| 282 | { |
| 283 | output_tile.width = 1; |
| 284 | output_tile.height = 2; |
| 285 | } |
| 286 | else if(weights_shape[0] == 1) |
Gian Marco Iodice | f1c2bf0 | 2018-06-13 14:05:54 +0100 | [diff] [blame] | 287 | { |
| 288 | output_tile.width = 1; |
| 289 | } |
| 290 | else if(weights_shape[1] == 1) |
| 291 | { |
| 292 | output_tile.height = 1; |
| 293 | } |
| 294 | |
| 295 | WinogradInfo winograd_info(output_tile, |
Gian Marco Iodice | 2213d4b | 2018-04-27 10:39:06 +0100 | [diff] [blame] | 296 | Size2D(weights_shape[0], weights_shape[1]), |
| 297 | Size2D(input_shape[0], input_shape[1]), |
| 298 | info, |
Vidhya Sudhan Loganathan | a25d16c | 2018-11-16 11:33:12 +0000 | [diff] [blame] | 299 | src_t1.data_layout()); |
Gian Marco Iodice | 2213d4b | 2018-04-27 10:39:06 +0100 | [diff] [blame] | 300 | |
| 301 | // Compute tensor shapes for input, filter and output transforms |
| 302 | TensorShape input_transform_shape = compute_winograd_input_transform_shape(TensorInfo(input_shape, 1, data_type), winograd_info); |
| 303 | TensorShape filter_transform_shape = compute_winograd_filter_transform_shape(TensorInfo(weights_shape, 1, data_type), winograd_info); |
| 304 | TensorShape batched_gemm_shape = input_transform_shape; |
| 305 | batched_gemm_shape[0] = filter_transform_shape[0]; |
| 306 | TensorShape output_transform_shape = compute_winograd_output_transform_shape(TensorInfo(batched_gemm_shape, 1, data_type), winograd_info); |
| 307 | |
| 308 | // Dummy matrix C to perform matrix multiplication |
Vidhya Sudhan Loganathan | a25d16c | 2018-11-16 11:33:12 +0000 | [diff] [blame] | 309 | SimpleTensor<T1> dummy_c{ batched_gemm_shape, data_type, 1 }; |
Gian Marco Iodice | 2213d4b | 2018-04-27 10:39:06 +0100 | [diff] [blame] | 310 | |
| 311 | // Compute Winograd-based convolution |
Vidhya Sudhan Loganathan | a25d16c | 2018-11-16 11:33:12 +0000 | [diff] [blame] | 312 | SimpleTensor<T1> input_transform_out = reference::winograd_input_transform<T1>(src_t1, input_transform_shape, winograd_info); |
Gian Marco Iodice | 2213d4b | 2018-04-27 10:39:06 +0100 | [diff] [blame] | 313 | |
Vidhya Sudhan Loganathan | a25d16c | 2018-11-16 11:33:12 +0000 | [diff] [blame] | 314 | SimpleTensor<T1> filter_transform_out = reference::winograd_filter_transform<T1>(weights_t1, filter_transform_shape, winograd_info); |
| 315 | SimpleTensor<T1> batched_gemm = reference::gemm<T1>(input_transform_out, filter_transform_out, dummy_c, 1.0f, 0.0f); |
| 316 | SimpleTensor<T1> conv_out = reference::winograd_output_transform<T1>(batched_gemm, bias_t1, output_transform_shape, winograd_info); |
| 317 | SimpleTensor<T> conv_out_t(std::move(copy_tensor<T, T1>(conv_out))); |
| 318 | return (act_info.enabled()) ? reference::activation_layer<T>(conv_out_t, act_info) : conv_out_t; |
Gian Marco Iodice | 2213d4b | 2018-04-27 10:39:06 +0100 | [diff] [blame] | 319 | } |
| 320 | |
| 321 | TensorType _target{}; |
| 322 | SimpleTensor<T> _reference{}; |
| 323 | }; |
| 324 | |
| 325 | template <typename TensorType, typename AccessorType, typename FunctionType, typename T> |
Giorgio Arena | 1f9ca1d | 2018-03-01 11:13:45 +0000 | [diff] [blame] | 326 | class WinogradInputTransformValidationFixture : public framework::Fixture |
| 327 | { |
| 328 | public: |
| 329 | template <typename...> |
Gian Marco Iodice | 247f52c | 2018-03-22 11:24:56 +0000 | [diff] [blame] | 330 | void setup(TensorShape input_shape, WinogradInfo winograd_info, DataLayout data_layout, DataType data_type) |
Giorgio Arena | 1f9ca1d | 2018-03-01 11:13:45 +0000 | [diff] [blame] | 331 | { |
Gian Marco Iodice | 247f52c | 2018-03-22 11:24:56 +0000 | [diff] [blame] | 332 | TensorShape output_shape = compute_winograd_input_transform_shape(TensorInfo(input_shape, 1, data_type), winograd_info); |
Giorgio Arena | 1f9ca1d | 2018-03-01 11:13:45 +0000 | [diff] [blame] | 333 | |
Gian Marco Iodice | 247f52c | 2018-03-22 11:24:56 +0000 | [diff] [blame] | 334 | _target = compute_target(input_shape, output_shape, winograd_info, data_layout, data_type); |
| 335 | _reference = compute_reference(input_shape, output_shape, winograd_info, data_layout, data_type); |
Giorgio Arena | 1f9ca1d | 2018-03-01 11:13:45 +0000 | [diff] [blame] | 336 | } |
| 337 | |
| 338 | protected: |
| 339 | template <typename U> |
| 340 | void fill(U &&tensor, int i, float min, float max) |
| 341 | { |
| 342 | switch(tensor.data_type()) |
| 343 | { |
Vidhya Sudhan Loganathan | 71ecf39 | 2018-08-31 16:10:16 +0100 | [diff] [blame] | 344 | case DataType::F16: |
Giorgio Arena | 1f9ca1d | 2018-03-01 11:13:45 +0000 | [diff] [blame] | 345 | case DataType::F32: |
| 346 | { |
| 347 | std::uniform_real_distribution<> distribution(min, max); |
| 348 | library->fill(tensor, distribution, i); |
| 349 | break; |
| 350 | } |
| 351 | default: |
| 352 | { |
| 353 | ARM_COMPUTE_ERROR("Not supported"); |
| 354 | library->fill_tensor_uniform(tensor, i); |
| 355 | break; |
| 356 | } |
| 357 | } |
| 358 | } |
| 359 | |
Giorgio Arena | c42f28d | 2018-04-26 11:33:05 +0100 | [diff] [blame] | 360 | TensorType compute_target(TensorShape input_shape, const TensorShape &output_shape, const WinogradInfo &winograd_info, DataLayout data_layout, DataType data_type) |
Giorgio Arena | 1f9ca1d | 2018-03-01 11:13:45 +0000 | [diff] [blame] | 361 | { |
Giorgio Arena | c42f28d | 2018-04-26 11:33:05 +0100 | [diff] [blame] | 362 | if(data_layout == DataLayout::NHWC) |
| 363 | { |
| 364 | permute(input_shape, PermutationVector(2U, 0U, 1U)); |
| 365 | } |
| 366 | |
Vidhya Sudhan Loganathan | 014333d | 2018-07-02 09:13:49 +0100 | [diff] [blame] | 367 | TensorType src = create_tensor<TensorType>(input_shape, data_type, 1, QuantizationInfo(), data_layout); |
| 368 | TensorType dst = create_tensor<TensorType>(output_shape, data_type, 1, QuantizationInfo()); |
Giorgio Arena | 1f9ca1d | 2018-03-01 11:13:45 +0000 | [diff] [blame] | 369 | |
| 370 | // Create and configure function |
| 371 | FunctionType transf; |
Gian Marco Iodice | 247f52c | 2018-03-22 11:24:56 +0000 | [diff] [blame] | 372 | transf.configure(&src, &dst, winograd_info); |
Giorgio Arena | 1f9ca1d | 2018-03-01 11:13:45 +0000 | [diff] [blame] | 373 | |
| 374 | ARM_COMPUTE_EXPECT(src.info()->is_resizable(), framework::LogLevel::ERRORS); |
| 375 | ARM_COMPUTE_EXPECT(dst.info()->is_resizable(), framework::LogLevel::ERRORS); |
| 376 | |
| 377 | // Allocate tensors |
| 378 | src.allocator()->allocate(); |
| 379 | dst.allocator()->allocate(); |
| 380 | |
| 381 | ARM_COMPUTE_EXPECT(!src.info()->is_resizable(), framework::LogLevel::ERRORS); |
| 382 | ARM_COMPUTE_EXPECT(!dst.info()->is_resizable(), framework::LogLevel::ERRORS); |
| 383 | |
| 384 | // Fill tensors |
| 385 | fill(AccessorType(src), 0, -1.f, 1.f); |
| 386 | |
Gian Marco Iodice | 247f52c | 2018-03-22 11:24:56 +0000 | [diff] [blame] | 387 | // Compute Winograd input transform function |
Giorgio Arena | 1f9ca1d | 2018-03-01 11:13:45 +0000 | [diff] [blame] | 388 | transf.run(); |
| 389 | |
| 390 | return dst; |
| 391 | } |
| 392 | |
Gian Marco Iodice | 247f52c | 2018-03-22 11:24:56 +0000 | [diff] [blame] | 393 | SimpleTensor<T> compute_reference(const TensorShape &input_shape, const TensorShape &output_shape, const WinogradInfo &winograd_info, DataLayout data_layout, DataType data_type) |
Giorgio Arena | 1f9ca1d | 2018-03-01 11:13:45 +0000 | [diff] [blame] | 394 | { |
Giorgio Arena | 1f9ca1d | 2018-03-01 11:13:45 +0000 | [diff] [blame] | 395 | // Create reference |
Vidhya Sudhan Loganathan | 014333d | 2018-07-02 09:13:49 +0100 | [diff] [blame] | 396 | SimpleTensor<T> src{ input_shape, data_type, 1, QuantizationInfo() }; |
Giorgio Arena | 1f9ca1d | 2018-03-01 11:13:45 +0000 | [diff] [blame] | 397 | |
| 398 | // Fill reference |
| 399 | fill(src, 0, -1.f, 1.f); |
| 400 | |
Gian Marco Iodice | 247f52c | 2018-03-22 11:24:56 +0000 | [diff] [blame] | 401 | return reference::winograd_input_transform<T>(src, output_shape, winograd_info); |
Giorgio Arena | 1f9ca1d | 2018-03-01 11:13:45 +0000 | [diff] [blame] | 402 | } |
| 403 | |
| 404 | TensorType _target{}; |
| 405 | SimpleTensor<T> _reference{}; |
| 406 | }; |
Gian Marco Iodice | 7e4b239 | 2018-02-22 16:17:20 +0000 | [diff] [blame] | 407 | |
| 408 | template <typename TensorType, typename AccessorType, typename FunctionType, typename T> |
| 409 | class WinogradFilterTransformValidationFixture : public framework::Fixture |
| 410 | { |
| 411 | public: |
| 412 | template <typename...> |
Gian Marco Iodice | 247f52c | 2018-03-22 11:24:56 +0000 | [diff] [blame] | 413 | void setup(TensorShape input_shape, Size2D output_tile, DataLayout data_layout, DataType data_type) |
Gian Marco Iodice | 7e4b239 | 2018-02-22 16:17:20 +0000 | [diff] [blame] | 414 | { |
Gian Marco Iodice | 247f52c | 2018-03-22 11:24:56 +0000 | [diff] [blame] | 415 | WinogradInfo winograd_info(output_tile, Size2D(input_shape[0], input_shape[1]), Size2D() /* Not needed */, PadStrideInfo() /* Not needed */, DataLayout::NCHW /* Not needed */); |
| 416 | TensorShape output_shape = compute_winograd_filter_transform_shape(TensorInfo(input_shape, 1, data_type), winograd_info); |
Gian Marco Iodice | 7e4b239 | 2018-02-22 16:17:20 +0000 | [diff] [blame] | 417 | |
Gian Marco Iodice | 247f52c | 2018-03-22 11:24:56 +0000 | [diff] [blame] | 418 | _target = compute_target(input_shape, output_shape, winograd_info, data_layout, data_type); |
| 419 | _reference = compute_reference(input_shape, output_shape, winograd_info, data_layout, data_type); |
Gian Marco Iodice | 7e4b239 | 2018-02-22 16:17:20 +0000 | [diff] [blame] | 420 | } |
| 421 | |
| 422 | protected: |
| 423 | template <typename U> |
| 424 | void fill(U &&tensor, int i, float min, float max) |
| 425 | { |
| 426 | switch(tensor.data_type()) |
| 427 | { |
Vidhya Sudhan Loganathan | 71ecf39 | 2018-08-31 16:10:16 +0100 | [diff] [blame] | 428 | case DataType::F16: |
Gian Marco Iodice | 7e4b239 | 2018-02-22 16:17:20 +0000 | [diff] [blame] | 429 | case DataType::F32: |
| 430 | { |
| 431 | std::uniform_real_distribution<> distribution(min, max); |
| 432 | library->fill(tensor, distribution, i); |
| 433 | break; |
| 434 | } |
| 435 | default: |
| 436 | { |
| 437 | ARM_COMPUTE_ERROR("Not supported"); |
| 438 | library->fill_tensor_uniform(tensor, i); |
| 439 | break; |
| 440 | } |
| 441 | } |
| 442 | } |
| 443 | |
Giorgio Arena | dcb5b28 | 2018-04-25 12:07:29 +0100 | [diff] [blame] | 444 | TensorType compute_target(TensorShape input_shape, const TensorShape &output_shape, const WinogradInfo &winograd_info, DataLayout data_layout, DataType data_type) |
Gian Marco Iodice | 7e4b239 | 2018-02-22 16:17:20 +0000 | [diff] [blame] | 445 | { |
Giorgio Arena | dcb5b28 | 2018-04-25 12:07:29 +0100 | [diff] [blame] | 446 | if(data_layout == DataLayout::NHWC) |
| 447 | { |
| 448 | permute(input_shape, PermutationVector(2U, 0U, 1U)); |
| 449 | } |
| 450 | |
Gian Marco Iodice | 7e4b239 | 2018-02-22 16:17:20 +0000 | [diff] [blame] | 451 | // Create tensors |
Vidhya Sudhan Loganathan | 014333d | 2018-07-02 09:13:49 +0100 | [diff] [blame] | 452 | TensorType src = create_tensor<TensorType>(input_shape, data_type, 1, QuantizationInfo(), data_layout); |
| 453 | TensorType dst = create_tensor<TensorType>(output_shape, data_type, 1, QuantizationInfo()); |
Gian Marco Iodice | 7e4b239 | 2018-02-22 16:17:20 +0000 | [diff] [blame] | 454 | |
| 455 | // Create and configure function |
| 456 | FunctionType filter_transform; |
Gian Marco Iodice | 247f52c | 2018-03-22 11:24:56 +0000 | [diff] [blame] | 457 | filter_transform.configure(&src, &dst, winograd_info); |
Gian Marco Iodice | 7e4b239 | 2018-02-22 16:17:20 +0000 | [diff] [blame] | 458 | |
| 459 | ARM_COMPUTE_EXPECT(src.info()->is_resizable(), framework::LogLevel::ERRORS); |
| 460 | ARM_COMPUTE_EXPECT(dst.info()->is_resizable(), framework::LogLevel::ERRORS); |
| 461 | |
| 462 | // Allocate tensors |
| 463 | src.allocator()->allocate(); |
| 464 | dst.allocator()->allocate(); |
| 465 | |
| 466 | ARM_COMPUTE_EXPECT(!src.info()->is_resizable(), framework::LogLevel::ERRORS); |
| 467 | ARM_COMPUTE_EXPECT(!dst.info()->is_resizable(), framework::LogLevel::ERRORS); |
| 468 | |
| 469 | // Fill tensors |
| 470 | fill(AccessorType(src), 0, -1.f, 1.f); |
| 471 | |
| 472 | filter_transform.run(); |
| 473 | |
| 474 | return dst; |
| 475 | } |
| 476 | |
Gian Marco Iodice | 247f52c | 2018-03-22 11:24:56 +0000 | [diff] [blame] | 477 | SimpleTensor<T> compute_reference(const TensorShape &input_shape, const TensorShape &output_shape, const WinogradInfo &winograd_info, DataLayout data_layout, DataType data_type) |
Gian Marco Iodice | 7e4b239 | 2018-02-22 16:17:20 +0000 | [diff] [blame] | 478 | { |
Gian Marco Iodice | 7e4b239 | 2018-02-22 16:17:20 +0000 | [diff] [blame] | 479 | // Create reference |
Vidhya Sudhan Loganathan | 014333d | 2018-07-02 09:13:49 +0100 | [diff] [blame] | 480 | SimpleTensor<T> src{ input_shape, data_type, 1, QuantizationInfo() }; |
Gian Marco Iodice | 7e4b239 | 2018-02-22 16:17:20 +0000 | [diff] [blame] | 481 | |
| 482 | // Fill reference |
| 483 | fill(src, 0, -1.f, 1.f); |
| 484 | |
Gian Marco Iodice | 247f52c | 2018-03-22 11:24:56 +0000 | [diff] [blame] | 485 | return reference::winograd_filter_transform<T>(src, output_shape, winograd_info); |
Gian Marco Iodice | 7e4b239 | 2018-02-22 16:17:20 +0000 | [diff] [blame] | 486 | } |
| 487 | |
| 488 | TensorType _target{}; |
| 489 | SimpleTensor<T> _reference{}; |
| 490 | }; |
Gian Marco Iodice | d2fab73 | 2018-03-02 11:18:12 +0000 | [diff] [blame] | 491 | |
| 492 | template <typename TensorType, typename AccessorType, typename FunctionType, typename T> |
| 493 | class WinogradOutputTransformValidationFixture : public framework::Fixture |
| 494 | { |
| 495 | public: |
| 496 | template <typename...> |
Manuel Bottini | 0d0028c | 2018-10-02 16:41:52 +0100 | [diff] [blame] | 497 | void setup(TensorShape input_shape, WinogradInfo winograd_info, DataType data_type, ActivationLayerInfo act_info = ActivationLayerInfo()) |
Gian Marco Iodice | d2fab73 | 2018-03-02 11:18:12 +0000 | [diff] [blame] | 498 | { |
Manuel Bottini | 0d0028c | 2018-10-02 16:41:52 +0100 | [diff] [blame] | 499 | _target = compute_target(input_shape, winograd_info, data_type, act_info); |
| 500 | _reference = compute_reference(input_shape, winograd_info, data_type, act_info); |
Gian Marco Iodice | d2fab73 | 2018-03-02 11:18:12 +0000 | [diff] [blame] | 501 | } |
| 502 | |
| 503 | protected: |
| 504 | template <typename U> |
| 505 | void fill(U &&tensor, int i, float min, float max) |
| 506 | { |
| 507 | switch(tensor.data_type()) |
| 508 | { |
Vidhya Sudhan Loganathan | 71ecf39 | 2018-08-31 16:10:16 +0100 | [diff] [blame] | 509 | case DataType::F16: |
Gian Marco Iodice | d2fab73 | 2018-03-02 11:18:12 +0000 | [diff] [blame] | 510 | case DataType::F32: |
| 511 | { |
| 512 | std::uniform_real_distribution<> distribution(min, max); |
| 513 | library->fill(tensor, distribution, i); |
| 514 | break; |
| 515 | } |
| 516 | default: |
| 517 | { |
| 518 | ARM_COMPUTE_ERROR("Not supported"); |
| 519 | library->fill_tensor_uniform(tensor, i); |
| 520 | break; |
| 521 | } |
| 522 | } |
| 523 | } |
| 524 | |
Manuel Bottini | 0d0028c | 2018-10-02 16:41:52 +0100 | [diff] [blame] | 525 | TensorType compute_target(const TensorShape &input_shape, const WinogradInfo &winograd_info, DataType data_type, ActivationLayerInfo act_info) |
Gian Marco Iodice | d2fab73 | 2018-03-02 11:18:12 +0000 | [diff] [blame] | 526 | { |
Giorgio Arena | 3695f9a | 2018-04-23 17:41:22 +0100 | [diff] [blame] | 527 | TensorShape output_shape = compute_winograd_output_transform_shape(TensorInfo(input_shape, 1, data_type), winograd_info); |
| 528 | |
Gian Marco Iodice | d2fab73 | 2018-03-02 11:18:12 +0000 | [diff] [blame] | 529 | // Create tensors |
Giorgio Arena | ea55f91 | 2018-07-12 15:41:35 +0100 | [diff] [blame] | 530 | TensorType src = create_tensor<TensorType>(input_shape, data_type); |
| 531 | TensorType bias = create_tensor<TensorType>(output_shape[get_data_layout_dimension_index(winograd_info.output_data_layout, DataLayoutDimension::CHANNEL)], data_type); |
| 532 | TensorType dst = create_tensor<TensorType>(output_shape, data_type, 1, QuantizationInfo(), winograd_info.output_data_layout); |
Gian Marco Iodice | d2fab73 | 2018-03-02 11:18:12 +0000 | [diff] [blame] | 533 | |
| 534 | // Create and configure function |
| 535 | FunctionType output_transform; |
Manuel Bottini | 0d0028c | 2018-10-02 16:41:52 +0100 | [diff] [blame] | 536 | output_transform.configure(&src, &bias, &dst, winograd_info, act_info); |
Gian Marco Iodice | d2fab73 | 2018-03-02 11:18:12 +0000 | [diff] [blame] | 537 | |
| 538 | ARM_COMPUTE_EXPECT(src.info()->is_resizable(), framework::LogLevel::ERRORS); |
Giorgio Arena | ea55f91 | 2018-07-12 15:41:35 +0100 | [diff] [blame] | 539 | ARM_COMPUTE_EXPECT(bias.info()->is_resizable(), framework::LogLevel::ERRORS); |
Gian Marco Iodice | d2fab73 | 2018-03-02 11:18:12 +0000 | [diff] [blame] | 540 | ARM_COMPUTE_EXPECT(dst.info()->is_resizable(), framework::LogLevel::ERRORS); |
| 541 | |
| 542 | // Allocate tensors |
| 543 | src.allocator()->allocate(); |
Giorgio Arena | ea55f91 | 2018-07-12 15:41:35 +0100 | [diff] [blame] | 544 | bias.allocator()->allocate(); |
Gian Marco Iodice | d2fab73 | 2018-03-02 11:18:12 +0000 | [diff] [blame] | 545 | dst.allocator()->allocate(); |
| 546 | |
| 547 | ARM_COMPUTE_EXPECT(!src.info()->is_resizable(), framework::LogLevel::ERRORS); |
Giorgio Arena | ea55f91 | 2018-07-12 15:41:35 +0100 | [diff] [blame] | 548 | ARM_COMPUTE_EXPECT(!bias.info()->is_resizable(), framework::LogLevel::ERRORS); |
Gian Marco Iodice | d2fab73 | 2018-03-02 11:18:12 +0000 | [diff] [blame] | 549 | ARM_COMPUTE_EXPECT(!dst.info()->is_resizable(), framework::LogLevel::ERRORS); |
| 550 | |
| 551 | // Fill tensors |
| 552 | fill(AccessorType(src), 0, -1.f, 1.f); |
Giorgio Arena | ea55f91 | 2018-07-12 15:41:35 +0100 | [diff] [blame] | 553 | fill(AccessorType(bias), 1, -1.f, 1.f); |
Gian Marco Iodice | d2fab73 | 2018-03-02 11:18:12 +0000 | [diff] [blame] | 554 | |
| 555 | output_transform.run(); |
| 556 | |
| 557 | return dst; |
| 558 | } |
| 559 | |
Manuel Bottini | 0d0028c | 2018-10-02 16:41:52 +0100 | [diff] [blame] | 560 | SimpleTensor<T> compute_reference(const TensorShape &input_shape, WinogradInfo winograd_info, DataType data_type, ActivationLayerInfo act_info) |
Gian Marco Iodice | d2fab73 | 2018-03-02 11:18:12 +0000 | [diff] [blame] | 561 | { |
Giorgio Arena | 3695f9a | 2018-04-23 17:41:22 +0100 | [diff] [blame] | 562 | winograd_info.output_data_layout = DataLayout::NCHW; |
| 563 | TensorShape output_shape = compute_winograd_output_transform_shape(TensorInfo(input_shape, 1, data_type), winograd_info); |
| 564 | |
Gian Marco Iodice | d2fab73 | 2018-03-02 11:18:12 +0000 | [diff] [blame] | 565 | // Create reference |
Gian Marco Iodice | 247f52c | 2018-03-22 11:24:56 +0000 | [diff] [blame] | 566 | SimpleTensor<T> src{ input_shape, data_type }; |
Gian Marco Iodice | 2213d4b | 2018-04-27 10:39:06 +0100 | [diff] [blame] | 567 | SimpleTensor<T> bias{ TensorShape(input_shape[0]), data_type }; |
Gian Marco Iodice | d2fab73 | 2018-03-02 11:18:12 +0000 | [diff] [blame] | 568 | |
| 569 | // Fill reference |
| 570 | fill(src, 0, -1.f, 1.f); |
Giorgio Arena | ea55f91 | 2018-07-12 15:41:35 +0100 | [diff] [blame] | 571 | fill(bias, 1, -1.f, 1.f); |
Gian Marco Iodice | d2fab73 | 2018-03-02 11:18:12 +0000 | [diff] [blame] | 572 | |
Manuel Bottini | 0d0028c | 2018-10-02 16:41:52 +0100 | [diff] [blame] | 573 | const SimpleTensor<T> winograd_output = reference::winograd_output_transform<T>(src, bias, output_shape, winograd_info); |
| 574 | |
| 575 | return (act_info.enabled()) ? reference::activation_layer<T>(winograd_output, act_info) : winograd_output; |
Gian Marco Iodice | d2fab73 | 2018-03-02 11:18:12 +0000 | [diff] [blame] | 576 | } |
| 577 | |
| 578 | TensorType _target{}; |
| 579 | SimpleTensor<T> _reference{}; |
| 580 | }; |
Pablo Tello | 8951933 | 2017-11-17 11:52:36 +0000 | [diff] [blame] | 581 | } // namespace validation |
| 582 | } // namespace test |
| 583 | } // namespace arm_compute |
| 584 | #endif /* ARM_COMPUTE_TEST_WINOGRAD_LAYER_FIXTURE */ |