Georgios Pinitas | dea2d2d | 2018-12-19 16:23:17 +0000 | [diff] [blame] | 1 | /* |
Georgios Pinitas | 0f7ef8a | 2021-01-10 04:23:52 +0000 | [diff] [blame] | 2 | * Copyright (c) 2018-2021 Arm Limited. |
Georgios Pinitas | dea2d2d | 2018-12-19 16:23:17 +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 | #include "arm_compute/runtime/NEON/functions/NEPadLayer.h" |
| 25 | |
Georgios Pinitas | dea2d2d | 2018-12-19 16:23:17 +0000 | [diff] [blame] | 26 | #include "arm_compute/core/Types.h" |
| 27 | #include "arm_compute/core/utils/misc/ShapeCalculator.h" |
Felix Thomasmathibalan | afd38f0 | 2023-09-27 17:46:17 +0100 | [diff] [blame] | 28 | #include "arm_compute/runtime/NEON/NEScheduler.h" |
| 29 | |
ramelg01 | cbbb038 | 2021-09-17 17:36:57 +0100 | [diff] [blame] | 30 | #include "src/common/utils/Log.h" |
Sang-Hoon Park | 68dd25f | 2020-10-19 16:00:11 +0100 | [diff] [blame] | 31 | #include "src/core/helpers/AutoConfiguration.h" |
Felix Thomasmathibalan | afd38f0 | 2023-09-27 17:46:17 +0100 | [diff] [blame] | 32 | #include "src/core/NEON/kernels/NEPadLayerKernel.h" |
Georgios Pinitas | dea2d2d | 2018-12-19 16:23:17 +0000 | [diff] [blame] | 33 | |
Georgios Pinitas | dea2d2d | 2018-12-19 16:23:17 +0000 | [diff] [blame] | 34 | namespace arm_compute |
| 35 | { |
| 36 | namespace |
| 37 | { |
Usama Arif | 8cf8c11 | 2019-03-14 15:36:54 +0000 | [diff] [blame] | 38 | uint32_t last_padding_dimension(const PaddingList &padding) |
| 39 | { |
| 40 | int last_padding_dim = padding.size() - 1; |
Felix Thomasmathibalan | afd38f0 | 2023-09-27 17:46:17 +0100 | [diff] [blame] | 41 | for (; last_padding_dim >= 0; --last_padding_dim) |
Usama Arif | 8cf8c11 | 2019-03-14 15:36:54 +0000 | [diff] [blame] | 42 | { |
Felix Thomasmathibalan | afd38f0 | 2023-09-27 17:46:17 +0100 | [diff] [blame] | 43 | if (padding[last_padding_dim].first > 0 || padding[last_padding_dim].second > 0) |
Usama Arif | 8cf8c11 | 2019-03-14 15:36:54 +0000 | [diff] [blame] | 44 | { |
| 45 | break; |
| 46 | } |
| 47 | } |
| 48 | return static_cast<uint32_t>(last_padding_dim); |
| 49 | } |
Georgios Pinitas | dea2d2d | 2018-12-19 16:23:17 +0000 | [diff] [blame] | 50 | } // namespace |
| 51 | |
Michalis Spyrou | ebcebf1 | 2020-10-21 00:04:14 +0100 | [diff] [blame] | 52 | NEPadLayer::~NEPadLayer() = default; |
| 53 | |
Georgios Pinitas | dea2d2d | 2018-12-19 16:23:17 +0000 | [diff] [blame] | 54 | NEPadLayer::NEPadLayer() |
Felix Thomasmathibalan | afd38f0 | 2023-09-27 17:46:17 +0100 | [diff] [blame] | 55 | : _copy_function(), |
| 56 | _pad_kernel(), |
| 57 | _mode(), |
| 58 | _padding(), |
| 59 | _num_dimensions(0), |
| 60 | _slice_functions(), |
| 61 | _concat_functions(), |
| 62 | _slice_results(), |
| 63 | _concat_results() |
Georgios Pinitas | dea2d2d | 2018-12-19 16:23:17 +0000 | [diff] [blame] | 64 | { |
| 65 | } |
| 66 | |
Felix Thomasmathibalan | afd38f0 | 2023-09-27 17:46:17 +0100 | [diff] [blame] | 67 | void NEPadLayer::configure_constant_mode(ITensor *input, |
| 68 | ITensor *output, |
| 69 | const PaddingList &padding, |
| 70 | const PixelValue constant_value) |
Georgios Pinitas | dea2d2d | 2018-12-19 16:23:17 +0000 | [diff] [blame] | 71 | { |
Georgios Pinitas | 40f51a6 | 2020-11-21 03:04:18 +0000 | [diff] [blame] | 72 | _pad_kernel = std::make_unique<NEPadLayerKernel>(); |
Michalis Spyrou | ebcebf1 | 2020-10-21 00:04:14 +0100 | [diff] [blame] | 73 | _pad_kernel->configure(input, output, padding, constant_value, PaddingMode::CONSTANT); |
Georgios Pinitas | dea2d2d | 2018-12-19 16:23:17 +0000 | [diff] [blame] | 74 | } |
| 75 | |
Usama Arif | 8cf8c11 | 2019-03-14 15:36:54 +0000 | [diff] [blame] | 76 | void NEPadLayer::configure_reflect_symmetric_mode(ITensor *input, ITensor *output) |
| 77 | { |
| 78 | // Reflecting can be performed by effectively unfolding the input as follows: |
| 79 | // For each dimension starting at DimX: |
| 80 | // For before and after: |
| 81 | // Use strided slice to extract and reverse the part of the |
| 82 | // input / previously produced tensor required for the padding. |
| 83 | // Concatenate the before and after padding with the input / previously |
| 84 | // produced tensor along the current dimension. |
| 85 | |
| 86 | // Two strided slice functions will be required for each dimension padded as well as a |
| 87 | // concatenate function and the tensors to hold the temporary results. |
Michalis Spyrou | bcfd09a | 2019-05-01 13:03:59 +0100 | [diff] [blame] | 88 | _slice_functions.resize(2 * _num_dimensions); |
| 89 | _slice_results.resize(2 * _num_dimensions); |
| 90 | _concat_functions.resize(_num_dimensions); |
| 91 | _concat_results.resize(_num_dimensions - 1); |
| 92 | |
| 93 | Coordinates starts_before{}; |
| 94 | Coordinates ends_before{}; |
| 95 | Coordinates starts_after{}; |
| 96 | Coordinates ends_after{}; |
| 97 | Coordinates strides{}; |
Usama Arif | 8cf8c11 | 2019-03-14 15:36:54 +0000 | [diff] [blame] | 98 | ITensor *prev = input; |
Felix Thomasmathibalan | afd38f0 | 2023-09-27 17:46:17 +0100 | [diff] [blame] | 99 | for (uint32_t i = 0; i < _num_dimensions; ++i) |
Usama Arif | 8cf8c11 | 2019-03-14 15:36:54 +0000 | [diff] [blame] | 100 | { |
| 101 | // Values in strides from the previous dimensions need to be set to 1 to avoid reversing again. |
Felix Thomasmathibalan | afd38f0 | 2023-09-27 17:46:17 +0100 | [diff] [blame] | 102 | if (i > 0) |
Usama Arif | 8cf8c11 | 2019-03-14 15:36:54 +0000 | [diff] [blame] | 103 | { |
| 104 | strides.set(i - 1, 1); |
| 105 | } |
| 106 | |
Felix Thomasmathibalan | afd38f0 | 2023-09-27 17:46:17 +0100 | [diff] [blame] | 107 | if (_padding[i].first > 0 || _padding[i].second > 0) |
Usama Arif | 8cf8c11 | 2019-03-14 15:36:54 +0000 | [diff] [blame] | 108 | { |
| 109 | // Set the starts, ends, and strides values for the current dimension. |
| 110 | // Due to the bit masks passed to strided slice, the values below the current dimension in |
| 111 | // starts and ends will be ignored so do not need to be modified. |
Felix Thomasmathibalan | afd38f0 | 2023-09-27 17:46:17 +0100 | [diff] [blame] | 112 | if (_mode == PaddingMode::REFLECT) |
Usama Arif | 8cf8c11 | 2019-03-14 15:36:54 +0000 | [diff] [blame] | 113 | { |
| 114 | starts_before.set(i, _padding[i].first); |
| 115 | ends_before.set(i, 0); |
| 116 | starts_after.set(i, input->info()->dimension(i) - 2); |
| 117 | ends_after.set(i, input->info()->dimension(i) - _padding[i].second - 2); |
| 118 | strides.set(i, -1); |
| 119 | } |
| 120 | else |
| 121 | { |
| 122 | starts_before.set(i, _padding[i].first - 1); |
| 123 | ends_before.set(i, -1); |
| 124 | starts_after.set(i, input->info()->dimension(i) - 1); |
| 125 | ends_after.set(i, input->info()->dimension(i) - _padding[i].second - 1); |
| 126 | strides.set(i, -1); |
| 127 | } |
| 128 | |
| 129 | // Strided slice wraps negative indexes around to the end of the range, |
| 130 | // instead this should indicate use of the full range and so the bit mask will be modified. |
| 131 | const int32_t begin_mask_before = starts_before[i] < 0 ? ~0 : ~(1u << i); |
| 132 | const int32_t end_mask_before = ends_before[i] < 0 ? ~0 : ~(1u << i); |
| 133 | const int32_t begin_mask_after = starts_after[i] < 0 ? ~0 : ~(1u << i); |
| 134 | const int32_t end_mask_after = ends_after[i] < 0 ? ~0 : ~(1u << i); |
| 135 | |
| 136 | // Reflect the input values for the padding before and after the input. |
Georgios Pinitas | 4667ddd | 2020-07-13 21:21:33 +0100 | [diff] [blame] | 137 | std::vector<const ITensor *> concat_vector; |
Felix Thomasmathibalan | afd38f0 | 2023-09-27 17:46:17 +0100 | [diff] [blame] | 138 | if (_padding[i].first > 0) |
Usama Arif | 8cf8c11 | 2019-03-14 15:36:54 +0000 | [diff] [blame] | 139 | { |
Felix Thomasmathibalan | afd38f0 | 2023-09-27 17:46:17 +0100 | [diff] [blame] | 140 | if (i < prev->info()->num_dimensions()) |
Usama Arif | 8cf8c11 | 2019-03-14 15:36:54 +0000 | [diff] [blame] | 141 | { |
Felix Thomasmathibalan | afd38f0 | 2023-09-27 17:46:17 +0100 | [diff] [blame] | 142 | _slice_functions[2 * i].configure(prev, &_slice_results[2 * i], starts_before, ends_before, strides, |
| 143 | begin_mask_before, end_mask_before); |
Michalis Spyrou | bcfd09a | 2019-05-01 13:03:59 +0100 | [diff] [blame] | 144 | concat_vector.emplace_back(&_slice_results[2 * i]); |
Usama Arif | 8cf8c11 | 2019-03-14 15:36:54 +0000 | [diff] [blame] | 145 | } |
| 146 | else |
| 147 | { |
| 148 | // Performing the slice is unnecessary if the result would simply be a copy of the tensor. |
| 149 | concat_vector.push_back(prev); |
| 150 | } |
| 151 | } |
| 152 | concat_vector.push_back(prev); |
Felix Thomasmathibalan | afd38f0 | 2023-09-27 17:46:17 +0100 | [diff] [blame] | 153 | if (_padding[i].second > 0) |
Usama Arif | 8cf8c11 | 2019-03-14 15:36:54 +0000 | [diff] [blame] | 154 | { |
Felix Thomasmathibalan | afd38f0 | 2023-09-27 17:46:17 +0100 | [diff] [blame] | 155 | if (i < prev->info()->num_dimensions()) |
Usama Arif | 8cf8c11 | 2019-03-14 15:36:54 +0000 | [diff] [blame] | 156 | { |
Felix Thomasmathibalan | afd38f0 | 2023-09-27 17:46:17 +0100 | [diff] [blame] | 157 | _slice_functions[2 * i + 1].configure(prev, &_slice_results[2 * i + 1], starts_after, ends_after, |
| 158 | strides, begin_mask_after, end_mask_after); |
Michalis Spyrou | bcfd09a | 2019-05-01 13:03:59 +0100 | [diff] [blame] | 159 | concat_vector.emplace_back(&_slice_results[2 * i + 1]); |
Usama Arif | 8cf8c11 | 2019-03-14 15:36:54 +0000 | [diff] [blame] | 160 | } |
| 161 | else |
| 162 | { |
| 163 | // Performing the slice is unnecessary if the result would simply be a copy of the tensor. |
| 164 | concat_vector.push_back(prev); |
| 165 | } |
| 166 | } |
| 167 | // Concatenate the padding before and after with the input. |
| 168 | ITensor *out = (i == _num_dimensions - 1) ? output : &_concat_results[i]; |
Pablo Marquez Tello | e7a5b0e | 2021-11-10 15:41:57 +0000 | [diff] [blame] | 169 | out->info()->set_quantization_info(output->info()->quantization_info()); |
Felix Thomasmathibalan | afd38f0 | 2023-09-27 17:46:17 +0100 | [diff] [blame] | 170 | for (auto &v : concat_vector) |
Pablo Marquez Tello | e7a5b0e | 2021-11-10 15:41:57 +0000 | [diff] [blame] | 171 | { |
| 172 | v->info()->set_quantization_info(input->info()->quantization_info()); |
| 173 | } |
Georgios Pinitas | 9e4824c | 2019-04-12 13:15:58 +0100 | [diff] [blame] | 174 | _concat_functions[i].configure(concat_vector, out, i); |
Felix Thomasmathibalan | afd38f0 | 2023-09-27 17:46:17 +0100 | [diff] [blame] | 175 | if (i != _num_dimensions - 1) |
Usama Arif | 8cf8c11 | 2019-03-14 15:36:54 +0000 | [diff] [blame] | 176 | { |
| 177 | _concat_results[i].allocator()->allocate(); |
| 178 | } |
| 179 | prev = out; |
| 180 | } |
| 181 | _slice_results[2 * i].allocator()->allocate(); |
| 182 | _slice_results[2 * i + 1].allocator()->allocate(); |
| 183 | } |
| 184 | } |
| 185 | |
Felix Thomasmathibalan | afd38f0 | 2023-09-27 17:46:17 +0100 | [diff] [blame] | 186 | void NEPadLayer::configure(ITensor *input, |
| 187 | ITensor *output, |
| 188 | const PaddingList &padding, |
| 189 | const PixelValue constant_value, |
| 190 | const PaddingMode mode) |
Usama Arif | 8cf8c11 | 2019-03-14 15:36:54 +0000 | [diff] [blame] | 191 | { |
| 192 | ARM_COMPUTE_ERROR_THROW_ON(validate(input->info(), output->info(), padding, constant_value, mode)); |
ramelg01 | cbbb038 | 2021-09-17 17:36:57 +0100 | [diff] [blame] | 193 | ARM_COMPUTE_LOG_PARAMS(input, output, padding, constant_value, mode); |
Usama Arif | 8cf8c11 | 2019-03-14 15:36:54 +0000 | [diff] [blame] | 194 | |
| 195 | _padding = padding; |
| 196 | _mode = mode; |
| 197 | |
Felix Thomasmathibalan | afd38f0 | 2023-09-27 17:46:17 +0100 | [diff] [blame] | 198 | const TensorShape padded_shape = |
| 199 | misc::shape_calculator::compute_padded_shape(input->info()->tensor_shape(), _padding); |
Usama Arif | 8cf8c11 | 2019-03-14 15:36:54 +0000 | [diff] [blame] | 200 | |
| 201 | auto_init_if_empty(*output->info(), input->info()->clone()->set_tensor_shape(padded_shape)); |
| 202 | |
| 203 | // Find the last dimension requiring padding so that it is known when to write to output and whether any padding is applied. |
| 204 | _num_dimensions = last_padding_dimension(padding) + 1; |
Felix Thomasmathibalan | afd38f0 | 2023-09-27 17:46:17 +0100 | [diff] [blame] | 205 | if (_num_dimensions > 0) |
Usama Arif | 8cf8c11 | 2019-03-14 15:36:54 +0000 | [diff] [blame] | 206 | { |
Felix Thomasmathibalan | afd38f0 | 2023-09-27 17:46:17 +0100 | [diff] [blame] | 207 | switch (_mode) |
Usama Arif | 8cf8c11 | 2019-03-14 15:36:54 +0000 | [diff] [blame] | 208 | { |
| 209 | case PaddingMode::CONSTANT: |
| 210 | { |
| 211 | configure_constant_mode(input, output, padding, constant_value); |
| 212 | break; |
| 213 | } |
| 214 | case PaddingMode::REFLECT: |
| 215 | case PaddingMode::SYMMETRIC: |
| 216 | { |
| 217 | configure_reflect_symmetric_mode(input, output); |
| 218 | break; |
| 219 | } |
| 220 | default: |
| 221 | ARM_COMPUTE_ERROR("Padding mode not supported."); |
| 222 | } |
| 223 | } |
| 224 | else |
| 225 | { |
| 226 | // Copy the input to the whole output if no padding is applied |
Georgios Pinitas | 0f7ef8a | 2021-01-10 04:23:52 +0000 | [diff] [blame] | 227 | _copy_function.configure(input, output); |
Usama Arif | 8cf8c11 | 2019-03-14 15:36:54 +0000 | [diff] [blame] | 228 | } |
| 229 | } |
| 230 | |
Felix Thomasmathibalan | afd38f0 | 2023-09-27 17:46:17 +0100 | [diff] [blame] | 231 | Status NEPadLayer::validate(const ITensorInfo *input, |
| 232 | const ITensorInfo *output, |
| 233 | const PaddingList &padding, |
| 234 | const PixelValue constant_value, |
| 235 | const PaddingMode mode) |
Georgios Pinitas | dea2d2d | 2018-12-19 16:23:17 +0000 | [diff] [blame] | 236 | { |
| 237 | ARM_COMPUTE_UNUSED(constant_value); |
Georgios Pinitas | dea2d2d | 2018-12-19 16:23:17 +0000 | [diff] [blame] | 238 | |
Usama Arif | 8cf8c11 | 2019-03-14 15:36:54 +0000 | [diff] [blame] | 239 | const TensorShape padded_shape = misc::shape_calculator::compute_padded_shape(input->tensor_shape(), padding); |
Georgios Pinitas | dea2d2d | 2018-12-19 16:23:17 +0000 | [diff] [blame] | 240 | |
Felix Thomasmathibalan | afd38f0 | 2023-09-27 17:46:17 +0100 | [diff] [blame] | 241 | if (output->total_size() > 0) |
Usama Arif | 8cf8c11 | 2019-03-14 15:36:54 +0000 | [diff] [blame] | 242 | { |
| 243 | ARM_COMPUTE_RETURN_ERROR_ON_MISMATCHING_DIMENSIONS(output->tensor_shape(), padded_shape); |
| 244 | ARM_COMPUTE_RETURN_ERROR_ON_MISMATCHING_DATA_TYPES(input, output); |
| 245 | } |
Georgios Pinitas | dea2d2d | 2018-12-19 16:23:17 +0000 | [diff] [blame] | 246 | |
Felix Thomasmathibalan | afd38f0 | 2023-09-27 17:46:17 +0100 | [diff] [blame] | 247 | switch (mode) |
Usama Arif | 8cf8c11 | 2019-03-14 15:36:54 +0000 | [diff] [blame] | 248 | { |
| 249 | case PaddingMode::CONSTANT: |
| 250 | { |
Manuel Bottini | 9032ee3 | 2019-08-07 17:04:11 +0100 | [diff] [blame] | 251 | return NEPadLayerKernel::validate(input, output, padding, constant_value, mode); |
Usama Arif | 8cf8c11 | 2019-03-14 15:36:54 +0000 | [diff] [blame] | 252 | } |
| 253 | case PaddingMode::REFLECT: |
| 254 | case PaddingMode::SYMMETRIC: |
| 255 | { |
Felix Thomasmathibalan | afd38f0 | 2023-09-27 17:46:17 +0100 | [diff] [blame] | 256 | for (uint32_t i = 0; i < padding.size(); ++i) |
Usama Arif | 8cf8c11 | 2019-03-14 15:36:54 +0000 | [diff] [blame] | 257 | { |
Felix Thomasmathibalan | afd38f0 | 2023-09-27 17:46:17 +0100 | [diff] [blame] | 258 | if (mode == PaddingMode::REFLECT) |
Usama Arif | 8cf8c11 | 2019-03-14 15:36:54 +0000 | [diff] [blame] | 259 | { |
| 260 | ARM_COMPUTE_RETURN_ERROR_ON(padding[i].first >= input->dimension(i)); |
| 261 | ARM_COMPUTE_RETURN_ERROR_ON(padding[i].second >= input->dimension(i)); |
| 262 | } |
| 263 | else |
| 264 | { |
| 265 | ARM_COMPUTE_RETURN_ERROR_ON(padding[i].first > input->dimension(i)); |
| 266 | ARM_COMPUTE_RETURN_ERROR_ON(padding[i].second > input->dimension(i)); |
| 267 | } |
| 268 | } |
| 269 | break; |
| 270 | } |
| 271 | default: |
| 272 | { |
| 273 | ARM_COMPUTE_ERROR("Invalid mode"); |
| 274 | } |
| 275 | } |
Georgios Pinitas | dea2d2d | 2018-12-19 16:23:17 +0000 | [diff] [blame] | 276 | return Status{}; |
| 277 | } |
| 278 | |
| 279 | void NEPadLayer::run() |
| 280 | { |
Felix Thomasmathibalan | afd38f0 | 2023-09-27 17:46:17 +0100 | [diff] [blame] | 281 | if (_num_dimensions > 0) |
Usama Arif | 8cf8c11 | 2019-03-14 15:36:54 +0000 | [diff] [blame] | 282 | { |
Felix Thomasmathibalan | afd38f0 | 2023-09-27 17:46:17 +0100 | [diff] [blame] | 283 | switch (_mode) |
Usama Arif | 8cf8c11 | 2019-03-14 15:36:54 +0000 | [diff] [blame] | 284 | { |
| 285 | case PaddingMode::CONSTANT: |
| 286 | { |
Michalis Spyrou | ebcebf1 | 2020-10-21 00:04:14 +0100 | [diff] [blame] | 287 | NEScheduler::get().schedule(_pad_kernel.get(), Window::DimZ); |
Usama Arif | 8cf8c11 | 2019-03-14 15:36:54 +0000 | [diff] [blame] | 288 | break; |
| 289 | } |
| 290 | case PaddingMode::REFLECT: |
| 291 | case PaddingMode::SYMMETRIC: |
| 292 | { |
Felix Thomasmathibalan | afd38f0 | 2023-09-27 17:46:17 +0100 | [diff] [blame] | 293 | for (uint32_t i = 0; i < _num_dimensions; ++i) |
Usama Arif | 8cf8c11 | 2019-03-14 15:36:54 +0000 | [diff] [blame] | 294 | { |
Felix Thomasmathibalan | afd38f0 | 2023-09-27 17:46:17 +0100 | [diff] [blame] | 295 | if (_padding[i].first > 0 || _padding[i].second > 0) |
Usama Arif | 8cf8c11 | 2019-03-14 15:36:54 +0000 | [diff] [blame] | 296 | { |
Felix Thomasmathibalan | afd38f0 | 2023-09-27 17:46:17 +0100 | [diff] [blame] | 297 | if (_padding[i].first > 0 && _slice_results[2 * i].info()->total_size() > 0) |
Usama Arif | 8cf8c11 | 2019-03-14 15:36:54 +0000 | [diff] [blame] | 298 | { |
| 299 | _slice_functions[2 * i].run(); |
| 300 | } |
Felix Thomasmathibalan | afd38f0 | 2023-09-27 17:46:17 +0100 | [diff] [blame] | 301 | if (_padding[i].second > 0 && _slice_results[2 * i + 1].info()->total_size() > 0) |
Usama Arif | 8cf8c11 | 2019-03-14 15:36:54 +0000 | [diff] [blame] | 302 | { |
| 303 | _slice_functions[2 * i + 1].run(); |
| 304 | } |
| 305 | _concat_functions[i].run(); |
| 306 | } |
| 307 | } |
| 308 | break; |
| 309 | } |
| 310 | default: |
| 311 | ARM_COMPUTE_ERROR("Padding mode not supported."); |
| 312 | } |
| 313 | } |
| 314 | else |
| 315 | { |
Georgios Pinitas | 0f7ef8a | 2021-01-10 04:23:52 +0000 | [diff] [blame] | 316 | _copy_function.run(); |
Usama Arif | 8cf8c11 | 2019-03-14 15:36:54 +0000 | [diff] [blame] | 317 | } |
Georgios Pinitas | dea2d2d | 2018-12-19 16:23:17 +0000 | [diff] [blame] | 318 | } |
| 319 | } // namespace arm_compute |