Compute Library
 19.08
CLReductionOperationKernel Class Reference

Interface for the reduction operation kernel. More...

#include <CLReductionOperationKernel.h>

Collaboration diagram for CLReductionOperationKernel:
[legend]

Public Member Functions

 CLReductionOperationKernel ()
 Default constructor. More...
 
 CLReductionOperationKernel (const CLReductionOperationKernel &)=delete
 Prevent instances of this class from being copied (As this class contains pointers) More...
 
CLReductionOperationKerneloperator= (const CLReductionOperationKernel &)=delete
 Prevent instances of this class from being copied (As this class contains pointers) More...
 
 CLReductionOperationKernel (CLReductionOperationKernel &&)=default
 Allow instances of this class to be moved. More...
 
CLReductionOperationKerneloperator= (CLReductionOperationKernel &&)=default
 Allow instances of this class to be moved. More...
 
 ~CLReductionOperationKernel ()=default
 Default destructor. More...
 
void configure (const ICLTensor *input, ICLTensor *output, unsigned int axis, ReductionOperation op, unsigned int width=0)
 Set the input and output tensors. More...
 
void run (const Window &window, cl::CommandQueue &queue) override
 Enqueue the OpenCL kernel to process the given window on the passed OpenCL command queue. More...
 
BorderSize border_size () const override
 The size of the border for that kernel. More...
 
- Public Member Functions inherited from ICLKernel
 ICLKernel ()
 Constructor. More...
 
cl::Kernel & kernel ()
 Returns a reference to the OpenCL kernel of this object. More...
 
template<typename T >
void add_1D_array_argument (unsigned int &idx, const ICLArray< T > *array, const Strides &strides, unsigned int num_dimensions, const Window &window)
 Add the passed 1D array's parameters to the object's kernel's arguments starting from the index idx. More...
 
void add_1D_tensor_argument (unsigned int &idx, const ICLTensor *tensor, const Window &window)
 Add the passed 1D tensor's parameters to the object's kernel's arguments starting from the index idx. More...
 
void add_1D_tensor_argument_if (bool cond, unsigned int &idx, const ICLTensor *tensor, const Window &window)
 Add the passed 1D tensor's parameters to the object's kernel's arguments starting from the index idx if the condition is true. More...
 
void add_2D_tensor_argument (unsigned int &idx, const ICLTensor *tensor, const Window &window)
 Add the passed 2D tensor's parameters to the object's kernel's arguments starting from the index idx. More...
 
void add_2D_tensor_argument_if (bool cond, unsigned int &idx, const ICLTensor *tensor, const Window &window)
 Add the passed 2D tensor's parameters to the object's kernel's arguments starting from the index idx if the condition is true. More...
 
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. More...
 
void add_4D_tensor_argument (unsigned int &idx, const ICLTensor *tensor, const Window &window)
 Add the passed 4D tensor's parameters to the object's kernel's arguments starting from the index idx. More...
 
template<typename T >
void add_argument (unsigned int &idx, T value)
 Add the passed parameters to the object's kernel's arguments starting from the index idx. More...
 
void set_lws_hint (const cl::NDRange &lws_hint)
 Set the Local-Workgroup-Size hint. More...
 
cl::NDRange lws_hint () const
 Return the Local-Workgroup-Size hint. More...
 
const std::string & config_id () const
 Get the configuration ID. More...
 
void set_target (GPUTarget target)
 Set the targeted GPU architecture. More...
 
void set_target (cl::Device &device)
 Set the targeted GPU architecture according to the CL device. More...
 
GPUTarget get_target () const
 Get the targeted GPU architecture. More...
 
size_t get_max_workgroup_size ()
 Get the maximum workgroup size for the device the CLKernelLibrary uses. More...
 
template<typename T , unsigned int dimension_size>
void add_array_argument (unsigned &idx, const ICLArray< T > *array, const Strides &strides, unsigned int num_dimensions, const Window &window)
 Add the passed array's parameters to the object's kernel's arguments starting from the index idx. More...
 
template<unsigned int dimension_size>
void add_tensor_argument (unsigned &idx, const ICLTensor *tensor, const Window &window)
 
- Public Member Functions inherited from IKernel
 IKernel ()
 Constructor. More...
 
virtual ~IKernel ()=default
 Destructor. More...
 
virtual bool is_parallelisable () const
 Indicates whether or not the kernel is parallelisable. More...
 
const Windowwindow () const
 The maximum window the kernel can be executed on. More...
 

Static Public Member Functions

static Status validate (const ITensorInfo *input, const ITensorInfo *output, unsigned int axis, ReductionOperation op, unsigned int width=0)
 Static function to check if given info will lead to a valid configuration of CLReductionOperationKernel. More...
 
- Static Public Member Functions inherited from ICLKernel
static constexpr unsigned int num_arguments_per_1D_array ()
 Returns the number of arguments enqueued per 1D array object. More...
 
static constexpr unsigned int num_arguments_per_1D_tensor ()
 Returns the number of arguments enqueued per 1D tensor object. More...
 
static constexpr unsigned int num_arguments_per_2D_tensor ()
 Returns the number of arguments enqueued per 2D tensor object. More...
 
static constexpr unsigned int num_arguments_per_3D_tensor ()
 Returns the number of arguments enqueued per 3D tensor object. More...
 
static constexpr unsigned int num_arguments_per_4D_tensor ()
 Returns the number of arguments enqueued per 4D tensor object. More...
 
static cl::NDRange gws_from_window (const Window &window)
 Get the global work size given an execution window. More...
 

Detailed Description

Interface for the reduction operation kernel.

Definition at line 35 of file CLReductionOperationKernel.h.

Constructor & Destructor Documentation

◆ CLReductionOperationKernel() [1/3]

Default constructor.

Definition at line 136 of file CLReductionOperationKernel.cpp.

137  : _input(nullptr), _output(nullptr), _reduction_axis(0), _op(ReductionOperation::SUM_SQUARE), _border_size()
138 {
139 }

References arm_compute::SUM_SQUARE.

◆ CLReductionOperationKernel() [2/3]

Prevent instances of this class from being copied (As this class contains pointers)

◆ CLReductionOperationKernel() [3/3]

Allow instances of this class to be moved.

◆ ~CLReductionOperationKernel()

Default destructor.

Member Function Documentation

◆ border_size()

BorderSize border_size ( ) const
overridevirtual

The size of the border for that kernel.

Returns
The width in number of elements of the border.

Reimplemented from IKernel.

Definition at line 141 of file CLReductionOperationKernel.cpp.

142 {
143  return _border_size;
144 }

◆ configure()

void configure ( const ICLTensor input,
ICLTensor output,
unsigned int  axis,
ReductionOperation  op,
unsigned int  width = 0 
)

Set the input and output tensors.

Parameters
[in]inputSource tensor. Data types supported: QASYMM8/S32/F16/F32.
[out]outputDestination tensor. Data types and data layouts supported: Same as input. Output will have the same number of dimensions as input.
[in]axisAxis along which to reduce. Supported reduction axis : 0,1,2,3
[in]opReduction operation to perform.
[in]width(Optional) In case of x-axis we also need to provide the width of the input image.

Definition at line 146 of file CLReductionOperationKernel.cpp.

147 {
148  ARM_COMPUTE_ERROR_ON_NULLPTR(input, output);
149 
150  ARM_COMPUTE_ERROR_THROW_ON(validate_arguments(input->info(), output->info(), axis, op, width));
151 
152  _input = input;
153  _output = output;
154  _reduction_axis = axis;
155  _op = op;
156 
157  // Set build options
158  CLBuildOptions build_opts;
159  std::string data_type_promoted = get_cl_type_from_data_type(input->info()->data_type());
160  if(is_data_type_quantized(input->info()->data_type()))
161  {
162  data_type_promoted = "uint";
163  }
164 
165  build_opts.add_option("-DDATA_TYPE=" + get_cl_type_from_data_type(input->info()->data_type()));
166  build_opts.add_option("-DDATA_TYPE_PROMOTED=" + data_type_promoted);
167  build_opts.add_option_if(is_data_type_float(input->info()->data_type()), "-DFLOAT_DATA_TYPE");
168  build_opts.add_option_if(op == ReductionOperation::SUM_SQUARE, "-DSUM_SQUARE");
169  build_opts.add_option_if(op == ReductionOperation::MEAN_SUM, "-DMEAN");
170  build_opts.add_option_if(op == ReductionOperation::ARG_IDX_MAX, "-DARG_MAX");
171  build_opts.add_option_if(op == ReductionOperation::ARG_IDX_MIN, "-DARG_MIN");
172  build_opts.add_option_if(op == ReductionOperation::PROD, "-DPROD");
173  build_opts.add_option_if(op == ReductionOperation::MIN, "-DMIN");
174  build_opts.add_option_if(op == ReductionOperation::MAX, "-DMAX");
175  build_opts.add_option_if(input->info()->num_channels() == 2, "-DCOMPLEX");
176 
177  switch(op)
178  {
180  build_opts.add_option(("-DOPERATION=square_sum"));
181  break;
184  build_opts.add_option(("-DOPERATION=sum"));
185  break;
190  break;
192  build_opts.add_option(("-DOPERATION=product"));
193  break;
194  default:
195  ARM_COMPUTE_ERROR("Unsupported reduction operation");
196  }
197 
198  // Create kernel
200  std::string kernel_axis_name;
202  || is_data_type_quantized(input->info()->data_type()));
203  switch(axis)
204  {
205  case 0:
206  {
207  if(is_serial_op)
208  {
209  build_opts.add_option("-DWIDTH=" + support::cpp11::to_string(input->info()->dimension(0)));
210  build_opts.add_option_if_else(_input->info()->data_type() == DataType::F16, "-DCOND_DATA_TYPE=short", "-DCOND_DATA_TYPE=int");
211  kernel_axis_name = "non_parallel_x";
212  }
213  else
214  {
215  build_opts.add_option_if(op == ReductionOperation::MEAN_SUM, "-DWIDTH=" + support::cpp11::to_string(width));
216  const unsigned int width_leftover = input->info()->dimension(0) % border_val;
217  const unsigned int border_width = (width_leftover != 0) ? border_val - width_leftover : 0;
218  const unsigned int num_of_threads = ((input->info()->dimension(0) + border_width) / 16);
219  kernel_axis_name = "x";
220 
221  // Set the number of WG based on the input size. If input width is < 128
222  // we can use fewer threads than 8.
223  lws_hint = cl::NDRange(std::min(8U, num_of_threads));
224  _border_size = BorderSize(0, border_width, 0, 0);
225  }
226  }
227  break;
228  case 1:
229  build_opts.add_option("-DHEIGHT=" + support::cpp11::to_string(input->info()->dimension(1)));
230  kernel_axis_name = "y";
231  break;
232  case 2:
233  build_opts.add_option("-DDEPTH=" + support::cpp11::to_string(input->info()->dimension(2)));
234  kernel_axis_name = "z";
235  break;
236  case 3:
237  build_opts.add_option("-DDEPTH=" + support::cpp11::to_string(input->info()->dimension(2)));
238  build_opts.add_option("-DBATCH=" + support::cpp11::to_string(input->info()->dimension(3)));
239  kernel_axis_name = "w";
240  break;
241  default:
242  ARM_COMPUTE_ERROR("Not supported");
243  }
244  _kernel = static_cast<cl::Kernel>(CLKernelLibrary::get().create_kernel("reduction_operation_" + kernel_axis_name, build_opts.options()));
245 
246  // Configure kernel window
247  auto win_config = validate_and_configure_window(_input->info(), _output->info(), axis, op);
248 
249  ARM_COMPUTE_ERROR_THROW_ON(std::get<0>(win_config));
250 
251  ICLKernel::configure_internal(std::get<1>(win_config), lws_hint);
252 }
bool is_data_type_quantized(DataType dt)
Check if a given data type is of quantized type.
Definition: Utils.h:1010
#define ARM_COMPUTE_ERROR(...)
Print the given message then throw an std::runtime_error.
Definition: Error.h:261
virtual size_t dimension(size_t index) const =0
Return the size of the requested dimension.
Container for 2D border size.
Definition: Types.h:259
const StringSet & options() const
Gets the current options list set.
std::pair< Status, Window > validate_and_configure_window(ITensorInfo *input, ITensorInfo *weights, ITensorInfo *biases, ITensorInfo *output, const PadStrideInfo &conv_info, unsigned int depth_multiplier, const Size2D &dilation)
cl::NDRange lws_hint() const
Return the Local-Workgroup-Size hint.
Definition: ICLKernel.h:247
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.
static CLKernelLibrary & get()
Access the KernelLibrary singleton.
#define ARM_COMPUTE_ERROR_THROW_ON(status)
Definition: Error.h:327
1 channel, 1 F16 per channel
void add_option(std::string option)
Adds option to the existing build option list.
cl::NDRange default_ndrange() const
Return the default NDRange for the device.
std::string get_cl_type_from_data_type(const DataType &dt)
Translates a tensor data type to the appropriate OpenCL type.
Definition: CLHelpers.cpp:35
virtual ITensorInfo * info() const =0
Interface to be implemented by the child class to return the tensor's metadata.
void add_option_if(bool cond, std::string option)
Adds option if a given condition is true;.
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
#define ARM_COMPUTE_ERROR_ON_NULLPTR(...)
Definition: Validate.h:161
virtual size_t num_channels() const =0
The number of channels for each tensor element.
bool is_data_type_float(DataType dt)
Check if a given data type is of floating point type.
Definition: Utils.h:990
void add_option_if_else(bool cond, std::string option_true, std::string option_false)
Adds first option if condition is true else the second one.

References CLBuildOptions::add_option(), CLBuildOptions::add_option_if(), CLBuildOptions::add_option_if_else(), arm_compute::ARG_IDX_MAX, arm_compute::ARG_IDX_MIN, ARM_COMPUTE_ERROR, ARM_COMPUTE_ERROR_ON_NULLPTR, ARM_COMPUTE_ERROR_THROW_ON, arm_compute::test::validation::axis, arm_compute::create_kernel(), ITensorInfo::data_type(), CLKernelLibrary::default_ndrange(), ITensorInfo::dimension(), arm_compute::F16, CLKernelLibrary::get(), arm_compute::get_cl_type_from_data_type(), ITensor::info(), arm_compute::is_data_type_float(), arm_compute::is_data_type_quantized(), ICLKernel::lws_hint(), arm_compute::MAX, arm_compute::MEAN_SUM, arm_compute::MIN, ITensorInfo::num_channels(), CLBuildOptions::options(), arm_compute::PROD, arm_compute::SUM, arm_compute::SUM_SQUARE, arm_compute::support::cpp11::to_string(), arm_compute::U, and arm_compute::validate_and_configure_window().

◆ operator=() [1/2]

CLReductionOperationKernel& operator= ( const CLReductionOperationKernel )
delete

Prevent instances of this class from being copied (As this class contains pointers)

◆ operator=() [2/2]

Allow instances of this class to be moved.

◆ run()

void run ( const Window window,
cl::CommandQueue &  queue 
)
overridevirtual

Enqueue the OpenCL kernel to process the given window on the passed OpenCL command queue.

Note
The queue is not flushed by this method, and therefore the kernel will not have been executed by the time this method returns.
Parameters
[in]windowRegion on which to execute the kernel. (Must be a valid region of the window returned by window()).
[in,out]queueCommand queue on which to enqueue the kernel.

Implements ICLKernel.

Definition at line 262 of file CLReductionOperationKernel.cpp.

263 {
266 
267  const bool is_serial_op = (_op == ReductionOperation::ARG_IDX_MAX || _op == ReductionOperation::ARG_IDX_MIN || _op == ReductionOperation::MIN || _op == ReductionOperation::MAX
268  || is_data_type_quantized(_input->info()->data_type()));
269  switch(_reduction_axis)
270  {
271  case 0:
272  {
273  // We use parallel reduction only in non quantized types
274  if(is_serial_op)
275  {
276  // Get first input and output slices
277  Window window_in{ window };
278  window_in.set(Window::DimX, Window::Dimension(0, _input->info()->dimension(0), _input->info()->dimension(0)));
279 
280  Window in_slice = window.first_slice_window_1D();
281  Window out_slice = window.first_slice_window_1D();
282 
283  do
284  {
285  unsigned int idx = 0;
286  add_1D_tensor_argument(idx, _input, in_slice);
287  add_1D_tensor_argument(idx, _output, out_slice);
288  enqueue(queue, *this, in_slice);
289  }
290  while(window_in.slide_window_slice_1D(in_slice) && window.slide_window_slice_1D(out_slice));
291  }
292  else
293  {
294  // Set out window
295  Window out_window(window);
296  out_window.set(Window::DimX, Window::Dimension(0, 0, 0));
297 
298  // Get first input and output slices
299  Window in_slice = window.first_slice_window_2D();
300  Window out_slice = out_window.first_slice_window_2D();
301 
302  // Reshape window
303  const unsigned int border_width = ((in_slice.x().end() % border_val) != 0) ? border_val - in_slice.x().end() % border_val : 0;
304  in_slice.set(Window::DimX, Window::Dimension(in_slice.x().start(), in_slice.x().end() + border_width, in_slice.x().step()));
305 
306  // Set local sums buffer
307  unsigned int local_res_size = lws_hint()[0] * _input->info()->element_size();
308  _kernel.setArg(num_arguments_per_2D_tensor() * 2, local_res_size, nullptr);
309 
310  do
311  {
312  unsigned int idx = 0;
313  add_2D_tensor_argument(idx, _input, in_slice);
314  add_2D_tensor_argument(idx, _output, out_slice);
315  enqueue(queue, *this, in_slice, lws_hint());
316  }
317  while(window.slide_window_slice_2D(in_slice) && window.slide_window_slice_2D(out_slice));
318  }
319  }
320  break;
321  case 1:
322  {
323  // Get first input and output slices
324  Window window_in{ window };
325  window_in.set(Window::DimY, Window::Dimension(0, _input->info()->dimension(1), _input->info()->dimension(1)));
326  Window in_slice = window_in.first_slice_window_2D();
327  Window out_slice = window.first_slice_window_2D();
328 
329  do
330  {
331  unsigned int idx = 0;
332  add_2D_tensor_argument(idx, _input, in_slice);
333  add_2D_tensor_argument(idx, _output, out_slice);
334  enqueue(queue, *this, in_slice);
335  }
336  while(window_in.slide_window_slice_2D(in_slice) && window.slide_window_slice_2D(out_slice));
337  }
338  break;
339  case 2:
340  {
341  // Get first input and output slices
342  Window window_in{ window };
343  window_in.set(Window::DimZ, Window::Dimension(0, _input->info()->dimension(2), _input->info()->dimension(2)));
344  Window in_slice = window_in.first_slice_window_3D();
345  Window out_slice = window.first_slice_window_3D();
346 
347  do
348  {
349  unsigned int idx = 0;
350  add_3D_tensor_argument(idx, _input, in_slice);
351  add_3D_tensor_argument(idx, _output, out_slice);
352  enqueue(queue, *this, in_slice);
353  }
354  while(window_in.slide_window_slice_3D(in_slice) && window.slide_window_slice_3D(out_slice));
355  }
356  break;
357  case 3:
358  {
359  // Get first input and output slices
360  Window window_in{ window };
361  window_in.set(3, Window::Dimension(0, 1, 1));
362  Window in_slice = window_in.first_slice_window_4D();
363  Window out_slice = window.first_slice_window_4D();
364 
365  do
366  {
367  unsigned int idx = 0;
368  add_4D_tensor_argument(idx, _input, in_slice);
369  add_4D_tensor_argument(idx, _output, out_slice);
370  enqueue(queue, *this, in_slice);
371  }
372  while(window_in.slide_window_slice_4D(in_slice) && window.slide_window_slice_4D(out_slice));
373  }
374  break;
375  default:
376  ARM_COMPUTE_ERROR("Not supported");
377  }
378 }
bool is_data_type_quantized(DataType dt)
Check if a given data type is of quantized type.
Definition: Utils.h:1010
Window first_slice_window_2D() const
First 2D slice of the window.
Definition: Window.h:267
#define ARM_COMPUTE_ERROR(...)
Print the given message then throw an std::runtime_error.
Definition: Error.h:261
const Window & window() const
The maximum window the kernel can be executed on.
Definition: IKernel.cpp:28
virtual size_t dimension(size_t index) const =0
Return the size of the requested dimension.
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
constexpr int step() const
Return the step of the dimension.
Definition: Window.h:102
cl::NDRange lws_hint() const
Return the Local-Workgroup-Size hint.
Definition: ICLKernel.h:247
virtual DataType data_type() const =0
Data type used for each element of the tensor.
Describe one of the image's dimensions with a start, end and step.
Definition: Window.h:75
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
bool slide_window_slice_2D(Window &slice) const
Slide the passed 2D window slice.
Definition: Window.h:307
static constexpr size_t DimX
Alias for dimension 0 also known as X dimension.
Definition: Window.h:43
virtual ITensorInfo * info() const =0
Interface to be implemented by the child class to return the tensor's metadata.
virtual size_t element_size() const =0
Element size in bytes calculated as data_size() * num_channels()
void set(size_t dimension, const Dimension &dim)
Set the values of a given dimension.
Definition: Window.inl:48
static constexpr unsigned int num_arguments_per_2D_tensor()
Returns the number of arguments enqueued per 2D tensor object.
Definition: ICLKernel.h:192
bool slide_window_slice_3D(Window &slice) const
Slide the passed 3D window slice.
Definition: Window.h:319
static constexpr size_t DimY
Alias for dimension 1 also known as Y dimension.
Definition: Window.h:45
void add_2D_tensor_argument(unsigned int &idx, const ICLTensor *tensor, const Window &window)
Add the passed 2D tensor's parameters to the object's kernel's arguments starting from the index idx.
Definition: ICLKernel.h:134
static constexpr size_t DimZ
Alias for dimension 2 also known as Z dimension.
Definition: Window.h:47
Window first_slice_window_4D() const
First 4D slice of the window.
Definition: Window.h:283
bool slide_window_slice_4D(Window &slice) const
Slide the passed 4D window slice.
Definition: Window.h:331
constexpr int end() const
Return the end of the dimension.
Definition: Window.h:97
void add_1D_tensor_argument(unsigned int &idx, const ICLTensor *tensor, const Window &window)
Add the passed 1D tensor's parameters to the object's kernel's arguments starting from the index idx.
Definition: ICLKernel.h:110
Window first_slice_window_3D() const
First 3D slice of the window.
Definition: Window.h:275
#define ARM_COMPUTE_ERROR_ON_INVALID_SUBWINDOW(f, s)
Definition: Validate.h:205
void add_4D_tensor_argument(unsigned int &idx, const ICLTensor *tensor, const Window &window)
Add the passed 4D tensor's parameters to the object's kernel's arguments starting from the index idx.
Definition: ICLKernel.h:168
bool slide_window_slice_1D(Window &slice) const
Slide the passed 1D window slice.
Definition: Window.h:295
constexpr int start() const
Return the start of the dimension.
Definition: Window.h:92
Describe a multidimensional execution window.
Definition: Window.h:39
#define ARM_COMPUTE_ERROR_ON_UNCONFIGURED_KERNEL(k)
Definition: Validate.h:940
Window first_slice_window_1D() const
First 1D slice of the window.
Definition: Window.h:259
constexpr const Dimension & x() const
Alias to access the first dimension of the window.
Definition: Window.h:143

References ICLKernel::add_1D_tensor_argument(), ICLKernel::add_2D_tensor_argument(), ICLKernel::add_3D_tensor_argument(), ICLKernel::add_4D_tensor_argument(), arm_compute::ARG_IDX_MAX, arm_compute::ARG_IDX_MIN, ARM_COMPUTE_ERROR, ARM_COMPUTE_ERROR_ON_INVALID_SUBWINDOW, ARM_COMPUTE_ERROR_ON_UNCONFIGURED_KERNEL, ITensorInfo::data_type(), ITensorInfo::dimension(), Window::DimX, Window::DimY, Window::DimZ, ITensorInfo::element_size(), Window::Dimension::end(), arm_compute::enqueue(), Window::first_slice_window_1D(), Window::first_slice_window_2D(), Window::first_slice_window_3D(), Window::first_slice_window_4D(), ITensor::info(), arm_compute::is_data_type_quantized(), ICLKernel::lws_hint(), arm_compute::MAX, arm_compute::MIN, ICLKernel::num_arguments_per_2D_tensor(), Window::set(), Window::slide_window_slice_1D(), Window::slide_window_slice_2D(), Window::slide_window_slice_3D(), Window::slide_window_slice_4D(), Window::Dimension::start(), Window::Dimension::step(), IKernel::window(), and Window::x().

◆ validate()

Status validate ( const ITensorInfo input,
const ITensorInfo output,
unsigned int  axis,
ReductionOperation  op,
unsigned int  width = 0 
)
static

Static function to check if given info will lead to a valid configuration of CLReductionOperationKernel.

Parameters
[in]inputSource tensor info. Data types supported: QASYMM8/S32/F16/F32.
[in]outputDestination tensor info. Data types and data layouts supported: Same as input. Output will have the same number of dimensions as input.
[in]axisAxis along which to reduce. Supported reduction axis : 0,1,2,3
[in]opReduction operation to perform.
[in]width(Optional) In case of x-axis we also need to provide the width of the input image.
Returns
a status

Definition at line 254 of file CLReductionOperationKernel.cpp.

255 {
256  ARM_COMPUTE_RETURN_ON_ERROR(validate_arguments(input, output, axis, op, width));
257  ARM_COMPUTE_RETURN_ON_ERROR(std::get<0>(validate_and_configure_window(input->clone().get(), output->clone().get(), axis, op)));
258 
259  return Status{};
260 }
std::pair< Status, Window > validate_and_configure_window(ITensorInfo *input, ITensorInfo *weights, ITensorInfo *biases, ITensorInfo *output, const PadStrideInfo &conv_info, unsigned int depth_multiplier, const Size2D &dilation)
#define ARM_COMPUTE_RETURN_ON_ERROR(status)
Checks if a status contains an error and returns it.
Definition: Error.h:193
Status class.
Definition: Error.h:52
virtual std::unique_ptr< T > clone() const =0
Provide a clone of the current object of class T.

References ARM_COMPUTE_RETURN_ON_ERROR, arm_compute::test::validation::axis, ICloneable< T >::clone(), and arm_compute::validate_and_configure_window().

Referenced by CLArgMinMaxLayer::validate(), and CLReductionOperation::validate().


The documentation for this class was generated from the following files: