Compute Library
 19.11
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.

Note
For ARG_MIN/ARG_MAX reduction, the default data type for an uninitialized output tensor is signed 32-bit integer (S32). It is the user's responsibility to check that the results do not overflow because the indices are computed in unsigned 32-bit (U32).

Definition at line 41 of file CLReductionOperationKernel.h.

Constructor & Destructor Documentation

◆ CLReductionOperationKernel() [1/3]

Default constructor.

Definition at line 135 of file CLReductionOperationKernel.cpp.

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

◆ 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 140 of file CLReductionOperationKernel.cpp.

141 {
142  return _border_size;
143 }

◆ 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, U32/S32 for ARG_MIX/ARG_MAX. 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 145 of file CLReductionOperationKernel.cpp.

146 {
148 
149  ARM_COMPUTE_ERROR_THROW_ON(validate_arguments(input->info(), output->info(), axis, op, width));
150 
151  _input = input;
152  _output = output;
153  _reduction_axis = axis;
154  _op = op;
155 
156  // Set build options
157  CLBuildOptions build_opts;
158  std::string data_type_promoted = get_cl_type_from_data_type(input->info()->data_type());
159  if(is_data_type_quantized(input->info()->data_type()))
160  {
161  data_type_promoted = "uint";
162  }
163 
164  build_opts.add_option("-DDATA_TYPE=" + get_cl_type_from_data_type(input->info()->data_type()));
165  build_opts.add_option("-DDATA_TYPE_PROMOTED=" + data_type_promoted);
166  build_opts.add_option_if(is_data_type_float(input->info()->data_type()), "-DFLOAT_DATA_TYPE");
167  build_opts.add_option_if(op == ReductionOperation::SUM_SQUARE, "-DSUM_SQUARE");
168  build_opts.add_option_if(op == ReductionOperation::MEAN_SUM, "-DMEAN");
169  build_opts.add_option_if(op == ReductionOperation::ARG_IDX_MAX, "-DARG_MAX");
170  build_opts.add_option_if(op == ReductionOperation::ARG_IDX_MIN, "-DARG_MIN");
171  build_opts.add_option_if(op == ReductionOperation::PROD, "-DPROD");
172  build_opts.add_option_if(op == ReductionOperation::MIN, "-DMIN");
173  build_opts.add_option_if(op == ReductionOperation::MAX, "-DMAX");
174  build_opts.add_option_if(input->info()->num_channels() == 2, "-DCOMPLEX");
175 
176  switch(op)
177  {
179  build_opts.add_option(("-DOPERATION=square_sum"));
180  break;
183  build_opts.add_option(("-DOPERATION=sum"));
184  break;
189  break;
191  build_opts.add_option(("-DOPERATION=product"));
192  break;
193  default:
194  ARM_COMPUTE_ERROR("Unsupported reduction operation");
195  }
196 
197  // Create kernel
199  std::string kernel_axis_name;
200  const bool is_serial_op = needs_serialized_reduction(_op, _input->info()->data_type(), _reduction_axis);
201 
202  switch(axis)
203  {
204  case 0:
205  {
206  if(is_serial_op)
207  {
208  build_opts.add_option("-DWIDTH=" + support::cpp11::to_string(input->info()->dimension(0)));
209  build_opts.add_option_if_else(_input->info()->data_type() == DataType::F16, "-DCOND_DATA_TYPE=short", "-DCOND_DATA_TYPE=int");
210  kernel_axis_name = "non_parallel_x";
211  }
212  else
213  {
214  build_opts.add_option_if(op == ReductionOperation::MEAN_SUM, "-DWIDTH=" + support::cpp11::to_string(width));
215  const unsigned int width_leftover = input->info()->dimension(0) % border_val;
216  const unsigned int border_width = (width_leftover != 0) ? border_val - width_leftover : 0;
217  const unsigned int num_of_threads = ((input->info()->dimension(0) + border_width) / 16);
218  kernel_axis_name = "x";
219 
220  // Set the number of WG based on the input size. If input width is < 128
221  // we can use fewer threads than 8.
222  lws_hint = cl::NDRange(std::min(8U, num_of_threads));
223  _border_size = BorderSize(0, border_width, 0, 0);
224  }
225  }
226  break;
227  case 1:
228  build_opts.add_option("-DHEIGHT=" + support::cpp11::to_string(input->info()->dimension(1)));
229  kernel_axis_name = "y";
230  break;
231  case 2:
232  build_opts.add_option("-DDEPTH=" + support::cpp11::to_string(input->info()->dimension(2)));
233  kernel_axis_name = "z";
234  break;
235  case 3:
236  build_opts.add_option("-DDEPTH=" + support::cpp11::to_string(input->info()->dimension(2)));
237  build_opts.add_option("-DBATCH=" + support::cpp11::to_string(input->info()->dimension(3)));
238  kernel_axis_name = "w";
239  break;
240  default:
241  ARM_COMPUTE_ERROR("Not supported");
242  }
243  _kernel = static_cast<cl::Kernel>(CLKernelLibrary::get().create_kernel("reduction_operation_" + kernel_axis_name, build_opts.options()));
244 
245  // Configure kernel window
246  auto win_config = validate_and_configure_window(_input->info(), _output->info(), axis, op);
247 
248  ARM_COMPUTE_ERROR_THROW_ON(std::get<0>(win_config));
249 
250  ICLKernel::configure_internal(std::get<1>(win_config), lws_hint);
251 }
bool is_data_type_quantized(DataType dt)
Check if a given data type is of quantized type.
Definition: Utils.h:1022
bool needs_serialized_reduction(ReductionOperation op, DataType dt, unsigned int axis)
Check if the given reduction operation should be handled in a serial way.
Definition: Utils.cpp:432
#define ARM_COMPUTE_ERROR(msg)
Print the given message then throw an std::runtime_error.
Definition: Error.h:352
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:455
1 channel, 1 F16 per channel
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:37
virtual ITensorInfo * info() const =0
Interface to be implemented by the child class to return the tensor's metadata.
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
bool is_data_type_float(DataType dt)
Check if a given data type is of floating point type.
Definition: Utils.h:1002

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(), arm_compute::F16, CLKernelLibrary::get(), arm_compute::get_cl_type_from_data_type(), ITensor::info(), arm_compute::test::validation::input, 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, arm_compute::needs_serialized_reduction(), CLBuildOptions::options(), arm_compute::PROD, arm_compute::SUM, arm_compute::SUM_SQUARE, arm_compute::support::cpp11::to_string(), and arm_compute::U.

◆ 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 261 of file CLReductionOperationKernel.cpp.

262 {
265 
266  const bool is_serial_op = needs_serialized_reduction(_op, _input->info()->data_type(), _reduction_axis);
267  switch(_reduction_axis)
268  {
269  case 0:
270  {
271  // We use parallel reduction only in non quantized types
272  if(is_serial_op)
273  {
274  // Get first input and output slices
275  Window window_in{ window };
276  window_in.set(Window::DimX, Window::Dimension(0, _input->info()->dimension(0), _input->info()->dimension(0)));
277 
278  Window in_slice = window.first_slice_window_1D();
279  Window out_slice = window.first_slice_window_1D();
280 
281  do
282  {
283  unsigned int idx = 0;
284  add_1D_tensor_argument(idx, _input, in_slice);
285  add_1D_tensor_argument(idx, _output, out_slice);
286  enqueue(queue, *this, in_slice, lws_hint());
287  }
288  while(window_in.slide_window_slice_1D(in_slice) && window.slide_window_slice_1D(out_slice));
289  }
290  else
291  {
292  // Set out window
293  Window out_window(window);
294  out_window.set(Window::DimX, Window::Dimension(0, 0, 0));
295 
296  // Get first input and output slices
297  Window in_slice = window.first_slice_window_2D();
298  Window out_slice = out_window.first_slice_window_2D();
299 
300  // Reshape window
301  const unsigned int border_width = ((in_slice.x().end() % border_val) != 0) ? border_val - in_slice.x().end() % border_val : 0;
302  in_slice.set(Window::DimX, Window::Dimension(in_slice.x().start(), in_slice.x().end() + border_width, in_slice.x().step()));
303 
304  // Set local sums buffer
305  unsigned int local_res_size = lws_hint()[0] * _input->info()->element_size();
306  _kernel.setArg(num_arguments_per_2D_tensor() * 2, local_res_size, nullptr);
307 
308  do
309  {
310  unsigned int idx = 0;
311  add_2D_tensor_argument(idx, _input, in_slice);
312  add_2D_tensor_argument(idx, _output, out_slice);
313  enqueue(queue, *this, in_slice, lws_hint());
314  }
315  while(window.slide_window_slice_2D(in_slice) && window.slide_window_slice_2D(out_slice));
316  }
317  }
318  break;
319  case 1:
320  {
321  // Get first input and output slices
322  Window window_in{ window };
323  window_in.set(Window::DimY, Window::Dimension(0, _input->info()->dimension(1), _input->info()->dimension(1)));
324  Window in_slice = window_in.first_slice_window_2D();
325  Window out_slice = window.first_slice_window_2D();
326 
327  do
328  {
329  unsigned int idx = 0;
330  add_2D_tensor_argument(idx, _input, in_slice);
331  add_2D_tensor_argument(idx, _output, out_slice);
332  enqueue(queue, *this, in_slice, lws_hint());
333  }
334  while(window_in.slide_window_slice_2D(in_slice) && window.slide_window_slice_2D(out_slice));
335  }
336  break;
337  case 2:
338  {
339  // Get first input and output slices
340  Window window_in{ window };
341  window_in.set(Window::DimZ, Window::Dimension(0, _input->info()->dimension(2), _input->info()->dimension(2)));
342  Window in_slice = window_in.first_slice_window_3D();
343  Window out_slice = window.first_slice_window_3D();
344 
345  do
346  {
347  unsigned int idx = 0;
348  add_3D_tensor_argument(idx, _input, in_slice);
349  add_3D_tensor_argument(idx, _output, out_slice);
350  enqueue(queue, *this, in_slice, lws_hint());
351  }
352  while(window_in.slide_window_slice_3D(in_slice) && window.slide_window_slice_3D(out_slice));
353  }
354  break;
355  case 3:
356  {
357  // Get first input and output slices
358  Window window_in{ window };
359  window_in.set(3, Window::Dimension(0, 1, 1));
360  Window in_slice = window_in.first_slice_window_4D();
361  Window out_slice = window.first_slice_window_4D();
362 
363  do
364  {
365  unsigned int idx = 0;
366  add_4D_tensor_argument(idx, _input, in_slice);
367  add_4D_tensor_argument(idx, _output, out_slice);
368  enqueue(queue, *this, in_slice, lws_hint());
369  }
370  while(window_in.slide_window_slice_4D(in_slice) && window.slide_window_slice_4D(out_slice));
371  }
372  break;
373  default:
374  ARM_COMPUTE_ERROR("Not supported");
375  }
376 }
Window first_slice_window_2D() const
First 2D slice of the window.
Definition: Window.h:281
bool needs_serialized_reduction(ReductionOperation op, DataType dt, unsigned int axis)
Check if the given reduction operation should be handled in a serial way.
Definition: Utils.cpp:432
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
#define ARM_COMPUTE_ERROR(msg)
Print the given message then throw an std::runtime_error.
Definition: Error.h:352
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.
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:321
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:49
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:333
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:297
bool slide_window_slice_4D(Window &slice) const
Slide the passed 4D window slice.
Definition: Window.h:345
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:289
#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:309
#define ARM_COMPUTE_ERROR_ON_UNCONFIGURED_KERNEL(k)
Definition: Validate.h:941
Window first_slice_window_1D() const
First 1D slice of the window.
Definition: Window.h:273
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_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(), ICLKernel::lws_hint(), arm_compute::needs_serialized_reduction(), 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, U32/S32 for ARG_MIX/ARG_MAX. 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 253 of file CLReductionOperationKernel.cpp.

254 {
255  ARM_COMPUTE_RETURN_ON_ERROR(validate_arguments(input, output, axis, op, width));
256  ARM_COMPUTE_RETURN_ON_ERROR(std::get<0>(validate_and_configure_window(input->clone().get(), output->clone().get(), axis, op)));
257 
258  return Status{};
259 }
#define ARM_COMPUTE_RETURN_ON_ERROR(status)
Checks if a status contains an error and returns it.
Definition: Error.h:204

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

Referenced by CLReductionOperation::validate().


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