Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 1 | /* |
Vidhya Sudhan Loganathan | 7485d5a | 2018-07-04 09:34:00 +0100 | [diff] [blame] | 2 | * Copyright (c) 2017-2018 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/NEON/kernels/NENormalizationLayerKernel.h" |
| 25 | |
Georgios Pinitas | 7f32d01 | 2018-10-11 18:41:19 +0100 | [diff] [blame] | 26 | #include "arm_compute/core/AccessWindowStatic.h" |
Anthony Barbier | eaefd00 | 2018-07-20 17:49:35 +0100 | [diff] [blame] | 27 | #include "arm_compute/core/CPP/Validate.h" |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 28 | #include "arm_compute/core/Error.h" |
| 29 | #include "arm_compute/core/Helpers.h" |
| 30 | #include "arm_compute/core/NEON/NEFixedPoint.h" |
| 31 | #include "arm_compute/core/NEON/NEMath.h" |
Michalis Spyrou | 0c71d0b | 2018-11-22 11:22:18 +0000 | [diff] [blame] | 32 | #include "arm_compute/core/NEON/wrapper/wrapper.h" |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 33 | #include "arm_compute/core/TensorInfo.h" |
| 34 | #include "arm_compute/core/Utils.h" |
| 35 | #include "arm_compute/core/Validate.h" |
| 36 | #include "arm_compute/core/Window.h" |
| 37 | |
| 38 | using namespace arm_compute; |
| 39 | |
Michalis Spyrou | afa5d81 | 2017-11-30 14:25:57 +0000 | [diff] [blame] | 40 | namespace |
| 41 | { |
| 42 | Status validate_arguments(const ITensorInfo *input, const ITensorInfo *input_squared, const ITensorInfo *output, const NormalizationLayerInfo &norm_info) |
| 43 | { |
| 44 | ARM_COMPUTE_RETURN_ERROR_ON_NULLPTR(input, input_squared, output); |
Anthony Barbier | eaefd00 | 2018-07-20 17:49:35 +0100 | [diff] [blame] | 45 | ARM_COMPUTE_RETURN_ERROR_ON_CPU_F16_UNSUPPORTED(input); |
Vidhya Sudhan Loganathan | 7485d5a | 2018-07-04 09:34:00 +0100 | [diff] [blame] | 46 | ARM_COMPUTE_RETURN_ERROR_ON_DATA_TYPE_CHANNEL_NOT_IN(input, 1, DataType::F16, DataType::F32); |
Michalis Spyrou | afa5d81 | 2017-11-30 14:25:57 +0000 | [diff] [blame] | 47 | |
| 48 | ARM_COMPUTE_RETURN_ERROR_ON_MISMATCHING_DATA_TYPES(input, input_squared); |
| 49 | ARM_COMPUTE_RETURN_ERROR_ON_MISMATCHING_SHAPES(input, input_squared); |
| 50 | ARM_COMPUTE_RETURN_ERROR_ON_MSG(!(norm_info.norm_size() % 2), "Normalization size should be odd"); |
| 51 | |
Michalis Spyrou | afa5d81 | 2017-11-30 14:25:57 +0000 | [diff] [blame] | 52 | // Checks performed when output is configured |
| 53 | if(output->total_size() != 0) |
| 54 | { |
| 55 | ARM_COMPUTE_RETURN_ERROR_ON_MISMATCHING_DATA_TYPES(input, output); |
| 56 | ARM_COMPUTE_RETURN_ERROR_ON_MISMATCHING_SHAPES(input, output); |
Michalis Spyrou | 0c71d0b | 2018-11-22 11:22:18 +0000 | [diff] [blame] | 57 | ARM_COMPUTE_RETURN_ERROR_ON_MISMATCHING_DATA_LAYOUT(input, output); |
Michalis Spyrou | afa5d81 | 2017-11-30 14:25:57 +0000 | [diff] [blame] | 58 | } |
| 59 | |
| 60 | return Status{}; |
| 61 | } |
| 62 | |
| 63 | std::pair<Status, Window> validate_and_configure_window(ITensorInfo *input, ITensorInfo *input_squared, ITensorInfo *output, const NormalizationLayerInfo &norm_info) |
| 64 | { |
Georgios Pinitas | 7f32d01 | 2018-10-11 18:41:19 +0100 | [diff] [blame] | 65 | // Output tensor auto initialization if not yet initialized |
| 66 | auto_init_if_empty(*output, *input->clone()); |
| 67 | |
| 68 | const unsigned int num_elems_processed_per_iteration = 16 / input->element_size(); |
| 69 | |
| 70 | const unsigned int norm_idx = get_normalization_dimension_index(input->data_layout(), norm_info); |
| 71 | const bool is_norm_accross_width = norm_idx == 0; |
| 72 | |
| 73 | const unsigned int border_width = is_norm_accross_width ? num_elems_processed_per_iteration - 1 : 0; |
| 74 | const BorderSize border_size = BorderSize(0, border_width); |
Michalis Spyrou | afa5d81 | 2017-11-30 14:25:57 +0000 | [diff] [blame] | 75 | |
| 76 | // Configure window |
Georgios Pinitas | 7f32d01 | 2018-10-11 18:41:19 +0100 | [diff] [blame] | 77 | Window win = calculate_max_window(*input, Steps(num_elems_processed_per_iteration)); |
| 78 | bool window_changed = false; |
Michalis Spyrou | afa5d81 | 2017-11-30 14:25:57 +0000 | [diff] [blame] | 79 | |
Georgios Pinitas | 7f32d01 | 2018-10-11 18:41:19 +0100 | [diff] [blame] | 80 | if(is_norm_accross_width) |
| 81 | { |
| 82 | AccessWindowStatic input_access(input, -border_size.left, 0, input->dimension(0) + border_size.right, 0); |
| 83 | AccessWindowStatic input_squared_access(input_squared, -border_size.left, 0, input->dimension(0) + border_size.right, 0); |
| 84 | window_changed = window_changed || update_window_and_padding(win, input_access, input_squared_access); |
| 85 | } |
| 86 | else |
| 87 | { |
| 88 | AccessWindowHorizontal input_access(input, -border_size.left, num_elems_processed_per_iteration); |
| 89 | AccessWindowHorizontal input_squared_access(input_squared, -border_size.left, num_elems_processed_per_iteration); |
| 90 | window_changed = window_changed || update_window_and_padding(win, input_access, input_squared_access); |
| 91 | } |
Michalis Spyrou | afa5d81 | 2017-11-30 14:25:57 +0000 | [diff] [blame] | 92 | |
| 93 | if(output->total_size() != 0) |
| 94 | { |
| 95 | AccessWindowHorizontal output_access(output, 0, num_elems_processed_per_iteration); |
Georgios Pinitas | 7f32d01 | 2018-10-11 18:41:19 +0100 | [diff] [blame] | 96 | window_changed = window_changed || update_window_and_padding(win, output_access); |
Michalis Spyrou | afa5d81 | 2017-11-30 14:25:57 +0000 | [diff] [blame] | 97 | output_access.set_valid_region(win, input->valid_region()); |
| 98 | } |
Michalis Spyrou | afa5d81 | 2017-11-30 14:25:57 +0000 | [diff] [blame] | 99 | |
| 100 | Status err = (window_changed) ? ARM_COMPUTE_CREATE_ERROR(ErrorCode::RUNTIME_ERROR, "Insufficient Padding!") : Status{}; |
| 101 | return std::make_pair(err, win); |
| 102 | } |
| 103 | } // namespace |
| 104 | |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 105 | NENormalizationLayerKernel::NENormalizationLayerKernel() |
| 106 | : _func(nullptr), _input(nullptr), _input_squared(nullptr), _output(nullptr), _norm_info(NormType::IN_MAP_1D), _border_size() |
| 107 | { |
| 108 | } |
| 109 | |
| 110 | BorderSize NENormalizationLayerKernel::border_size() const |
| 111 | { |
| 112 | return _border_size; |
| 113 | } |
| 114 | |
| 115 | void NENormalizationLayerKernel::configure(const ITensor *input, const ITensor *input_squared, ITensor *output, NormalizationLayerInfo norm_info) |
| 116 | { |
Michalis Spyrou | afa5d81 | 2017-11-30 14:25:57 +0000 | [diff] [blame] | 117 | ARM_COMPUTE_ERROR_ON_NULLPTR(input, input_squared, output); |
Georgios Pinitas | 09004ca | 2017-07-03 17:30:14 +0100 | [diff] [blame] | 118 | // Output tensor auto initialization if not yet initialized |
Michalis Spyrou | afa5d81 | 2017-11-30 14:25:57 +0000 | [diff] [blame] | 119 | auto_init_if_empty(*output->info(), *input->info()); |
| 120 | |
| 121 | // Perform validation step |
| 122 | ARM_COMPUTE_ERROR_THROW_ON(validate_arguments(input->info(), input_squared->info(), output->info(), norm_info)); |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 123 | |
Georgios Pinitas | 7f32d01 | 2018-10-11 18:41:19 +0100 | [diff] [blame] | 124 | const unsigned int num_elems_processed_per_iteration = 16 / input->info()->element_size(); |
| 125 | |
| 126 | const unsigned int norm_idx = get_normalization_dimension_index(input->info()->data_layout(), norm_info); |
| 127 | const bool is_norm_accross_width = norm_idx == 0; |
| 128 | const unsigned int border_width = is_norm_accross_width ? num_elems_processed_per_iteration - 1 : 0; |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 129 | |
| 130 | _input = input; |
| 131 | _input_squared = input_squared; |
| 132 | _output = output; |
| 133 | _norm_info = norm_info; |
| 134 | _border_size = BorderSize(0, border_width); |
| 135 | |
Pablo Tello | df24618 | 2017-07-03 16:25:09 +0100 | [diff] [blame] | 136 | switch(_input->info()->data_type()) |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 137 | { |
Pablo Tello | df24618 | 2017-07-03 16:25:09 +0100 | [diff] [blame] | 138 | case DataType::F32: |
| 139 | { |
Georgios Pinitas | e222055 | 2018-07-20 13:23:44 +0100 | [diff] [blame] | 140 | switch(norm_idx) |
Pablo Tello | df24618 | 2017-07-03 16:25:09 +0100 | [diff] [blame] | 141 | { |
Georgios Pinitas | e222055 | 2018-07-20 13:23:44 +0100 | [diff] [blame] | 142 | case 0: |
| 143 | { |
| 144 | if(norm_info.type() == NormType::IN_MAP_2D) |
| 145 | { |
Michalis Spyrou | 0c71d0b | 2018-11-22 11:22:18 +0000 | [diff] [blame] | 146 | _func = &NENormalizationLayerKernel::normalize_float<float, 4, 0, true>; |
Georgios Pinitas | e222055 | 2018-07-20 13:23:44 +0100 | [diff] [blame] | 147 | } |
| 148 | else |
| 149 | { |
Michalis Spyrou | 0c71d0b | 2018-11-22 11:22:18 +0000 | [diff] [blame] | 150 | _func = &NENormalizationLayerKernel::normalize_float<float, 4, 0, false>; |
Georgios Pinitas | e222055 | 2018-07-20 13:23:44 +0100 | [diff] [blame] | 151 | } |
Pablo Tello | df24618 | 2017-07-03 16:25:09 +0100 | [diff] [blame] | 152 | break; |
Georgios Pinitas | e222055 | 2018-07-20 13:23:44 +0100 | [diff] [blame] | 153 | } |
Michalis Spyrou | 0c71d0b | 2018-11-22 11:22:18 +0000 | [diff] [blame] | 154 | case 1: |
| 155 | if(norm_info.type() == NormType::IN_MAP_2D) |
| 156 | { |
| 157 | _func = &NENormalizationLayerKernel::normalize_float<float, 4, 1, true>; |
| 158 | } |
| 159 | else |
| 160 | { |
| 161 | _func = &NENormalizationLayerKernel::normalize_float<float, 4, 1, false>; |
| 162 | } |
| 163 | break; |
Georgios Pinitas | e222055 | 2018-07-20 13:23:44 +0100 | [diff] [blame] | 164 | case 2: |
Michalis Spyrou | 0c71d0b | 2018-11-22 11:22:18 +0000 | [diff] [blame] | 165 | _func = &NENormalizationLayerKernel::normalize_float<float, 4, 2, false>; |
Pablo Tello | df24618 | 2017-07-03 16:25:09 +0100 | [diff] [blame] | 166 | break; |
| 167 | default: |
Pablo Tello | df24618 | 2017-07-03 16:25:09 +0100 | [diff] [blame] | 168 | break; |
| 169 | } |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 170 | break; |
Pablo Tello | df24618 | 2017-07-03 16:25:09 +0100 | [diff] [blame] | 171 | } |
Gian Marco Iodice | f2cde9b | 2018-08-23 15:29:16 +0100 | [diff] [blame] | 172 | #ifdef __ARM_FEATURE_FP16_VECTOR_ARITHMETIC |
Pablo Tello | df24618 | 2017-07-03 16:25:09 +0100 | [diff] [blame] | 173 | case DataType::F16: |
| 174 | { |
Georgios Pinitas | e222055 | 2018-07-20 13:23:44 +0100 | [diff] [blame] | 175 | switch(norm_idx) |
Pablo Tello | df24618 | 2017-07-03 16:25:09 +0100 | [diff] [blame] | 176 | { |
Georgios Pinitas | e222055 | 2018-07-20 13:23:44 +0100 | [diff] [blame] | 177 | case 0: |
| 178 | { |
| 179 | if(norm_info.type() == NormType::IN_MAP_2D) |
| 180 | { |
Michalis Spyrou | 0c71d0b | 2018-11-22 11:22:18 +0000 | [diff] [blame] | 181 | _func = &NENormalizationLayerKernel::normalize_float<float16_t, 8, 0, true>; |
Georgios Pinitas | e222055 | 2018-07-20 13:23:44 +0100 | [diff] [blame] | 182 | } |
| 183 | else |
| 184 | { |
Michalis Spyrou | 0c71d0b | 2018-11-22 11:22:18 +0000 | [diff] [blame] | 185 | _func = &NENormalizationLayerKernel::normalize_float<float16_t, 8, 0, false>; |
Georgios Pinitas | e222055 | 2018-07-20 13:23:44 +0100 | [diff] [blame] | 186 | } |
Pablo Tello | df24618 | 2017-07-03 16:25:09 +0100 | [diff] [blame] | 187 | break; |
Georgios Pinitas | e222055 | 2018-07-20 13:23:44 +0100 | [diff] [blame] | 188 | } |
Michalis Spyrou | 0c71d0b | 2018-11-22 11:22:18 +0000 | [diff] [blame] | 189 | case 1: |
| 190 | if(norm_info.type() == NormType::IN_MAP_2D) |
| 191 | { |
| 192 | _func = &NENormalizationLayerKernel::normalize_float<float16_t, 8, 1, true>; |
| 193 | } |
| 194 | else |
| 195 | { |
| 196 | _func = &NENormalizationLayerKernel::normalize_float<float16_t, 8, 1, false>; |
| 197 | } |
| 198 | break; |
Georgios Pinitas | e222055 | 2018-07-20 13:23:44 +0100 | [diff] [blame] | 199 | case 2: |
Michalis Spyrou | 0c71d0b | 2018-11-22 11:22:18 +0000 | [diff] [blame] | 200 | _func = &NENormalizationLayerKernel::normalize_float<float16_t, 8, 2, false>; |
Pablo Tello | df24618 | 2017-07-03 16:25:09 +0100 | [diff] [blame] | 201 | break; |
| 202 | default: |
Pablo Tello | df24618 | 2017-07-03 16:25:09 +0100 | [diff] [blame] | 203 | break; |
| 204 | } |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 205 | break; |
Pablo Tello | df24618 | 2017-07-03 16:25:09 +0100 | [diff] [blame] | 206 | } |
Gian Marco Iodice | f2cde9b | 2018-08-23 15:29:16 +0100 | [diff] [blame] | 207 | #endif /* __ARM_FEATURE_FP16_VECTOR_ARITHMETIC */ |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 208 | default: |
| 209 | ARM_COMPUTE_ERROR("NOT SUPPORTED!"); |
| 210 | } |
| 211 | |
Michalis Spyrou | afa5d81 | 2017-11-30 14:25:57 +0000 | [diff] [blame] | 212 | // Configure kernel window |
| 213 | auto win_config = validate_and_configure_window(input->info(), input_squared->info(), output->info(), norm_info); |
| 214 | ARM_COMPUTE_ERROR_THROW_ON(win_config.first); |
| 215 | INEKernel::configure(win_config.second); |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 216 | } |
| 217 | |
Michalis Spyrou | 0c71d0b | 2018-11-22 11:22:18 +0000 | [diff] [blame] | 218 | template <typename T, unsigned int S, unsigned int dim, bool do_2D_norm> |
Pablo Tello | df24618 | 2017-07-03 16:25:09 +0100 | [diff] [blame] | 219 | void NENormalizationLayerKernel::normalize_float(const Window &window) |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 220 | { |
Michalis Spyrou | 0c71d0b | 2018-11-22 11:22:18 +0000 | [diff] [blame] | 221 | /** NEON vector tag type. */ |
| 222 | using ExactTagType = typename wrapper::traits::neon_vector<T, S>::tag_type; |
| 223 | |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 224 | Iterator input(_input, window); |
| 225 | Iterator input_squared(_input_squared, window); |
| 226 | Iterator output(_output, window); |
| 227 | |
Michalis Spyrou | 0c71d0b | 2018-11-22 11:22:18 +0000 | [diff] [blame] | 228 | const int dim_y = _input->info()->data_layout() == DataLayout::NCHW ? 1 : 2; |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 229 | const int radius = _norm_info.norm_size() / 2; |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 230 | const int input_squared_stride = _input_squared->info()->strides_in_bytes()[dim]; |
| 231 | // We account padding across X only and we iterate over rows |
| 232 | const int min_left = (dim == 2) ? 0 : -static_cast<int>(border_size().left); |
Georgios Pinitas | 7f32d01 | 2018-10-11 18:41:19 +0100 | [diff] [blame] | 233 | const int max_right = _input->info()->dimension(dim) - 1; |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 234 | const int max_bottom = _input->info()->dimension(dim_y) - 1; |
| 235 | |
Michalis Spyrou | 0c71d0b | 2018-11-22 11:22:18 +0000 | [diff] [blame] | 236 | const auto coeff_vec = wrapper::vdup_n(static_cast<T>(_norm_info.scale_coeff()), ExactTagType{}); |
| 237 | const auto beta_vec = wrapper::vdup_n(static_cast<T>(_norm_info.beta()), ExactTagType{}); |
| 238 | const auto kappa_vec = wrapper::vdup_n(static_cast<T>(_norm_info.kappa()), ExactTagType{}); |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 239 | |
Michalis Spyrou | 0c71d0b | 2018-11-22 11:22:18 +0000 | [diff] [blame] | 240 | execute_window_loop(window, [&](const Coordinates & id) |
| 241 | { |
| 242 | // Get range to normalize |
| 243 | const int current_row = do_2D_norm ? id[dim_y] : 0; |
| 244 | const int current_slice = id[dim]; |
| 245 | const int first_row = do_2D_norm ? std::max(current_row - radius, 0) : 0; |
| 246 | const int last_row = do_2D_norm ? std::min(current_row + radius, max_bottom) : 0; |
| 247 | const int first_slice = std::max(current_slice - radius, min_left); |
| 248 | const int last_slice = std::min(current_slice + radius, max_right); |
| 249 | |
| 250 | // Accumulate 2D In-Map values |
| 251 | auto accu = wrapper::vdup_n(static_cast<T>(0.f), ExactTagType{}); |
| 252 | for(int j = first_row; j <= last_row; j++) |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 253 | { |
Michalis Spyrou | 0c71d0b | 2018-11-22 11:22:18 +0000 | [diff] [blame] | 254 | // Compute row displacement |
| 255 | const int row = (j - current_row) * _input_squared->info()->strides_in_bytes()[dim_y]; |
| 256 | const uint8_t *const input_squared_ptr = input_squared.ptr() + row - (current_slice * input_squared_stride); |
| 257 | for(int i = first_slice; i <= last_slice; ++i) |
Pablo Tello | df24618 | 2017-07-03 16:25:09 +0100 | [diff] [blame] | 258 | { |
Michalis Spyrou | 0c71d0b | 2018-11-22 11:22:18 +0000 | [diff] [blame] | 259 | accu = wrapper::vadd(accu, wrapper::vloadq(reinterpret_cast<const T *>(input_squared_ptr + i * input_squared_stride))); |
Pablo Tello | df24618 | 2017-07-03 16:25:09 +0100 | [diff] [blame] | 260 | } |
Michalis Spyrou | 0c71d0b | 2018-11-22 11:22:18 +0000 | [diff] [blame] | 261 | } |
Pablo Tello | df24618 | 2017-07-03 16:25:09 +0100 | [diff] [blame] | 262 | |
Michalis Spyrou | 0c71d0b | 2018-11-22 11:22:18 +0000 | [diff] [blame] | 263 | // Normalize |
| 264 | const auto normalized = wrapper::vpow(wrapper::vmla(kappa_vec, coeff_vec, accu), beta_vec); |
| 265 | const auto normalized_pixel = wrapper::vmul(wrapper::vloadq(reinterpret_cast<const T *>(input.ptr())), wrapper::vinv(normalized)); |
| 266 | wrapper::vstore(reinterpret_cast<T *>(output.ptr()), normalized_pixel); |
| 267 | }, |
| 268 | input, input_squared, output); |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 269 | } |
| 270 | |
Michalis Spyrou | afa5d81 | 2017-11-30 14:25:57 +0000 | [diff] [blame] | 271 | Status NENormalizationLayerKernel::validate(const ITensorInfo *input, const ITensorInfo *input_squared, const ITensorInfo *output, const NormalizationLayerInfo norm_info) |
| 272 | { |
| 273 | ARM_COMPUTE_RETURN_ON_ERROR(validate_arguments(input, input_squared, output, norm_info)); |
| 274 | ARM_COMPUTE_RETURN_ON_ERROR(validate_and_configure_window(input->clone().get(), input_squared->clone().get(), output->clone().get(), norm_info).first); |
| 275 | |
| 276 | return Status{}; |
| 277 | } |
| 278 | |
Moritz Pflanzer | c186b57 | 2017-09-07 09:48:04 +0100 | [diff] [blame] | 279 | void NENormalizationLayerKernel::run(const Window &window, const ThreadInfo &info) |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 280 | { |
Moritz Pflanzer | c186b57 | 2017-09-07 09:48:04 +0100 | [diff] [blame] | 281 | ARM_COMPUTE_UNUSED(info); |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 282 | ARM_COMPUTE_ERROR_ON_UNCONFIGURED_KERNEL(this); |
| 283 | ARM_COMPUTE_ERROR_ON_INVALID_SUBWINDOW(INEKernel::window(), window); |
| 284 | ARM_COMPUTE_ERROR_ON(_func == nullptr); |
| 285 | |
| 286 | // Run function |
| 287 | (this->*_func)(window); |
| 288 | } |