Compute Library
 20.02.1
CLElementwiseOperationKernel.cpp
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2018-2019 ARM Limited.
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  */
25 
29 #include <map>
30 
31 namespace arm_compute
32 {
33 namespace
34 {
35 constexpr unsigned int num_elems_processed_per_iteration = 16;
36 
37 std::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" },
45  { ArithmeticOperation::POWER, "POWER" },
46  { ArithmeticOperation::PRELU, "PRELU" },
47 };
48 
49 std::map<ArithmeticOperation, std::string> supported_sat_arithmetic_ops =
50 {
51  { ArithmeticOperation::ADD, "ADD" },
52  { ArithmeticOperation::SUB, "SUB" },
53 };
54 
55 std::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 
69 Status validate_arguments_with_float_only_supported_rules(const ITensorInfo &input1, const ITensorInfo &input2, const ITensorInfo &output)
70 {
71  ARM_COMPUTE_RETURN_ERROR_ON_NULLPTR(&input1, &input2, &output);
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  {
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 
92 Status validate_arguments_with_arithmetic_rules(const ITensorInfo &input1, const ITensorInfo &input2, const ITensorInfo &output)
93 {
98 
99  const bool is_quantized = is_data_type_quantized(input1.data_type()) || is_data_type_quantized(input2.data_type());
100  if(is_quantized)
101  {
103 
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  }
111  }
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  {
122  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");
126 
127  if(is_quantized)
128  {
130 
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  }
136  }
137  }
138  return Status{};
139 }
140 
141 CLBuildOptions 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);
150  if(is_data_type_quantized(input1.data_type()))
151  {
152  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));
162  }
163  return build_opts;
164 }
165 
166 std::pair<Status, Window> configure_window_arithmetic_common(const ValidRegion &valid_region, ITensorInfo &input1, ITensorInfo &input2, ITensorInfo &output)
167 {
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 
186 std::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  {
197  }
198  else if(input1.data_type() == DataType::F16 || input2.data_type() == DataType::F16)
199  {
201  }
202  else if(input1.data_type() == DataType::F32 || input2.data_type() == DataType::F32)
203  {
205  }
206  else if(input1.data_type() == DataType::QASYMM8 || input2.data_type() == DataType::QASYMM8)
207  {
209  }
210  else if(input1.data_type() == DataType::QASYMM8_SIGNED || input2.data_type() == DataType::QASYMM8_SIGNED)
211  {
213  }
214  else if(input1.data_type() == DataType::QSYMM16 || input2.data_type() == DataType::QSYMM16)
215  {
217  }
218 
219  return configure_window_arithmetic_common(valid_region, input1, input2, output);
220 }
221 
222 std::pair<Status, Window> validate_and_configure_window_for_division(ITensorInfo &input1, ITensorInfo &input2, ITensorInfo &output)
223 {
224  const std::pair<TensorShape, ValidRegion> broadcast_pair = ITensorInfo::broadcast_shape_and_valid_region(input1, input2);
225  const TensorShape &out_shape = broadcast_pair.first;
226  const ValidRegion &valid_region = broadcast_pair.second;
227  auto_init_if_empty(output, out_shape, 1, input1.data_type());
228  return configure_window_arithmetic_common(valid_region, input1, input2, output);
229 }
230 } // namespace
231 
233  : _input1(nullptr), _input2(nullptr), _output(nullptr)
234 {
235 }
236 
237 void CLElementwiseOperationKernel::configure_common(const ICLTensor *input1, const ICLTensor *input2, ICLTensor *output)
238 {
239  ARM_COMPUTE_ERROR_ON_NULLPTR(input1, input2, output);
240  ARM_COMPUTE_ERROR_THROW_ON(validate_arguments(*input1->info(), *input2->info(), *output->info()));
241 
242  // Configure kernel window
243  auto win_config = validate_and_configure_window(*input1->info(), *input2->info(), *output->info());
244  ARM_COMPUTE_ERROR_THROW_ON(win_config.first);
245 
246  _input1 = input1;
247  _input2 = input2;
248  _output = output;
249 
250  std::string kernel_name = "elementwise_operation_" + name();
251  if(is_data_type_quantized(input1->info()->data_type()))
252  {
253  kernel_name += "_quantized";
254  }
255 
256  // Set kernel build options
257  CLBuildOptions build_opts = generate_build_options(*input1->info(), *input2->info(), *output->info());
258 
259  // Create kernel
260  _kernel = static_cast<cl::Kernel>(CLKernelLibrary::get().create_kernel(kernel_name, build_opts.options()));
261 
262  ICLKernel::configure_internal(win_config.second);
263 
264  _config_id = generate_id_for_tuning(kernel_name, *input1->info(), *output->info());
265 }
266 
267 void CLElementwiseOperationKernel::run(const Window &window, cl::CommandQueue &queue)
268 {
271 
272  const TensorShape &in_shape1 = _input1->info()->tensor_shape();
273  const TensorShape &in_shape2 = _input2->info()->tensor_shape();
274  const TensorShape &out_shape = _output->info()->tensor_shape();
275 
276  bool can_collapse = true;
277  const bool is_vector = in_shape1.num_dimensions() == 1 || in_shape2.num_dimensions() == 1;
278  if(std::min(in_shape1.total_size(), in_shape2.total_size()) > 1 && !is_vector)
279  {
280  can_collapse = (std::min(in_shape1.num_dimensions(), in_shape2.num_dimensions()) > Window::DimZ);
281  for(size_t d = Window::DimZ; can_collapse && (d < out_shape.num_dimensions()); d++)
282  {
283  can_collapse = (in_shape1[d] == in_shape2[d]);
284  }
285  }
286 
287  bool has_collapsed = false;
288  Window collapsed = can_collapse ? window.collapse_if_possible(ICLKernel::window(), Window::DimZ, &has_collapsed) : window;
289 
290  const TensorShape &in_shape1_collapsed = has_collapsed ? in_shape1.collapsed_from(Window::DimZ) : in_shape1;
291  const TensorShape &in_shape2_collapsed = has_collapsed ? in_shape2.collapsed_from(Window::DimZ) : in_shape2;
292 
293  Window slice = collapsed.first_slice_window_3D();
294  Window slice_input1 = slice.broadcast_if_dimension_le_one(in_shape1_collapsed);
295  Window slice_input2 = slice.broadcast_if_dimension_le_one(in_shape2_collapsed);
296 
297  do
298  {
299  unsigned int idx = 0;
300 
301  add_3D_tensor_argument(idx, _input1, slice_input1);
302  add_3D_tensor_argument(idx, _input2, slice_input2);
303  add_3D_tensor_argument(idx, _output, slice);
304 
305  enqueue(queue, *this, slice, lws_hint());
306 
307  ARM_COMPUTE_UNUSED(collapsed.slide_window_slice_3D(slice_input1));
308  ARM_COMPUTE_UNUSED(collapsed.slide_window_slice_3D(slice_input2));
309  }
310  while(collapsed.slide_window_slice_3D(slice));
311 }
312 
314 {
315  const unsigned int replicateSize = _output->info()->dimension(0) - std::min(_input1->info()->dimension(0), _input2->info()->dimension(0));
316  const unsigned int border = std::min<unsigned int>(num_elems_processed_per_iteration - 1U, replicateSize);
317  return BorderSize{ 0, border, 0, 0 };
318 }
319 
320 /** Arithmetic operations with saturation*/
321 
323 {
324  _policy = policy;
325  _op = op;
326  configure_common(input1, input2, output);
327 }
328 
330 {
332  ARM_COMPUTE_RETURN_ERROR_ON_NULLPTR(input1, input2, output);
333  ARM_COMPUTE_RETURN_ON_ERROR(validate_arguments_with_arithmetic_rules(*input1, *input2, *output));
334  ARM_COMPUTE_RETURN_ON_ERROR(validate_and_configure_window_for_arithmetic_operators(*input1->clone(), *input2->clone(), *output->clone()).first);
335 
336  return Status{};
337 }
338 
339 std::pair<Status, Window> CLSaturatedArithmeticOperationKernel::validate_and_configure_window(ITensorInfo &input1, ITensorInfo &input2, ITensorInfo &output)
340 {
341  return validate_and_configure_window_for_arithmetic_operators(input1, input2, output);
342 }
343 
344 Status CLSaturatedArithmeticOperationKernel::validate_arguments(const ITensorInfo &input1, const ITensorInfo &input2, const ITensorInfo &output)
345 {
346  return validate_arguments_with_arithmetic_rules(input1, input2, output);
347 }
348 
349 CLBuildOptions CLSaturatedArithmeticOperationKernel::generate_build_options(const ITensorInfo &input1, const ITensorInfo &input2, const ITensorInfo &output)
350 {
351  const bool has_float_out = is_data_type_float(output.data_type());
352  auto build_options = generate_build_options_with_arithmetic_rules(input1, input2, output, name());
353  build_options.add_option((_policy == ConvertPolicy::WRAP || has_float_out) ? "-DWRAP" : "-DSATURATE");
354  return build_options;
355 }
356 std::string CLSaturatedArithmeticOperationKernel::generate_id_for_tuning(const std::string &kernel_name, const ITensorInfo &input1, const ITensorInfo &output)
357 {
358  auto config_id = generate_id_for_tuning_common(kernel_name, input1, output);
359  config_id += (_policy == ConvertPolicy::WRAP) ? "_wrap_" : "_saturate_";
360  config_id += lower_string(string_from_data_layout(input1.data_layout()));
361  return config_id;
362 }
363 
364 std::string CLSaturatedArithmeticOperationKernel::name()
365 {
366  return supported_sat_arithmetic_ops[_op];
367 }
368 
369 /** Arithmetic operations*/
370 
372 {
373  _op = op;
374  configure_common(input1, input2, output);
375 }
376 
378 {
379  ARM_COMPUTE_RETURN_ERROR_ON_NULLPTR(input1, input2, output);
381  {
382  // Division and Power operators don't support integer arithmetic
383  ARM_COMPUTE_RETURN_ON_ERROR(validate_arguments_with_float_only_supported_rules(*input1, *input2, *output));
384  ARM_COMPUTE_RETURN_ON_ERROR(validate_and_configure_window_for_division(*input1->clone(), *input2->clone(), *output->clone()).first);
385  }
386  else
387  {
388  ARM_COMPUTE_RETURN_ON_ERROR(validate_arguments_with_arithmetic_rules(*input1, *input2, *output));
389  ARM_COMPUTE_RETURN_ON_ERROR(validate_and_configure_window_for_arithmetic_operators(*input1->clone(), *input2->clone(), *output->clone()).first);
390  }
391 
392  return Status{};
393 }
394 std::pair<Status, Window> CLArithmeticOperationKernel::validate_and_configure_window(ITensorInfo &input1, ITensorInfo &input2, ITensorInfo &output)
395 {
397  {
398  // Division and Power operators don't support integer arithmetic
399  return validate_and_configure_window_for_division(input1, input2, output);
400  }
401  else
402  {
403  return validate_and_configure_window_for_arithmetic_operators(input1, input2, output);
404  }
405 }
406 Status CLArithmeticOperationKernel::validate_arguments(const ITensorInfo &input1, const ITensorInfo &input2, const ITensorInfo &output)
407 {
409  {
410  // Division and Power operators don't support integer arithmetic
411  return validate_arguments_with_float_only_supported_rules(input1, input2, output);
412  }
413  else
414  {
415  return validate_arguments_with_arithmetic_rules(input1, input2, output);
416  }
417 }
418 
419 CLBuildOptions CLArithmeticOperationKernel::generate_build_options(const ITensorInfo &input1, const ITensorInfo &input2, const ITensorInfo &output)
420 {
421  return generate_build_options_with_arithmetic_rules(input1, input2, output, name());
422 }
423 std::string CLArithmeticOperationKernel::generate_id_for_tuning(const std::string &kernel_name, const ITensorInfo &input1, const ITensorInfo &output)
424 {
425  return generate_id_for_tuning_common(kernel_name, input1, output);
426 }
427 
428 std::string CLArithmeticOperationKernel::name()
429 {
430  return supported_arithmetic_ops[_op];
431 }
432 } // namespace arm_compute
bool is_data_type_quantized(DataType dt)
Check if a given data type is of quantized type.
Definition: Utils.h:1117
__global uchar * offset(const Image *img, int x, int y)
Get the pointer position of a Image.
Definition: helpers.h:510
ArithmeticOperation
Available element-wise operations.
Definition: Types.h:508
#define ARM_COMPUTE_RETURN_ERROR_ON_F16_UNSUPPORTED(tensor)
Definition: CLValidate.h:34
const Window & window() const
The maximum window the kernel can be executed on.
Definition: IKernel.cpp:28
Shape of a tensor.
Definition: TensorShape.h:39
quantized, symmetric fixed-point 16-bit number
virtual size_t dimension(size_t index) const =0
Return the size of the requested dimension.
Container for 2D border size.
Definition: Types.h:269
void enqueue(cl::CommandQueue &queue, ICLKernel &kernel, const Window &window, const cl::NDRange &lws_hint=CLKernelLibrary::get().default_ndrange(), bool use_dummy_work_items=false)
Add the kernel to the command queue with the given window.
Definition: ICLKernel.cpp:39
#define ARM_COMPUTE_RETURN_ERROR_ON_MISMATCHING_DATA_TYPES(...)
Definition: Validate.h:545
cl::NDRange lws_hint() const
Return the Local-Workgroup-Size hint.
Definition: ICLKernel.h:247
TensorShape collapsed_from(size_t start) const
Return a copy with collapsed dimensions starting from a given point.
Definition: TensorShape.h:160
1 channel, 1 U8 per channel
#define ARM_COMPUTE_RETURN_ON_ERROR(status)
Checks if a status contains an error and returns it.
Definition: Error.h:204
std::string to_string(T &&value)
Convert integer and float values to string.
virtual DataType data_type() const =0
Data type used for each element of the tensor.
#define ARM_COMPUTE_RETURN_ERROR_ON_DATA_TYPE_CHANNEL_NOT_IN(t, c,...)
Definition: Validate.h:792
1 channel, 1 F32 per channel
static TensorShape broadcast_shape(const Shapes &... shapes)
If shapes are broadcast compatible, return the broadcasted shape.
Definition: TensorShape.h:210
static CLKernelLibrary & get()
Access the KernelLibrary singleton.
Store the tensor's metadata.
Definition: ITensorInfo.h:40
static Status validate(ArithmeticOperation op, const ITensorInfo *input1, const ITensorInfo *input2, const ITensorInfo *output)
Static function to check if given info will lead to a valid configuration of CLArithmeticOperationKer...
#define ARM_COMPUTE_ERROR_THROW_ON(status)
Definition: Error.h:455
Status class.
Definition: Error.h:52
std::string lower_string(const std::string &val)
Lower a given string.
Definition: Utils.cpp:333
bool is_data_type_quantized_symmetric(DataType dt)
Check if a given data type is of symmetric quantized type.
Definition: Utils.h:1175
static std::pair< TensorShape, ValidRegion > broadcast_shape_and_valid_region(const Infos &... infos)
If infos are broadcast compatible tensor info's, return the broadcasted shape and the intersection of...
Definition: ITensorInfo.h:259
bool set_data_type_if_unknown(ITensorInfo &info, DataType data_type)
Set the data type and number of channels to the specified value if the current data type is unknown.
Definition: Helpers.inl:257
Window calculate_max_window(const ValidRegion &valid_region, const Steps &steps=Steps(), bool skip_border=false, BorderSize border_size=BorderSize())
Calculate the maximum window for a given tensor shape and border setting.
Definition: Helpers.cpp:28
void add_3D_tensor_argument(unsigned int &idx, const ICLTensor *tensor, const Window &window)
Add the passed 3D tensor's parameters to the object's kernel's arguments starting from the index idx.
Definition: ICLKernel.h:158
Copyright (c) 2017-2020 ARM Limited.
bool auto_init_if_empty(ITensorInfo &info, const TensorShape &shape, int num_channels, DataType data_type, QuantizationInfo quantization_info=QuantizationInfo())
Auto initialize the tensor info (shape, number of channels and data type) if the current assignment i...
Definition: Helpers.inl:202
1 channel, 1 F16 per channel
const std::string & config_id() const
Get the configuration ID.
Definition: ICLKernel.h:262
const std::string & string_from_data_type(DataType dt)
Convert a data type identity into a string.
Definition: Utils.cpp:144
bool update_window_and_padding(Window &win, Ts &&... patterns)
Update window and padding size for each of the access patterns.
Definition: Helpers.h:402
#define ARM_COMPUTE_UNUSED(...)
To avoid unused variables warnings.
Definition: Error.h:152
Window collapse_if_possible(const Window &full_window, size_t first, size_t last, bool *has_collapsed=nullptr) const
Collapse the dimensions between first and last if possible.
Definition: Window.inl:68
std::string float_to_string_with_full_precision(float val)
Create a string with the float in full precision.
Definition: Utils.h:1211
void run(const Window &window, cl::CommandQueue &queue) override
Enqueue the OpenCL kernel to process the given window on the passed OpenCL command queue.
virtual const TensorShape & tensor_shape() const =0
Size for each dimension of the tensor.
void configure(ArithmeticOperation op, const ICLTensor *input1, const ICLTensor *input2, ICLTensor *output)
Static function to check if given info will lead to a valid configuration of CLArithmeticOperationKer...
quantized, asymmetric fixed-point 8-bit number unsigned
std::set< std::string > build_options
std::string kernel_name
size_t total_size() const
Collapses all dimensions to a single linear total size.
Definition: TensorShape.h:171
static Status validate(ArithmeticOperation op, const ITensorInfo *input1, const ITensorInfo *input2, const ITensorInfo *output, const ConvertPolicy &policy)
Static function to check if given info will lead to a valid configuration of CLSaturatedArithmeticOpe...
std::string get_cl_type_from_data_type(const DataType &dt)
Translates a tensor data type to the appropriate OpenCL type.
Definition: CLHelpers.cpp:37
virtual std::unique_ptr< T > clone() const =0
Provide a clone of the current object of class T.
virtual ITensorInfo * info() const =0
Interface to be implemented by the child class to return the tensor's metadata.
bool have_different_dimensions(const Dimensions< T > &dim1, const Dimensions< T > &dim2, unsigned int upper_dim)
Definition: Validate.h:51
std::unique_ptr< Kernel > create_kernel()
Helper function to create and return a unique_ptr pointed to a CL/GLES kernel object.
Definition: Helpers.h:86
bool slide_window_slice_3D(Window &slice) const
Slide the passed 3D window slice.
Definition: Window.h:333
1 channel, 1 S16 per channel
#define ARM_COMPUTE_RETURN_ERROR_ON_NULLPTR(...)
Definition: Validate.h:163
#define ARM_COMPUTE_ERROR_ON_NULLPTR(...)
Definition: Validate.h:161
Interface for OpenCL tensor.
Definition: ICLTensor.h:42
const std::string & string_from_data_layout(DataLayout dl)
Convert a data layout identity into a string.
Definition: Utils.cpp:132
#define ARM_COMPUTE_CREATE_ERROR(error_code, msg)
Creates an error with a given message.
Definition: Error.h:159
BorderSize border_size() const override
The size of the border for that kernel.
static constexpr size_t DimZ
Alias for dimension 2 also known as Z dimension.
Definition: Window.h:47
unsigned int num_dimensions() const
Returns the effective dimensionality of the tensor.
Definition: Dimensions.h:122
bool set_shape_if_empty(ITensorInfo &info, const TensorShape &shape)
Set the shape to the specified value if the current assignment is empty.
Definition: Helpers.inl:235
void configure(ArithmeticOperation op, const ICLTensor *input1, const ICLTensor *input2, ICLTensor *output, const ConvertPolicy &policy)
Static function to check if given info will lead to a valid configuration of CLSaturatedArithmeticOpe...
unsigned int num_elems_processed_per_iteration
#define ARM_COMPUTE_RETURN_ERROR_ON_MSG(cond, msg)
If the condition is true, an error is returned.
Definition: Error.h:244
bool set_format_if_unknown(ITensorInfo &info, Format format)
Set the format, data type and number of channels to the specified value if the current data type is u...
Definition: Helpers.inl:246
quantized, asymmetric fixed-point 8-bit number signed
Window first_slice_window_3D() const
First 3D slice of the window.
Definition: Window.h:289
#define ARM_COMPUTE_ERROR_ON_INVALID_SUBWINDOW(f, s)
Definition: Validate.h:205
Describe a multidimensional execution window.
Definition: Window.h:39
ConvertPolicy
Policy to handle overflow.
Definition: Types.h:359
#define ARM_COMPUTE_ERROR_ON_UNCONFIGURED_KERNEL(k)
Definition: Validate.h:941
bool is_data_type_float(DataType dt)
Check if a given data type is of floating point type.
Definition: Utils.h:1097
SimpleTensor< T > slice(const SimpleTensor< T > &src, Coordinates starts, Coordinates ends)