Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 1 | /* |
Sheri Zhang | ac6499a | 2021-02-10 15:32:38 +0000 | [diff] [blame] | 2 | * Copyright (c) 2017-2021 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 | */ |
Georgios Pinitas | 7891a73 | 2021-08-20 21:39:25 +0100 | [diff] [blame] | 24 | #include "src/cpu/kernels/CpuDirectConv2dOutputStageKernel.h" |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 25 | |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 26 | #include "arm_compute/core/Error.h" |
| 27 | #include "arm_compute/core/Helpers.h" |
| 28 | #include "arm_compute/core/ITensor.h" |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 29 | #include "arm_compute/core/Types.h" |
| 30 | #include "arm_compute/core/Validate.h" |
| 31 | #include "arm_compute/core/Window.h" |
Michele Di Giorgio | 4536193 | 2019-12-19 13:53:44 +0000 | [diff] [blame] | 32 | #include "arm_compute/core/utils/misc/Traits.h" |
Sang-Hoon Park | 68dd25f | 2020-10-19 16:00:11 +0100 | [diff] [blame] | 33 | #include "src/core/CPP/Validate.h" |
Georgios Pinitas | ddb93bb | 2020-10-02 16:38:59 +0100 | [diff] [blame] | 34 | #include "src/core/NEON/NEAsymm.h" |
| 35 | #include "src/core/NEON/NEFixedPoint.h" |
| 36 | #include "src/core/NEON/wrapper/wrapper.h" |
Sang-Hoon Park | 68dd25f | 2020-10-19 16:00:11 +0100 | [diff] [blame] | 37 | #include "src/core/helpers/AutoConfiguration.h" |
| 38 | #include "src/core/helpers/WindowHelpers.h" |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 39 | |
| 40 | #include <arm_neon.h> |
| 41 | #include <cstddef> |
| 42 | #include <cstdint> |
| 43 | |
Michele Di Giorgio | f29d1b7 | 2019-10-29 10:58:13 +0000 | [diff] [blame] | 44 | namespace arm_compute |
| 45 | { |
Manuel Bottini | 327225d | 2021-04-13 13:09:30 +0100 | [diff] [blame] | 46 | namespace cpu |
| 47 | { |
| 48 | namespace kernels |
| 49 | { |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 50 | namespace |
| 51 | { |
Manuel Bottini | 327225d | 2021-04-13 13:09:30 +0100 | [diff] [blame] | 52 | Status validate_arguments(const ITensorInfo *src, const ITensorInfo *bias, const ITensorInfo *dst, |
Michele Di Giorgio | 4536193 | 2019-12-19 13:53:44 +0000 | [diff] [blame] | 53 | const DirectConvolutionLayerOutputStageKernelInfo &info) |
Michalis Spyrou | afa5d81 | 2017-11-30 14:25:57 +0000 | [diff] [blame] | 54 | { |
Manuel Bottini | 327225d | 2021-04-13 13:09:30 +0100 | [diff] [blame] | 55 | ARM_COMPUTE_RETURN_ERROR_ON_NULLPTR(src); |
| 56 | ARM_COMPUTE_RETURN_ERROR_ON_CPU_F16_UNSUPPORTED(src); |
| 57 | ARM_COMPUTE_RETURN_ERROR_ON(src->data_layout() == DataLayout::UNKNOWN); |
| 58 | ARM_COMPUTE_RETURN_ERROR_ON_DATA_TYPE_CHANNEL_NOT_IN(src, 1, DataType::F16, DataType::S32, DataType::F32); |
Michalis Spyrou | b91e34c | 2017-12-20 15:50:55 +0000 | [diff] [blame] | 59 | |
| 60 | if(bias != nullptr) |
Michalis Spyrou | afa5d81 | 2017-11-30 14:25:57 +0000 | [diff] [blame] | 61 | { |
Manuel Bottini | 327225d | 2021-04-13 13:09:30 +0100 | [diff] [blame] | 62 | ARM_COMPUTE_RETURN_ERROR_ON_MISMATCHING_DATA_TYPES(src, bias); |
| 63 | ARM_COMPUTE_RETURN_ERROR_ON(bias->dimension(0) != src->dimension(get_data_layout_dimension_index(src->data_layout(), DataLayoutDimension::CHANNEL))); |
Michalis Spyrou | b91e34c | 2017-12-20 15:50:55 +0000 | [diff] [blame] | 64 | ARM_COMPUTE_RETURN_ERROR_ON(bias->num_dimensions() > 1); |
Michalis Spyrou | afa5d81 | 2017-11-30 14:25:57 +0000 | [diff] [blame] | 65 | } |
Michalis Spyrou | afa5d81 | 2017-11-30 14:25:57 +0000 | [diff] [blame] | 66 | |
Manuel Bottini | 327225d | 2021-04-13 13:09:30 +0100 | [diff] [blame] | 67 | if(src->data_type() == DataType::S32) |
Michele Di Giorgio | 4536193 | 2019-12-19 13:53:44 +0000 | [diff] [blame] | 68 | { |
Manuel Bottini | 327225d | 2021-04-13 13:09:30 +0100 | [diff] [blame] | 69 | ARM_COMPUTE_RETURN_ERROR_ON_MSG(dst == nullptr, "In-place computation not allowed for quantized output"); |
Michele Di Giorgio | 4536193 | 2019-12-19 13:53:44 +0000 | [diff] [blame] | 70 | } |
| 71 | |
Michalis Spyrou | afa5d81 | 2017-11-30 14:25:57 +0000 | [diff] [blame] | 72 | // Checks performed when output is configured |
Manuel Bottini | 327225d | 2021-04-13 13:09:30 +0100 | [diff] [blame] | 73 | if((dst != nullptr) && (dst->total_size() != 0)) |
Michalis Spyrou | afa5d81 | 2017-11-30 14:25:57 +0000 | [diff] [blame] | 74 | { |
Manuel Bottini | 327225d | 2021-04-13 13:09:30 +0100 | [diff] [blame] | 75 | if(is_data_type_float(src->data_type())) |
Michalis Spyrou | b91e34c | 2017-12-20 15:50:55 +0000 | [diff] [blame] | 76 | { |
Manuel Bottini | 327225d | 2021-04-13 13:09:30 +0100 | [diff] [blame] | 77 | ARM_COMPUTE_RETURN_ERROR_ON_MISMATCHING_DATA_TYPES(src, dst); |
Michalis Spyrou | b91e34c | 2017-12-20 15:50:55 +0000 | [diff] [blame] | 78 | } |
Michele Di Giorgio | 4536193 | 2019-12-19 13:53:44 +0000 | [diff] [blame] | 79 | else |
| 80 | { |
Manuel Bottini | 327225d | 2021-04-13 13:09:30 +0100 | [diff] [blame] | 81 | ARM_COMPUTE_RETURN_ERROR_ON_DATA_TYPE_CHANNEL_NOT_IN(dst, 1, DataType::QASYMM8, DataType::QASYMM8_SIGNED); |
Michele Di Giorgio | 4536193 | 2019-12-19 13:53:44 +0000 | [diff] [blame] | 82 | } |
Manuel Bottini | 327225d | 2021-04-13 13:09:30 +0100 | [diff] [blame] | 83 | ARM_COMPUTE_RETURN_ERROR_ON_MISMATCHING_SHAPES(src, dst); |
Michele Di Giorgio | 4536193 | 2019-12-19 13:53:44 +0000 | [diff] [blame] | 84 | } |
Manuel Bottini | 327225d | 2021-04-13 13:09:30 +0100 | [diff] [blame] | 85 | else if(src->data_type() == DataType::S32) |
Michele Di Giorgio | 4536193 | 2019-12-19 13:53:44 +0000 | [diff] [blame] | 86 | { |
| 87 | // In case of quantized computation and unconfigured output, the output data type must be provided through DirectConvolutionLayerOutputStageKernelInfo |
| 88 | ARM_COMPUTE_RETURN_ERROR_ON((info.output_data_type != DataType::QASYMM8) && (info.output_data_type != DataType::QASYMM8_SIGNED)); |
Michalis Spyrou | afa5d81 | 2017-11-30 14:25:57 +0000 | [diff] [blame] | 89 | } |
| 90 | |
Michalis Spyrou | afa5d81 | 2017-11-30 14:25:57 +0000 | [diff] [blame] | 91 | return Status{}; |
| 92 | } |
| 93 | |
Michalis Spyrou | 14e868e | 2020-09-30 00:33:05 +0100 | [diff] [blame] | 94 | template <typename T> |
Michele Di Giorgio | 4536193 | 2019-12-19 13:53:44 +0000 | [diff] [blame] | 95 | typename std::enable_if<arm_compute::utils::traits::is_floating_point<T>::value, void>::type |
Manuel Bottini | 327225d | 2021-04-13 13:09:30 +0100 | [diff] [blame] | 96 | output_stage_nchw(ITensor *src, const ITensor *bias, const Window &window, ITensor *dst, |
| 97 | int result_fixedpoint_multiplier, int result_shift, int result_offset_after_shift) |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 98 | { |
Manuel Bottini | 327225d | 2021-04-13 13:09:30 +0100 | [diff] [blame] | 99 | const bool has_bias = bias != nullptr; |
Michele Di Giorgio | 33f41fa | 2021-03-09 14:09:08 +0000 | [diff] [blame] | 100 | /** SIMD vector tag type. */ |
Michele Di Giorgio | 4536193 | 2019-12-19 13:53:44 +0000 | [diff] [blame] | 101 | using ExactTagType = typename wrapper::traits::neon_bitvector_tag_t<T, wrapper::traits::BitWidth::W128>; |
Pablo Tello | f87cc7f | 2017-07-26 10:28:40 +0100 | [diff] [blame] | 102 | |
Manuel Bottini | 327225d | 2021-04-13 13:09:30 +0100 | [diff] [blame] | 103 | ARM_COMPUTE_ERROR_ON(src->info()->data_layout() == DataLayout::UNKNOWN); |
Georgios Pinitas | f72f936 | 2018-01-12 16:29:45 +0000 | [diff] [blame] | 104 | ARM_COMPUTE_UNUSED(result_fixedpoint_multiplier); |
| 105 | ARM_COMPUTE_UNUSED(result_shift); |
| 106 | ARM_COMPUTE_UNUSED(result_offset_after_shift); |
| 107 | |
Michalis Spyrou | 017ead2 | 2020-09-28 23:28:08 +0100 | [diff] [blame] | 108 | const int window_start_x = window.x().start(); |
| 109 | const int window_end_x = window.x().end(); |
Manuel Bottini | 327225d | 2021-04-13 13:09:30 +0100 | [diff] [blame] | 110 | const int window_step_x = 16 / src->info()->element_size(); |
Michalis Spyrou | 017ead2 | 2020-09-28 23:28:08 +0100 | [diff] [blame] | 111 | Window win = window; |
| 112 | win.set(Window::DimX, Window::Dimension(0, 1, 1)); |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 113 | |
Manuel Bottini | 327225d | 2021-04-13 13:09:30 +0100 | [diff] [blame] | 114 | Iterator in(src, win); |
| 115 | Iterator out(dst, win); |
Michalis Spyrou | 017ead2 | 2020-09-28 23:28:08 +0100 | [diff] [blame] | 116 | execute_window_loop(win, [&](const Coordinates & id) |
| 117 | { |
| 118 | int x = window_start_x; |
Michalis Spyrou | c226853 | 2020-10-09 11:52:10 +0100 | [diff] [blame] | 119 | for(; x <= (window_end_x - window_step_x); x += window_step_x) |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 120 | { |
Michalis Spyrou | 017ead2 | 2020-09-28 23:28:08 +0100 | [diff] [blame] | 121 | // Get bias and pointer to input |
| 122 | const auto in_ptr = reinterpret_cast<const T *>(in.ptr()) + x; |
| 123 | auto v_in = wrapper::vloadq(in_ptr); |
| 124 | |
| 125 | // Accumulate bias |
| 126 | if(has_bias) |
| 127 | { |
| 128 | const auto vb = wrapper::vdup_n(*reinterpret_cast<const T *>(bias->ptr_to_element(Coordinates(id.z()))), ExactTagType{}); |
| 129 | v_in = wrapper::vadd(v_in, vb); |
| 130 | } |
| 131 | |
| 132 | const auto out_ptr = reinterpret_cast<T *>(out.ptr()) + x; |
| 133 | wrapper::vstore(out_ptr, v_in); |
Michele Di Giorgio | 4536193 | 2019-12-19 13:53:44 +0000 | [diff] [blame] | 134 | } |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 135 | |
Michalis Spyrou | 017ead2 | 2020-09-28 23:28:08 +0100 | [diff] [blame] | 136 | // Left-overs loop |
| 137 | for(; x < window_end_x; ++x) |
| 138 | { |
| 139 | // Get bias and pointer to input |
| 140 | auto s_in = *(reinterpret_cast<const T *>(in.ptr()) + x); |
| 141 | |
| 142 | // Accumulate bias |
| 143 | if(has_bias) |
| 144 | { |
| 145 | const auto b = *reinterpret_cast<const T *>(bias->ptr_to_element(Coordinates(id.z()))); |
| 146 | s_in += b; |
| 147 | } |
| 148 | |
| 149 | *(reinterpret_cast<T *>(out.ptr()) + x) = s_in; |
| 150 | } |
| 151 | |
Michele Di Giorgio | 4536193 | 2019-12-19 13:53:44 +0000 | [diff] [blame] | 152 | }, |
| 153 | in, out); |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 154 | } |
Georgios Pinitas | f72f936 | 2018-01-12 16:29:45 +0000 | [diff] [blame] | 155 | |
Michalis Spyrou | 14e868e | 2020-09-30 00:33:05 +0100 | [diff] [blame] | 156 | template <typename T> |
Michele Di Giorgio | 4536193 | 2019-12-19 13:53:44 +0000 | [diff] [blame] | 157 | typename std::enable_if<arm_compute::utils::traits::is_floating_point<T>::value, void>::type |
Manuel Bottini | 327225d | 2021-04-13 13:09:30 +0100 | [diff] [blame] | 158 | output_stage_nhwc(ITensor *src, const ITensor *bias, const Window &window, ITensor *dst, |
| 159 | int result_fixedpoint_multiplier, int result_shift, int result_offset_after_shift) |
Giorgio Arena | 1ed1fc6 | 2018-03-26 16:20:05 +0100 | [diff] [blame] | 160 | { |
Manuel Bottini | 327225d | 2021-04-13 13:09:30 +0100 | [diff] [blame] | 161 | const bool has_bias = bias != nullptr; |
Giorgio Arena | 1ed1fc6 | 2018-03-26 16:20:05 +0100 | [diff] [blame] | 162 | ARM_COMPUTE_UNUSED(result_fixedpoint_multiplier); |
| 163 | ARM_COMPUTE_UNUSED(result_shift); |
| 164 | ARM_COMPUTE_UNUSED(result_offset_after_shift); |
| 165 | |
| 166 | Window window_bias = window; |
Michalis Spyrou | 017ead2 | 2020-09-28 23:28:08 +0100 | [diff] [blame] | 167 | window_bias.set(Window::DimX, Window::Dimension(0, 1, 1)); |
Giorgio Arena | 1ed1fc6 | 2018-03-26 16:20:05 +0100 | [diff] [blame] | 168 | window_bias.set(Window::DimY, Window::Dimension(0, 0, 0)); |
| 169 | window_bias.set(Window::DimZ, Window::Dimension(0, 0, 0)); |
| 170 | window_bias.set(3, Window::Dimension(0, 0, 0)); |
| 171 | |
Michalis Spyrou | 017ead2 | 2020-09-28 23:28:08 +0100 | [diff] [blame] | 172 | const int window_start_x = window.x().start(); |
| 173 | const int window_end_x = window.x().end(); |
Manuel Bottini | 327225d | 2021-04-13 13:09:30 +0100 | [diff] [blame] | 174 | const int window_step_x = 16 / src->info()->element_size(); |
Michalis Spyrou | 017ead2 | 2020-09-28 23:28:08 +0100 | [diff] [blame] | 175 | Window win = window; |
| 176 | win.set(Window::DimX, Window::Dimension(0, 1, 1)); |
Giorgio Arena | 1ed1fc6 | 2018-03-26 16:20:05 +0100 | [diff] [blame] | 177 | |
Manuel Bottini | 327225d | 2021-04-13 13:09:30 +0100 | [diff] [blame] | 178 | Iterator in(src, win); |
Michalis Spyrou | 017ead2 | 2020-09-28 23:28:08 +0100 | [diff] [blame] | 179 | Iterator bi(bias, window_bias); |
Manuel Bottini | 327225d | 2021-04-13 13:09:30 +0100 | [diff] [blame] | 180 | Iterator out(dst, win); |
Michalis Spyrou | 017ead2 | 2020-09-28 23:28:08 +0100 | [diff] [blame] | 181 | |
| 182 | execute_window_loop(win, [&](const Coordinates &) |
| 183 | { |
| 184 | int x = window_start_x; |
Michalis Spyrou | c226853 | 2020-10-09 11:52:10 +0100 | [diff] [blame] | 185 | for(; x <= (window_end_x - window_step_x); x += window_step_x) |
Giorgio Arena | 1ed1fc6 | 2018-03-26 16:20:05 +0100 | [diff] [blame] | 186 | { |
Michalis Spyrou | 017ead2 | 2020-09-28 23:28:08 +0100 | [diff] [blame] | 187 | // Get bias and pointer to input |
| 188 | const auto in_ptr = reinterpret_cast<const T *>(in.ptr()); |
| 189 | auto v_in = wrapper::vloadq(in_ptr + x); |
| 190 | |
| 191 | // Accumulate bias |
| 192 | if(has_bias) |
| 193 | { |
| 194 | const auto bias_ptr = reinterpret_cast<T *>(bi.ptr()) + x; |
| 195 | v_in = wrapper::vadd(v_in, wrapper::vloadq(bias_ptr)); |
| 196 | } |
| 197 | |
| 198 | const auto out_ptr = reinterpret_cast<T *>(out.ptr()); |
| 199 | wrapper::vstore(out_ptr + x, v_in); |
Michele Di Giorgio | 4536193 | 2019-12-19 13:53:44 +0000 | [diff] [blame] | 200 | } |
Giorgio Arena | 1ed1fc6 | 2018-03-26 16:20:05 +0100 | [diff] [blame] | 201 | |
Michalis Spyrou | 017ead2 | 2020-09-28 23:28:08 +0100 | [diff] [blame] | 202 | // Left-overs loop |
| 203 | for(; x < window_end_x; ++x) |
| 204 | { |
| 205 | // Get bias and pointer to input |
| 206 | auto s_in = *(reinterpret_cast<const T *>(in.ptr()) + x); |
Michele Di Giorgio | 4536193 | 2019-12-19 13:53:44 +0000 | [diff] [blame] | 207 | |
Michalis Spyrou | 017ead2 | 2020-09-28 23:28:08 +0100 | [diff] [blame] | 208 | // Accumulate bias |
| 209 | if(has_bias) |
| 210 | { |
| 211 | const auto bias_ptr = reinterpret_cast<T *>(bi.ptr()) + x; |
| 212 | s_in += *bias_ptr; |
| 213 | } |
| 214 | |
| 215 | const auto out_ptr = reinterpret_cast<T *>(out.ptr()); |
| 216 | *(out_ptr + x) = s_in; |
| 217 | } |
Michele Di Giorgio | 4536193 | 2019-12-19 13:53:44 +0000 | [diff] [blame] | 218 | }, |
| 219 | in, bi, out); |
Giorgio Arena | 1ed1fc6 | 2018-03-26 16:20:05 +0100 | [diff] [blame] | 220 | } |
| 221 | |
Michele Di Giorgio | 4536193 | 2019-12-19 13:53:44 +0000 | [diff] [blame] | 222 | // Quantized case |
Michalis Spyrou | 14e868e | 2020-09-30 00:33:05 +0100 | [diff] [blame] | 223 | template < typename TOut, typename std::enable_if < std::is_same<TOut, uint8_t>::value || std::is_same<TOut, int8_t>::value, int >::type = 0 > |
Manuel Bottini | 327225d | 2021-04-13 13:09:30 +0100 | [diff] [blame] | 224 | void output_stage_nchw(ITensor *src, const ITensor *bias, const Window &window, ITensor *dst, |
| 225 | int result_fixedpoint_multiplier, int result_shift, int result_offset_after_shift) |
Georgios Pinitas | f72f936 | 2018-01-12 16:29:45 +0000 | [diff] [blame] | 226 | { |
Manuel Bottini | 327225d | 2021-04-13 13:09:30 +0100 | [diff] [blame] | 227 | const bool has_bias = bias != nullptr; |
| 228 | using VectorType = typename wrapper::traits::neon_bitvector_t<TOut, wrapper::traits::BitWidth::W128>; |
| 229 | using TagType = typename wrapper::traits::neon_bitvector_tag_t<TOut, wrapper::traits::BitWidth::W128>; |
Michele Di Giorgio | 4536193 | 2019-12-19 13:53:44 +0000 | [diff] [blame] | 230 | |
Georgios Pinitas | f72f936 | 2018-01-12 16:29:45 +0000 | [diff] [blame] | 231 | const int32x4_t result_offset_after_shift_s32 = vdupq_n_s32(result_offset_after_shift); |
Michele Di Giorgio | 4536193 | 2019-12-19 13:53:44 +0000 | [diff] [blame] | 232 | |
| 233 | const VectorType min = wrapper::vdup_n(std::numeric_limits<TOut>::lowest(), TagType{}); |
| 234 | const VectorType max = wrapper::vdup_n(std::numeric_limits<TOut>::max(), TagType{}); |
Georgios Pinitas | f72f936 | 2018-01-12 16:29:45 +0000 | [diff] [blame] | 235 | |
Michalis Spyrou | 017ead2 | 2020-09-28 23:28:08 +0100 | [diff] [blame] | 236 | const int window_start_x = window.x().start(); |
| 237 | const int window_end_x = window.x().end(); |
Manuel Bottini | 327225d | 2021-04-13 13:09:30 +0100 | [diff] [blame] | 238 | const int window_step_x = 16 / src->info()->element_size(); |
Michalis Spyrou | 017ead2 | 2020-09-28 23:28:08 +0100 | [diff] [blame] | 239 | Window win = window; |
| 240 | win.set(Window::DimX, Window::Dimension(0, 1, 1)); |
Georgios Pinitas | f72f936 | 2018-01-12 16:29:45 +0000 | [diff] [blame] | 241 | |
Manuel Bottini | 327225d | 2021-04-13 13:09:30 +0100 | [diff] [blame] | 242 | Iterator in(src, win); |
| 243 | Iterator out(dst, win); |
Michalis Spyrou | 017ead2 | 2020-09-28 23:28:08 +0100 | [diff] [blame] | 244 | |
| 245 | execute_window_loop(win, [&](const Coordinates & id) |
Georgios Pinitas | f72f936 | 2018-01-12 16:29:45 +0000 | [diff] [blame] | 246 | { |
Georgios Pinitas | f72f936 | 2018-01-12 16:29:45 +0000 | [diff] [blame] | 247 | |
Michalis Spyrou | 017ead2 | 2020-09-28 23:28:08 +0100 | [diff] [blame] | 248 | int x = window_start_x; |
Michalis Spyrou | c226853 | 2020-10-09 11:52:10 +0100 | [diff] [blame] | 249 | for(; x <= (window_end_x - window_step_x); x += window_step_x) |
Georgios Pinitas | f72f936 | 2018-01-12 16:29:45 +0000 | [diff] [blame] | 250 | { |
Michalis Spyrou | 017ead2 | 2020-09-28 23:28:08 +0100 | [diff] [blame] | 251 | // Get bias and pointer to input |
| 252 | const auto in_ptr = reinterpret_cast<int32_t *>(in.ptr()) + x; |
| 253 | int32x4x4_t v_in = |
Georgios Pinitas | f72f936 | 2018-01-12 16:29:45 +0000 | [diff] [blame] | 254 | { |
Michele Di Giorgio | 4536193 | 2019-12-19 13:53:44 +0000 | [diff] [blame] | 255 | { |
Michalis Spyrou | 017ead2 | 2020-09-28 23:28:08 +0100 | [diff] [blame] | 256 | wrapper::vloadq(in_ptr), |
| 257 | wrapper::vloadq(in_ptr + 4), |
| 258 | wrapper::vloadq(in_ptr + 8), |
| 259 | wrapper::vloadq(in_ptr + 12) |
Michele Di Giorgio | 4536193 | 2019-12-19 13:53:44 +0000 | [diff] [blame] | 260 | } |
| 261 | }; |
Michalis Spyrou | 017ead2 | 2020-09-28 23:28:08 +0100 | [diff] [blame] | 262 | |
| 263 | // Accumulate bias |
| 264 | if(has_bias) |
| 265 | { |
| 266 | const auto vb = wrapper::vdup_n(*reinterpret_cast<const int32_t *>(bias->ptr_to_element(Coordinates(id.z()))), TagType{}); |
| 267 | v_in = |
| 268 | { |
| 269 | { |
| 270 | wrapper::vadd(v_in.val[0], vb), |
| 271 | wrapper::vadd(v_in.val[1], vb), |
| 272 | wrapper::vadd(v_in.val[2], vb), |
| 273 | wrapper::vadd(v_in.val[3], vb) |
| 274 | } |
| 275 | }; |
| 276 | } |
| 277 | |
| 278 | const auto out_ptr = reinterpret_cast<TOut *>(out.ptr()) + x; |
| 279 | wrapper::vstore(out_ptr, finalize_quantization(v_in, result_fixedpoint_multiplier, result_shift, result_offset_after_shift_s32, |
| 280 | min, max, false)); |
Michele Di Giorgio | 4536193 | 2019-12-19 13:53:44 +0000 | [diff] [blame] | 281 | } |
Georgios Pinitas | f72f936 | 2018-01-12 16:29:45 +0000 | [diff] [blame] | 282 | |
Michalis Spyrou | 017ead2 | 2020-09-28 23:28:08 +0100 | [diff] [blame] | 283 | // Left-overs loop |
| 284 | for(; x < window_end_x; ++x) |
| 285 | { |
| 286 | // Get bias and pointer to input |
| 287 | int32_t s_in = *(reinterpret_cast<const int32_t *>(in.ptr()) + x); |
| 288 | |
| 289 | // Accumulate bias |
| 290 | if(has_bias) |
| 291 | { |
| 292 | const auto b = *reinterpret_cast<const int32_t *>(bias->ptr_to_element(Coordinates(id.z()))); |
| 293 | s_in += b; |
| 294 | } |
| 295 | |
| 296 | const auto out_ptr = reinterpret_cast<TOut *>(out.ptr()) + x; |
| 297 | *out_ptr = finalize_quantization(s_in, result_fixedpoint_multiplier, result_shift, result_offset_after_shift, |
| 298 | std::numeric_limits<TOut>::lowest(), std::numeric_limits<TOut>::max(), false); |
| 299 | } |
Georgios Pinitas | f72f936 | 2018-01-12 16:29:45 +0000 | [diff] [blame] | 300 | }, |
| 301 | in, out); |
| 302 | } |
Michalis Spyrou | 14e868e | 2020-09-30 00:33:05 +0100 | [diff] [blame] | 303 | template < typename TOut, typename std::enable_if < std::is_same<TOut, uint8_t>::value || std::is_same<TOut, int8_t>::value, int >::type = 0 > |
Manuel Bottini | 327225d | 2021-04-13 13:09:30 +0100 | [diff] [blame] | 304 | void output_stage_nhwc(ITensor *src, const ITensor *bias, const Window &window, ITensor *dst, |
| 305 | int result_fixedpoint_multiplier, int result_shift, int result_offset_after_shift) |
Georgios Pinitas | f72f936 | 2018-01-12 16:29:45 +0000 | [diff] [blame] | 306 | { |
Manuel Bottini | 327225d | 2021-04-13 13:09:30 +0100 | [diff] [blame] | 307 | const bool has_bias = bias != nullptr; |
| 308 | using VectorType = typename wrapper::traits::neon_bitvector_t<TOut, wrapper::traits::BitWidth::W128>; |
| 309 | using TagType = typename wrapper::traits::neon_bitvector_tag_t<TOut, wrapper::traits::BitWidth::W128>; |
Georgios Pinitas | f72f936 | 2018-01-12 16:29:45 +0000 | [diff] [blame] | 310 | |
| 311 | const int32x4_t result_offset_after_shift_s32 = vdupq_n_s32(result_offset_after_shift); |
Georgios Pinitas | f72f936 | 2018-01-12 16:29:45 +0000 | [diff] [blame] | 312 | |
Michele Di Giorgio | 4536193 | 2019-12-19 13:53:44 +0000 | [diff] [blame] | 313 | const VectorType min = wrapper::vdup_n(std::numeric_limits<TOut>::lowest(), TagType{}); |
| 314 | const VectorType max = wrapper::vdup_n(std::numeric_limits<TOut>::max(), TagType{}); |
Georgios Pinitas | a799ce0 | 2018-09-12 20:11:34 +0100 | [diff] [blame] | 315 | |
| 316 | Window window_bias = window; |
Michalis Spyrou | 017ead2 | 2020-09-28 23:28:08 +0100 | [diff] [blame] | 317 | window_bias.set(Window::DimX, Window::Dimension(0, 1, 1)); |
Georgios Pinitas | a799ce0 | 2018-09-12 20:11:34 +0100 | [diff] [blame] | 318 | window_bias.set(Window::DimY, Window::Dimension(0, 0, 0)); |
| 319 | window_bias.set(Window::DimZ, Window::Dimension(0, 0, 0)); |
| 320 | window_bias.set(3, Window::Dimension(0, 0, 0)); |
| 321 | |
Michalis Spyrou | 017ead2 | 2020-09-28 23:28:08 +0100 | [diff] [blame] | 322 | const int window_start_x = window.x().start(); |
| 323 | const int window_end_x = window.x().end(); |
Manuel Bottini | 327225d | 2021-04-13 13:09:30 +0100 | [diff] [blame] | 324 | const int window_step_x = 16 / src->info()->element_size(); |
Michalis Spyrou | 017ead2 | 2020-09-28 23:28:08 +0100 | [diff] [blame] | 325 | Window win = window; |
| 326 | win.set(Window::DimX, Window::Dimension(0, 1, 1)); |
| 327 | |
Manuel Bottini | 327225d | 2021-04-13 13:09:30 +0100 | [diff] [blame] | 328 | Iterator in(src, win); |
Georgios Pinitas | a799ce0 | 2018-09-12 20:11:34 +0100 | [diff] [blame] | 329 | Iterator bi(bias, window_bias); |
Manuel Bottini | 327225d | 2021-04-13 13:09:30 +0100 | [diff] [blame] | 330 | Iterator out(dst, win); |
Georgios Pinitas | a799ce0 | 2018-09-12 20:11:34 +0100 | [diff] [blame] | 331 | |
Michalis Spyrou | 017ead2 | 2020-09-28 23:28:08 +0100 | [diff] [blame] | 332 | execute_window_loop(win, [&](const Coordinates &) |
Georgios Pinitas | a799ce0 | 2018-09-12 20:11:34 +0100 | [diff] [blame] | 333 | { |
Michalis Spyrou | 017ead2 | 2020-09-28 23:28:08 +0100 | [diff] [blame] | 334 | int x = window_start_x; |
Michalis Spyrou | c226853 | 2020-10-09 11:52:10 +0100 | [diff] [blame] | 335 | for(; x <= (window_end_x - window_step_x); x += window_step_x) |
Michele Di Giorgio | 4536193 | 2019-12-19 13:53:44 +0000 | [diff] [blame] | 336 | { |
Michalis Spyrou | 017ead2 | 2020-09-28 23:28:08 +0100 | [diff] [blame] | 337 | // Get bias and pointer to input |
| 338 | const auto in_ptr = reinterpret_cast<int32_t *>(in.ptr()) + x; |
| 339 | int32x4x4_t v_in = |
Michele Di Giorgio | 4536193 | 2019-12-19 13:53:44 +0000 | [diff] [blame] | 340 | { |
Michalis Spyrou | 017ead2 | 2020-09-28 23:28:08 +0100 | [diff] [blame] | 341 | { |
| 342 | wrapper::vloadq(in_ptr), |
| 343 | wrapper::vloadq(in_ptr + 4), |
| 344 | wrapper::vloadq(in_ptr + 8), |
| 345 | wrapper::vloadq(in_ptr + 12), |
| 346 | } |
| 347 | }; |
| 348 | |
| 349 | // Accumulate bias |
| 350 | if(has_bias) |
| 351 | { |
| 352 | const auto bias_ptr = reinterpret_cast<int32_t *>(bi.ptr()) + x; |
| 353 | |
| 354 | wrapper::vadd(v_in.val[0], wrapper::vloadq(bias_ptr)); |
| 355 | wrapper::vadd(v_in.val[1], wrapper::vloadq(bias_ptr + 4)); |
| 356 | wrapper::vadd(v_in.val[2], wrapper::vloadq(bias_ptr + 8)); |
| 357 | wrapper::vadd(v_in.val[3], wrapper::vloadq(bias_ptr + 12)); |
Michele Di Giorgio | 4536193 | 2019-12-19 13:53:44 +0000 | [diff] [blame] | 358 | } |
Georgios Pinitas | a799ce0 | 2018-09-12 20:11:34 +0100 | [diff] [blame] | 359 | |
Michalis Spyrou | 017ead2 | 2020-09-28 23:28:08 +0100 | [diff] [blame] | 360 | const auto out_ptr = reinterpret_cast<TOut *>(out.ptr()) + x; |
| 361 | wrapper::vstore(out_ptr, finalize_quantization(v_in, result_fixedpoint_multiplier, result_shift, result_offset_after_shift_s32, min, max, false)); |
Michele Di Giorgio | 4536193 | 2019-12-19 13:53:44 +0000 | [diff] [blame] | 362 | } |
| 363 | |
Michalis Spyrou | 017ead2 | 2020-09-28 23:28:08 +0100 | [diff] [blame] | 364 | // Left-overs loop |
| 365 | for(; x < window_end_x; ++x) |
| 366 | { |
| 367 | // Get bias and pointer to input |
| 368 | const auto in_ptr = reinterpret_cast<int32_t *>(in.ptr()) + x; |
| 369 | int32_t s_in = *in_ptr; |
| 370 | |
| 371 | // Accumulate bias |
| 372 | if(has_bias) |
| 373 | { |
| 374 | const auto bias_ptr = reinterpret_cast<int32_t *>(bi.ptr()) + x; |
| 375 | s_in += *bias_ptr; |
| 376 | } |
| 377 | |
| 378 | const auto out_ptr = reinterpret_cast<TOut *>(out.ptr()) + x; |
| 379 | *out_ptr = finalize_quantization(s_in, result_fixedpoint_multiplier, result_shift, result_offset_after_shift, |
| 380 | std::numeric_limits<TOut>::lowest(), std::numeric_limits<TOut>::max(), false); |
| 381 | } |
Georgios Pinitas | a799ce0 | 2018-09-12 20:11:34 +0100 | [diff] [blame] | 382 | }, |
| 383 | in, bi, out); |
| 384 | } |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 385 | } // namespace |
| 386 | |
Manuel Bottini | b4bb6a0 | 2021-05-24 16:01:32 +0100 | [diff] [blame] | 387 | void CpuDirectConv2dOutputStageKernel::configure(ITensorInfo *src, const ITensorInfo *bias, ITensorInfo *dst, |
| 388 | const DirectConvolutionLayerOutputStageKernelInfo &info) |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 389 | { |
Manuel Bottini | 327225d | 2021-04-13 13:09:30 +0100 | [diff] [blame] | 390 | ARM_COMPUTE_UNUSED(bias); |
Michalis Spyrou | afa5d81 | 2017-11-30 14:25:57 +0000 | [diff] [blame] | 391 | // Perform validation step |
Manuel Bottini | 327225d | 2021-04-13 13:09:30 +0100 | [diff] [blame] | 392 | ARM_COMPUTE_ERROR_ON_NULLPTR(src); |
| 393 | ARM_COMPUTE_ERROR_THROW_ON(validate_arguments(src, bias, dst, info)); |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 394 | |
Georgios Pinitas | f72f936 | 2018-01-12 16:29:45 +0000 | [diff] [blame] | 395 | _func = nullptr; |
Michele Di Giorgio | 4536193 | 2019-12-19 13:53:44 +0000 | [diff] [blame] | 396 | _result_fixedpoint_multiplier = info.result_fixedpoint_multiplier; |
| 397 | _result_shift = info.result_shift; |
| 398 | _result_offset_after_shift = info.result_offset_after_shift; |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 399 | |
Michalis Spyrou | 017ead2 | 2020-09-28 23:28:08 +0100 | [diff] [blame] | 400 | // Auto-initialize output output if required |
Manuel Bottini | 327225d | 2021-04-13 13:09:30 +0100 | [diff] [blame] | 401 | if(dst != nullptr) |
Michalis Spyrou | 017ead2 | 2020-09-28 23:28:08 +0100 | [diff] [blame] | 402 | { |
| 403 | // Work out expected output data type |
Manuel Bottini | 327225d | 2021-04-13 13:09:30 +0100 | [diff] [blame] | 404 | const DataType output_dt = (src->data_type() == DataType::S32) ? info.output_data_type : DataType::S32; |
Michalis Spyrou | 017ead2 | 2020-09-28 23:28:08 +0100 | [diff] [blame] | 405 | // Output tensor auto initialization if not yet initialized |
Manuel Bottini | 327225d | 2021-04-13 13:09:30 +0100 | [diff] [blame] | 406 | auto_init_if_empty(*dst, src->clone()->set_data_type(output_dt)); |
Michalis Spyrou | 017ead2 | 2020-09-28 23:28:08 +0100 | [diff] [blame] | 407 | } |
| 408 | |
Manuel Bottini | 327225d | 2021-04-13 13:09:30 +0100 | [diff] [blame] | 409 | Window win = calculate_max_window(*src, Steps()); |
Michalis Spyrou | 017ead2 | 2020-09-28 23:28:08 +0100 | [diff] [blame] | 410 | |
Manuel Bottini | 327225d | 2021-04-13 13:09:30 +0100 | [diff] [blame] | 411 | ICpuKernel::configure(win); |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 412 | |
Manuel Bottini | 327225d | 2021-04-13 13:09:30 +0100 | [diff] [blame] | 413 | const bool is_qasymm8_signed = (dst != nullptr) ? is_data_type_quantized_asymmetric_signed(dst->data_type()) : false; |
Gian Marco Iodice | 618493d | 2018-11-27 16:38:33 +0000 | [diff] [blame] | 414 | |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 415 | // Set appropriate function |
Manuel Bottini | 327225d | 2021-04-13 13:09:30 +0100 | [diff] [blame] | 416 | if(src->data_layout() == DataLayout::NCHW) |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 417 | { |
Manuel Bottini | 327225d | 2021-04-13 13:09:30 +0100 | [diff] [blame] | 418 | switch(src->data_type()) |
Pablo Tello | f87cc7f | 2017-07-26 10:28:40 +0100 | [diff] [blame] | 419 | { |
Giorgio Arena | 1ed1fc6 | 2018-03-26 16:20:05 +0100 | [diff] [blame] | 420 | case DataType::S32: |
Michalis Spyrou | b91e34c | 2017-12-20 15:50:55 +0000 | [diff] [blame] | 421 | { |
Michele Di Giorgio | 4536193 | 2019-12-19 13:53:44 +0000 | [diff] [blame] | 422 | if(is_qasymm8_signed) |
| 423 | { |
Michalis Spyrou | 14e868e | 2020-09-30 00:33:05 +0100 | [diff] [blame] | 424 | _func = &output_stage_nchw<int8_t>; |
Michele Di Giorgio | 4536193 | 2019-12-19 13:53:44 +0000 | [diff] [blame] | 425 | } |
| 426 | else |
| 427 | { |
Michalis Spyrou | 14e868e | 2020-09-30 00:33:05 +0100 | [diff] [blame] | 428 | _func = &output_stage_nchw<uint8_t>; |
Michele Di Giorgio | 4536193 | 2019-12-19 13:53:44 +0000 | [diff] [blame] | 429 | } |
Giorgio Arena | 1ed1fc6 | 2018-03-26 16:20:05 +0100 | [diff] [blame] | 430 | break; |
Pablo Tello | f87cc7f | 2017-07-26 10:28:40 +0100 | [diff] [blame] | 431 | } |
Ioan-Cristian Szabo | 5edbd1c | 2017-11-13 13:34:08 +0000 | [diff] [blame] | 432 | #ifdef __ARM_FEATURE_FP16_VECTOR_ARITHMETIC |
Giorgio Arena | 1ed1fc6 | 2018-03-26 16:20:05 +0100 | [diff] [blame] | 433 | case DataType::F16: |
| 434 | { |
Michalis Spyrou | 14e868e | 2020-09-30 00:33:05 +0100 | [diff] [blame] | 435 | _func = &output_stage_nchw<float16_t>; |
Giorgio Arena | 1ed1fc6 | 2018-03-26 16:20:05 +0100 | [diff] [blame] | 436 | break; |
| 437 | } |
Ioan-Cristian Szabo | 5edbd1c | 2017-11-13 13:34:08 +0000 | [diff] [blame] | 438 | #endif /* __ARM_FEATURE_FP16_VECTOR_ARITHMETIC */ |
Giorgio Arena | 1ed1fc6 | 2018-03-26 16:20:05 +0100 | [diff] [blame] | 439 | case DataType::F32: |
| 440 | { |
Michalis Spyrou | 14e868e | 2020-09-30 00:33:05 +0100 | [diff] [blame] | 441 | _func = &output_stage_nchw<float>; |
Giorgio Arena | 1ed1fc6 | 2018-03-26 16:20:05 +0100 | [diff] [blame] | 442 | break; |
| 443 | } |
| 444 | default: |
| 445 | { |
| 446 | ARM_COMPUTE_ERROR("Unsupported combination of types among the inputs."); |
| 447 | } |
Pablo Tello | f87cc7f | 2017-07-26 10:28:40 +0100 | [diff] [blame] | 448 | } |
Giorgio Arena | 1ed1fc6 | 2018-03-26 16:20:05 +0100 | [diff] [blame] | 449 | } |
| 450 | else |
| 451 | { |
Manuel Bottini | 327225d | 2021-04-13 13:09:30 +0100 | [diff] [blame] | 452 | switch(src->data_type()) |
Pablo Tello | f87cc7f | 2017-07-26 10:28:40 +0100 | [diff] [blame] | 453 | { |
Georgios Pinitas | a799ce0 | 2018-09-12 20:11:34 +0100 | [diff] [blame] | 454 | case DataType::S32: |
| 455 | { |
Michele Di Giorgio | 4536193 | 2019-12-19 13:53:44 +0000 | [diff] [blame] | 456 | if(is_qasymm8_signed) |
| 457 | { |
Michalis Spyrou | 14e868e | 2020-09-30 00:33:05 +0100 | [diff] [blame] | 458 | _func = &output_stage_nhwc<int8_t>; |
Michele Di Giorgio | 4536193 | 2019-12-19 13:53:44 +0000 | [diff] [blame] | 459 | } |
| 460 | else |
| 461 | { |
Michalis Spyrou | 14e868e | 2020-09-30 00:33:05 +0100 | [diff] [blame] | 462 | _func = &output_stage_nhwc<uint8_t>; |
Michele Di Giorgio | 4536193 | 2019-12-19 13:53:44 +0000 | [diff] [blame] | 463 | } |
Georgios Pinitas | a799ce0 | 2018-09-12 20:11:34 +0100 | [diff] [blame] | 464 | break; |
| 465 | } |
Georgios Pinitas | 20c246a | 2018-09-12 16:45:53 +0100 | [diff] [blame] | 466 | #ifdef __ARM_FEATURE_FP16_VECTOR_ARITHMETIC |
| 467 | case DataType::F16: |
| 468 | { |
Michalis Spyrou | 14e868e | 2020-09-30 00:33:05 +0100 | [diff] [blame] | 469 | _func = &output_stage_nhwc<float16_t>; |
Georgios Pinitas | 20c246a | 2018-09-12 16:45:53 +0100 | [diff] [blame] | 470 | break; |
| 471 | } |
| 472 | #endif /* __ARM_FEATURE_FP16_VECTOR_ARITHMETIC */ |
Giorgio Arena | 1ed1fc6 | 2018-03-26 16:20:05 +0100 | [diff] [blame] | 473 | case DataType::F32: |
| 474 | { |
Michalis Spyrou | 14e868e | 2020-09-30 00:33:05 +0100 | [diff] [blame] | 475 | _func = &output_stage_nhwc<float>; |
Giorgio Arena | 1ed1fc6 | 2018-03-26 16:20:05 +0100 | [diff] [blame] | 476 | break; |
| 477 | } |
| 478 | default: |
| 479 | { |
| 480 | ARM_COMPUTE_ERROR("Unsupported combination of types among the inputs."); |
| 481 | } |
Pablo Tello | f87cc7f | 2017-07-26 10:28:40 +0100 | [diff] [blame] | 482 | } |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 483 | } |
| 484 | } |
| 485 | |
Manuel Bottini | b4bb6a0 | 2021-05-24 16:01:32 +0100 | [diff] [blame] | 486 | Status CpuDirectConv2dOutputStageKernel::validate(const ITensorInfo *src, const ITensorInfo *bias, const ITensorInfo *dst, |
| 487 | const DirectConvolutionLayerOutputStageKernelInfo &info) |
Michalis Spyrou | afa5d81 | 2017-11-30 14:25:57 +0000 | [diff] [blame] | 488 | { |
Manuel Bottini | 327225d | 2021-04-13 13:09:30 +0100 | [diff] [blame] | 489 | ARM_COMPUTE_RETURN_ON_ERROR(validate_arguments(src, bias, dst, info)); |
Michalis Spyrou | afa5d81 | 2017-11-30 14:25:57 +0000 | [diff] [blame] | 490 | return Status{}; |
| 491 | } |
| 492 | |
Manuel Bottini | b4bb6a0 | 2021-05-24 16:01:32 +0100 | [diff] [blame] | 493 | void CpuDirectConv2dOutputStageKernel::run_op(ITensorPack &tensors, const Window &window, const ThreadInfo &info) |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 494 | { |
Moritz Pflanzer | c186b57 | 2017-09-07 09:48:04 +0100 | [diff] [blame] | 495 | ARM_COMPUTE_UNUSED(info); |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 496 | ARM_COMPUTE_ERROR_ON_UNCONFIGURED_KERNEL(this); |
Manuel Bottini | 327225d | 2021-04-13 13:09:30 +0100 | [diff] [blame] | 497 | ARM_COMPUTE_ERROR_ON_INVALID_SUBWINDOW(ICpuKernel::window(), window); |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 498 | ARM_COMPUTE_ERROR_ON(_func == nullptr); |
| 499 | |
Manuel Bottini | 327225d | 2021-04-13 13:09:30 +0100 | [diff] [blame] | 500 | auto src = tensors.get_tensor(TensorType::ACL_SRC_0); |
| 501 | auto bias = tensors.get_const_tensor(TensorType::ACL_SRC_1); |
| 502 | auto dst = tensors.get_tensor(TensorType::ACL_DST); |
| 503 | |
| 504 | (*_func)(src, bias, window, dst, _result_fixedpoint_multiplier, _result_shift, _result_offset_after_shift); |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 505 | } |
Manuel Bottini | 327225d | 2021-04-13 13:09:30 +0100 | [diff] [blame] | 506 | |
Manuel Bottini | b4bb6a0 | 2021-05-24 16:01:32 +0100 | [diff] [blame] | 507 | const char *CpuDirectConv2dOutputStageKernel::name() const |
Manuel Bottini | 327225d | 2021-04-13 13:09:30 +0100 | [diff] [blame] | 508 | { |
Manuel Bottini | b4bb6a0 | 2021-05-24 16:01:32 +0100 | [diff] [blame] | 509 | return "CpuDirectConv2dOutputStageKernel"; |
Manuel Bottini | 327225d | 2021-04-13 13:09:30 +0100 | [diff] [blame] | 510 | } |
| 511 | } // namespace kernels |
| 512 | } // namespace cpu |
Michele Di Giorgio | f29d1b7 | 2019-10-29 10:58:13 +0000 | [diff] [blame] | 513 | } // namespace arm_compute |