| 185 | } |
| 186 | |
| 187 | void NEPadLayer::configure(ITensor *input, |
| 188 | ITensor *output, |
| 189 | const PaddingList &padding, |
| 190 | const PixelValue constant_value, |
| 191 | const PaddingMode mode) |
| 192 | { |
| 193 | ARM_COMPUTE_TRACE_EVENT(ARM_COMPUTE_PROF_CAT_CPU, ARM_COMPUTE_PROF_LVL_CPU, "NEPadLayer::configure"); |
| 194 | ARM_COMPUTE_ERROR_THROW_ON(validate(input->info(), output->info(), padding, constant_value, mode)); |
| 195 | ARM_COMPUTE_LOG_PARAMS(input, output, padding, constant_value, mode); |
| 196 | |
| 197 | _padding = padding; |
| 198 | _mode = mode; |
| 199 | |
| 200 | const TensorShape padded_shape = |
| 201 | misc::shape_calculator::compute_padded_shape(input->info()->tensor_shape(), _padding); |
| 202 | |
| 203 | auto_init_if_empty(*output->info(), input->info()->clone()->set_tensor_shape(padded_shape)); |
| 204 | |
| 205 | // Find the last dimension requiring padding so that it is known when to write to output and whether any padding is applied. |
| 206 | _num_dimensions = last_padding_dimension(padding) + 1; |
| 207 | if (_num_dimensions > 0) |
| 208 | { |
| 209 | switch (_mode) |
| 210 | { |
| 211 | case PaddingMode::CONSTANT: |
| 212 | { |
| 213 | configure_constant_mode(input, output, padding, constant_value); |
| 214 | break; |
| 215 | } |
| 216 | case PaddingMode::REFLECT: |
| 217 | case PaddingMode::SYMMETRIC: |
| 218 | { |
| 219 | configure_reflect_symmetric_mode(input, output); |
| 220 | break; |
| 221 | } |
| 222 | default: |
| 223 | ARM_COMPUTE_ERROR("Padding mode not supported."); |
| 224 | } |
| 225 | } |
| 226 | else |
| 227 | { |
| 228 | // Copy the input to the whole output if no padding is applied |
| 229 | _copy_function.configure(input, output); |
| 230 | } |
| 231 | } |
| 232 | |
| 233 | Status NEPadLayer::validate(const ITensorInfo *input, |
| 234 | const ITensorInfo *output, |
no test coverage detected