Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 1 | /* |
Michele Di Giorgio | d9eaf61 | 2020-07-08 11:12:57 +0100 | [diff] [blame] | 2 | * Copyright (c) 2016-2020 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/CL/kernels/CLPixelWiseMultiplicationKernel.h" |
| 25 | |
| 26 | #include "arm_compute/core/CL/CLHelpers.h" |
| 27 | #include "arm_compute/core/CL/CLKernelLibrary.h" |
| 28 | #include "arm_compute/core/CL/ICLTensor.h" |
| 29 | #include "arm_compute/core/CL/OpenCL.h" |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 30 | #include "arm_compute/core/TensorInfo.h" |
Sang-Hoon Park | 68dd25f | 2020-10-19 16:00:11 +0100 | [diff] [blame^] | 31 | #include "src/core/CL/CLValidate.h" |
| 32 | #include "src/core/helpers/AutoConfiguration.h" |
| 33 | #include "src/core/helpers/WindowHelpers.h" |
| 34 | #include "support/Cast.h" |
Matthew Bentham | 758b5ba | 2020-03-05 23:37:48 +0000 | [diff] [blame] | 35 | #include "support/StringSupport.h" |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 36 | |
Georgios Pinitas | 8be9148 | 2019-03-26 17:23:28 +0000 | [diff] [blame] | 37 | namespace arm_compute |
| 38 | { |
Giorgio Arena | 7062382 | 2017-11-27 15:50:10 +0000 | [diff] [blame] | 39 | namespace |
| 40 | { |
Michele Di Giorgio | 6259e5f | 2018-01-17 17:29:33 +0000 | [diff] [blame] | 41 | constexpr unsigned int num_elems_processed_per_iteration = 16; |
| 42 | |
Georgios Pinitas | 631c41a | 2017-12-06 11:53:03 +0000 | [diff] [blame] | 43 | Status validate_arguments(const ITensorInfo *input1, const ITensorInfo *input2, const ITensorInfo *output, float scale, |
Giorgio Arena | 8b2a7d3 | 2020-02-11 17:21:31 +0000 | [diff] [blame] | 44 | ConvertPolicy overflow_policy, RoundingPolicy rounding_policy, const ActivationLayerInfo &act_info) |
Giorgio Arena | 7062382 | 2017-11-27 15:50:10 +0000 | [diff] [blame] | 45 | { |
| 46 | ARM_COMPUTE_UNUSED(overflow_policy); |
| 47 | ARM_COMPUTE_UNUSED(rounding_policy); |
| 48 | |
Michele Di Giorgio | cbbed28 | 2019-12-20 13:26:08 +0000 | [diff] [blame] | 49 | ARM_COMPUTE_RETURN_ERROR_ON_NULLPTR(input1, input2, output); |
Vidhya Sudhan Loganathan | f1f4906 | 2018-05-25 13:21:26 +0100 | [diff] [blame] | 50 | ARM_COMPUTE_RETURN_ERROR_ON_F16_UNSUPPORTED(input1); |
Michele Di Giorgio | cbbed28 | 2019-12-20 13:26:08 +0000 | [diff] [blame] | 51 | ARM_COMPUTE_RETURN_ERROR_ON_DATA_TYPE_CHANNEL_NOT_IN(input1, |
| 52 | 1, |
| 53 | DataType::U8, DataType::QASYMM8, DataType::QASYMM8_SIGNED, |
| 54 | DataType::S16, DataType::QSYMM16, DataType::F16, |
| 55 | DataType::F32); |
| 56 | ARM_COMPUTE_RETURN_ERROR_ON_DATA_TYPE_CHANNEL_NOT_IN(input2, |
| 57 | 1, |
| 58 | DataType::U8, DataType::QASYMM8, DataType::QASYMM8_SIGNED, |
| 59 | DataType::S16, DataType::QSYMM16, DataType::F16, |
| 60 | DataType::F32); |
Giorgio Arena | 7062382 | 2017-11-27 15:50:10 +0000 | [diff] [blame] | 61 | ARM_COMPUTE_RETURN_ERROR_ON_MSG(scale < 0, "Scale cannot be negative."); |
Giorgio Arena | 8b2a7d3 | 2020-02-11 17:21:31 +0000 | [diff] [blame] | 62 | ARM_COMPUTE_RETURN_ERROR_ON(act_info.enabled() && !is_data_type_float(output->data_type())); |
Giorgio Arena | 7062382 | 2017-11-27 15:50:10 +0000 | [diff] [blame] | 63 | |
Michele Di Giorgio | 6259e5f | 2018-01-17 17:29:33 +0000 | [diff] [blame] | 64 | const TensorShape &out_shape = TensorShape::broadcast_shape(input1->tensor_shape(), input2->tensor_shape()); |
| 65 | |
| 66 | ARM_COMPUTE_RETURN_ERROR_ON_MSG(out_shape.total_size() == 0, "Inputs are not broadcast compatible"); |
Giorgio Arena | 7062382 | 2017-11-27 15:50:10 +0000 | [diff] [blame] | 67 | |
| 68 | // Validate in case of configured output |
Michele Di Giorgio | 6259e5f | 2018-01-17 17:29:33 +0000 | [diff] [blame] | 69 | if(output->total_size() > 0) |
Giorgio Arena | 7062382 | 2017-11-27 15:50:10 +0000 | [diff] [blame] | 70 | { |
Michele Di Giorgio | cbbed28 | 2019-12-20 13:26:08 +0000 | [diff] [blame] | 71 | ARM_COMPUTE_RETURN_ERROR_ON_DATA_TYPE_CHANNEL_NOT_IN(output, |
| 72 | 1, |
| 73 | DataType::U8, DataType::QASYMM8, DataType::QASYMM8_SIGNED, |
| 74 | DataType::S16, DataType::QSYMM16, DataType::F16, |
Michele Di Giorgio | 7a0212a | 2020-04-14 16:08:32 +0100 | [diff] [blame] | 75 | DataType::S32, DataType::F32); |
Giorgio Arena | 7062382 | 2017-11-27 15:50:10 +0000 | [diff] [blame] | 76 | ARM_COMPUTE_RETURN_ERROR_ON_MSG(output->data_type() == DataType::U8 && (input1->data_type() != DataType::U8 || input2->data_type() != DataType::U8), |
| 77 | "Output can only be U8 if both inputs are U8"); |
Michele Di Giorgio | d8a468f | 2019-06-19 15:34:41 +0100 | [diff] [blame] | 78 | ARM_COMPUTE_RETURN_ERROR_ON_MSG(output->data_type() == DataType::QASYMM8 && (input1->data_type() != DataType::QASYMM8 || input2->data_type() != DataType::QASYMM8), |
| 79 | "Output can only be QASYMM8 if both inputs are QASYMM8"); |
Michele Di Giorgio | cbbed28 | 2019-12-20 13:26:08 +0000 | [diff] [blame] | 80 | ARM_COMPUTE_RETURN_ERROR_ON_MSG(output->data_type() == DataType::QASYMM8_SIGNED && (input1->data_type() != DataType::QASYMM8_SIGNED || input2->data_type() != DataType::QASYMM8_SIGNED), |
| 81 | "Output can only be QASYMM8_SIGNED if both inputs are QASYMM8_SIGNED"); |
Michele Di Giorgio | d8a468f | 2019-06-19 15:34:41 +0100 | [diff] [blame] | 82 | ARM_COMPUTE_RETURN_ERROR_ON_MSG(output->data_type() == DataType::QSYMM16 && (input1->data_type() != DataType::QSYMM16 || input2->data_type() != DataType::QSYMM16), |
| 83 | "Output can only be QSYMM16 if both inputs are QSYMM16"); |
Michele Di Giorgio | 7a0212a | 2020-04-14 16:08:32 +0100 | [diff] [blame] | 84 | ARM_COMPUTE_RETURN_ERROR_ON_MSG(output->data_type() == DataType::S32 && (input1->data_type() != DataType::QSYMM16 || input2->data_type() != DataType::QSYMM16), |
| 85 | "Output can only be S32 if both inputs are QSYMM16"); |
Michele Di Giorgio | 6259e5f | 2018-01-17 17:29:33 +0000 | [diff] [blame] | 86 | ARM_COMPUTE_RETURN_ERROR_ON_MSG(detail::have_different_dimensions(out_shape, output->tensor_shape(), 0), "Wrong shape for output"); |
Giorgio Arena | 7062382 | 2017-11-27 15:50:10 +0000 | [diff] [blame] | 87 | } |
| 88 | |
Georgios Pinitas | 631c41a | 2017-12-06 11:53:03 +0000 | [diff] [blame] | 89 | return Status{}; |
Giorgio Arena | 7062382 | 2017-11-27 15:50:10 +0000 | [diff] [blame] | 90 | } |
| 91 | |
Georgios Pinitas | 631c41a | 2017-12-06 11:53:03 +0000 | [diff] [blame] | 92 | std::pair<Status, Window> validate_and_configure_window(ITensorInfo *input1, ITensorInfo *input2, ITensorInfo *output) |
Giorgio Arena | 7062382 | 2017-11-27 15:50:10 +0000 | [diff] [blame] | 93 | { |
Michele Di Giorgio | 6259e5f | 2018-01-17 17:29:33 +0000 | [diff] [blame] | 94 | const std::pair<TensorShape, ValidRegion> broadcast_pair = ITensorInfo::broadcast_shape_and_valid_region(*input1, *input2); |
| 95 | const TensorShape &out_shape = broadcast_pair.first; |
| 96 | const ValidRegion &valid_region = broadcast_pair.second; |
Giorgio Arena | 7062382 | 2017-11-27 15:50:10 +0000 | [diff] [blame] | 97 | |
Michele Di Giorgio | 6259e5f | 2018-01-17 17:29:33 +0000 | [diff] [blame] | 98 | // Auto initialize output if not initialized |
| 99 | { |
| 100 | set_shape_if_empty(*output, out_shape); |
| 101 | |
| 102 | if(input1->data_type() == DataType::S16 || input2->data_type() == DataType::S16) |
| 103 | { |
| 104 | set_format_if_unknown(*output, Format::S16); |
| 105 | } |
| 106 | else if(input1->data_type() == DataType::F32 || input2->data_type() == DataType::F32) |
| 107 | { |
| 108 | set_format_if_unknown(*output, Format::F32); |
| 109 | } |
Michele Di Giorgio | d8a468f | 2019-06-19 15:34:41 +0100 | [diff] [blame] | 110 | else if(input1->data_type() == DataType::QASYMM8) |
| 111 | { |
| 112 | set_data_type_if_unknown(*output, DataType::QASYMM8); |
| 113 | } |
Michele Di Giorgio | cbbed28 | 2019-12-20 13:26:08 +0000 | [diff] [blame] | 114 | else if(input1->data_type() == DataType::QASYMM8_SIGNED) |
| 115 | { |
| 116 | set_data_type_if_unknown(*output, DataType::QASYMM8_SIGNED); |
| 117 | } |
Michele Di Giorgio | d8a468f | 2019-06-19 15:34:41 +0100 | [diff] [blame] | 118 | else if(input1->data_type() == DataType::QSYMM16) |
| 119 | { |
| 120 | set_data_type_if_unknown(*output, DataType::QSYMM16); |
| 121 | } |
Michele Di Giorgio | 6259e5f | 2018-01-17 17:29:33 +0000 | [diff] [blame] | 122 | } |
| 123 | |
| 124 | Window win = calculate_max_window(valid_region, Steps(num_elems_processed_per_iteration)); |
| 125 | Window win_input1 = win.broadcast_if_dimension_le_one(*input1); |
| 126 | Window win_input2 = win.broadcast_if_dimension_le_one(*input2); |
Giorgio Arena | 7062382 | 2017-11-27 15:50:10 +0000 | [diff] [blame] | 127 | |
| 128 | AccessWindowHorizontal input1_access(input1, 0, num_elems_processed_per_iteration); |
| 129 | AccessWindowHorizontal input2_access(input2, 0, num_elems_processed_per_iteration); |
| 130 | AccessWindowHorizontal output_access(output, 0, num_elems_processed_per_iteration); |
| 131 | |
Michele Di Giorgio | 6259e5f | 2018-01-17 17:29:33 +0000 | [diff] [blame] | 132 | bool window_changed = update_window_and_padding(win_input1, input1_access) |
| 133 | || update_window_and_padding(win_input2, input2_access) |
| 134 | || update_window_and_padding(win, output_access); |
Giorgio Arena | 7062382 | 2017-11-27 15:50:10 +0000 | [diff] [blame] | 135 | |
Giorgio Arena | 7062382 | 2017-11-27 15:50:10 +0000 | [diff] [blame] | 136 | output_access.set_valid_region(win, valid_region); |
| 137 | |
Georgios Pinitas | 631c41a | 2017-12-06 11:53:03 +0000 | [diff] [blame] | 138 | Status err = (window_changed) ? ARM_COMPUTE_CREATE_ERROR(ErrorCode::RUNTIME_ERROR, "Insufficient Padding!") : Status{}; |
Giorgio Arena | 7062382 | 2017-11-27 15:50:10 +0000 | [diff] [blame] | 139 | return std::make_pair(err, win); |
| 140 | } |
| 141 | } // namespace |
| 142 | |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 143 | CLPixelWiseMultiplicationKernel::CLPixelWiseMultiplicationKernel() |
| 144 | : _input1(nullptr), _input2(nullptr), _output(nullptr) |
| 145 | { |
| 146 | } |
| 147 | |
Michalis Spyrou | 1009e87 | 2020-07-27 12:48:34 +0100 | [diff] [blame] | 148 | void CLPixelWiseMultiplicationKernel::configure(ITensorInfo *input1, ITensorInfo *input2, ITensorInfo *output, float scale, |
Giorgio Arena | 8b2a7d3 | 2020-02-11 17:21:31 +0000 | [diff] [blame] | 149 | ConvertPolicy overflow_policy, RoundingPolicy rounding_policy, const ActivationLayerInfo &act_info) |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 150 | { |
Manuel Bottini | 4c6bd51 | 2020-04-08 10:15:51 +0100 | [diff] [blame] | 151 | configure(CLKernelLibrary::get().get_compile_context(), input1, input2, output, scale, overflow_policy, rounding_policy, act_info); |
| 152 | } |
| 153 | |
Michalis Spyrou | 1009e87 | 2020-07-27 12:48:34 +0100 | [diff] [blame] | 154 | void CLPixelWiseMultiplicationKernel::configure(const CLCompileContext &compile_context, ITensorInfo *input1, ITensorInfo *input2, ITensorInfo *output, float scale, |
Manuel Bottini | 4c6bd51 | 2020-04-08 10:15:51 +0100 | [diff] [blame] | 155 | ConvertPolicy overflow_policy, RoundingPolicy rounding_policy, const ActivationLayerInfo &act_info) |
| 156 | { |
Georgios Pinitas | f0dea70 | 2017-07-03 18:17:28 +0100 | [diff] [blame] | 157 | ARM_COMPUTE_ERROR_ON_NULLPTR(input1, input2, output); |
Michalis Spyrou | 1009e87 | 2020-07-27 12:48:34 +0100 | [diff] [blame] | 158 | ARM_COMPUTE_ERROR_THROW_ON(validate_arguments(input1, input2, output, |
Giorgio Arena | 8b2a7d3 | 2020-02-11 17:21:31 +0000 | [diff] [blame] | 159 | scale, overflow_policy, rounding_policy, act_info)); |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 160 | |
Michele Di Giorgio | 6259e5f | 2018-01-17 17:29:33 +0000 | [diff] [blame] | 161 | // Configure kernel window |
Michalis Spyrou | 1009e87 | 2020-07-27 12:48:34 +0100 | [diff] [blame] | 162 | auto win_config = validate_and_configure_window(input1, input2, output); |
Michele Di Giorgio | 6259e5f | 2018-01-17 17:29:33 +0000 | [diff] [blame] | 163 | ARM_COMPUTE_ERROR_THROW_ON(win_config.first); |
| 164 | |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 165 | _input1 = input1; |
| 166 | _input2 = input2; |
| 167 | _output = output; |
| 168 | |
| 169 | int scale_int = -1; |
| 170 | // Extract sign, exponent and mantissa |
| 171 | int exponent = 0; |
| 172 | float normalized_mantissa = std::frexp(scale, &exponent); |
| 173 | // Use int scaling if factor is equal to 1/2^n for 0 <= n <= 15 |
| 174 | // frexp returns 0.5 as mantissa which means that the exponent will be in the range of -1 <= e <= 14 |
| 175 | // Moreover, it will be negative as we deal with 1/2^n |
| 176 | if((normalized_mantissa == 0.5f) && (-14 <= exponent) && (exponent <= 1)) |
| 177 | { |
| 178 | // Store the positive exponent. We know that we compute 1/2^n |
| 179 | // Additionally we need to subtract 1 to compensate that frexp used a mantissa of 0.5 |
| 180 | scale_int = std::abs(exponent - 1); |
| 181 | } |
| 182 | |
Michele Di Giorgio | 7a0212a | 2020-04-14 16:08:32 +0100 | [diff] [blame] | 183 | std::string acc_type; |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 184 | // Check if it has float inputs and output |
Michalis Spyrou | 1009e87 | 2020-07-27 12:48:34 +0100 | [diff] [blame] | 185 | if(is_data_type_float(input1->data_type()) || is_data_type_float(input2->data_type())) |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 186 | { |
Michele Di Giorgio | 7a0212a | 2020-04-14 16:08:32 +0100 | [diff] [blame] | 187 | scale_int = -1; |
Michalis Spyrou | 1009e87 | 2020-07-27 12:48:34 +0100 | [diff] [blame] | 188 | acc_type = (input1->data_type() == DataType::F32 || input2->data_type() == DataType::F32) ? "float" : "half"; |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 189 | } |
| 190 | else |
| 191 | { |
Michalis Spyrou | 1009e87 | 2020-07-27 12:48:34 +0100 | [diff] [blame] | 192 | if(input1->element_size() == 2 || input2->element_size() == 2) |
Michele Di Giorgio | ab0a77e | 2017-06-21 15:36:24 +0100 | [diff] [blame] | 193 | { |
Michele Di Giorgio | 7a0212a | 2020-04-14 16:08:32 +0100 | [diff] [blame] | 194 | // Use 32-bit accumulator for 16-bit input |
| 195 | acc_type = "int"; |
Michele Di Giorgio | ab0a77e | 2017-06-21 15:36:24 +0100 | [diff] [blame] | 196 | } |
Michele Di Giorgio | ab0a77e | 2017-06-21 15:36:24 +0100 | [diff] [blame] | 197 | else |
| 198 | { |
Michele Di Giorgio | 7a0212a | 2020-04-14 16:08:32 +0100 | [diff] [blame] | 199 | // Use 16-bit accumulator for 8-bit input |
| 200 | acc_type = "ushort"; |
Michele Di Giorgio | ab0a77e | 2017-06-21 15:36:24 +0100 | [diff] [blame] | 201 | } |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 202 | } |
| 203 | |
Michalis Spyrou | 1009e87 | 2020-07-27 12:48:34 +0100 | [diff] [blame] | 204 | const bool is_quantized = is_data_type_quantized(input1->data_type()); |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 205 | |
| 206 | // Set kernel build options |
Michele Di Giorgio | d8a468f | 2019-06-19 15:34:41 +0100 | [diff] [blame] | 207 | std::string kernel_name = "pixelwise_mul"; |
Georgios Pinitas | bf28a3c | 2018-09-18 14:34:48 +0100 | [diff] [blame] | 208 | CLBuildOptions build_opts; |
Michalis Spyrou | 1009e87 | 2020-07-27 12:48:34 +0100 | [diff] [blame] | 209 | build_opts.add_option("-DDATA_TYPE_IN1=" + get_cl_type_from_data_type(input1->data_type())); |
| 210 | build_opts.add_option("-DDATA_TYPE_IN2=" + get_cl_type_from_data_type(input2->data_type())); |
| 211 | build_opts.add_option("-DDATA_TYPE_OUT=" + get_cl_type_from_data_type(output->data_type())); |
Michele Di Giorgio | d8a468f | 2019-06-19 15:34:41 +0100 | [diff] [blame] | 212 | build_opts.add_option("-DVEC_SIZE=" + support::cpp11::to_string(num_elems_processed_per_iteration)); |
Michalis Spyrou | 1009e87 | 2020-07-27 12:48:34 +0100 | [diff] [blame] | 213 | if(is_quantized && (output->data_type() != DataType::S32)) |
Georgios Pinitas | bf28a3c | 2018-09-18 14:34:48 +0100 | [diff] [blame] | 214 | { |
Michalis Spyrou | 1009e87 | 2020-07-27 12:48:34 +0100 | [diff] [blame] | 215 | const UniformQuantizationInfo iq1_info = input1->quantization_info().uniform(); |
| 216 | const UniformQuantizationInfo iq2_info = input2->quantization_info().uniform(); |
| 217 | const UniformQuantizationInfo oq_info = output->quantization_info().uniform(); |
Georgios Pinitas | 4c5469b | 2019-05-21 13:32:43 +0100 | [diff] [blame] | 218 | |
Michalis Spyrou | 1009e87 | 2020-07-27 12:48:34 +0100 | [diff] [blame] | 219 | build_opts.add_option_if(is_data_type_quantized_asymmetric(input1->data_type()), |
Michele Di Giorgio | d8a468f | 2019-06-19 15:34:41 +0100 | [diff] [blame] | 220 | "-DOFFSET_IN1=" + support::cpp11::to_string(iq1_info.offset)); |
Michalis Spyrou | 1009e87 | 2020-07-27 12:48:34 +0100 | [diff] [blame] | 221 | build_opts.add_option_if(is_data_type_quantized_asymmetric(input2->data_type()), |
Michele Di Giorgio | d8a468f | 2019-06-19 15:34:41 +0100 | [diff] [blame] | 222 | "-DOFFSET_IN2=" + support::cpp11::to_string(iq2_info.offset)); |
Michalis Spyrou | 1009e87 | 2020-07-27 12:48:34 +0100 | [diff] [blame] | 223 | build_opts.add_option_if(is_data_type_quantized_asymmetric(output->data_type()), |
Michele Di Giorgio | d8a468f | 2019-06-19 15:34:41 +0100 | [diff] [blame] | 224 | "-DOFFSET_OUT=" + support::cpp11::to_string(oq_info.offset)); |
| 225 | build_opts.add_option("-DSCALE_IN1=" + float_to_string_with_full_precision(iq1_info.scale)); |
| 226 | build_opts.add_option("-DSCALE_IN2=" + float_to_string_with_full_precision(iq2_info.scale)); |
| 227 | build_opts.add_option("-DSCALE_OUT=" + float_to_string_with_full_precision(oq_info.scale)); |
Georgios Pinitas | bf28a3c | 2018-09-18 14:34:48 +0100 | [diff] [blame] | 228 | kernel_name += "_quantized"; |
| 229 | } |
| 230 | else |
| 231 | { |
Michele Di Giorgio | d8a468f | 2019-06-19 15:34:41 +0100 | [diff] [blame] | 232 | kernel_name += (scale_int >= 0) ? "_int" : "_float"; |
Michalis Spyrou | 1009e87 | 2020-07-27 12:48:34 +0100 | [diff] [blame] | 233 | build_opts.add_option_if_else(overflow_policy == ConvertPolicy::WRAP || is_data_type_float(output->data_type()), "-DWRAP", "-DSATURATE"); |
Georgios Pinitas | bf28a3c | 2018-09-18 14:34:48 +0100 | [diff] [blame] | 234 | build_opts.add_option_if_else(rounding_policy == RoundingPolicy::TO_ZERO, "-DROUND=_rtz", "-DROUND=_rte"); |
Michele Di Giorgio | 7a0212a | 2020-04-14 16:08:32 +0100 | [diff] [blame] | 235 | build_opts.add_option("-DACC_DATA_TYPE=" + acc_type); |
Giorgio Arena | 8b2a7d3 | 2020-02-11 17:21:31 +0000 | [diff] [blame] | 236 | if(act_info.enabled()) |
| 237 | { |
| 238 | build_opts.add_option("-DACTIVATION_TYPE=" + lower_string(string_from_activation_func(act_info.activation()))); |
| 239 | build_opts.add_option("-DA_VAL=" + float_to_string_with_full_precision(act_info.a())); |
| 240 | build_opts.add_option("-DB_VAL=" + float_to_string_with_full_precision(act_info.b())); |
| 241 | } |
Georgios Pinitas | bf28a3c | 2018-09-18 14:34:48 +0100 | [diff] [blame] | 242 | } |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 243 | |
| 244 | // Create kernel |
Manuel Bottini | 4c6bd51 | 2020-04-08 10:15:51 +0100 | [diff] [blame] | 245 | _kernel = create_kernel(compile_context, kernel_name, build_opts.options()); |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 246 | |
| 247 | // Set scale argument |
Michele Di Giorgio | d8a468f | 2019-06-19 15:34:41 +0100 | [diff] [blame] | 248 | unsigned int idx = 3 * num_arguments_per_3D_tensor(); // Skip the inputs and output parameters |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 249 | |
Georgios Pinitas | bf28a3c | 2018-09-18 14:34:48 +0100 | [diff] [blame] | 250 | if(scale_int >= 0 && !is_quantized) |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 251 | { |
| 252 | _kernel.setArg(idx++, scale_int); |
| 253 | } |
| 254 | else |
| 255 | { |
| 256 | _kernel.setArg(idx++, scale); |
| 257 | } |
| 258 | |
Anthony Barbier | b6eb353 | 2018-08-08 13:20:04 +0100 | [diff] [blame] | 259 | ICLKernel::configure_internal(win_config.second); |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 260 | } |
| 261 | |
Georgios Pinitas | 631c41a | 2017-12-06 11:53:03 +0000 | [diff] [blame] | 262 | Status CLPixelWiseMultiplicationKernel::validate(const ITensorInfo *input1, const ITensorInfo *input2, const ITensorInfo *output, float scale, |
Giorgio Arena | 8b2a7d3 | 2020-02-11 17:21:31 +0000 | [diff] [blame] | 263 | ConvertPolicy overflow_policy, RoundingPolicy rounding_policy, const ActivationLayerInfo &act_info) |
Georgios Pinitas | f9d3a0a | 2017-11-03 19:01:44 +0000 | [diff] [blame] | 264 | { |
Michele Di Giorgio | 6259e5f | 2018-01-17 17:29:33 +0000 | [diff] [blame] | 265 | ARM_COMPUTE_ERROR_ON_NULLPTR(input1, input2, output); |
Giorgio Arena | 8b2a7d3 | 2020-02-11 17:21:31 +0000 | [diff] [blame] | 266 | ARM_COMPUTE_RETURN_ON_ERROR(validate_arguments(input1, input2, output, scale, overflow_policy, rounding_policy, act_info)); |
Giorgio Arena | 7062382 | 2017-11-27 15:50:10 +0000 | [diff] [blame] | 267 | ARM_COMPUTE_RETURN_ON_ERROR(validate_and_configure_window(input1->clone().get(), input2->clone().get(), output->clone().get()).first); |
Georgios Pinitas | f9d3a0a | 2017-11-03 19:01:44 +0000 | [diff] [blame] | 268 | |
Georgios Pinitas | 631c41a | 2017-12-06 11:53:03 +0000 | [diff] [blame] | 269 | return Status{}; |
Georgios Pinitas | f9d3a0a | 2017-11-03 19:01:44 +0000 | [diff] [blame] | 270 | } |
| 271 | |
Georgios Pinitas | 0499dff | 2020-07-31 22:21:38 +0100 | [diff] [blame] | 272 | void CLPixelWiseMultiplicationKernel::run_op(ITensorPack &tensors, const Window &window, cl::CommandQueue &queue) |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 273 | { |
| 274 | ARM_COMPUTE_ERROR_ON_UNCONFIGURED_KERNEL(this); |
| 275 | ARM_COMPUTE_ERROR_ON_INVALID_SUBWINDOW(ICLKernel::window(), window); |
| 276 | |
Georgios Pinitas | 0499dff | 2020-07-31 22:21:38 +0100 | [diff] [blame] | 277 | const auto src_0 = utils::cast::polymorphic_downcast<const ICLTensor *>(tensors.get_const_tensor(TensorType::ACL_SRC_0)); |
| 278 | const auto src_1 = utils::cast::polymorphic_downcast<const ICLTensor *>(tensors.get_const_tensor(TensorType::ACL_SRC_1)); |
| 279 | auto dst = utils::cast::polymorphic_downcast<ICLTensor *>(tensors.get_tensor(TensorType::ACL_DST)); |
Michalis Spyrou | 1009e87 | 2020-07-27 12:48:34 +0100 | [diff] [blame] | 280 | |
| 281 | const TensorShape &in_shape1 = src_0->info()->tensor_shape(); |
| 282 | const TensorShape &in_shape2 = src_1->info()->tensor_shape(); |
| 283 | const TensorShape &out_shape = dst->info()->tensor_shape(); |
Michele Di Giorgio | 6259e5f | 2018-01-17 17:29:33 +0000 | [diff] [blame] | 284 | |
| 285 | bool can_collapse = true; |
| 286 | if(std::min(in_shape1.total_size(), in_shape2.total_size()) > 1) |
| 287 | { |
| 288 | can_collapse = (std::min(in_shape1.num_dimensions(), in_shape2.num_dimensions()) > Window::DimZ); |
| 289 | for(size_t d = Window::DimZ; can_collapse && (d < out_shape.num_dimensions()); ++d) |
| 290 | { |
| 291 | can_collapse = (in_shape1[d] == in_shape2[d]); |
| 292 | } |
| 293 | } |
| 294 | |
| 295 | bool has_collapsed = false; |
| 296 | Window collapsed = can_collapse ? window.collapse_if_possible(ICLKernel::window(), Window::DimZ, &has_collapsed) : window; |
| 297 | |
| 298 | const TensorShape &in_shape1_collapsed = has_collapsed ? in_shape1.collapsed_from(Window::DimZ) : in_shape1; |
| 299 | const TensorShape &in_shape2_collapsed = has_collapsed ? in_shape2.collapsed_from(Window::DimZ) : in_shape2; |
| 300 | |
| 301 | Window slice = collapsed.first_slice_window_3D(); |
| 302 | Window slice_input1 = slice.broadcast_if_dimension_le_one(in_shape1_collapsed); |
| 303 | Window slice_input2 = slice.broadcast_if_dimension_le_one(in_shape2_collapsed); |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 304 | |
| 305 | do |
| 306 | { |
| 307 | unsigned int idx = 0; |
Michalis Spyrou | 1009e87 | 2020-07-27 12:48:34 +0100 | [diff] [blame] | 308 | add_3D_tensor_argument(idx, src_0, slice_input1); |
| 309 | add_3D_tensor_argument(idx, src_1, slice_input2); |
| 310 | add_3D_tensor_argument(idx, dst, slice); |
Georgios Pinitas | 275f99c | 2019-08-23 12:44:11 +0100 | [diff] [blame] | 311 | enqueue(queue, *this, slice, lws_hint()); |
Michele Di Giorgio | 6259e5f | 2018-01-17 17:29:33 +0000 | [diff] [blame] | 312 | |
Michalis Spyrou | ebdde65 | 2019-07-08 11:52:46 +0100 | [diff] [blame] | 313 | ARM_COMPUTE_UNUSED(collapsed.slide_window_slice_3D(slice_input1)); |
| 314 | ARM_COMPUTE_UNUSED(collapsed.slide_window_slice_3D(slice_input2)); |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 315 | } |
Georgios Pinitas | 1d08a31 | 2018-01-03 12:29:22 +0000 | [diff] [blame] | 316 | while(collapsed.slide_window_slice_3D(slice)); |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 317 | } |
Michele Di Giorgio | 6259e5f | 2018-01-17 17:29:33 +0000 | [diff] [blame] | 318 | |
| 319 | BorderSize CLPixelWiseMultiplicationKernel::border_size() const |
| 320 | { |
Michalis Spyrou | 1009e87 | 2020-07-27 12:48:34 +0100 | [diff] [blame] | 321 | const unsigned int replicateSize = _output->dimension(0) - std::min(_input1->dimension(0), _input2->dimension(0)); |
Michele Di Giorgio | 6259e5f | 2018-01-17 17:29:33 +0000 | [diff] [blame] | 322 | const unsigned int border = std::min<unsigned int>(num_elems_processed_per_iteration - 1U, replicateSize); |
Michalis Spyrou | a4f378d | 2019-04-26 14:54:54 +0100 | [diff] [blame] | 323 | return BorderSize{ 0, border, 0, 0 }; |
Michele Di Giorgio | 6259e5f | 2018-01-17 17:29:33 +0000 | [diff] [blame] | 324 | } |
Georgios Pinitas | 8be9148 | 2019-03-26 17:23:28 +0000 | [diff] [blame] | 325 | |
| 326 | namespace |
| 327 | { |
| 328 | constexpr unsigned int num_elems_processed_per_iteration_complex = 1; |
| 329 | |
Giorgio Arena | 8b2a7d3 | 2020-02-11 17:21:31 +0000 | [diff] [blame] | 330 | Status validate_arguments_complex(const ITensorInfo *input1, const ITensorInfo *input2, const ITensorInfo *output, const ActivationLayerInfo &act_info) |
Georgios Pinitas | 8be9148 | 2019-03-26 17:23:28 +0000 | [diff] [blame] | 331 | { |
| 332 | ARM_COMPUTE_RETURN_ERROR_ON_DATA_TYPE_CHANNEL_NOT_IN(input1, 2, DataType::F32); |
| 333 | ARM_COMPUTE_RETURN_ERROR_ON_DATA_TYPE_CHANNEL_NOT_IN(input2, 2, DataType::F32); |
| 334 | |
| 335 | const TensorShape &out_shape = TensorShape::broadcast_shape(input1->tensor_shape(), input2->tensor_shape()); |
| 336 | |
| 337 | ARM_COMPUTE_RETURN_ERROR_ON_MSG(out_shape.total_size() == 0, "Inputs are not broadcast compatible"); |
Giorgio Arena | 8b2a7d3 | 2020-02-11 17:21:31 +0000 | [diff] [blame] | 338 | ARM_COMPUTE_RETURN_ERROR_ON(act_info.enabled() && !is_data_type_float(output->data_type())); |
Georgios Pinitas | 8be9148 | 2019-03-26 17:23:28 +0000 | [diff] [blame] | 339 | |
| 340 | // Validate in case of configured output |
| 341 | if(output->total_size() > 0) |
| 342 | { |
| 343 | ARM_COMPUTE_RETURN_ERROR_ON_DATA_TYPE_CHANNEL_NOT_IN(output, 2, DataType::F32); |
| 344 | ARM_COMPUTE_RETURN_ERROR_ON_MSG(detail::have_different_dimensions(out_shape, output->tensor_shape(), 0), "Wrong shape for output"); |
| 345 | } |
| 346 | |
| 347 | return Status{}; |
| 348 | } |
| 349 | |
| 350 | std::pair<Status, Window> validate_and_configure_window_complex(ITensorInfo *input1, ITensorInfo *input2, ITensorInfo *output) |
| 351 | { |
| 352 | const std::pair<TensorShape, ValidRegion> broadcast_pair = ITensorInfo::broadcast_shape_and_valid_region(*input1, *input2); |
| 353 | const TensorShape &out_shape = broadcast_pair.first; |
| 354 | const ValidRegion &valid_region = broadcast_pair.second; |
| 355 | |
| 356 | // Auto initialize output if not initialized |
| 357 | const TensorInfo out_info(out_shape, input1->num_channels(), input1->data_type()); |
| 358 | auto_init_if_empty(*output, out_info); |
| 359 | |
| 360 | Window win = calculate_max_window(valid_region, Steps(num_elems_processed_per_iteration_complex)); |
| 361 | Window win_input1 = win.broadcast_if_dimension_le_one(*input1); |
| 362 | Window win_input2 = win.broadcast_if_dimension_le_one(*input2); |
| 363 | |
| 364 | AccessWindowHorizontal input1_access(input1, 0, num_elems_processed_per_iteration_complex); |
| 365 | AccessWindowHorizontal input2_access(input2, 0, num_elems_processed_per_iteration_complex); |
| 366 | AccessWindowHorizontal output_access(output, 0, num_elems_processed_per_iteration_complex); |
| 367 | |
| 368 | bool window_changed = update_window_and_padding(win_input1, input1_access) |
| 369 | || update_window_and_padding(win_input2, input2_access) |
| 370 | || update_window_and_padding(win, output_access); |
| 371 | |
| 372 | output_access.set_valid_region(win, valid_region); |
| 373 | |
| 374 | Status err = (window_changed) ? ARM_COMPUTE_CREATE_ERROR(ErrorCode::RUNTIME_ERROR, "Insufficient Padding!") : Status{}; |
| 375 | return std::make_pair(err, win); |
| 376 | } |
| 377 | } // namespace |
| 378 | |
| 379 | CLComplexPixelWiseMultiplicationKernel::CLComplexPixelWiseMultiplicationKernel() |
| 380 | : _input1(nullptr), _input2(nullptr), _output(nullptr) |
| 381 | { |
| 382 | } |
| 383 | |
Michalis Spyrou | 1009e87 | 2020-07-27 12:48:34 +0100 | [diff] [blame] | 384 | void CLComplexPixelWiseMultiplicationKernel::configure(ITensorInfo *input1, ITensorInfo *input2, ITensorInfo *output, const ActivationLayerInfo &act_info) |
Georgios Pinitas | 8be9148 | 2019-03-26 17:23:28 +0000 | [diff] [blame] | 385 | { |
Manuel Bottini | 4c6bd51 | 2020-04-08 10:15:51 +0100 | [diff] [blame] | 386 | configure(CLKernelLibrary::get().get_compile_context(), input1, input2, output, act_info); |
| 387 | } |
| 388 | |
Michalis Spyrou | 1009e87 | 2020-07-27 12:48:34 +0100 | [diff] [blame] | 389 | void CLComplexPixelWiseMultiplicationKernel::configure(const CLCompileContext &compile_context, ITensorInfo *input1, ITensorInfo *input2, ITensorInfo *output, const ActivationLayerInfo &act_info) |
Manuel Bottini | 4c6bd51 | 2020-04-08 10:15:51 +0100 | [diff] [blame] | 390 | { |
Georgios Pinitas | 8be9148 | 2019-03-26 17:23:28 +0000 | [diff] [blame] | 391 | ARM_COMPUTE_ERROR_ON_NULLPTR(input1, input2, output); |
Michalis Spyrou | 1009e87 | 2020-07-27 12:48:34 +0100 | [diff] [blame] | 392 | ARM_COMPUTE_ERROR_THROW_ON(validate_arguments_complex(input1, input2, output, act_info)); |
Georgios Pinitas | 8be9148 | 2019-03-26 17:23:28 +0000 | [diff] [blame] | 393 | |
| 394 | // Configure kernel window |
Michalis Spyrou | 1009e87 | 2020-07-27 12:48:34 +0100 | [diff] [blame] | 395 | auto win_config = validate_and_configure_window_complex(input1, input2, output); |
Georgios Pinitas | 8be9148 | 2019-03-26 17:23:28 +0000 | [diff] [blame] | 396 | ARM_COMPUTE_ERROR_THROW_ON(win_config.first); |
| 397 | |
| 398 | _input1 = input1; |
| 399 | _input2 = input2; |
| 400 | _output = output; |
| 401 | |
Giorgio Arena | 8b2a7d3 | 2020-02-11 17:21:31 +0000 | [diff] [blame] | 402 | CLBuildOptions build_opts; |
| 403 | if(act_info.enabled()) |
| 404 | { |
| 405 | build_opts.add_option("-DACTIVATION_TYPE=" + lower_string(string_from_activation_func(act_info.activation()))); |
| 406 | build_opts.add_option("-DA_VAL=" + float_to_string_with_full_precision(act_info.a())); |
| 407 | build_opts.add_option("-DB_VAL=" + float_to_string_with_full_precision(act_info.b())); |
| 408 | } |
| 409 | |
Georgios Pinitas | 8be9148 | 2019-03-26 17:23:28 +0000 | [diff] [blame] | 410 | // Create kernel |
Manuel Bottini | 4c6bd51 | 2020-04-08 10:15:51 +0100 | [diff] [blame] | 411 | _kernel = create_kernel(compile_context, "pixelwise_mul_complex", build_opts.options()); |
Georgios Pinitas | 8be9148 | 2019-03-26 17:23:28 +0000 | [diff] [blame] | 412 | |
| 413 | ICLKernel::configure_internal(win_config.second); |
| 414 | } |
| 415 | |
Giorgio Arena | 8b2a7d3 | 2020-02-11 17:21:31 +0000 | [diff] [blame] | 416 | Status CLComplexPixelWiseMultiplicationKernel::validate(const ITensorInfo *input1, const ITensorInfo *input2, const ITensorInfo *output, const ActivationLayerInfo &act_info) |
Georgios Pinitas | 8be9148 | 2019-03-26 17:23:28 +0000 | [diff] [blame] | 417 | { |
| 418 | ARM_COMPUTE_ERROR_ON_NULLPTR(input1, input2, output); |
Giorgio Arena | 8b2a7d3 | 2020-02-11 17:21:31 +0000 | [diff] [blame] | 419 | ARM_COMPUTE_RETURN_ON_ERROR(validate_arguments_complex(input1, input2, output, act_info)); |
Georgios Pinitas | 8be9148 | 2019-03-26 17:23:28 +0000 | [diff] [blame] | 420 | ARM_COMPUTE_RETURN_ON_ERROR(validate_and_configure_window_complex(input1->clone().get(), input2->clone().get(), output->clone().get()).first); |
| 421 | |
| 422 | return Status{}; |
| 423 | } |
| 424 | |
Georgios Pinitas | 0499dff | 2020-07-31 22:21:38 +0100 | [diff] [blame] | 425 | void CLComplexPixelWiseMultiplicationKernel::run_op(ITensorPack &tensors, const Window &window, cl::CommandQueue &queue) |
Georgios Pinitas | 8be9148 | 2019-03-26 17:23:28 +0000 | [diff] [blame] | 426 | { |
| 427 | ARM_COMPUTE_ERROR_ON_UNCONFIGURED_KERNEL(this); |
| 428 | ARM_COMPUTE_ERROR_ON_INVALID_SUBWINDOW(ICLKernel::window(), window); |
| 429 | |
Georgios Pinitas | 0499dff | 2020-07-31 22:21:38 +0100 | [diff] [blame] | 430 | const auto src_0 = utils::cast::polymorphic_downcast<const ICLTensor *>(tensors.get_const_tensor(TensorType::ACL_SRC_0)); |
| 431 | const auto src_1 = utils::cast::polymorphic_downcast<const ICLTensor *>(tensors.get_const_tensor(TensorType::ACL_SRC_1)); |
| 432 | auto dst = utils::cast::polymorphic_downcast<ICLTensor *>(tensors.get_tensor(TensorType::ACL_DST)); |
Michalis Spyrou | 1009e87 | 2020-07-27 12:48:34 +0100 | [diff] [blame] | 433 | |
| 434 | const TensorShape &in_shape1 = src_0->info()->tensor_shape(); |
| 435 | const TensorShape &in_shape2 = src_1->info()->tensor_shape(); |
| 436 | const TensorShape &out_shape = dst->info()->tensor_shape(); |
Georgios Pinitas | 8be9148 | 2019-03-26 17:23:28 +0000 | [diff] [blame] | 437 | |
| 438 | bool can_collapse = true; |
| 439 | if(std::min(in_shape1.total_size(), in_shape2.total_size()) > 1) |
| 440 | { |
| 441 | can_collapse = (std::min(in_shape1.num_dimensions(), in_shape2.num_dimensions()) > Window::DimZ); |
| 442 | for(size_t d = Window::DimZ; can_collapse && (d < out_shape.num_dimensions()); ++d) |
| 443 | { |
| 444 | can_collapse = (in_shape1[d] == in_shape2[d]); |
| 445 | } |
| 446 | } |
| 447 | |
| 448 | bool has_collapsed = false; |
| 449 | Window collapsed = can_collapse ? window.collapse_if_possible(ICLKernel::window(), Window::DimZ, &has_collapsed) : window; |
| 450 | |
| 451 | const TensorShape &in_shape1_collapsed = has_collapsed ? in_shape1.collapsed_from(Window::DimZ) : in_shape1; |
| 452 | const TensorShape &in_shape2_collapsed = has_collapsed ? in_shape2.collapsed_from(Window::DimZ) : in_shape2; |
| 453 | |
| 454 | Window slice = collapsed.first_slice_window_3D(); |
| 455 | Window slice_input1 = slice.broadcast_if_dimension_le_one(in_shape1_collapsed); |
| 456 | Window slice_input2 = slice.broadcast_if_dimension_le_one(in_shape2_collapsed); |
| 457 | |
| 458 | do |
| 459 | { |
| 460 | unsigned int idx = 0; |
Michalis Spyrou | 1009e87 | 2020-07-27 12:48:34 +0100 | [diff] [blame] | 461 | add_3D_tensor_argument(idx, src_0, slice_input1); |
| 462 | add_3D_tensor_argument(idx, src_1, slice_input2); |
| 463 | add_3D_tensor_argument(idx, dst, slice); |
Georgios Pinitas | 275f99c | 2019-08-23 12:44:11 +0100 | [diff] [blame] | 464 | enqueue(queue, *this, slice, lws_hint()); |
Georgios Pinitas | 8be9148 | 2019-03-26 17:23:28 +0000 | [diff] [blame] | 465 | |
Michalis Spyrou | ebdde65 | 2019-07-08 11:52:46 +0100 | [diff] [blame] | 466 | ARM_COMPUTE_UNUSED(collapsed.slide_window_slice_3D(slice_input1)); |
| 467 | ARM_COMPUTE_UNUSED(collapsed.slide_window_slice_3D(slice_input2)); |
Georgios Pinitas | 8be9148 | 2019-03-26 17:23:28 +0000 | [diff] [blame] | 468 | } |
| 469 | while(collapsed.slide_window_slice_3D(slice)); |
| 470 | } |
| 471 | |
| 472 | BorderSize CLComplexPixelWiseMultiplicationKernel::border_size() const |
| 473 | { |
Michalis Spyrou | 1009e87 | 2020-07-27 12:48:34 +0100 | [diff] [blame] | 474 | const unsigned int replicateSize = _output->dimension(0) - std::min(_input1->dimension(0), _input2->dimension(0)); |
Georgios Pinitas | 8be9148 | 2019-03-26 17:23:28 +0000 | [diff] [blame] | 475 | const unsigned int border = std::min<unsigned int>(num_elems_processed_per_iteration_complex - 1U, replicateSize); |
Michalis Spyrou | a4f378d | 2019-04-26 14:54:54 +0100 | [diff] [blame] | 476 | return BorderSize{ 0, border, 0, 0 }; |
Georgios Pinitas | 8be9148 | 2019-03-26 17:23:28 +0000 | [diff] [blame] | 477 | } |
Michele Di Giorgio | d8a468f | 2019-06-19 15:34:41 +0100 | [diff] [blame] | 478 | } // namespace arm_compute |