Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 1 | /* |
Michele Di Giorgio | d9eaf61 | 2020-07-08 11:12:57 +0100 | [diff] [blame] | 2 | * Copyright (c) 2017-2020 Arm Limited. |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [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 | #include "arm_compute/core/CL/kernels/CLPoolingLayerKernel.h" |
| 25 | |
| 26 | #include "arm_compute/core/AccessWindowStatic.h" |
| 27 | #include "arm_compute/core/CL/CLHelpers.h" |
| 28 | #include "arm_compute/core/CL/CLKernelLibrary.h" |
Vidhya Sudhan Loganathan | f1f4906 | 2018-05-25 13:21:26 +0100 | [diff] [blame] | 29 | #include "arm_compute/core/CL/CLValidate.h" |
Anton Lokhmotov | af6204c | 2017-11-08 09:34:19 +0000 | [diff] [blame] | 30 | #include "arm_compute/core/CL/ICLKernel.h" |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 31 | #include "arm_compute/core/CL/ICLTensor.h" |
| 32 | #include "arm_compute/core/CL/OpenCL.h" |
| 33 | #include "arm_compute/core/Helpers.h" |
| 34 | #include "arm_compute/core/TensorInfo.h" |
| 35 | #include "arm_compute/core/Utils.h" |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 36 | #include "arm_compute/core/Window.h" |
Michalis Spyrou | e74b201 | 2018-04-18 09:49:16 +0100 | [diff] [blame] | 37 | #include "arm_compute/core/utils/misc/ShapeCalculator.h" |
Matthew Bentham | 758b5ba | 2020-03-05 23:37:48 +0000 | [diff] [blame] | 38 | #include "support/StringSupport.h" |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 39 | |
| 40 | #include <set> |
| 41 | #include <string> |
| 42 | #include <tuple> |
| 43 | |
Michele Di Giorgio | cbbed28 | 2019-12-20 13:26:08 +0000 | [diff] [blame] | 44 | namespace arm_compute |
| 45 | { |
Michalis Spyrou | e74b201 | 2018-04-18 09:49:16 +0100 | [diff] [blame] | 46 | using namespace arm_compute::misc::shape_calculator; |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 47 | |
Giorgio Arena | 9f26b3e | 2017-11-28 14:35:00 +0000 | [diff] [blame] | 48 | namespace |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 49 | { |
Giorgio Arena | 9f26b3e | 2017-11-28 14:35:00 +0000 | [diff] [blame] | 50 | // Internal window config info |
| 51 | using CLPoolingConfig = std::pair<unsigned int, BorderSize>; //num_elems_processed_per_iteration, border_size |
| 52 | |
Michalis Spyrou | e74b201 | 2018-04-18 09:49:16 +0100 | [diff] [blame] | 53 | void auto_init(const ITensorInfo *input, ITensorInfo *output, PoolingLayerInfo pool_info) |
Giorgio Arena | 9f26b3e | 2017-11-28 14:35:00 +0000 | [diff] [blame] | 54 | { |
Michalis Spyrou | e74b201 | 2018-04-18 09:49:16 +0100 | [diff] [blame] | 55 | TensorShape out_shape = compute_pool_shape(*input, pool_info); |
| 56 | auto_init_if_empty(*output, input->clone()->set_tensor_shape(out_shape)); |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 57 | } |
| 58 | |
morgolock | cc1f6c9 | 2020-03-24 09:26:48 +0000 | [diff] [blame] | 59 | Status validate_arguments(const ITensorInfo *input, const ITensorInfo *output, const PoolingLayerInfo &pool_info, const ITensorInfo *indices) |
Georgios Pinitas | 3faea25 | 2017-10-30 14:13:50 +0000 | [diff] [blame] | 60 | { |
| 61 | ARM_COMPUTE_RETURN_ERROR_ON_NULLPTR(input, output); |
Vidhya Sudhan Loganathan | f1f4906 | 2018-05-25 13:21:26 +0100 | [diff] [blame] | 62 | ARM_COMPUTE_RETURN_ERROR_ON_F16_UNSUPPORTED(input); |
Michele Di Giorgio | cbbed28 | 2019-12-20 13:26:08 +0000 | [diff] [blame] | 63 | ARM_COMPUTE_RETURN_ERROR_ON_DATA_TYPE_CHANNEL_NOT_IN(input, 1, DataType::QASYMM8, DataType::QASYMM8_SIGNED, DataType::F16, DataType::F32); |
Sang-Hoon Park | 0cb3da6 | 2020-01-15 12:39:56 +0000 | [diff] [blame] | 64 | ARM_COMPUTE_RETURN_ERROR_ON_MSG((is_data_type_quantized_asymmetric(input->data_type()) && pool_info.pool_type == PoolingType::L2), |
Anton Lokhmotov | af6204c | 2017-11-08 09:34:19 +0000 | [diff] [blame] | 65 | "Unsupported combination of parameters!"); |
Michele Di Giorgio | 2c87719 | 2020-02-18 19:06:27 +0000 | [diff] [blame] | 66 | ARM_COMPUTE_RETURN_ERROR_ON_MSG(is_data_type_quantized(input->data_type()) && !pool_info.exclude_padding && (pool_info.pool_type == PoolingType::AVG) && pool_info.pad_stride_info.has_padding() |
| 67 | && (input->data_layout() == DataLayout::NHWC), |
| 68 | "exclude_padding equal false is not supported for AVG Pooling with padding on quantized types"); |
Sheri Zhang | 801bbcb | 2020-08-03 20:11:56 +0100 | [diff] [blame^] | 69 | // Check indices |
| 70 | if(indices) |
| 71 | { |
| 72 | ARM_COMPUTE_RETURN_ERROR_ON_DATA_TYPE_CHANNEL_NOT_IN(indices, 1, DataType::U32); |
| 73 | ARM_COMPUTE_RETURN_ERROR_ON_DATA_TYPE_CHANNEL_NOT_IN(input, 1, DataType::F16, DataType::F32); |
| 74 | ARM_COMPUTE_RETURN_ERROR_ON_MSG(pool_info.pool_type != PoolingType::MAX, "Pooling indices only supported for MAX pooling method"); |
| 75 | ARM_COMPUTE_RETURN_ERROR_ON_MSG((pool_info.pool_size != Size2D(2, 2)), "Pooling indices only supported for pool size 2x2"); |
| 76 | } |
Georgios Pinitas | 3faea25 | 2017-10-30 14:13:50 +0000 | [diff] [blame] | 77 | |
Georgios Pinitas | 3faea25 | 2017-10-30 14:13:50 +0000 | [diff] [blame] | 78 | // Checks performed when output is configured |
| 79 | if(output->total_size() != 0) |
| 80 | { |
| 81 | ARM_COMPUTE_RETURN_ERROR_ON_MISMATCHING_DATA_TYPES(input, output); |
Michalis Spyrou | e74b201 | 2018-04-18 09:49:16 +0100 | [diff] [blame] | 82 | ARM_COMPUTE_RETURN_ERROR_ON_MISMATCHING_DATA_LAYOUT(input, output); |
Vidhya Sudhan Loganathan | 7485d5a | 2018-07-04 09:34:00 +0100 | [diff] [blame] | 83 | TensorInfo out_info(TensorInfo(compute_pool_shape(*input, pool_info), 1, output->data_type())); |
Michalis Spyrou | e74b201 | 2018-04-18 09:49:16 +0100 | [diff] [blame] | 84 | ARM_COMPUTE_RETURN_ERROR_ON_MISMATCHING_SHAPES(output, &out_info); |
Georgios Pinitas | 3faea25 | 2017-10-30 14:13:50 +0000 | [diff] [blame] | 85 | } |
| 86 | |
Georgios Pinitas | 631c41a | 2017-12-06 11:53:03 +0000 | [diff] [blame] | 87 | return Status{}; |
Georgios Pinitas | 3faea25 | 2017-10-30 14:13:50 +0000 | [diff] [blame] | 88 | } |
| 89 | |
Sheri Zhang | 801bbcb | 2020-08-03 20:11:56 +0100 | [diff] [blame^] | 90 | std::tuple<Status, Window, CLPoolingConfig> validate_and_configure_window(ITensorInfo *input, ITensorInfo *output, const PoolingLayerInfo &pool_info, ITensorInfo *indices = nullptr) |
Giorgio Arena | 9f26b3e | 2017-11-28 14:35:00 +0000 | [diff] [blame] | 91 | { |
Michalis Spyrou | e74b201 | 2018-04-18 09:49:16 +0100 | [diff] [blame] | 92 | ARM_COMPUTE_ERROR_ON_NULLPTR(input, output); |
| 93 | |
| 94 | // Get data layout |
Sang-Hoon Park | 11fedda | 2020-01-15 14:44:04 +0000 | [diff] [blame] | 95 | const DataLayout data_layout = pool_info.data_layout == DataLayout::UNKNOWN ? input->data_layout() : pool_info.data_layout; |
Michalis Spyrou | e74b201 | 2018-04-18 09:49:16 +0100 | [diff] [blame] | 96 | const int idx_width = get_data_layout_dimension_index(data_layout, DataLayoutDimension::WIDTH); |
| 97 | const int idx_height = get_data_layout_dimension_index(data_layout, DataLayoutDimension::HEIGHT); |
| 98 | |
Giorgio Arena | 9f26b3e | 2017-11-28 14:35:00 +0000 | [diff] [blame] | 99 | int pool_stride_x = 0; |
| 100 | int pool_stride_y = 0; |
| 101 | unsigned int pooled_w = 0; |
| 102 | unsigned int pooled_h = 0; |
Sang-Hoon Park | 0cb3da6 | 2020-01-15 12:39:56 +0000 | [diff] [blame] | 103 | int pool_size_x = pool_info.is_global_pooling ? input->dimension(idx_width) : pool_info.pool_size.width; |
| 104 | int pool_size_y = pool_info.is_global_pooling ? input->dimension(idx_height) : pool_info.pool_size.height; |
| 105 | const PadStrideInfo pad_stride_info = pool_info.pad_stride_info; |
Giorgio Arena | 9f26b3e | 2017-11-28 14:35:00 +0000 | [diff] [blame] | 106 | std::tie(pool_stride_x, pool_stride_y) = pad_stride_info.stride(); |
Michalis Spyrou | e74b201 | 2018-04-18 09:49:16 +0100 | [diff] [blame] | 107 | const int pool_pad_right = pad_stride_info.pad_right(); |
| 108 | const int pool_pad_top = pad_stride_info.pad_top(); |
| 109 | const int pool_pad_left = pad_stride_info.pad_left(); |
| 110 | const int pool_pad_bottom = pad_stride_info.pad_bottom(); |
| 111 | BorderSize border_size = BorderSize(pool_pad_top, pool_pad_right, pool_pad_bottom, pool_pad_left); |
Giorgio Arena | 9f26b3e | 2017-11-28 14:35:00 +0000 | [diff] [blame] | 112 | |
Michalis Spyrou | e74b201 | 2018-04-18 09:49:16 +0100 | [diff] [blame] | 113 | auto_init(input, output, pool_info); |
| 114 | pooled_w = output->tensor_shape()[idx_width]; |
| 115 | pooled_h = output->tensor_shape()[idx_height]; |
Giorgio Arena | 9f26b3e | 2017-11-28 14:35:00 +0000 | [diff] [blame] | 116 | |
Michalis Spyrou | e74b201 | 2018-04-18 09:49:16 +0100 | [diff] [blame] | 117 | const DataType data_type = input->data_type(); |
Giorgio Arena | 9f26b3e | 2017-11-28 14:35:00 +0000 | [diff] [blame] | 118 | |
Michalis Spyrou | e74b201 | 2018-04-18 09:49:16 +0100 | [diff] [blame] | 119 | const int input_width = input->dimension(idx_width); |
| 120 | const int input_height = input->dimension(idx_height); |
Giorgio Arena | 9f26b3e | 2017-11-28 14:35:00 +0000 | [diff] [blame] | 121 | |
Michalis Spyrou | e74b201 | 2018-04-18 09:49:16 +0100 | [diff] [blame] | 122 | unsigned int num_elems_processed_per_iteration = 0; |
| 123 | bool window_changed = false; |
| 124 | Window win{}; |
| 125 | switch(data_layout) |
| 126 | { |
| 127 | case DataLayout::NCHW: |
| 128 | { |
| 129 | // Change the number of elements processed per iteration |
| 130 | // for pooling 3x3 with stride less equal than 3 |
| 131 | const bool can_optimize = (pool_size_x == 3) && (pool_size_y == 3) && (pool_stride_x <= 3) && !is_data_type_quantized(data_type); |
| 132 | num_elems_processed_per_iteration = can_optimize ? 4 : 1; |
| 133 | const unsigned int num_elems_read_per_iteration = (num_elems_processed_per_iteration - 1) * pool_stride_x + pool_size_x; |
Giorgio Arena | 9f26b3e | 2017-11-28 14:35:00 +0000 | [diff] [blame] | 134 | |
Michalis Spyrou | e74b201 | 2018-04-18 09:49:16 +0100 | [diff] [blame] | 135 | // Number of iterations in X dimension |
| 136 | const int num_iterations_x = (pooled_w + num_elems_processed_per_iteration - 1) / num_elems_processed_per_iteration; |
Giorgio Arena | 9f26b3e | 2017-11-28 14:35:00 +0000 | [diff] [blame] | 137 | |
Michalis Spyrou | e74b201 | 2018-04-18 09:49:16 +0100 | [diff] [blame] | 138 | // Upper limit for the number of right/bottom border elements that are accessed |
| 139 | const int upper_bound_w = ((num_iterations_x - 1) * num_elems_processed_per_iteration * pool_stride_x - pool_pad_left + num_elems_read_per_iteration) - input_width; |
| 140 | const int upper_bound_h = ((pooled_h - 1) * pool_stride_y - pool_pad_top + pool_size_y) - input_height; |
Giorgio Arena | 9f26b3e | 2017-11-28 14:35:00 +0000 | [diff] [blame] | 141 | |
Michalis Spyrou | e74b201 | 2018-04-18 09:49:16 +0100 | [diff] [blame] | 142 | border_size.right = std::max(upper_bound_w, pool_pad_right); |
| 143 | border_size.bottom = std::max(upper_bound_h, pool_pad_bottom); |
Giorgio Arena | 9f26b3e | 2017-11-28 14:35:00 +0000 | [diff] [blame] | 144 | |
Michalis Spyrou | e74b201 | 2018-04-18 09:49:16 +0100 | [diff] [blame] | 145 | win = calculate_max_window(*output, Steps(num_elems_processed_per_iteration)); |
Giorgio Arena | 9f26b3e | 2017-11-28 14:35:00 +0000 | [diff] [blame] | 146 | |
Michalis Spyrou | e74b201 | 2018-04-18 09:49:16 +0100 | [diff] [blame] | 147 | AccessWindowRectangle input_access(input, -pool_pad_left, -pool_pad_top, num_elems_read_per_iteration, pool_size_y, |
Giorgio Arena | 3c520c5 | 2018-05-01 11:47:24 +0100 | [diff] [blame] | 148 | pool_stride_x, pool_stride_y); |
Michalis Spyrou | e74b201 | 2018-04-18 09:49:16 +0100 | [diff] [blame] | 149 | AccessWindowHorizontal output_access(output, 0, num_elems_processed_per_iteration); |
Sheri Zhang | 801bbcb | 2020-08-03 20:11:56 +0100 | [diff] [blame^] | 150 | |
| 151 | // Update indices window |
| 152 | if(indices) |
| 153 | { |
| 154 | AccessWindowHorizontal indices_access(indices, 0, num_elems_processed_per_iteration); |
| 155 | window_changed = update_window_and_padding(win, input_access, output_access, indices_access); |
| 156 | indices_access.set_valid_region(win, ValidRegion(Coordinates(), indices->tensor_shape())); |
| 157 | } |
| 158 | else |
| 159 | { |
| 160 | window_changed = update_window_and_padding(win, input_access, output_access); |
| 161 | } |
| 162 | |
Michalis Spyrou | e74b201 | 2018-04-18 09:49:16 +0100 | [diff] [blame] | 163 | output_access.set_valid_region(win, ValidRegion(Coordinates(), output->tensor_shape())); |
| 164 | break; |
| 165 | } |
| 166 | case DataLayout::NHWC: |
| 167 | { |
| 168 | num_elems_processed_per_iteration = 8; |
| 169 | win = calculate_max_window(*output, Steps(num_elems_processed_per_iteration)); |
Giorgio Arena | 9f26b3e | 2017-11-28 14:35:00 +0000 | [diff] [blame] | 170 | |
Georgios Pinitas | e222055 | 2018-07-20 13:23:44 +0100 | [diff] [blame] | 171 | AccessWindowStatic input_access(input, |
| 172 | 0, -1, |
| 173 | ceil_to_multiple(input->dimension(0), num_elems_processed_per_iteration), input->dimension(1)); |
Michalis Spyrou | e74b201 | 2018-04-18 09:49:16 +0100 | [diff] [blame] | 174 | AccessWindowHorizontal output_access(output, 0, num_elems_processed_per_iteration); |
Sheri Zhang | 801bbcb | 2020-08-03 20:11:56 +0100 | [diff] [blame^] | 175 | |
| 176 | // Update indices window |
| 177 | if(indices) |
| 178 | { |
| 179 | AccessWindowHorizontal indices_access(indices, 0, num_elems_processed_per_iteration); |
| 180 | window_changed = update_window_and_padding(win, input_access, output_access, indices_access); |
| 181 | indices_access.set_valid_region(win, ValidRegion(Coordinates(), indices->tensor_shape())); |
| 182 | } |
| 183 | else |
| 184 | { |
| 185 | window_changed = update_window_and_padding(win, input_access, output_access); |
| 186 | } |
| 187 | |
Michalis Spyrou | e74b201 | 2018-04-18 09:49:16 +0100 | [diff] [blame] | 188 | output_access.set_valid_region(win, ValidRegion(Coordinates(), output->tensor_shape())); |
| 189 | break; |
| 190 | } |
| 191 | default: |
| 192 | ARM_COMPUTE_ERROR("Not implemented"); |
| 193 | } |
Giorgio Arena | 9f26b3e | 2017-11-28 14:35:00 +0000 | [diff] [blame] | 194 | |
Georgios Pinitas | 631c41a | 2017-12-06 11:53:03 +0000 | [diff] [blame] | 195 | Status err = (window_changed) ? ARM_COMPUTE_CREATE_ERROR(ErrorCode::RUNTIME_ERROR, "Insufficient Padding!") : Status{}; |
Giorgio Arena | 9f26b3e | 2017-11-28 14:35:00 +0000 | [diff] [blame] | 196 | return std::make_tuple(err, win, CLPoolingConfig(num_elems_processed_per_iteration, border_size)); |
| 197 | } |
| 198 | } // namespace |
| 199 | |
| 200 | CLPoolingLayerKernel::CLPoolingLayerKernel() |
morgolock | cc1f6c9 | 2020-03-24 09:26:48 +0000 | [diff] [blame] | 201 | : _input(nullptr), _output(nullptr), _indices(nullptr), _pool_info(), _data_layout(DataLayout::UNKNOWN), _border_size(0), _num_elems_processed_per_iteration(1) |
Giorgio Arena | 9f26b3e | 2017-11-28 14:35:00 +0000 | [diff] [blame] | 202 | { |
| 203 | } |
| 204 | |
| 205 | BorderSize CLPoolingLayerKernel::border_size() const |
| 206 | { |
| 207 | return _border_size; |
| 208 | } |
| 209 | |
morgolock | cc1f6c9 | 2020-03-24 09:26:48 +0000 | [diff] [blame] | 210 | void CLPoolingLayerKernel::configure(const ICLTensor *input, ICLTensor *output, const PoolingLayerInfo &pool_info, ICLTensor *indices) |
Giorgio Arena | 9f26b3e | 2017-11-28 14:35:00 +0000 | [diff] [blame] | 211 | { |
Manuel Bottini | 4c6bd51 | 2020-04-08 10:15:51 +0100 | [diff] [blame] | 212 | configure(CLKernelLibrary::get().get_compile_context(), input, output, pool_info, indices); |
| 213 | } |
| 214 | |
Manuel Bottini | 679fc96 | 2020-04-21 16:08:53 +0100 | [diff] [blame] | 215 | void CLPoolingLayerKernel::configure(const CLCompileContext &compile_context, const ICLTensor *input, ICLTensor *output, const PoolingLayerInfo &pool_info, ICLTensor *indices) |
Manuel Bottini | 4c6bd51 | 2020-04-08 10:15:51 +0100 | [diff] [blame] | 216 | { |
Michalis Spyrou | e74b201 | 2018-04-18 09:49:16 +0100 | [diff] [blame] | 217 | ARM_COMPUTE_ERROR_ON_NULLPTR(input, output); |
| 218 | |
Georgios Pinitas | 14d9d98 | 2019-12-13 12:33:09 +0000 | [diff] [blame] | 219 | // Set instance variables |
morgolock | cc1f6c9 | 2020-03-24 09:26:48 +0000 | [diff] [blame] | 220 | _input = input; |
| 221 | _output = output; |
| 222 | _pool_info = pool_info; |
| 223 | _data_layout = pool_info.data_layout == DataLayout::UNKNOWN ? input->info()->data_layout() : pool_info.data_layout; |
| 224 | _indices = indices; |
Giorgio Arena | 9f26b3e | 2017-11-28 14:35:00 +0000 | [diff] [blame] | 225 | int pool_stride_x = 0; |
| 226 | int pool_stride_y = 0; |
Sang-Hoon Park | 0cb3da6 | 2020-01-15 12:39:56 +0000 | [diff] [blame] | 227 | const PoolingType pool_type = pool_info.pool_type; |
Georgios Pinitas | 14d9d98 | 2019-12-13 12:33:09 +0000 | [diff] [blame] | 228 | const int idx_width = get_data_layout_dimension_index(_data_layout, DataLayoutDimension::WIDTH); |
| 229 | const int idx_height = get_data_layout_dimension_index(_data_layout, DataLayoutDimension::HEIGHT); |
| 230 | const int idx_channel = get_data_layout_dimension_index(_data_layout, DataLayoutDimension::CHANNEL); |
Sang-Hoon Park | 0cb3da6 | 2020-01-15 12:39:56 +0000 | [diff] [blame] | 231 | const int pool_size_x = pool_info.is_global_pooling ? input->info()->dimension(idx_width) : pool_info.pool_size.width; |
| 232 | const int pool_size_y = pool_info.is_global_pooling ? input->info()->dimension(idx_height) : pool_info.pool_size.height; |
| 233 | const PadStrideInfo pad_stride_info = pool_info.pad_stride_info; |
| 234 | const bool exclude_padding = pool_info.exclude_padding; |
Giorgio Arena | 9f26b3e | 2017-11-28 14:35:00 +0000 | [diff] [blame] | 235 | std::tie(pool_stride_x, pool_stride_y) = pad_stride_info.stride(); |
Georgios Pinitas | 1599787 | 2018-02-19 13:58:22 +0000 | [diff] [blame] | 236 | const int pool_pad_top = pad_stride_info.pad_top(); |
| 237 | const int pool_pad_left = pad_stride_info.pad_left(); |
Giorgio Arena | 9f26b3e | 2017-11-28 14:35:00 +0000 | [diff] [blame] | 238 | |
Pablo Tello | a52e4cf | 2019-04-01 14:55:18 +0100 | [diff] [blame] | 239 | // Set build options |
| 240 | CLBuildOptions build_opts; |
Sheri Zhang | 801bbcb | 2020-08-03 20:11:56 +0100 | [diff] [blame^] | 241 | const DataType data_type = input->info()->data_type(); |
Pablo Tello | a52e4cf | 2019-04-01 14:55:18 +0100 | [diff] [blame] | 242 | |
Sheri Zhang | 801bbcb | 2020-08-03 20:11:56 +0100 | [diff] [blame^] | 243 | // Configure kernel window |
| 244 | auto win_config = validate_and_configure_window(input->info(), output->info(), pool_info, (indices ? indices->info() : nullptr)); |
| 245 | |
| 246 | ARM_COMPUTE_ERROR_THROW_ON(std::get<0>(win_config)); |
| 247 | ICLKernel::configure_internal(std::get<1>(win_config)); |
| 248 | |
| 249 | if(_data_layout == DataLayout::NCHW) |
| 250 | { |
| 251 | CLPoolingConfig pooling_config = std::get<2>(win_config); |
| 252 | _num_elems_processed_per_iteration = pooling_config.first; |
| 253 | _border_size = pooling_config.second; |
| 254 | } |
| 255 | else |
| 256 | { |
| 257 | _border_size = BorderSize(1, 0, 0, 0); |
| 258 | _num_elems_processed_per_iteration = 8; |
| 259 | } |
| 260 | |
| 261 | // Tensor paddings are used to calculate the indicies for MAX pooling |
| 262 | if(pool_info.pool_size == Size2D(2, 2) && pool_type == PoolingType::MAX && _indices && is_data_type_float(data_type)) |
| 263 | { |
| 264 | build_opts.add_option("-DPAD_TENSOR_LEFT=" + support::cpp11::to_string(input->info()->padding().left)); |
| 265 | build_opts.add_option("-DPAD_TENSOR_RIGHT=" + support::cpp11::to_string(input->info()->padding().right)); |
| 266 | build_opts.add_option("-DPAD_TENSOR_TOP=" + support::cpp11::to_string(input->info()->padding().top)); |
| 267 | build_opts.add_option("-DPAD_TENSOR_BOTTOM=" + support::cpp11::to_string(input->info()->padding().bottom)); |
| 268 | build_opts.add_option("-DTENSOR_CHANNEL=" + support::cpp11::to_string(input->info()->dimension(idx_channel))); |
| 269 | build_opts.add_option("-DTENSOR_WIDTH=" + support::cpp11::to_string(input->info()->dimension(idx_width))); |
| 270 | build_opts.add_option("-DTENSOR_HEIGHT=" + support::cpp11::to_string(input->info()->dimension(idx_height))); |
| 271 | } |
| 272 | |
| 273 | if(is_data_type_quantized_asymmetric(data_type) && input->info()->quantization_info() != output->info()->quantization_info()) |
Pablo Tello | a52e4cf | 2019-04-01 14:55:18 +0100 | [diff] [blame] | 274 | { |
Georgios Pinitas | 4c5469b | 2019-05-21 13:32:43 +0100 | [diff] [blame] | 275 | const UniformQuantizationInfo iq_info = input->info()->quantization_info().uniform(); |
| 276 | const UniformQuantizationInfo oq_info = output->info()->quantization_info().uniform(); |
| 277 | |
| 278 | build_opts.add_option("-DOFFSET_IN1=" + float_to_string_with_full_precision(iq_info.offset)); |
| 279 | build_opts.add_option("-DOFFSET_OUT=" + float_to_string_with_full_precision(oq_info.offset)); |
| 280 | build_opts.add_option("-DSCALE_IN1=" + float_to_string_with_full_precision(iq_info.scale)); |
| 281 | build_opts.add_option("-DSCALE_OUT=" + float_to_string_with_full_precision(oq_info.scale)); |
Pablo Tello | a52e4cf | 2019-04-01 14:55:18 +0100 | [diff] [blame] | 282 | } |
| 283 | |
Giorgio Arena | 9f26b3e | 2017-11-28 14:35:00 +0000 | [diff] [blame] | 284 | // Check output dimensions |
Michalis Spyrou | e74b201 | 2018-04-18 09:49:16 +0100 | [diff] [blame] | 285 | auto_init(input->info(), output->info(), pool_info); |
morgolock | cc1f6c9 | 2020-03-24 09:26:48 +0000 | [diff] [blame] | 286 | ARM_COMPUTE_ERROR_THROW_ON(validate_arguments(input->info(), output->info(), pool_info, (indices) ? indices->info() : nullptr)); |
Giorgio Arena | 9f26b3e | 2017-11-28 14:35:00 +0000 | [diff] [blame] | 287 | |
Giorgio Arena | 9f26b3e | 2017-11-28 14:35:00 +0000 | [diff] [blame] | 288 | build_opts.add_option("-DDATA_TYPE=" + get_cl_type_from_data_type(data_type)); |
| 289 | build_opts.add_option("-DPOOL_" + string_from_pooling_type(pool_type)); |
Giorgio Arena | 9f26b3e | 2017-11-28 14:35:00 +0000 | [diff] [blame] | 290 | build_opts.add_option("-DSTRIDE_X=" + support::cpp11::to_string(pool_stride_x)); |
Michalis Spyrou | e74b201 | 2018-04-18 09:49:16 +0100 | [diff] [blame] | 291 | build_opts.add_option("-DSTRIDE_Y=" + support::cpp11::to_string(pool_stride_y)); |
| 292 | build_opts.add_option("-DPAD_X=" + support::cpp11::to_string(pool_pad_left)); |
| 293 | build_opts.add_option("-DPAD_Y=" + support::cpp11::to_string(pool_pad_top)); |
| 294 | build_opts.add_option("-DPOOL_SIZE_X=" + support::cpp11::to_string(pool_size_x)); |
| 295 | build_opts.add_option("-DPOOL_SIZE_Y=" + support::cpp11::to_string(pool_size_y)); |
Pablo Tello | a52e4cf | 2019-04-01 14:55:18 +0100 | [diff] [blame] | 296 | |
Michele Di Giorgio | cbbed28 | 2019-12-20 13:26:08 +0000 | [diff] [blame] | 297 | // Set the initial value for the pooling operation accordingly with the data type |
| 298 | if(pool_type == PoolingType::MAX) |
| 299 | { |
| 300 | if(is_data_type_quantized(data_type)) |
| 301 | { |
| 302 | PixelValue type_min{}; |
| 303 | std::tie(type_min, std::ignore) = get_min_max(data_type); |
| 304 | build_opts.add_option("-DINITIAL_VALUE=" + support::cpp11::to_string(type_min.get<int32_t>())); |
| 305 | } |
| 306 | else |
| 307 | { |
| 308 | build_opts.add_option("-DINITIAL_VALUE=" + float_to_string_with_full_precision(std::numeric_limits<float>::lowest())); |
| 309 | } |
| 310 | } |
| 311 | else |
| 312 | { |
| 313 | // Pool AVG and Pool L2 initial value |
| 314 | build_opts.add_option("-DINITIAL_VALUE=0"); |
| 315 | } |
Giorgio Arena | 9f26b3e | 2017-11-28 14:35:00 +0000 | [diff] [blame] | 316 | |
Sang-Hoon Park | 0cb3da6 | 2020-01-15 12:39:56 +0000 | [diff] [blame] | 317 | const auto use_fp_mixed_precision = (data_type == DataType::F16) && pool_info.fp_mixed_precision; |
Sang-Hoon Park | 2aa7fd0 | 2019-09-18 13:39:00 +0100 | [diff] [blame] | 318 | const auto use_wider_accumulator = use_fp_mixed_precision && (pool_type != PoolingType::MAX); |
| 319 | const auto acc_data_type = get_cl_type_from_data_type(use_wider_accumulator ? DataType::F32 : data_type); |
| 320 | build_opts.add_option("-DACC_DATA_TYPE=" + acc_data_type); |
| 321 | build_opts.add_option_if(use_wider_accumulator, "-DFP_MIXED_PRECISION"); |
| 322 | |
Giorgio Arena | 9f26b3e | 2017-11-28 14:35:00 +0000 | [diff] [blame] | 323 | // Create kernel |
Georgios Pinitas | 14d9d98 | 2019-12-13 12:33:09 +0000 | [diff] [blame] | 324 | switch(_data_layout) |
Giorgio Arena | 9f26b3e | 2017-11-28 14:35:00 +0000 | [diff] [blame] | 325 | { |
Michalis Spyrou | e74b201 | 2018-04-18 09:49:16 +0100 | [diff] [blame] | 326 | case DataLayout::NCHW: |
| 327 | { |
| 328 | build_opts.add_option("-DMAX_WIDTH=" + support::cpp11::to_string(input->info()->dimension(idx_width) + (exclude_padding ? 0 : pool_pad_left))); |
| 329 | build_opts.add_option("-DMAX_HEIGHT=" + support::cpp11::to_string(input->info()->dimension(idx_height) + (exclude_padding ? 0 : pool_pad_top))); |
| 330 | if(pool_type != PoolingType::MAX) |
| 331 | { |
| 332 | build_opts.add_option_if(exclude_padding, "-DEXCLUDE_PADDING"); |
| 333 | } |
Giorgio Arena | 9f26b3e | 2017-11-28 14:35:00 +0000 | [diff] [blame] | 334 | |
Michalis Spyrou | e74b201 | 2018-04-18 09:49:16 +0100 | [diff] [blame] | 335 | if((pool_size_x == 3) && (pool_size_y == 3) && !is_data_type_quantized_asymmetric(data_type)) |
| 336 | { |
| 337 | // Check if we have pool3x3 with stride_x less equal than 3. In these cases, run an optimized OpenCL kernel where |
| 338 | // each thread computes 4 output elements |
Vidhya Sudhan Loganathan | 7485d5a | 2018-07-04 09:34:00 +0100 | [diff] [blame] | 339 | const bool is_pool3x3_stride_le3 = (pool_size_x == 3) && (pool_size_y == 3) && (pool_stride_x <= 3); |
Giorgio Arena | 9f26b3e | 2017-11-28 14:35:00 +0000 | [diff] [blame] | 340 | |
Michalis Spyrou | e74b201 | 2018-04-18 09:49:16 +0100 | [diff] [blame] | 341 | std::string kernel_name = ((is_pool3x3_stride_le3) ? "pooling_layer_optimized_" : "pooling_layer_") |
| 342 | + support::cpp11::to_string(pool_size_x); |
Manuel Bottini | 4c6bd51 | 2020-04-08 10:15:51 +0100 | [diff] [blame] | 343 | _kernel = create_kernel(compile_context, kernel_name, build_opts.options()); |
Michalis Spyrou | e74b201 | 2018-04-18 09:49:16 +0100 | [diff] [blame] | 344 | } |
Sheri Zhang | 801bbcb | 2020-08-03 20:11:56 +0100 | [diff] [blame^] | 345 | else if(pool_info.pool_size == Size2D(2, 2) && pool_type == PoolingType::MAX && _indices && is_data_type_float(data_type)) |
| 346 | { |
| 347 | // For max pooling with pool2x2, store indicies which will be used in max unpooling |
| 348 | if(data_type == DataType::F32) |
| 349 | { |
| 350 | std::string kernel_name = "pooling_layer_2_nchw_indices_fp32"; |
| 351 | _kernel = create_kernel(compile_context, kernel_name, build_opts.options()); |
| 352 | } |
| 353 | else if(data_type == DataType::F16) |
| 354 | { |
| 355 | std::string kernel_name = "pooling_layer_2_nchw_indices_fp16"; |
| 356 | _kernel = create_kernel(compile_context, kernel_name, build_opts.options()); |
| 357 | } |
| 358 | } |
Michalis Spyrou | e74b201 | 2018-04-18 09:49:16 +0100 | [diff] [blame] | 359 | else // Run general case |
| 360 | { |
| 361 | std::string kernel_name = is_data_type_quantized_asymmetric(data_type) ? "pooling_layer_MxN_quantized_nchw" : "pooling_layer_MxN_nchw"; |
Manuel Bottini | 4c6bd51 | 2020-04-08 10:15:51 +0100 | [diff] [blame] | 362 | _kernel = create_kernel(compile_context, kernel_name, build_opts.options()); |
Michalis Spyrou | e74b201 | 2018-04-18 09:49:16 +0100 | [diff] [blame] | 363 | } |
| 364 | break; |
| 365 | } |
| 366 | case DataLayout::NHWC: |
| 367 | { |
| 368 | build_opts.add_option_if(exclude_padding, "-DEXCLUDE_PADDING"); |
| 369 | build_opts.add_option("-DMAX_WIDTH=" + support::cpp11::to_string(input->info()->dimension(idx_width))); |
| 370 | build_opts.add_option("-DMAX_HEIGHT=" + support::cpp11::to_string(input->info()->dimension(idx_height))); |
Georgios Pinitas | 89d7173 | 2018-10-29 20:07:15 +0000 | [diff] [blame] | 371 | build_opts.add_option_if(output->info()->tensor_shape().total_size_upper(3) > 1, |
| 372 | "-DDST_DEPTH=" + support::cpp11::to_string(output->info()->dimension(idx_height))); |
Sheri Zhang | 801bbcb | 2020-08-03 20:11:56 +0100 | [diff] [blame^] | 373 | build_opts.add_option_if(output->info()->tensor_shape().total_size_upper(3) > 1, |
| 374 | "-DBATCH_SIZE=" + support::cpp11::to_string(output->info()->tensor_shape().total_size_upper(3))); |
| 375 | |
| 376 | if(pool_info.pool_size == Size2D(2, 2) && pool_type == PoolingType::MAX && _indices && is_data_type_float(data_type)) |
| 377 | { |
| 378 | if(data_type == DataType::F32) |
| 379 | { |
| 380 | std::string kernel_name = "pooling_layer_2_nhwc_indices_fp32"; |
| 381 | _kernel = create_kernel(compile_context, kernel_name, build_opts.options()); |
| 382 | } |
| 383 | else if(data_type == DataType::F16) |
| 384 | { |
| 385 | std::string kernel_name = "pooling_layer_2_nhwc_indices_fp16"; |
| 386 | _kernel = create_kernel(compile_context, kernel_name, build_opts.options()); |
| 387 | } |
| 388 | } |
| 389 | else |
| 390 | { |
| 391 | std::string kernel_name = is_data_type_quantized_asymmetric(data_type) ? "pooling_layer_MxN_quantized_nhwc" : "pooling_layer_MxN_nhwc"; |
| 392 | _kernel = create_kernel(compile_context, kernel_name, build_opts.options()); |
| 393 | } |
Michalis Spyrou | e74b201 | 2018-04-18 09:49:16 +0100 | [diff] [blame] | 394 | break; |
| 395 | } |
| 396 | default: |
| 397 | ARM_COMPUTE_ERROR("Not implemented"); |
Giorgio Arena | 9f26b3e | 2017-11-28 14:35:00 +0000 | [diff] [blame] | 398 | } |
| 399 | |
Giorgio Arena | 9f26b3e | 2017-11-28 14:35:00 +0000 | [diff] [blame] | 400 | // Set config_id for enabling LWS tuning |
| 401 | _config_id = "pooling_layer_"; |
| 402 | _config_id += lower_string(string_from_data_type(data_type)); |
| 403 | _config_id += "_"; |
Georgios Pinitas | 14d9d98 | 2019-12-13 12:33:09 +0000 | [diff] [blame] | 404 | _config_id += lower_string(string_from_data_layout(_data_layout)); |
Giorgio Arena | 9f26b3e | 2017-11-28 14:35:00 +0000 | [diff] [blame] | 405 | _config_id += "_"; |
Michalis Spyrou | e74b201 | 2018-04-18 09:49:16 +0100 | [diff] [blame] | 406 | _config_id += support::cpp11::to_string(output->info()->dimension(idx_width)); |
| 407 | _config_id += "_"; |
| 408 | _config_id += support::cpp11::to_string(output->info()->dimension(idx_height)); |
| 409 | _config_id += "_"; |
| 410 | _config_id += support::cpp11::to_string(output->info()->dimension(idx_channel)); |
Giorgio Arena | 00b93f5 | 2018-06-28 17:18:50 +0100 | [diff] [blame] | 411 | _config_id += "_"; |
| 412 | _config_id += lower_string(string_from_data_layout(input->info()->data_layout())); |
Giorgio Arena | 9f26b3e | 2017-11-28 14:35:00 +0000 | [diff] [blame] | 413 | } |
| 414 | |
morgolock | cc1f6c9 | 2020-03-24 09:26:48 +0000 | [diff] [blame] | 415 | Status CLPoolingLayerKernel::validate(const ITensorInfo *input, const ITensorInfo *output, const PoolingLayerInfo &pool_info, const ITensorInfo *indices) |
Giorgio Arena | 9f26b3e | 2017-11-28 14:35:00 +0000 | [diff] [blame] | 416 | { |
morgolock | cc1f6c9 | 2020-03-24 09:26:48 +0000 | [diff] [blame] | 417 | ARM_COMPUTE_RETURN_ON_ERROR(validate_arguments(input, output, pool_info, indices)); |
Giorgio Arena | 9f26b3e | 2017-11-28 14:35:00 +0000 | [diff] [blame] | 418 | ARM_COMPUTE_RETURN_ON_ERROR(std::get<0>(validate_and_configure_window(input->clone().get(), output->clone().get(), pool_info))); |
| 419 | |
Georgios Pinitas | 631c41a | 2017-12-06 11:53:03 +0000 | [diff] [blame] | 420 | return Status{}; |
Giorgio Arena | 9f26b3e | 2017-11-28 14:35:00 +0000 | [diff] [blame] | 421 | } |
| 422 | |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 423 | void CLPoolingLayerKernel::run(const Window &window, cl::CommandQueue &queue) |
| 424 | { |
| 425 | ARM_COMPUTE_ERROR_ON_UNCONFIGURED_KERNEL(this); |
| 426 | ARM_COMPUTE_ERROR_ON_INVALID_SUBWINDOW(IKernel::window(), window); |
| 427 | |
Georgios Pinitas | 1599787 | 2018-02-19 13:58:22 +0000 | [diff] [blame] | 428 | unsigned int pool_stride_x = 0; |
| 429 | unsigned int pool_stride_y = 0; |
Sang-Hoon Park | 0cb3da6 | 2020-01-15 12:39:56 +0000 | [diff] [blame] | 430 | std::tie(pool_stride_x, pool_stride_y) = _pool_info.pad_stride_info.stride(); |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 431 | |
Georgios Pinitas | 89d7173 | 2018-10-29 20:07:15 +0000 | [diff] [blame] | 432 | // Collapse window |
| 433 | Window window_collapsed = window.collapse_if_possible(ICLKernel::window(), Window::DimZ); |
| 434 | |
Georgios Pinitas | 14d9d98 | 2019-12-13 12:33:09 +0000 | [diff] [blame] | 435 | switch(_data_layout) |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 436 | { |
Michalis Spyrou | e74b201 | 2018-04-18 09:49:16 +0100 | [diff] [blame] | 437 | case DataLayout::NCHW: |
| 438 | { |
Georgios Pinitas | 89d7173 | 2018-10-29 20:07:15 +0000 | [diff] [blame] | 439 | Window slice = window_collapsed.first_slice_window_3D(); |
Michalis Spyrou | e74b201 | 2018-04-18 09:49:16 +0100 | [diff] [blame] | 440 | do |
| 441 | { |
| 442 | // Upsample input by pool size |
| 443 | Window in_slice(slice); |
Sang-Hoon Park | 0cb3da6 | 2020-01-15 12:39:56 +0000 | [diff] [blame] | 444 | in_slice.set(Window::DimX, Window::Dimension(in_slice.x().start() - _pool_info.pad_stride_info.pad_left(), |
| 445 | (in_slice.x().end() - _pool_info.pad_stride_info.pad_left()) * pool_stride_x, |
Michalis Spyrou | e74b201 | 2018-04-18 09:49:16 +0100 | [diff] [blame] | 446 | pool_stride_x * _num_elems_processed_per_iteration)); |
Sang-Hoon Park | 0cb3da6 | 2020-01-15 12:39:56 +0000 | [diff] [blame] | 447 | in_slice.set(Window::DimY, Window::Dimension(in_slice.y().start() - _pool_info.pad_stride_info.pad_top(), |
| 448 | (in_slice.y().end() - _pool_info.pad_stride_info.pad_top()) * pool_stride_y, |
Michalis Spyrou | e74b201 | 2018-04-18 09:49:16 +0100 | [diff] [blame] | 449 | pool_stride_y)); |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 450 | |
Michalis Spyrou | e74b201 | 2018-04-18 09:49:16 +0100 | [diff] [blame] | 451 | // Set inputs |
| 452 | unsigned int idx = 0; |
| 453 | add_3D_tensor_argument(idx, _input, in_slice); |
| 454 | add_3D_tensor_argument(idx, _output, slice); |
Sheri Zhang | 801bbcb | 2020-08-03 20:11:56 +0100 | [diff] [blame^] | 455 | if(_indices && is_data_type_float(_input->info()->data_type()) && (_pool_info.pool_type == PoolingType::MAX) && (_pool_info.pool_size == Size2D(2, 2))) |
| 456 | { |
| 457 | add_3D_tensor_argument(idx, _indices, slice); |
| 458 | } |
Anthony Barbier | b6eb353 | 2018-08-08 13:20:04 +0100 | [diff] [blame] | 459 | enqueue(queue, *this, slice, lws_hint()); |
Michalis Spyrou | e74b201 | 2018-04-18 09:49:16 +0100 | [diff] [blame] | 460 | } |
| 461 | while(window_collapsed.slide_window_slice_3D(slice)); |
| 462 | break; |
| 463 | } |
| 464 | case DataLayout::NHWC: |
| 465 | { |
Georgios Pinitas | 89d7173 | 2018-10-29 20:07:15 +0000 | [diff] [blame] | 466 | const size_t total_batches = _output->info()->tensor_shape().total_size_upper(3); |
Michalis Spyrou | e74b201 | 2018-04-18 09:49:16 +0100 | [diff] [blame] | 467 | |
Georgios Pinitas | 89d7173 | 2018-10-29 20:07:15 +0000 | [diff] [blame] | 468 | Window slice = window_collapsed.first_slice_window_4D(); |
| 469 | Window in_slice = window_collapsed.first_slice_window_4D(); |
Michalis Spyrou | e74b201 | 2018-04-18 09:49:16 +0100 | [diff] [blame] | 470 | in_slice.set(Window::DimX, Window::Dimension(0, _input->info()->dimension(0), _num_elems_processed_per_iteration)); |
| 471 | in_slice.set(Window::DimY, Window::Dimension(0, _input->info()->dimension(1), pool_stride_x)); |
| 472 | in_slice.set(Window::DimZ, Window::Dimension(0, _input->info()->dimension(2), pool_stride_y)); |
Georgios Pinitas | 89d7173 | 2018-10-29 20:07:15 +0000 | [diff] [blame] | 473 | in_slice.set(3, Window::Dimension(0, total_batches, 1)); |
Michalis Spyrou | e74b201 | 2018-04-18 09:49:16 +0100 | [diff] [blame] | 474 | do |
| 475 | { |
| 476 | // Set inputs |
| 477 | unsigned int idx = 0; |
Georgios Pinitas | 89d7173 | 2018-10-29 20:07:15 +0000 | [diff] [blame] | 478 | add_4D_tensor_argument(idx, _input, in_slice); |
| 479 | add_4D_tensor_argument(idx, _output, slice); |
Sheri Zhang | 801bbcb | 2020-08-03 20:11:56 +0100 | [diff] [blame^] | 480 | if(_indices && is_data_type_float(_input->info()->data_type()) && (_pool_info.pool_type == PoolingType::MAX) && (_pool_info.pool_size == Size2D(2, 2))) |
| 481 | { |
| 482 | add_4D_tensor_argument(idx, _indices, slice); |
| 483 | } |
Anthony Barbier | b6eb353 | 2018-08-08 13:20:04 +0100 | [diff] [blame] | 484 | enqueue(queue, *this, slice, lws_hint()); |
Michalis Spyrou | e74b201 | 2018-04-18 09:49:16 +0100 | [diff] [blame] | 485 | } |
Georgios Pinitas | 89d7173 | 2018-10-29 20:07:15 +0000 | [diff] [blame] | 486 | while(window.slide_window_slice_4D(slice) && window.slide_window_slice_4D(in_slice)); |
Michalis Spyrou | e74b201 | 2018-04-18 09:49:16 +0100 | [diff] [blame] | 487 | break; |
| 488 | } |
| 489 | default: |
| 490 | ARM_COMPUTE_ERROR("Not implemented"); |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 491 | } |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 492 | } |
Michele Di Giorgio | cbbed28 | 2019-12-20 13:26:08 +0000 | [diff] [blame] | 493 | } // namespace arm_compute |