blob: 4c191de0bdb393bd14d476c5a27ad95d46513af8 [file] [log] [blame]
giuros01164a2722018-11-20 18:34:46 +00001/*
Michalis Spyroubcfd09a2019-05-01 13:03:59 +01002 * Copyright (c) 2018-2019 ARM Limited.
giuros01164a2722018-11-20 18:34:46 +00003 *
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/CLElementwiseOperationKernel.h"
25
26#include "arm_compute/core/CL/CLHelpers.h"
27#include "arm_compute/core/CL/CLValidate.h"
28#include "arm_compute/core/CL/ICLTensor.h"
29#include <map>
30
31namespace arm_compute
32{
33namespace
34{
35constexpr unsigned int num_elems_processed_per_iteration = 16;
36
37std::map<ArithmeticOperation, std::string> supported_arithmetic_ops =
38{
39 { ArithmeticOperation::ADD, "ADD" },
40 { ArithmeticOperation::SUB, "SUB" },
41 { ArithmeticOperation::DIV, "DIV" },
42 { ArithmeticOperation::SQUARED_DIFF, "SQUARED_DIFF" },
43 { ArithmeticOperation::MIN, "MIN" },
44 { ArithmeticOperation::MAX, "MAX" },
Usama Arif52c54f62019-05-14 10:22:36 +010045 { ArithmeticOperation::POWER, "POWER" },
giuros011e6e1b82019-05-14 16:12:53 +010046 { ArithmeticOperation::PRELU, "PRELU" },
giuros01164a2722018-11-20 18:34:46 +000047};
48
49std::map<ArithmeticOperation, std::string> supported_sat_arithmetic_ops =
50{
51 { ArithmeticOperation::ADD, "ADD" },
52 { ArithmeticOperation::SUB, "SUB" },
53};
54
55std::string generate_id_for_tuning_common(const std::string &kernel_name, const ITensorInfo &input1, const ITensorInfo &output)
56{
57 std::string config_id;
58 // Set config_id for enabling LWS tuning
59 config_id = kernel_name;
60 config_id += "_";
61 config_id += lower_string(string_from_data_type(input1.data_type()));
62 config_id += "_";
63 config_id += support::cpp11::to_string(output.dimension(0));
64 config_id += "_";
65 config_id += support::cpp11::to_string(output.dimension(1));
66 return config_id;
67}
68
Usama Arif52c54f62019-05-14 10:22:36 +010069Status validate_arguments_with_float_only_supported_rules(const ITensorInfo &input1, const ITensorInfo &input2, const ITensorInfo &output)
giuros0149f7c022018-12-03 19:25:22 +000070{
71 ARM_COMPUTE_RETURN_ERROR_ON_NULLPTR(&input1, &input2, &output);
72 ARM_COMPUTE_RETURN_ERROR_ON_F16_UNSUPPORTED(&input1);
73 ARM_COMPUTE_RETURN_ERROR_ON_DATA_TYPE_CHANNEL_NOT_IN(&input1, 1, DataType::F16, DataType::F32);
74 ARM_COMPUTE_RETURN_ERROR_ON_MISMATCHING_DATA_TYPES(&input1, &input2);
75
76 const TensorShape out_shape = TensorShape::broadcast_shape(input1.tensor_shape(), input2.tensor_shape());
77
78 ARM_COMPUTE_RETURN_ERROR_ON_MSG(out_shape.total_size() == 0, "Inputs are not broadcast compatible");
79
80 // Validate in case of configured output
81 if(output.total_size() > 0)
82 {
83 ARM_COMPUTE_RETURN_ERROR_ON_DATA_TYPE_CHANNEL_NOT_IN(&output, 1, DataType::F16, DataType::F32);
84 ARM_COMPUTE_RETURN_ERROR_ON_MISMATCHING_DATA_TYPES(&input1, &output);
85 ARM_COMPUTE_RETURN_ERROR_ON_MSG(detail::have_different_dimensions(out_shape, output.tensor_shape(), 0),
86 "Wrong shape for output");
87 }
88
89 return Status{};
90}
91
giuros01164a2722018-11-20 18:34:46 +000092Status validate_arguments_with_arithmetic_rules(const ITensorInfo &input1, const ITensorInfo &input2, const ITensorInfo &output)
93{
94 ARM_COMPUTE_RETURN_ERROR_ON_F16_UNSUPPORTED(&input1);
Michele Di Giorgio6997fc92019-06-18 10:23:22 +010095 ARM_COMPUTE_RETURN_ERROR_ON_DATA_TYPE_CHANNEL_NOT_IN(&input1, 1, DataType::U8, DataType::QASYMM8, DataType::S16, DataType::QSYMM16, DataType::F16, DataType::F32);
giuros01164a2722018-11-20 18:34:46 +000096 ARM_COMPUTE_RETURN_ERROR_ON_F16_UNSUPPORTED(&input2);
Michele Di Giorgio6997fc92019-06-18 10:23:22 +010097 ARM_COMPUTE_RETURN_ERROR_ON_DATA_TYPE_CHANNEL_NOT_IN(&input2, 1, DataType::U8, DataType::QASYMM8, DataType::S16, DataType::QSYMM16, DataType::F16, DataType::F32);
giuros01164a2722018-11-20 18:34:46 +000098
Michele Di Giorgio6997fc92019-06-18 10:23:22 +010099 const bool is_quantized = is_data_type_quantized(input1.data_type()) || is_data_type_quantized(input2.data_type());
100 if(is_quantized)
giuros01164a2722018-11-20 18:34:46 +0000101 {
102 ARM_COMPUTE_RETURN_ERROR_ON_MISMATCHING_DATA_TYPES(&input1, &input2);
Michele Di Giorgio6997fc92019-06-18 10:23:22 +0100103
104 if(is_data_type_quantized_symmetric(input1.data_type()))
105 {
106 const int32_t in1_offset = input1.quantization_info().uniform().offset;
107 const int32_t in2_offset = input2.quantization_info().uniform().offset;
108 ARM_COMPUTE_RETURN_ERROR_ON_MSG(in1_offset != 0, "For quantized symmetric, offset must be zero");
109 ARM_COMPUTE_RETURN_ERROR_ON_MSG(in2_offset != 0, "For quantized symmetric, offset must be zero");
110 }
giuros01164a2722018-11-20 18:34:46 +0000111 }
112
113 const TensorShape out_shape = TensorShape::broadcast_shape(input1.tensor_shape(), input2.tensor_shape());
114
115 ARM_COMPUTE_RETURN_ERROR_ON_MSG(out_shape.total_size() == 0, "Inputs are not broadcast compatible");
116
117 // Validate in case of configured output
118 if(output.total_size() > 0)
119 {
120 ARM_COMPUTE_RETURN_ERROR_ON_F16_UNSUPPORTED(&output);
Michele Di Giorgio6997fc92019-06-18 10:23:22 +0100121 ARM_COMPUTE_RETURN_ERROR_ON_DATA_TYPE_CHANNEL_NOT_IN(&output, 1, DataType::U8, DataType::QASYMM8, DataType::S16, DataType::QSYMM16, DataType::F16, DataType::F32);
giuros01164a2722018-11-20 18:34:46 +0000122 ARM_COMPUTE_RETURN_ERROR_ON_MSG((output.data_type() == DataType::U8) && ((input1.data_type() != DataType::U8) || (input2.data_type() != DataType::U8)),
123 "Output can only be U8 if both inputs are U8");
124 ARM_COMPUTE_RETURN_ERROR_ON_MSG(detail::have_different_dimensions(out_shape, output.tensor_shape(), 0),
125 "Wrong shape for output");
Michele Di Giorgio6997fc92019-06-18 10:23:22 +0100126
127 if(is_quantized)
giuros01164a2722018-11-20 18:34:46 +0000128 {
129 ARM_COMPUTE_RETURN_ERROR_ON_MISMATCHING_DATA_TYPES(&input1, &output);
Michele Di Giorgio6997fc92019-06-18 10:23:22 +0100130
131 if(is_data_type_quantized_symmetric(output.data_type()))
132 {
133 const int32_t offset = output.quantization_info().uniform().offset;
134 ARM_COMPUTE_RETURN_ERROR_ON_MSG(offset != 0, "For quantized symmetric, offset must be zero");
135 }
giuros01164a2722018-11-20 18:34:46 +0000136 }
137 }
138 return Status{};
139}
140
141CLBuildOptions generate_build_options_with_arithmetic_rules(const ITensorInfo &input1, const ITensorInfo &input2, const ITensorInfo &output, const std::string &operation_string)
142{
143 CLBuildOptions build_opts;
144
145 build_opts.add_option("-DDATA_TYPE_IN1=" + get_cl_type_from_data_type(input1.data_type()));
146 build_opts.add_option("-DDATA_TYPE_IN2=" + get_cl_type_from_data_type(input2.data_type()));
147 build_opts.add_option("-DDATA_TYPE_OUT=" + get_cl_type_from_data_type(output.data_type()));
148 build_opts.add_option("-DVEC_SIZE=" + support::cpp11::to_string(num_elems_processed_per_iteration));
149 build_opts.add_option("-DOP=" + operation_string);
Michele Di Giorgio6997fc92019-06-18 10:23:22 +0100150 if(is_data_type_quantized(input1.data_type()))
giuros01164a2722018-11-20 18:34:46 +0000151 {
Georgios Pinitas4c5469b2019-05-21 13:32:43 +0100152 const UniformQuantizationInfo iq1info = input1.quantization_info().uniform();
153 const UniformQuantizationInfo iq2info = input2.quantization_info().uniform();
154 const UniformQuantizationInfo oqinfo = output.quantization_info().uniform();
155
156 build_opts.add_option("-DOFFSET_IN1=" + support::cpp11::to_string(iq1info.offset));
157 build_opts.add_option("-DOFFSET_IN2=" + support::cpp11::to_string(iq2info.offset));
158 build_opts.add_option("-DOFFSET_OUT=" + support::cpp11::to_string(oqinfo.offset));
159 build_opts.add_option("-DSCALE_IN1=" + float_to_string_with_full_precision(iq1info.scale));
160 build_opts.add_option("-DSCALE_IN2=" + float_to_string_with_full_precision(iq2info.scale));
161 build_opts.add_option("-DSCALE_OUT=" + float_to_string_with_full_precision(oqinfo.scale));
giuros01164a2722018-11-20 18:34:46 +0000162 }
163 return build_opts;
164}
165
giuros0149f7c022018-12-03 19:25:22 +0000166std::pair<Status, Window> configure_window_arithmetic_common(const ValidRegion &valid_region, ITensorInfo &input1, ITensorInfo &input2, ITensorInfo &output)
167{
168 Window win = calculate_max_window(valid_region, Steps(num_elems_processed_per_iteration));
169 Window win_input1 = win.broadcast_if_dimension_le_one(input1);
170 Window win_input2 = win.broadcast_if_dimension_le_one(input2);
171
172 AccessWindowHorizontal input1_access(&input1, 0, num_elems_processed_per_iteration);
173 AccessWindowHorizontal input2_access(&input2, 0, num_elems_processed_per_iteration);
174 AccessWindowHorizontal output_access(&output, 0, num_elems_processed_per_iteration);
175
176 bool window_changed = update_window_and_padding(win_input1, input1_access)
177 || update_window_and_padding(win_input2, input2_access)
178 || update_window_and_padding(win, output_access);
179
180 output_access.set_valid_region(win, valid_region);
181
182 Status err = (window_changed) ? ARM_COMPUTE_CREATE_ERROR(ErrorCode::RUNTIME_ERROR, "Insufficient Padding!") : Status{};
183 return std::make_pair(err, win);
184}
185
giuros01164a2722018-11-20 18:34:46 +0000186std::pair<Status, Window> validate_and_configure_window_for_arithmetic_operators(ITensorInfo &input1, ITensorInfo &input2, ITensorInfo &output)
187{
188 const std::pair<TensorShape, ValidRegion> broadcast_pair = ITensorInfo::broadcast_shape_and_valid_region(input1, input2);
189 const TensorShape &out_shape = broadcast_pair.first;
190 const ValidRegion &valid_region = broadcast_pair.second;
191
192 set_shape_if_empty(output, out_shape);
193
194 if(input1.data_type() == DataType::S16 || input2.data_type() == DataType::S16)
195 {
196 set_format_if_unknown(output, Format::S16);
197 }
198 else if(input1.data_type() == DataType::F16 && input2.data_type() == DataType::F16)
199 {
200 set_format_if_unknown(output, Format::F16);
201 }
202 else if(input1.data_type() == DataType::F32 || input2.data_type() == DataType::F32)
203 {
204 set_format_if_unknown(output, Format::F32);
205 }
Michele Di Giorgio6997fc92019-06-18 10:23:22 +0100206 else if(input1.data_type() == DataType::QASYMM8 || input2.data_type() == DataType::QASYMM8)
207 {
208 set_data_type_if_unknown(output, DataType::QASYMM8);
209 }
210 else if(input1.data_type() == DataType::QSYMM16 || input2.data_type() == DataType::QSYMM16)
211 {
212 set_data_type_if_unknown(output, DataType::QSYMM16);
213 }
giuros01164a2722018-11-20 18:34:46 +0000214
giuros0149f7c022018-12-03 19:25:22 +0000215 return configure_window_arithmetic_common(valid_region, input1, input2, output);
216}
giuros01164a2722018-11-20 18:34:46 +0000217
giuros0149f7c022018-12-03 19:25:22 +0000218std::pair<Status, Window> validate_and_configure_window_for_division(ITensorInfo &input1, ITensorInfo &input2, ITensorInfo &output)
219{
220 const std::pair<TensorShape, ValidRegion> broadcast_pair = ITensorInfo::broadcast_shape_and_valid_region(input1, input2);
221 const TensorShape &out_shape = broadcast_pair.first;
222 const ValidRegion &valid_region = broadcast_pair.second;
223 auto_init_if_empty(output, out_shape, 1, input1.data_type());
224 return configure_window_arithmetic_common(valid_region, input1, input2, output);
giuros01164a2722018-11-20 18:34:46 +0000225}
226} // namespace
227
228CLElementwiseOperationKernel::CLElementwiseOperationKernel()
229 : _input1(nullptr), _input2(nullptr), _output(nullptr)
230{
231}
232
233void CLElementwiseOperationKernel::configure_common(const ICLTensor *input1, const ICLTensor *input2, ICLTensor *output)
234{
235 ARM_COMPUTE_ERROR_ON_NULLPTR(input1, input2, output);
236 ARM_COMPUTE_ERROR_THROW_ON(validate_arguments(*input1->info(), *input2->info(), *output->info()));
237
238 // Configure kernel window
239 auto win_config = validate_and_configure_window(*input1->info(), *input2->info(), *output->info());
240 ARM_COMPUTE_ERROR_THROW_ON(win_config.first);
241
242 _input1 = input1;
243 _input2 = input2;
244 _output = output;
245
246 std::string kernel_name = "elementwise_operation_" + name();
Michele Di Giorgio6997fc92019-06-18 10:23:22 +0100247 if(is_data_type_quantized(input1->info()->data_type()))
giuros01164a2722018-11-20 18:34:46 +0000248 {
249 kernel_name += "_quantized";
250 }
251
252 // Set kernel build options
253 CLBuildOptions build_opts = generate_build_options(*input1->info(), *input2->info(), *output->info());
254
255 // Create kernel
256 _kernel = static_cast<cl::Kernel>(CLKernelLibrary::get().create_kernel(kernel_name, build_opts.options()));
257
258 ICLKernel::configure_internal(win_config.second);
259
260 _config_id = generate_id_for_tuning(kernel_name, *input1->info(), *output->info());
261}
262
263void CLElementwiseOperationKernel::run(const Window &window, cl::CommandQueue &queue)
264{
265 ARM_COMPUTE_ERROR_ON_UNCONFIGURED_KERNEL(this);
266 ARM_COMPUTE_ERROR_ON_INVALID_SUBWINDOW(ICLKernel::window(), window);
267
268 const TensorShape &in_shape1 = _input1->info()->tensor_shape();
269 const TensorShape &in_shape2 = _input2->info()->tensor_shape();
270 const TensorShape &out_shape = _output->info()->tensor_shape();
271
272 bool can_collapse = true;
273 const bool is_vector = in_shape1.num_dimensions() == 1 || in_shape2.num_dimensions() == 1;
274 if(std::min(in_shape1.total_size(), in_shape2.total_size()) > 1 && !is_vector)
275 {
276 can_collapse = (std::min(in_shape1.num_dimensions(), in_shape2.num_dimensions()) > Window::DimZ);
277 for(size_t d = Window::DimZ; can_collapse && (d < out_shape.num_dimensions()); d++)
278 {
279 can_collapse = (in_shape1[d] == in_shape2[d]);
280 }
281 }
282
283 bool has_collapsed = false;
284 Window collapsed = can_collapse ? window.collapse_if_possible(ICLKernel::window(), Window::DimZ, &has_collapsed) : window;
285
286 const TensorShape &in_shape1_collapsed = has_collapsed ? in_shape1.collapsed_from(Window::DimZ) : in_shape1;
287 const TensorShape &in_shape2_collapsed = has_collapsed ? in_shape2.collapsed_from(Window::DimZ) : in_shape2;
288
289 Window slice = collapsed.first_slice_window_3D();
290 Window slice_input1 = slice.broadcast_if_dimension_le_one(in_shape1_collapsed);
291 Window slice_input2 = slice.broadcast_if_dimension_le_one(in_shape2_collapsed);
292
293 do
294 {
295 unsigned int idx = 0;
296
297 add_3D_tensor_argument(idx, _input1, slice_input1);
298 add_3D_tensor_argument(idx, _input2, slice_input2);
299 add_3D_tensor_argument(idx, _output, slice);
300
301 enqueue(queue, *this, slice, lws_hint());
302
303 collapsed.slide_window_slice_3D(slice_input1);
304 collapsed.slide_window_slice_3D(slice_input2);
305 }
306 while(collapsed.slide_window_slice_3D(slice));
307}
308
309BorderSize CLElementwiseOperationKernel::border_size() const
310{
311 const unsigned int replicateSize = _output->info()->dimension(0) - std::min(_input1->info()->dimension(0), _input2->info()->dimension(0));
312 const unsigned int border = std::min<unsigned int>(num_elems_processed_per_iteration - 1U, replicateSize);
Michalis Spyroubcfd09a2019-05-01 13:03:59 +0100313 return BorderSize{ 0, border, 0, 0 };
giuros01164a2722018-11-20 18:34:46 +0000314}
315
316/** Arithmetic operations with saturation*/
317
318void CLSaturatedArithmeticOperationKernel::configure(ArithmeticOperation op, const ICLTensor *input1, const ICLTensor *input2, ICLTensor *output, const ConvertPolicy &policy)
319{
320 _policy = policy;
321 _op = op;
322 configure_common(input1, input2, output);
323}
324
325Status CLSaturatedArithmeticOperationKernel::validate(ArithmeticOperation op, const ITensorInfo *input1, const ITensorInfo *input2, const ITensorInfo *output, const ConvertPolicy &policy)
326{
327 ARM_COMPUTE_UNUSED(op, policy);
328 ARM_COMPUTE_RETURN_ERROR_ON_NULLPTR(input1, input2, output);
329 ARM_COMPUTE_RETURN_ON_ERROR(validate_arguments_with_arithmetic_rules(*input1, *input2, *output));
330 ARM_COMPUTE_RETURN_ON_ERROR(validate_and_configure_window_for_arithmetic_operators(*input1->clone(), *input2->clone(), *output->clone()).first);
331
332 return Status{};
333}
334
335std::pair<Status, Window> CLSaturatedArithmeticOperationKernel::validate_and_configure_window(ITensorInfo &input1, ITensorInfo &input2, ITensorInfo &output)
336{
337 return validate_and_configure_window_for_arithmetic_operators(input1, input2, output);
338}
339
340Status CLSaturatedArithmeticOperationKernel::validate_arguments(const ITensorInfo &input1, const ITensorInfo &input2, const ITensorInfo &output)
341{
342 return validate_arguments_with_arithmetic_rules(input1, input2, output);
343}
344
345CLBuildOptions CLSaturatedArithmeticOperationKernel::generate_build_options(const ITensorInfo &input1, const ITensorInfo &input2, const ITensorInfo &output)
346{
347 const bool has_float_out = is_data_type_float(output.data_type());
348 auto build_options = generate_build_options_with_arithmetic_rules(input1, input2, output, name());
349 build_options.add_option((_policy == ConvertPolicy::WRAP || has_float_out) ? "-DWRAP" : "-DSATURATE");
350 return build_options;
351}
352std::string CLSaturatedArithmeticOperationKernel::generate_id_for_tuning(const std::string &kernel_name, const ITensorInfo &input1, const ITensorInfo &output)
353{
354 auto config_id = generate_id_for_tuning_common(kernel_name, input1, output);
355 config_id += (_policy == ConvertPolicy::WRAP) ? "_wrap_" : "_saturate_";
356 config_id += lower_string(string_from_data_layout(input1.data_layout()));
357 return config_id;
358}
359
360std::string CLSaturatedArithmeticOperationKernel::name()
361{
362 return supported_sat_arithmetic_ops[_op];
363}
364
365/** Arithmetic operations*/
366
367void CLArithmeticOperationKernel::configure(ArithmeticOperation op, const ICLTensor *input1, const ICLTensor *input2, ICLTensor *output)
368{
369 _op = op;
370 configure_common(input1, input2, output);
371}
372
373Status CLArithmeticOperationKernel::validate(ArithmeticOperation op, const ITensorInfo *input1, const ITensorInfo *input2, const ITensorInfo *output)
374{
giuros01164a2722018-11-20 18:34:46 +0000375 ARM_COMPUTE_RETURN_ERROR_ON_NULLPTR(input1, input2, output);
Usama Arif52c54f62019-05-14 10:22:36 +0100376 if(op == ArithmeticOperation::DIV || op == ArithmeticOperation::POWER)
giuros0149f7c022018-12-03 19:25:22 +0000377 {
Usama Arif52c54f62019-05-14 10:22:36 +0100378 // Division and Power operators don't support integer arithmetic
379 ARM_COMPUTE_RETURN_ON_ERROR(validate_arguments_with_float_only_supported_rules(*input1, *input2, *output));
giuros0149f7c022018-12-03 19:25:22 +0000380 ARM_COMPUTE_RETURN_ON_ERROR(validate_and_configure_window_for_division(*input1->clone(), *input2->clone(), *output->clone()).first);
381 }
382 else
383 {
384 ARM_COMPUTE_RETURN_ON_ERROR(validate_arguments_with_arithmetic_rules(*input1, *input2, *output));
385 ARM_COMPUTE_RETURN_ON_ERROR(validate_and_configure_window_for_arithmetic_operators(*input1->clone(), *input2->clone(), *output->clone()).first);
386 }
387
giuros01164a2722018-11-20 18:34:46 +0000388 return Status{};
389}
390std::pair<Status, Window> CLArithmeticOperationKernel::validate_and_configure_window(ITensorInfo &input1, ITensorInfo &input2, ITensorInfo &output)
391{
Usama Arif52c54f62019-05-14 10:22:36 +0100392 if(_op == ArithmeticOperation::DIV || _op == ArithmeticOperation::POWER)
giuros0149f7c022018-12-03 19:25:22 +0000393 {
Usama Arif52c54f62019-05-14 10:22:36 +0100394 // Division and Power operators don't support integer arithmetic
giuros0149f7c022018-12-03 19:25:22 +0000395 return validate_and_configure_window_for_division(input1, input2, output);
396 }
397 else
398 {
399 return validate_and_configure_window_for_arithmetic_operators(input1, input2, output);
400 }
giuros01164a2722018-11-20 18:34:46 +0000401}
402Status CLArithmeticOperationKernel::validate_arguments(const ITensorInfo &input1, const ITensorInfo &input2, const ITensorInfo &output)
403{
Usama Arif52c54f62019-05-14 10:22:36 +0100404 if(_op == ArithmeticOperation::DIV || _op == ArithmeticOperation::POWER)
giuros0149f7c022018-12-03 19:25:22 +0000405 {
Usama Arif52c54f62019-05-14 10:22:36 +0100406 // Division and Power operators don't support integer arithmetic
407 return validate_arguments_with_float_only_supported_rules(input1, input2, output);
giuros0149f7c022018-12-03 19:25:22 +0000408 }
409 else
410 {
411 return validate_arguments_with_arithmetic_rules(input1, input2, output);
412 }
giuros01164a2722018-11-20 18:34:46 +0000413}
414
415CLBuildOptions CLArithmeticOperationKernel::generate_build_options(const ITensorInfo &input1, const ITensorInfo &input2, const ITensorInfo &output)
416{
417 return generate_build_options_with_arithmetic_rules(input1, input2, output, name());
418}
419std::string CLArithmeticOperationKernel::generate_id_for_tuning(const std::string &kernel_name, const ITensorInfo &input1, const ITensorInfo &output)
420{
421 return generate_id_for_tuning_common(kernel_name, input1, output);
422}
423
424std::string CLArithmeticOperationKernel::name()
425{
426 return supported_arithmetic_ops[_op];
427}
428} // namespace arm_compute