Michalis Spyrou | 7362f0d | 2017-10-18 17:58:22 +0100 | [diff] [blame] | 1 | /* |
Georgios Pinitas | 8f5802f | 2019-02-22 11:08:32 +0000 | [diff] [blame] | 2 | * Copyright (c) 2017-2019 ARM Limited. |
Michalis Spyrou | 7362f0d | 2017-10-18 17:58:22 +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 | */ |
Giorgio Arena | 04a8f8c | 2017-11-23 11:45:24 +0000 | [diff] [blame] | 24 | #include "arm_compute/core/NEON/kernels/NEDepthwiseConvolutionLayer3x3Kernel.h" |
Georgios Pinitas | 4074c99 | 2018-01-30 18:13:46 +0000 | [diff] [blame] | 25 | #include "arm_compute/core/NEON/kernels/detail/NEDirectConvolutionDetail.h" |
Michalis Spyrou | 7362f0d | 2017-10-18 17:58:22 +0100 | [diff] [blame] | 26 | |
| 27 | #include "arm_compute/core/AccessWindowStatic.h" |
Georgios Pinitas | 8f5802f | 2019-02-22 11:08:32 +0000 | [diff] [blame] | 28 | #include "arm_compute/core/CPP/Validate.h" |
Michalis Spyrou | 7362f0d | 2017-10-18 17:58:22 +0100 | [diff] [blame] | 29 | #include "arm_compute/core/Coordinates.h" |
| 30 | #include "arm_compute/core/Error.h" |
| 31 | #include "arm_compute/core/Helpers.h" |
| 32 | #include "arm_compute/core/ITensor.h" |
| 33 | #include "arm_compute/core/NEON/INEKernel.h" |
| 34 | #include "arm_compute/core/TensorInfo.h" |
| 35 | #include "arm_compute/core/TensorShape.h" |
| 36 | #include "arm_compute/core/Types.h" |
Georgios Pinitas | 4074c99 | 2018-01-30 18:13:46 +0000 | [diff] [blame] | 37 | #include "arm_compute/core/Utils.h" |
Michalis Spyrou | 7362f0d | 2017-10-18 17:58:22 +0100 | [diff] [blame] | 38 | #include "arm_compute/core/Validate.h" |
| 39 | #include "arm_compute/core/Window.h" |
Georgios Pinitas | 1250a5a | 2018-01-02 13:27:37 +0000 | [diff] [blame] | 40 | #include "arm_compute/core/utils/misc/ShapeCalculator.h" |
Georgios Pinitas | 4074c99 | 2018-01-30 18:13:46 +0000 | [diff] [blame] | 41 | #include "support/ToolchainSupport.h" |
Michalis Spyrou | 7362f0d | 2017-10-18 17:58:22 +0100 | [diff] [blame] | 42 | |
Georgios Pinitas | 47d39dc | 2019-03-11 14:03:23 +0000 | [diff] [blame] | 43 | namespace arm_compute |
| 44 | { |
Georgios Pinitas | f72f936 | 2018-01-12 16:29:45 +0000 | [diff] [blame] | 45 | namespace |
Michalis Spyrou | 7362f0d | 2017-10-18 17:58:22 +0100 | [diff] [blame] | 46 | { |
Georgios Pinitas | f72f936 | 2018-01-12 16:29:45 +0000 | [diff] [blame] | 47 | template <typename T1, typename T2, unsigned int stridex> |
Michalis Spyrou | 7362f0d | 2017-10-18 17:58:22 +0100 | [diff] [blame] | 48 | class convolver_3x3 |
| 49 | { |
| 50 | public: |
| 51 | static void convolve(const Window &window, unsigned int num_elems_written_per_iteration, |
Giorgio Arena | 7657224 | 2018-04-04 17:44:26 +0100 | [diff] [blame] | 52 | const ITensor *input, const ITensor *weights, ITensor *output, const PadStrideInfo &conv_info, unsigned int depth_multiplier) |
Michalis Spyrou | 7362f0d | 2017-10-18 17:58:22 +0100 | [diff] [blame] | 53 | { |
Georgios Pinitas | f72f936 | 2018-01-12 16:29:45 +0000 | [diff] [blame] | 54 | const int input_offset = -input->info()->quantization_info().offset; |
| 55 | const int weights_offset = -weights->info()->quantization_info().offset; |
| 56 | |
Michalis Spyrou | 7362f0d | 2017-10-18 17:58:22 +0100 | [diff] [blame] | 57 | const int input_stride_x = input->info()->strides_in_bytes().x(); |
| 58 | const int input_stride_y = input->info()->strides_in_bytes().y(); |
Giorgio Arena | 7657224 | 2018-04-04 17:44:26 +0100 | [diff] [blame] | 59 | const int input_stride_z = input->info()->strides_in_bytes().z(); |
Michalis Spyrou | 7362f0d | 2017-10-18 17:58:22 +0100 | [diff] [blame] | 60 | const int output_stride_y = output->info()->strides_in_bytes().y(); |
| 61 | const int kernel_stride_y = weights->info()->strides_in_bytes().y(); |
| 62 | const int kernel_stride_z = weights->info()->strides_in_bytes().z(); |
| 63 | const int output_w = output->info()->dimension(0); |
| 64 | const int output_h = output->info()->dimension(1); |
Georgios Pinitas | 47d39dc | 2019-03-11 14:03:23 +0000 | [diff] [blame] | 65 | const int delta_input = detail::get_input_num_elems_processed<stridex>(num_elems_written_per_iteration); |
Michalis Spyrou | 7362f0d | 2017-10-18 17:58:22 +0100 | [diff] [blame] | 66 | const unsigned int conv_stride_y = std::get<1>(conv_info.stride()); |
Georgios Pinitas | f72f936 | 2018-01-12 16:29:45 +0000 | [diff] [blame] | 67 | const unsigned int conv_pad_x = conv_info.pad_left(); |
| 68 | const unsigned int conv_pad_y = conv_info.pad_top(); |
Michalis Spyrou | 7362f0d | 2017-10-18 17:58:22 +0100 | [diff] [blame] | 69 | |
| 70 | // setup output window for the iterator |
| 71 | Window window_out = window; |
| 72 | window_out.set(Window::DimX, Window::Dimension(0, output->info()->dimension(Window::DimX), output->info()->dimension(Window::DimX))); |
| 73 | window_out.set(Window::DimY, Window::Dimension(0, output->info()->dimension(Window::DimY), output->info()->dimension(Window::DimY))); |
| 74 | |
| 75 | // setup input window for the iterator |
| 76 | Window window_in = window; |
| 77 | // we just want execute_window_loop to iterate over the dimensions > 2, so we set the first 2 dimensions to 0 |
| 78 | window_in.set(Window::DimX, Window::Dimension(0, 0, 0)); |
| 79 | window_in.set(Window::DimY, Window::Dimension(0, 0, 0)); |
| 80 | |
| 81 | Window window_k = calculate_max_window(*weights->info(), Steps(1u)); |
| 82 | |
| 83 | Iterator in(input, window_in); |
| 84 | Iterator out(output, window_out); |
| 85 | Iterator w(weights, window_k); |
| 86 | |
| 87 | const uint8_t *weights_ptr = w.ptr(); |
| 88 | |
| 89 | execute_window_loop(window_out, [&](const Coordinates & id) |
| 90 | { |
Georgios Pinitas | f72f936 | 2018-01-12 16:29:45 +0000 | [diff] [blame] | 91 | int ih = 0; |
| 92 | int oh = 0; |
Michalis Spyrou | 7362f0d | 2017-10-18 17:58:22 +0100 | [diff] [blame] | 93 | |
Giorgio Arena | 7657224 | 2018-04-04 17:44:26 +0100 | [diff] [blame] | 94 | const uint8_t *input_ptr = in.ptr() - conv_pad_x * input_stride_x - conv_pad_y * input_stride_y - (id.z() - id.z() / depth_multiplier) * input_stride_z; |
Georgios Pinitas | f72f936 | 2018-01-12 16:29:45 +0000 | [diff] [blame] | 95 | const uint8_t *ptr_weights_base = weights_ptr + id.z() * kernel_stride_z; |
| 96 | |
| 97 | const auto ptr_weights_r0 = reinterpret_cast<const T1 *>(ptr_weights_base); |
| 98 | const auto ptr_weights_r1 = reinterpret_cast<const T1 *>(ptr_weights_base + kernel_stride_y); |
| 99 | const auto ptr_weights_r2 = reinterpret_cast<const T1 *>(ptr_weights_base + kernel_stride_y * 2); |
Georgios Pinitas | 47d39dc | 2019-03-11 14:03:23 +0000 | [diff] [blame] | 100 | const auto vw_r0 = detail::load_matrix_row(ptr_weights_r0, weights_offset); |
| 101 | const auto vw_r1 = detail::load_matrix_row(ptr_weights_r1, weights_offset); |
| 102 | const auto vw_r2 = detail::load_matrix_row(ptr_weights_r2, weights_offset); |
Michalis Spyrou | 7362f0d | 2017-10-18 17:58:22 +0100 | [diff] [blame] | 103 | |
| 104 | for(ih = 0, oh = 0; oh < output_h; ++oh, ih += conv_stride_y) |
| 105 | { |
Georgios Pinitas | f72f936 | 2018-01-12 16:29:45 +0000 | [diff] [blame] | 106 | auto in_top = reinterpret_cast<const T1 *>(input_ptr + (ih + 0) * input_stride_y); |
| 107 | auto in_mid = reinterpret_cast<const T1 *>(input_ptr + (ih + 1) * input_stride_y); |
| 108 | auto in_low = reinterpret_cast<const T1 *>(input_ptr + (ih + 2) * input_stride_y); |
| 109 | auto p_out = reinterpret_cast<T2 *>(out.ptr() + oh * output_stride_y); |
Michalis Spyrou | 7362f0d | 2017-10-18 17:58:22 +0100 | [diff] [blame] | 110 | |
| 111 | for(int ow = 0; ow < output_w; ow += num_elems_written_per_iteration, |
Georgios Pinitas | f72f936 | 2018-01-12 16:29:45 +0000 | [diff] [blame] | 112 | in_top += delta_input, in_mid += delta_input, in_low += delta_input, |
| 113 | p_out += num_elems_written_per_iteration) |
Michalis Spyrou | 7362f0d | 2017-10-18 17:58:22 +0100 | [diff] [blame] | 114 | { |
Georgios Pinitas | 47d39dc | 2019-03-11 14:03:23 +0000 | [diff] [blame] | 115 | auto vres = detail::convolve_3x3<stridex>(in_top, in_mid, in_low, vw_r0, vw_r1, vw_r2, input_offset); |
| 116 | detail::store_results<stridex>(p_out, vres); |
Michalis Spyrou | 7362f0d | 2017-10-18 17:58:22 +0100 | [diff] [blame] | 117 | } |
| 118 | } |
| 119 | }, |
| 120 | in, out); |
| 121 | } |
| 122 | }; |
| 123 | |
Georgios Pinitas | f72f936 | 2018-01-12 16:29:45 +0000 | [diff] [blame] | 124 | template <typename T1, typename T2> |
| 125 | inline void convolve_3x3(const Window &window, unsigned int num_elems_written_per_iteration, |
Giorgio Arena | 7657224 | 2018-04-04 17:44:26 +0100 | [diff] [blame] | 126 | const ITensor *input, const ITensor *weights, ITensor *output, const PadStrideInfo &conv_info, unsigned int depth_multiplier) |
Georgios Pinitas | f72f936 | 2018-01-12 16:29:45 +0000 | [diff] [blame] | 127 | { |
| 128 | const unsigned int conv_stride_x = std::get<0>(conv_info.stride()); |
| 129 | switch(conv_stride_x) |
| 130 | { |
| 131 | case 1: |
Giorgio Arena | 7657224 | 2018-04-04 17:44:26 +0100 | [diff] [blame] | 132 | convolver_3x3<T1, T2, 1>::convolve(window, num_elems_written_per_iteration, input, weights, output, conv_info, depth_multiplier); |
Georgios Pinitas | f72f936 | 2018-01-12 16:29:45 +0000 | [diff] [blame] | 133 | break; |
| 134 | case 2: |
Giorgio Arena | 7657224 | 2018-04-04 17:44:26 +0100 | [diff] [blame] | 135 | convolver_3x3<T1, T2, 2>::convolve(window, num_elems_written_per_iteration, input, weights, output, conv_info, depth_multiplier); |
Georgios Pinitas | f72f936 | 2018-01-12 16:29:45 +0000 | [diff] [blame] | 136 | break; |
| 137 | case 3: |
Giorgio Arena | 7657224 | 2018-04-04 17:44:26 +0100 | [diff] [blame] | 138 | convolver_3x3<T1, T2, 3>::convolve(window, num_elems_written_per_iteration, input, weights, output, conv_info, depth_multiplier); |
Georgios Pinitas | f72f936 | 2018-01-12 16:29:45 +0000 | [diff] [blame] | 139 | break; |
| 140 | default: |
| 141 | ARM_COMPUTE_ERROR("Not implemented"); |
| 142 | } |
| 143 | } |
Abe Mbise | 7784c83 | 2018-05-31 16:48:41 +0100 | [diff] [blame] | 144 | |
Georgios Pinitas | 47d39dc | 2019-03-11 14:03:23 +0000 | [diff] [blame] | 145 | Status validate_arguments(const ITensorInfo *input, const ITensorInfo *weights, const ITensorInfo *output, const PadStrideInfo &conv_info, unsigned int depth_multiplier) |
Abe Mbise | 7784c83 | 2018-05-31 16:48:41 +0100 | [diff] [blame] | 146 | { |
Georgios Pinitas | 8f5802f | 2019-02-22 11:08:32 +0000 | [diff] [blame] | 147 | ARM_COMPUTE_RETURN_ERROR_ON_CPU_F16_UNSUPPORTED(input); |
Georgios Pinitas | 20c246a | 2018-09-12 16:45:53 +0100 | [diff] [blame] | 148 | ARM_COMPUTE_RETURN_ERROR_ON_DATA_TYPE_CHANNEL_NOT_IN(input, 1, DataType::QASYMM8, DataType::F16, DataType::F32); |
Abe Mbise | 7784c83 | 2018-05-31 16:48:41 +0100 | [diff] [blame] | 149 | ARM_COMPUTE_RETURN_ERROR_ON_MISMATCHING_DATA_TYPES(input, weights); |
| 150 | |
Giorgio Arena | 66cbafb | 2018-08-23 14:51:00 +0100 | [diff] [blame] | 151 | const DataLayout data_layout = input->data_layout(); |
| 152 | const unsigned int width_idx = get_data_layout_dimension_index(data_layout, DataLayoutDimension::WIDTH); |
| 153 | const unsigned int height_idx = get_data_layout_dimension_index(data_layout, DataLayoutDimension::HEIGHT); |
| 154 | |
| 155 | ARM_COMPUTE_RETURN_ERROR_ON(weights->dimension(width_idx) != 3 || weights->dimension(height_idx) != 3); |
Georgios Pinitas | 47d39dc | 2019-03-11 14:03:23 +0000 | [diff] [blame] | 156 | ARM_COMPUTE_RETURN_ERROR_ON(conv_info.stride().first < 1 || conv_info.stride().first > 3); |
Abe Mbise | 7784c83 | 2018-05-31 16:48:41 +0100 | [diff] [blame] | 157 | |
| 158 | if(output->total_size() != 0) |
| 159 | { |
Georgios Pinitas | 47d39dc | 2019-03-11 14:03:23 +0000 | [diff] [blame] | 160 | const TensorShape output_shape = misc::shape_calculator::compute_depthwise_convolution_shape(*input, *weights, conv_info, depth_multiplier); |
Abe Mbise | 7784c83 | 2018-05-31 16:48:41 +0100 | [diff] [blame] | 161 | ARM_COMPUTE_RETURN_ERROR_ON_MISMATCHING_DIMENSIONS(output->tensor_shape(), output_shape); |
| 162 | |
Georgios Pinitas | 20c246a | 2018-09-12 16:45:53 +0100 | [diff] [blame] | 163 | if(is_data_type_quantized_asymmetric(input->data_type())) |
| 164 | { |
| 165 | ARM_COMPUTE_RETURN_ERROR_ON(output->data_type() != DataType::S32); |
| 166 | } |
| 167 | else |
| 168 | { |
| 169 | ARM_COMPUTE_RETURN_ERROR_ON_MISMATCHING_DATA_TYPES(input, output); |
| 170 | } |
Abe Mbise | 7784c83 | 2018-05-31 16:48:41 +0100 | [diff] [blame] | 171 | } |
| 172 | |
| 173 | return Status{}; |
| 174 | } |
| 175 | |
Georgios Pinitas | 47d39dc | 2019-03-11 14:03:23 +0000 | [diff] [blame] | 176 | std::pair<Status, Window> validate_and_configure_window(ITensorInfo *input, ITensorInfo *weights, ITensorInfo *output, const PadStrideInfo &conv_info, unsigned int depth_multiplier) |
Abe Mbise | 7784c83 | 2018-05-31 16:48:41 +0100 | [diff] [blame] | 177 | { |
| 178 | Window win; |
| 179 | bool window_changed = false; |
| 180 | |
Georgios Pinitas | 47d39dc | 2019-03-11 14:03:23 +0000 | [diff] [blame] | 181 | // Get convolved dimensions |
| 182 | const TensorShape output_shape = misc::shape_calculator::compute_depthwise_convolution_shape(*input, *weights, conv_info, depth_multiplier); |
| 183 | const DataType output_dt = (input->data_type() == DataType::QASYMM8) ? DataType::S32 : input->data_type(); |
| 184 | |
| 185 | // Output auto inizialitation if not yet initialized |
| 186 | auto_init_if_empty(*output, input->clone()->set_is_resizable(true).reset_padding().set_tensor_shape(output_shape).set_data_type(output_dt)); |
| 187 | |
| 188 | // Configure kernel window (generic) |
| 189 | const unsigned int conv_stride_x = conv_info.stride().first; |
| 190 | const unsigned int conv_stride_y = conv_info.stride().second; |
| 191 | const unsigned int conv_pad_top = conv_info.pad_top(); |
| 192 | const unsigned int conv_pad_left = conv_info.pad_left(); |
| 193 | |
| 194 | unsigned int num_elems_written_per_iteration = 16 >> conv_stride_x; |
| 195 | unsigned int num_elems_read_per_iteration = 0; |
| 196 | |
| 197 | switch(input->data_type()) |
Abe Mbise | 7784c83 | 2018-05-31 16:48:41 +0100 | [diff] [blame] | 198 | { |
Georgios Pinitas | 47d39dc | 2019-03-11 14:03:23 +0000 | [diff] [blame] | 199 | case DataType::QASYMM8: |
| 200 | num_elems_read_per_iteration = 16; |
| 201 | break; |
Georgios Pinitas | 20c246a | 2018-09-12 16:45:53 +0100 | [diff] [blame] | 202 | #ifdef __ARM_FEATURE_FP16_VECTOR_ARITHMETIC |
Georgios Pinitas | 47d39dc | 2019-03-11 14:03:23 +0000 | [diff] [blame] | 203 | case DataType::F16: |
| 204 | num_elems_read_per_iteration = 24; |
| 205 | break; |
Georgios Pinitas | 20c246a | 2018-09-12 16:45:53 +0100 | [diff] [blame] | 206 | #endif // __ARM_FEATURE_FP16_VECTOR_ARITHMETIC |
Georgios Pinitas | 47d39dc | 2019-03-11 14:03:23 +0000 | [diff] [blame] | 207 | case DataType::F32: |
| 208 | num_elems_read_per_iteration = 12; |
| 209 | break; |
| 210 | default: |
| 211 | ARM_COMPUTE_ERROR("Data type not supported."); |
Abe Mbise | 7784c83 | 2018-05-31 16:48:41 +0100 | [diff] [blame] | 212 | } |
| 213 | |
Georgios Pinitas | 47d39dc | 2019-03-11 14:03:23 +0000 | [diff] [blame] | 214 | // Configure kernel window |
| 215 | win = calculate_max_window(*output, Steps(num_elems_written_per_iteration)); |
| 216 | |
| 217 | AccessWindowRectangle input_access(input, -conv_pad_left, -conv_pad_top, num_elems_read_per_iteration, 3, conv_stride_x, conv_stride_y); |
| 218 | AccessWindowStatic weights_access(weights, 0, 0, 3, 3); |
| 219 | AccessWindowHorizontal output_access(output, 0, num_elems_written_per_iteration); |
| 220 | |
| 221 | window_changed = update_window_and_padding(win, input_access, weights_access, output_access); |
| 222 | output_access.set_valid_region(win, ValidRegion(Coordinates(), output->tensor_shape())); |
| 223 | |
Abe Mbise | 7784c83 | 2018-05-31 16:48:41 +0100 | [diff] [blame] | 224 | Status err = (window_changed) ? ARM_COMPUTE_CREATE_ERROR(ErrorCode::RUNTIME_ERROR, "Insufficient Padding!") : Status{}; |
| 225 | return std::make_pair(err, win); |
| 226 | } |
Georgios Pinitas | f72f936 | 2018-01-12 16:29:45 +0000 | [diff] [blame] | 227 | } // namespace |
| 228 | |
| 229 | NEDepthwiseConvolutionLayer3x3Kernel::NEDepthwiseConvolutionLayer3x3Kernel() |
Georgios Pinitas | 47d39dc | 2019-03-11 14:03:23 +0000 | [diff] [blame] | 230 | : _border_size(0), _input(), _output(), _weights(), _conv_info(), _num_elems_written_per_iteration(0), _depth_multiplier(1) |
Georgios Pinitas | f72f936 | 2018-01-12 16:29:45 +0000 | [diff] [blame] | 231 | { |
| 232 | } |
| 233 | |
| 234 | BorderSize NEDepthwiseConvolutionLayer3x3Kernel::border_size() const |
| 235 | { |
| 236 | return _border_size; |
| 237 | } |
| 238 | |
Georgios Pinitas | 47d39dc | 2019-03-11 14:03:23 +0000 | [diff] [blame] | 239 | void NEDepthwiseConvolutionLayer3x3Kernel::configure(const ITensor *input, const ITensor *weights, ITensor *output, const PadStrideInfo &conv_info, unsigned int depth_multiplier) |
Georgios Pinitas | f72f936 | 2018-01-12 16:29:45 +0000 | [diff] [blame] | 240 | { |
Abe Mbise | 7784c83 | 2018-05-31 16:48:41 +0100 | [diff] [blame] | 241 | ARM_COMPUTE_ERROR_ON_NULLPTR(input, weights, output); |
Georgios Pinitas | 47d39dc | 2019-03-11 14:03:23 +0000 | [diff] [blame] | 242 | ARM_COMPUTE_ERROR_THROW_ON(validate_arguments(input->info(), weights->info(), output->info(), conv_info, depth_multiplier)); |
Georgios Pinitas | 4074c99 | 2018-01-30 18:13:46 +0000 | [diff] [blame] | 243 | |
Georgios Pinitas | 47d39dc | 2019-03-11 14:03:23 +0000 | [diff] [blame] | 244 | _input = input; |
| 245 | _output = output; |
| 246 | _weights = weights; |
| 247 | _conv_info = conv_info; |
| 248 | _depth_multiplier = depth_multiplier; |
| 249 | _num_elems_written_per_iteration = 16 >> _conv_info.stride().first; |
| 250 | _border_size = BorderSize(_conv_info.pad_top(), _conv_info.pad_right(), _conv_info.pad_bottom(), _conv_info.pad_left()); |
Georgios Pinitas | 4074c99 | 2018-01-30 18:13:46 +0000 | [diff] [blame] | 251 | |
Georgios Pinitas | 47d39dc | 2019-03-11 14:03:23 +0000 | [diff] [blame] | 252 | auto win_config = validate_and_configure_window(_input->info(), _weights->info(), _output->info(), _conv_info, _depth_multiplier); |
| 253 | ARM_COMPUTE_ERROR_THROW_ON(win_config.first); |
| 254 | INEKernel::configure(win_config.second); |
Georgios Pinitas | 4074c99 | 2018-01-30 18:13:46 +0000 | [diff] [blame] | 255 | } |
| 256 | |
Abe Mbise | 7784c83 | 2018-05-31 16:48:41 +0100 | [diff] [blame] | 257 | Status NEDepthwiseConvolutionLayer3x3Kernel::validate(const ITensorInfo *input, const ITensorInfo *weights, const ITensorInfo *output, const PadStrideInfo &conv_info, unsigned int depth_multiplier) |
| 258 | { |
Georgios Pinitas | 47d39dc | 2019-03-11 14:03:23 +0000 | [diff] [blame] | 259 | ARM_COMPUTE_RETURN_ON_ERROR(validate_arguments(input, weights, output, conv_info, depth_multiplier)); |
| 260 | ARM_COMPUTE_RETURN_ON_ERROR(validate_and_configure_window(input->clone().get(), weights->clone().get(), output->clone().get(), conv_info, depth_multiplier).first); |
Abe Mbise | 7784c83 | 2018-05-31 16:48:41 +0100 | [diff] [blame] | 261 | return Status{}; |
| 262 | } |
| 263 | |
Georgios Pinitas | 4074c99 | 2018-01-30 18:13:46 +0000 | [diff] [blame] | 264 | void NEDepthwiseConvolutionLayer3x3Kernel::run(const Window &window, const ThreadInfo &info) |
| 265 | { |
| 266 | ARM_COMPUTE_ERROR_ON_UNCONFIGURED_KERNEL(this); |
| 267 | ARM_COMPUTE_UNUSED(info); |
| 268 | |
Michalis Spyrou | 7362f0d | 2017-10-18 17:58:22 +0100 | [diff] [blame] | 269 | ARM_COMPUTE_UNUSED(info); |
| 270 | |
Georgios Pinitas | f72f936 | 2018-01-12 16:29:45 +0000 | [diff] [blame] | 271 | switch(_input->info()->data_type()) |
Michalis Spyrou | 7362f0d | 2017-10-18 17:58:22 +0100 | [diff] [blame] | 272 | { |
Georgios Pinitas | 20c246a | 2018-09-12 16:45:53 +0100 | [diff] [blame] | 273 | #ifdef __ARM_FEATURE_FP16_VECTOR_ARITHMETIC |
| 274 | case DataType::F16: |
| 275 | convolve_3x3<float16_t, float16_t>(window, _num_elems_written_per_iteration, _input, _weights, _output, _conv_info, _depth_multiplier); |
| 276 | break; |
| 277 | #endif // __ARM_FEATURE_FP16_VECTOR_ARITHMETIC |
Georgios Pinitas | f72f936 | 2018-01-12 16:29:45 +0000 | [diff] [blame] | 278 | case DataType::F32: |
Giorgio Arena | 7657224 | 2018-04-04 17:44:26 +0100 | [diff] [blame] | 279 | convolve_3x3<float, float>(window, _num_elems_written_per_iteration, _input, _weights, _output, _conv_info, _depth_multiplier); |
Michalis Spyrou | 7362f0d | 2017-10-18 17:58:22 +0100 | [diff] [blame] | 280 | break; |
Georgios Pinitas | f72f936 | 2018-01-12 16:29:45 +0000 | [diff] [blame] | 281 | case DataType::QASYMM8: |
Giorgio Arena | 7657224 | 2018-04-04 17:44:26 +0100 | [diff] [blame] | 282 | convolve_3x3<uint8_t, int32_t>(window, _num_elems_written_per_iteration, _input, _weights, _output, _conv_info, _depth_multiplier); |
Michalis Spyrou | 7362f0d | 2017-10-18 17:58:22 +0100 | [diff] [blame] | 283 | break; |
| 284 | default: |
| 285 | ARM_COMPUTE_ERROR("Not implemented"); |
| 286 | } |
| 287 | } |
Georgios Pinitas | 47d39dc | 2019-03-11 14:03:23 +0000 | [diff] [blame] | 288 | } // namespace arm_compute |