Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2017 ARM Limited. |
| 3 | * |
| 4 | * SPDX-License-Identifier: MIT |
| 5 | * |
| 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy |
| 7 | * of this software and associated documentation files (the "Software"), to |
| 8 | * deal in the Software without restriction, including without limitation the |
| 9 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or |
| 10 | * sell copies of the Software, and to permit persons to whom the Software is |
| 11 | * furnished to do so, subject to the following conditions: |
| 12 | * |
| 13 | * The above copyright notice and this permission notice shall be included in all |
| 14 | * copies or substantial portions of the Software. |
| 15 | * |
| 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
| 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
| 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
| 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
| 22 | * SOFTWARE. |
| 23 | */ |
| 24 | #include "arm_compute/core/NEON/kernels/NEIm2ColKernel.h" |
| 25 | |
| 26 | #include "arm_compute/core/Error.h" |
| 27 | #include "arm_compute/core/FixedPoint.h" |
| 28 | #include "arm_compute/core/Helpers.h" |
| 29 | #include "arm_compute/core/ITensor.h" |
Gian Marco Iodice | 13edbff | 2017-06-26 17:20:16 +0100 | [diff] [blame] | 30 | #include "arm_compute/core/Size2D.h" |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 31 | #include "arm_compute/core/TensorInfo.h" |
| 32 | #include "arm_compute/core/Types.h" |
| 33 | #include "arm_compute/core/Validate.h" |
| 34 | |
| 35 | #include <arm_neon.h> |
| 36 | #include <cstddef> |
| 37 | #include <cstdint> |
| 38 | #include <cstring> |
| 39 | #include <tuple> |
| 40 | |
| 41 | using namespace arm_compute; |
| 42 | |
| 43 | namespace |
| 44 | { |
| 45 | template <typename T, bool has_pads> |
| 46 | inline void linearize_volume(const uint8_t *const in_ptr, |
| 47 | T *out_ptr, |
| 48 | bool has_bias, |
| 49 | int top_left_x, |
| 50 | int top_left_y, |
Gian Marco Iodice | 13edbff | 2017-06-26 17:20:16 +0100 | [diff] [blame] | 51 | int kernel_width, |
| 52 | int kernel_height, |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 53 | int kernel_depth, |
| 54 | int input_w, |
| 55 | int input_h, |
| 56 | int input_stride_x, |
| 57 | int input_stride_y, |
| 58 | int input_stride_z, |
| 59 | int fixed_point_position) |
| 60 | { |
Gian Marco Iodice | 13edbff | 2017-06-26 17:20:16 +0100 | [diff] [blame] | 61 | const int kernel_size2 = kernel_width * kernel_height; |
| 62 | const int x_e = top_left_x + kernel_width; |
| 63 | const int y_e = top_left_y + kernel_height; |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 64 | |
| 65 | // Linearize volume |
| 66 | int d = 0; |
| 67 | // This for loop linearize a volume with 3 slices. This allows: |
| 68 | // 1) to reduce the iterations of the outer for loop "d" |
| 69 | // 2) to have an optimized im2col for the first convolution layer where usually we have 3 IFMs |
| 70 | for(; d <= (kernel_depth - 3); d += 3) |
| 71 | { |
| 72 | for(int y = top_left_y; y < y_e; ++y) |
| 73 | { |
| 74 | if((y < 0 || y >= input_h) && has_pads) |
| 75 | { |
| 76 | // All the values will be zeros |
| 77 | for(int x = top_left_x; x < x_e; ++x, ++out_ptr) |
| 78 | { |
| 79 | *(out_ptr + 0 * kernel_size2) = 0; |
| 80 | *(out_ptr + 1 * kernel_size2) = 0; |
| 81 | *(out_ptr + 2 * kernel_size2) = 0; |
| 82 | } |
| 83 | } |
| 84 | else |
| 85 | { |
| 86 | for(int x = top_left_x; x < x_e; ++x, ++out_ptr) |
| 87 | { |
| 88 | if((x < 0 || x >= input_w) && has_pads) |
| 89 | { |
| 90 | *(out_ptr + 0 * kernel_size2) = 0; |
| 91 | *(out_ptr + 1 * kernel_size2) = 0; |
| 92 | *(out_ptr + 2 * kernel_size2) = 0; |
| 93 | } |
| 94 | else |
| 95 | { |
| 96 | *(out_ptr + 0 * kernel_size2) = *(reinterpret_cast<const T *>(in_ptr + ((d + 0) * input_stride_z + y * input_stride_y + x * input_stride_x))); |
| 97 | *(out_ptr + 1 * kernel_size2) = *(reinterpret_cast<const T *>(in_ptr + ((d + 1) * input_stride_z + y * input_stride_y + x * input_stride_x))); |
| 98 | *(out_ptr + 2 * kernel_size2) = *(reinterpret_cast<const T *>(in_ptr + ((d + 2) * input_stride_z + y * input_stride_y + x * input_stride_x))); |
| 99 | } |
| 100 | } |
| 101 | } |
| 102 | } |
| 103 | out_ptr += 2 * kernel_size2; |
| 104 | } |
| 105 | |
| 106 | // Left over |
| 107 | for(; d < kernel_depth; d++) |
| 108 | { |
| 109 | for(int y = top_left_y; y < y_e; ++y) |
| 110 | { |
| 111 | if((y < 0 || y >= input_h) && has_pads) |
| 112 | { |
| 113 | // All the values will be zeros |
Gian Marco Iodice | 13edbff | 2017-06-26 17:20:16 +0100 | [diff] [blame] | 114 | memset(out_ptr, 0, kernel_width * sizeof(T)); |
| 115 | out_ptr += kernel_width; |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 116 | } |
| 117 | else |
| 118 | { |
| 119 | for(int x = top_left_x; x < x_e; ++x, ++out_ptr) |
| 120 | { |
| 121 | if((x < 0 || x >= input_w) && has_pads) |
| 122 | { |
| 123 | *out_ptr = 0; |
| 124 | } |
| 125 | else |
| 126 | { |
| 127 | *out_ptr = *(reinterpret_cast<const T *>(in_ptr + (d * input_stride_z + y * input_stride_y + x * input_stride_x))); |
| 128 | } |
| 129 | } |
| 130 | } |
| 131 | } |
| 132 | } |
| 133 | |
| 134 | // Append 1 if the convolution layer has biases |
| 135 | if(has_bias) |
| 136 | { |
Gian Marco Iodice | 2bbd964 | 2017-07-04 16:46:32 +0100 | [diff] [blame] | 137 | if(std::is_same<T, qint8_t>::value) |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 138 | { |
Georgios Pinitas | 21efeb4 | 2017-07-04 12:47:17 +0100 | [diff] [blame] | 139 | *out_ptr = sqcvt_qs8_f32(1.0f, fixed_point_position); |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 140 | } |
Gian Marco Iodice | 2bbd964 | 2017-07-04 16:46:32 +0100 | [diff] [blame] | 141 | else if(std::is_same<T, qint16_t>::value) |
| 142 | { |
Georgios Pinitas | 21efeb4 | 2017-07-04 12:47:17 +0100 | [diff] [blame] | 143 | *out_ptr = sqcvt_qs16_f32(1.0f, fixed_point_position); |
Gian Marco Iodice | 2bbd964 | 2017-07-04 16:46:32 +0100 | [diff] [blame] | 144 | } |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 145 | else |
| 146 | { |
| 147 | *out_ptr = static_cast<T>(1); |
| 148 | } |
| 149 | } |
| 150 | } |
| 151 | } // namespace |
| 152 | |
| 153 | template <typename T, bool has_pads> |
| 154 | void NEIm2ColKernel::run_generic(const Window &window) |
| 155 | { |
| 156 | ARM_COMPUTE_ERROR_ON_UNCONFIGURED_KERNEL(this); |
| 157 | ARM_COMPUTE_ERROR_ON_INVALID_SUBWINDOW(INEKernel::window(), window); |
| 158 | |
| 159 | const int kernel_depth = _input->info()->dimension(2); |
| 160 | const int input_w = _input->info()->dimension(0); |
| 161 | const int input_h = _input->info()->dimension(1); |
| 162 | const int input_stride_x = _input->info()->strides_in_bytes().x(); |
| 163 | const int input_stride_y = _input->info()->strides_in_bytes().y(); |
| 164 | const int input_stride_z = _input->info()->strides_in_bytes().z(); |
| 165 | |
Jaroslaw Rzepecki | a1ed41f | 2017-10-13 11:13:58 +0100 | [diff] [blame] | 166 | int pad_left = 0; |
| 167 | int pad_top = 0; |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 168 | int stride_x = 0; |
| 169 | int stride_y = 0; |
Jaroslaw Rzepecki | a1ed41f | 2017-10-13 11:13:58 +0100 | [diff] [blame] | 170 | pad_left = _conv_info.pad_left(); |
| 171 | pad_top = _conv_info.pad_top(); |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 172 | std::tie(stride_x, stride_y) = _conv_info.stride(); |
| 173 | |
| 174 | // Setup input window |
Jaroslaw Rzepecki | a1ed41f | 2017-10-13 11:13:58 +0100 | [diff] [blame] | 175 | const int start_x = -pad_left; |
| 176 | const int start_y = -pad_top; |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 177 | |
| 178 | Window window_in(window); |
| 179 | // The first three dimensions of the input are increased by the inner loops |
| 180 | window_in.set(Window::DimX, Window::Dimension(0, 0, 0)); |
| 181 | window_in.set(Window::DimY, Window::Dimension(0, 0, 0)); |
| 182 | window_in.set(Window::DimZ, Window::Dimension(0, 0, 0)); |
| 183 | |
| 184 | // Setup output window |
| 185 | Window window_out(window); |
| 186 | window_out.set(Window::DimX, Window::Dimension(0, _output->info()->dimension(0), _output->info()->strides_in_bytes().y() / _output->info()->element_size())); |
| 187 | window_out.set(Window::DimY, Window::Dimension(window.y().start() * _convolved_dims.first, window.y().end() * _convolved_dims.first, _convolved_dims.first)); |
| 188 | window_out.set(Window::DimZ, Window::Dimension(0, 1, 1)); |
| 189 | |
| 190 | // Create iterators |
| 191 | Iterator in(_input, window_in); |
| 192 | Iterator out(_output, window_out); |
| 193 | |
| 194 | execute_window_loop(window, [&](const Coordinates & id) |
| 195 | { |
| 196 | const int top_left_x = id.x() * stride_x + start_x; |
| 197 | const int top_left_y = id.y() * stride_y + start_y; |
| 198 | |
| 199 | // Get pointers |
| 200 | const uint8_t *const input_ptr = in.ptr(); |
| 201 | auto output_ptr = reinterpret_cast<T *>(out.ptr()); |
| 202 | |
| 203 | // Linearize volume |
| 204 | linearize_volume<T, has_pads>(input_ptr, |
| 205 | output_ptr, |
| 206 | _has_bias, |
| 207 | top_left_x, |
| 208 | top_left_y, |
Gian Marco Iodice | 13edbff | 2017-06-26 17:20:16 +0100 | [diff] [blame] | 209 | static_cast<int>(_kernel_width), |
| 210 | static_cast<int>(_kernel_height), |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 211 | kernel_depth, |
| 212 | input_w, |
| 213 | input_h, |
| 214 | input_stride_x, |
| 215 | input_stride_y, |
| 216 | input_stride_z, |
| 217 | _input->info()->fixed_point_position()); |
| 218 | }, |
| 219 | in, out); |
| 220 | } |
| 221 | |
| 222 | template <typename T> |
| 223 | void NEIm2ColKernel::run_reduced(const Window &window) |
| 224 | { |
| 225 | const size_t in_width = _input->info()->dimension(0); |
| 226 | const size_t in_height = _input->info()->dimension(1); |
| 227 | const size_t out_step_x = in_width * _input->info()->element_size(); |
| 228 | const size_t out_step_y = out_step_x * in_height; |
| 229 | const size_t out_width = _output->info()->dimension(0); |
| 230 | |
| 231 | Window in_window(window); |
| 232 | in_window.set(Window::DimX, Window::Dimension(0, 1, 1)); |
| 233 | |
| 234 | Window out_window; |
SiCong Li | 86b5333 | 2017-08-23 11:02:43 +0100 | [diff] [blame] | 235 | out_window.use_tensor_dimensions(_output->info()->tensor_shape()); |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 236 | out_window.set(Window::DimX, Window::Dimension(out_window.x().start(), out_window.x().end(), in_width)); |
| 237 | |
| 238 | Window in_slice = in_window.first_slice_window_3D(); |
| 239 | Window out_slice = out_window.first_slice_window_1D(); |
| 240 | |
| 241 | do |
| 242 | { |
| 243 | Iterator in(_input, in_slice); |
| 244 | Iterator out(_output, out_slice); |
| 245 | |
| 246 | uint8_t *out_ptr = out.ptr(); |
| 247 | |
| 248 | execute_window_loop(in_slice, [&](const Coordinates & id) |
| 249 | { |
| 250 | memcpy(out_ptr + id.y() * out_step_x + id.z() * out_step_y, in.ptr(), out_step_x); |
| 251 | }, |
| 252 | in); |
| 253 | |
| 254 | // Add bias |
| 255 | if(_has_bias) |
| 256 | { |
Gian Marco Iodice | 2bbd964 | 2017-07-04 16:46:32 +0100 | [diff] [blame] | 257 | if(std::is_same<T, qint8_t>::value) |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 258 | { |
Georgios Pinitas | 21efeb4 | 2017-07-04 12:47:17 +0100 | [diff] [blame] | 259 | *(reinterpret_cast<T *>(out_ptr) + out_width - 1) = sqcvt_qs8_f32(1.0f, _input->info()->fixed_point_position()); |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 260 | } |
Gian Marco Iodice | 2bbd964 | 2017-07-04 16:46:32 +0100 | [diff] [blame] | 261 | else if(std::is_same<T, qint16_t>::value) |
| 262 | { |
Georgios Pinitas | 21efeb4 | 2017-07-04 12:47:17 +0100 | [diff] [blame] | 263 | *(reinterpret_cast<T *>(out_ptr) + out_width - 1) = sqcvt_qs16_f32(1.0f, _input->info()->fixed_point_position()); |
Gian Marco Iodice | 2bbd964 | 2017-07-04 16:46:32 +0100 | [diff] [blame] | 264 | } |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 265 | else |
| 266 | { |
| 267 | *(reinterpret_cast<T *>(out_ptr) + out_width - 1) = static_cast<T>(1); |
| 268 | } |
| 269 | } |
| 270 | } |
| 271 | while(in_window.slide_window_slice_3D(in_slice) && out_window.slide_window_slice_1D(out_slice)); |
| 272 | } |
| 273 | |
| 274 | NEIm2ColKernel::NEIm2ColKernel() |
Gian Marco Iodice | 13edbff | 2017-06-26 17:20:16 +0100 | [diff] [blame] | 275 | : _func(), _input(nullptr), _output(nullptr), _convolved_dims(), _conv_info(), _kernel_width(0), _kernel_height(0), _has_bias(false) |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 276 | { |
| 277 | } |
| 278 | |
Gian Marco Iodice | 13edbff | 2017-06-26 17:20:16 +0100 | [diff] [blame] | 279 | void NEIm2ColKernel::configure(const ITensor *input, ITensor *output, const Size2D &kernel_dims, const PadStrideInfo &conv_info, bool has_bias) |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 280 | { |
Gian Marco Iodice | 2bbd964 | 2017-07-04 16:46:32 +0100 | [diff] [blame] | 281 | ARM_COMPUTE_ERROR_ON_DATA_TYPE_CHANNEL_NOT_IN(input, 1, DataType::F16, DataType::F32, DataType::QS8, DataType::QS16); |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 282 | ARM_COMPUTE_ERROR_ON_MISMATCHING_DATA_TYPES(input, output); |
Gian Marco Iodice | 2bbd964 | 2017-07-04 16:46:32 +0100 | [diff] [blame] | 283 | ARM_COMPUTE_ERROR_ON_MISMATCHING_FIXED_POINT_POSITION(input, output); |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 284 | |
| 285 | _input = input; |
| 286 | _output = output; |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 287 | _conv_info = conv_info; |
Gian Marco Iodice | 13edbff | 2017-06-26 17:20:16 +0100 | [diff] [blame] | 288 | _kernel_width = kernel_dims.width; |
| 289 | _kernel_height = kernel_dims.height, |
| 290 | _convolved_dims = scaled_dimensions(input->info()->dimension(0), input->info()->dimension(1), |
| 291 | _kernel_width, _kernel_height, |
| 292 | _conv_info); |
| 293 | _has_bias = has_bias; |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 294 | |
Moritz Pflanzer | 484e7b3 | 2017-08-09 11:43:18 +0100 | [diff] [blame] | 295 | unsigned int stride_x = 0; |
| 296 | unsigned int stride_y = 0; |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 297 | std::tie(stride_x, stride_y) = conv_info.stride(); |
| 298 | |
| 299 | bool run_img2col_reduced = (output->info()->dimension(0) == (input->info()->dimension(0) * input->info()->dimension(1) * input->info()->dimension(2))) && (TensorShape::num_max_dimensions >= 4) |
| 300 | && (std::equal(input->info()->tensor_shape().cbegin() + 3, |
| 301 | input->info()->tensor_shape().cend(), |
| 302 | output->info()->tensor_shape().cbegin() + 1)) |
Jaroslaw Rzepecki | a1ed41f | 2017-10-13 11:13:58 +0100 | [diff] [blame] | 303 | && ((stride_x == 1) && (stride_y == 1) && !conv_info.has_padding()); |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 304 | |
| 305 | Window window = calculate_max_window(*input->info(), Steps()); |
| 306 | |
| 307 | if(run_img2col_reduced) |
| 308 | { |
| 309 | switch(_input->info()->data_type()) |
| 310 | { |
| 311 | case DataType::F32: |
| 312 | _func = &NEIm2ColKernel::run_reduced<float>; |
| 313 | break; |
Ioan-Cristian Szabo | 33fd07b | 2017-10-26 15:42:24 +0100 | [diff] [blame] | 314 | #ifdef ARM_COMPUTE_AARCH64_V8_2 |
Pablo Tello | 659abc0 | 2017-06-22 16:00:16 +0100 | [diff] [blame] | 315 | case DataType::F16: |
| 316 | _func = &NEIm2ColKernel::run_reduced<float16_t>; |
| 317 | break; |
Ioan-Cristian Szabo | 33fd07b | 2017-10-26 15:42:24 +0100 | [diff] [blame] | 318 | #endif /* ARM_COMPUTE_AARCH64_V8_2 */ |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 319 | case DataType::QS8: |
| 320 | _func = &NEIm2ColKernel::run_reduced<qint8_t>; |
| 321 | break; |
Gian Marco Iodice | 2bbd964 | 2017-07-04 16:46:32 +0100 | [diff] [blame] | 322 | case DataType::QS16: |
| 323 | _func = &NEIm2ColKernel::run_reduced<qint16_t>; |
| 324 | break; |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 325 | default: |
| 326 | ARM_COMPUTE_ERROR("Data type not supported"); |
| 327 | break; |
| 328 | } |
| 329 | } |
| 330 | else |
| 331 | { |
| 332 | switch(_input->info()->data_type()) |
| 333 | { |
| 334 | case DataType::F32: |
Jaroslaw Rzepecki | a1ed41f | 2017-10-13 11:13:58 +0100 | [diff] [blame] | 335 | _func = (!conv_info.has_padding()) ? &NEIm2ColKernel::run_generic<float, false> : &NEIm2ColKernel::run_generic<float, true>; |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 336 | break; |
Ioan-Cristian Szabo | 33fd07b | 2017-10-26 15:42:24 +0100 | [diff] [blame] | 337 | #ifdef ARM_COMPUTE_AARCH64_V8_2 |
Pablo Tello | 659abc0 | 2017-06-22 16:00:16 +0100 | [diff] [blame] | 338 | case DataType::F16: |
Jaroslaw Rzepecki | a1ed41f | 2017-10-13 11:13:58 +0100 | [diff] [blame] | 339 | _func = (!conv_info.has_padding()) ? &NEIm2ColKernel::run_generic<float16_t, false> : &NEIm2ColKernel::run_generic<float16_t, true>; |
Pablo Tello | 659abc0 | 2017-06-22 16:00:16 +0100 | [diff] [blame] | 340 | break; |
Ioan-Cristian Szabo | 33fd07b | 2017-10-26 15:42:24 +0100 | [diff] [blame] | 341 | #endif /* ARM_COMPUTE_AARCH64_V8_2 */ |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 342 | case DataType::QS8: |
Jaroslaw Rzepecki | a1ed41f | 2017-10-13 11:13:58 +0100 | [diff] [blame] | 343 | _func = (!conv_info.has_padding()) ? &NEIm2ColKernel::run_generic<qint8_t, false> : &NEIm2ColKernel::run_generic<qint8_t, true>; |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 344 | break; |
Gian Marco Iodice | 2bbd964 | 2017-07-04 16:46:32 +0100 | [diff] [blame] | 345 | case DataType::QS16: |
Jaroslaw Rzepecki | a1ed41f | 2017-10-13 11:13:58 +0100 | [diff] [blame] | 346 | _func = (!conv_info.has_padding()) ? &NEIm2ColKernel::run_generic<qint16_t, false> : &NEIm2ColKernel::run_generic<qint16_t, true>; |
Gian Marco Iodice | 2bbd964 | 2017-07-04 16:46:32 +0100 | [diff] [blame] | 347 | break; |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 348 | default: |
| 349 | ARM_COMPUTE_ERROR("Data type not supported"); |
| 350 | break; |
| 351 | } |
| 352 | window.set(Window::DimX, Window::Dimension(0, _convolved_dims.first, 1)); |
| 353 | window.set(Window::DimY, Window::Dimension(0, _convolved_dims.second, 1)); |
| 354 | window.set(Window::DimZ, Window::Dimension(0, 1, 1)); |
| 355 | } |
| 356 | |
| 357 | // The NEIm2ColKernel doesn't need padding so update_window_and_padding() can be skipped |
| 358 | output->info()->set_valid_region(ValidRegion(Coordinates(), output->info()->tensor_shape())); |
| 359 | |
| 360 | IKernel::configure(window); |
| 361 | } |
| 362 | |
Moritz Pflanzer | c186b57 | 2017-09-07 09:48:04 +0100 | [diff] [blame] | 363 | void NEIm2ColKernel::run(const Window &window, const ThreadInfo &info) |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 364 | { |
Moritz Pflanzer | c186b57 | 2017-09-07 09:48:04 +0100 | [diff] [blame] | 365 | ARM_COMPUTE_UNUSED(info); |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 366 | ARM_COMPUTE_ERROR_ON_UNCONFIGURED_KERNEL(this); |
| 367 | ARM_COMPUTE_ERROR_ON_INVALID_SUBWINDOW(INEKernel::window(), window); |
| 368 | |
| 369 | (this->*_func)(window); |
| 370 | } |