Compute Library
 21.02
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 configure (const CLCompileContext &compile_context, 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...
 
virtual void run_op (ITensorPack &tensors, const Window &window, cl::CommandQueue &queue)
 Enqueue the OpenCL kernel to process the given window on the passed OpenCL command queue. 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...
 
void set_wbsm_hint (const cl_int &wbsm_hint)
 Set the workgroup batch size modifier hint. More...
 
cl_int wbsm_hint () const
 Return the workgroup batch size modifier 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<unsigned int dimension_size>
void add_tensor_argument (unsigned &idx, const ICLTensor *tensor, const Window &window)
 
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...
 
- 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 36 of file CLReductionOperationKernel.h.

Constructor & Destructor Documentation

◆ CLReductionOperationKernel() [1/3]

Default constructor.

Definition at line 121 of file CLReductionOperationKernel.cpp.

122  : _input(nullptr), _output(nullptr), _reduction_axis(0), _op(ReductionOperation::SUM_SQUARE), _border_size()
123 {
124 }

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

127 {
128  return _border_size;
129 }

◆ configure() [1/2]

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/QASYMM8_SIGNED/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. Operations supported: MEAN_SUM, PROD, SUM_SQUARE, SUM, MIN, MAX
[in]width(Optional) In case of x-axis we also need to provide the width of the input image.

Definition at line 131 of file CLReductionOperationKernel.cpp.

References CLKernelLibrary::get().

132 {
133  configure(CLKernelLibrary::get().get_compile_context(), input, output, axis, op, width);
134 }
static CLKernelLibrary & get()
Access the KernelLibrary singleton.
void configure(const ICLTensor *input, ICLTensor *output, unsigned int axis, ReductionOperation op, unsigned int width=0)
Set the input and output tensors.

◆ configure() [2/2]

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

Set the input and output tensors.

Parameters
[in]compile_contextThe compile context to be used.
[in]inputSource tensor. Data types supported: QASYMM8/QASYMM8_SIGNED/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. Operations supported: MEAN_SUM, PROD, SUM_SQUARE, SUM, MIN, MAX
[in]width(Optional) In case of x-axis we also need to provide the width of the input image.

Definition at line 136 of file CLReductionOperationKernel.cpp.

References CLBuildOptions::add_option(), CLBuildOptions::add_option_if(), CLBuildOptions::add_option_if_else(), ARM_COMPUTE_ERROR, ARM_COMPUTE_ERROR_ON_NULLPTR, ARM_COMPUTE_ERROR_THROW_ON, arm_compute::create_kernel(), arm_compute::create_lws_hint_parallel_implementations(), arm_compute::test::validation::data_type, ITensorInfo::data_type(), CLKernelLibrary::default_ndrange(), ITensorInfo::dimension(), arm_compute::F16, arm_compute::float_to_string_with_full_precision(), 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(), ITensorInfo::num_channels(), UniformQuantizationInfo::offset, CLBuildOptions::options(), arm_compute::PROD, ITensorInfo::quantization_info(), UniformQuantizationInfo::scale, arm_compute::SUM, arm_compute::SUM_SQUARE, arm_compute::support::cpp11::to_string(), QuantizationInfo::uniform(), and arm_compute::validate_arguments().

137 {
139 
140  ARM_COMPUTE_ERROR_THROW_ON(validate_arguments(input->info(), output->info(), axis, op, width));
141 
142  _input = input;
143  _output = output;
144  _reduction_axis = axis;
145  _op = op;
146 
147  // Set build options
148  CLBuildOptions build_opts;
149  DataType data_type = input->info()->data_type();
150  std::string data_type_promoted{};
151 
152  if(is_data_type_quantized(data_type))
153  {
154  data_type_promoted = "int";
155  }
156  else
157  {
158  data_type_promoted = get_cl_type_from_data_type(data_type);
159  }
160 
161  build_opts.add_option("-DDATA_TYPE=" + get_cl_type_from_data_type(data_type));
162  build_opts.add_option("-DDATA_TYPE_PROMOTED=" + data_type_promoted);
163  build_opts.add_option_if(is_data_type_float(data_type), "-DFLOAT_DATA_TYPE");
164  build_opts.add_option_if(op == ReductionOperation::SUM_SQUARE, "-DSUM_SQUARE");
165  build_opts.add_option_if(op == ReductionOperation::MEAN_SUM, "-DMEAN");
166  build_opts.add_option_if(op == ReductionOperation::SUM, "-DSUM");
167  build_opts.add_option_if(op == ReductionOperation::PROD, "-DPROD");
168  build_opts.add_option_if(op == ReductionOperation::MIN, "-DMIN");
169  build_opts.add_option_if(op == ReductionOperation::MAX, "-DMAX");
170  build_opts.add_option_if(input->info()->num_channels() == 2, "-DCOMPLEX");
171  build_opts.add_option_if(is_data_type_quantized(data_type), "-DOFFSET=" + support::cpp11::to_string(input->info()->quantization_info().uniform().offset));
172  build_opts.add_option_if(is_data_type_quantized(data_type), "-DSCALE=" + float_to_string_with_full_precision(input->info()->quantization_info().uniform().scale));
173 
174  switch(op)
175  {
177  build_opts.add_option(("-DOPERATION=square_sum"));
178  break;
181  build_opts.add_option(("-DOPERATION=sum"));
182  break;
185  break;
187  build_opts.add_option(("-DOPERATION=product"));
188  break;
189  default:
190  ARM_COMPUTE_ERROR("Unsupported reduction operation");
191  }
192 
193  // Create kernel
195  std::string kernel_axis_name;
196  const bool is_serial_op = needs_serialized_reduction(_op, _input->info()->data_type(), _reduction_axis);
197 
198  switch(axis)
199  {
200  case 0:
201  {
202  if(is_serial_op)
203  {
204  build_opts.add_option("-DWIDTH=" + support::cpp11::to_string(input->info()->dimension(0)));
205  build_opts.add_option_if_else(_input->info()->data_type() == DataType::F16, "-DCOND_DATA_TYPE=short", "-DCOND_DATA_TYPE=int");
206  kernel_axis_name = "non_parallel_x";
207  }
208  else
209  {
210  build_opts.add_option_if(op == ReductionOperation::MEAN_SUM, "-DWIDTH=" + support::cpp11::to_string(width));
211  const unsigned int width_leftover = input->info()->dimension(0) % border_val;
212  const unsigned int border_width = (width_leftover != 0) ? border_val - width_leftover : 0;
213  kernel_axis_name = "x";
214 
215  lws_hint = create_lws_hint_parallel_implementations(input->info()->dimension(0), border_val);
216  _border_size = BorderSize(0, border_width, 0, 0);
217  }
218  }
219  break;
220  case 1:
221  build_opts.add_option("-DHEIGHT=" + support::cpp11::to_string(input->info()->dimension(1)));
222  kernel_axis_name = "y";
223  break;
224  case 2:
225  build_opts.add_option("-DDEPTH=" + support::cpp11::to_string(input->info()->dimension(2)));
226  kernel_axis_name = "z";
227  break;
228  case 3:
229  build_opts.add_option("-DDEPTH=" + support::cpp11::to_string(input->info()->dimension(2)));
230  build_opts.add_option("-DBATCH=" + support::cpp11::to_string(input->info()->dimension(3)));
231  kernel_axis_name = "w";
232  break;
233  default:
234  ARM_COMPUTE_ERROR("Not supported");
235  }
236  _kernel = create_kernel(compile_context, "reduction_operation_" + kernel_axis_name, build_opts.options());
237 
238  // Configure kernel window
239  auto win_config = validate_and_configure_window(_input->info(), _output->info(), axis, op);
240 
241  ARM_COMPUTE_ERROR_THROW_ON(std::get<0>(win_config));
242 
243  ICLKernel::configure_internal(std::get<1>(win_config), lws_hint);
244 }
bool is_data_type_quantized(DataType dt)
Check if a given data type is of quantized type.
Definition: Utils.h:1168
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:453
#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:276
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
const DataType data_type
Definition: Im2Col.cpp:150
cl::NDRange default_ndrange() const
Return the default NDRange for the device.
cl::Kernel create_kernel(const CLCompileContext &ctx, const std::string &kernel_name, const std::set< std::string > &build_opts=std::set< std::string >())
Creates an opencl kernel using a compile context.
Definition: CLHelpers.cpp:403
std::string float_to_string_with_full_precision(float val)
Create a string with the float in full precision.
Definition: Utils.h:1262
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&#39;s metadata.
cl::NDRange create_lws_hint_parallel_implementations(unsigned int input_dimension, unsigned int vector_size)
Creates a suitable LWS hint object for parallel implementations.
Definition: CLHelpers.cpp:411
Status validate_arguments(const ITensorInfo *input, const ITensorInfo *bias, const ITensorInfo *output, const GEMMLowpOutputStageInfo *output_stage)
#define ARM_COMPUTE_ERROR_ON_NULLPTR(...)
Definition: Validate.h:161
DataType
Available data types.
Definition: Types.h:77
bool is_data_type_float(DataType dt)
Check if a given data type is of floating point type.
Definition: Utils.h:1148

◆ 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.

Reimplemented from ICLKernel.

Definition at line 254 of file CLReductionOperationKernel.cpp.

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_2D(), Window::slide_window_slice_3D(), Window::slide_window_slice_4D(), Window::Dimension::start(), Window::Dimension::step(), IKernel::window(), and Window::x().

255 {
258 
259  const bool is_serial_op = needs_serialized_reduction(_op, _input->info()->data_type(), _reduction_axis);
260  switch(_reduction_axis)
261  {
262  case 0:
263  {
264  // We use parallel reduction only in non quantized types
265  if(is_serial_op)
266  {
267  // Get first input and output slices
268  Window window_in{ window };
269  window_in.set(Window::DimX, Window::Dimension(0, _input->info()->dimension(0), _input->info()->dimension(0)));
270 
271  Window out_window{ window };
272  out_window.set(Window::DimX, Window::Dimension(0, 0, 0));
273 
274  Window in_slice = window_in.first_slice_window_1D();
275  Window out_slice = out_window.first_slice_window_1D();
276 
277  do
278  {
279  unsigned int idx = 0;
280  add_1D_tensor_argument(idx, _input, in_slice);
281  add_1D_tensor_argument(idx, _output, out_slice);
282  enqueue(queue, *this, in_slice, lws_hint());
283  }
284  while(window_in.slide_window_slice_1D(in_slice) && out_window.slide_window_slice_1D(out_slice));
285  }
286  else
287  {
288  // Set out window
289  Window out_window(window);
290  out_window.set(Window::DimX, Window::Dimension(0, 0, 0));
291 
292  // Get first input and output slices
293  Window in_slice = window.first_slice_window_2D();
294  Window out_slice = out_window.first_slice_window_2D();
295 
296  // Reshape window
297  const unsigned int border_width = ((in_slice.x().end() % border_val) != 0) ? border_val - in_slice.x().end() % border_val : 0;
298  in_slice.set(Window::DimX, Window::Dimension(in_slice.x().start(), in_slice.x().end() + border_width, in_slice.x().step()));
299 
300  // Set local sums buffer
301  unsigned int local_res_size = lws_hint()[0] * _input->info()->element_size();
302  _kernel.setArg(num_arguments_per_2D_tensor() * 2, local_res_size, nullptr);
303 
304  do
305  {
306  unsigned int idx = 0;
307  add_2D_tensor_argument(idx, _input, in_slice);
308  add_2D_tensor_argument(idx, _output, out_slice);
309  enqueue(queue, *this, in_slice, lws_hint());
310  }
311  while(window.slide_window_slice_2D(in_slice) && window.slide_window_slice_2D(out_slice));
312  }
313  }
314  break;
315  case 1:
316  {
317  // Get first input and output slices
318  Window window_in{ window };
319  window_in.set(Window::DimY, Window::Dimension(0, _input->info()->dimension(1), _input->info()->dimension(1)));
320  Window in_slice = window_in.first_slice_window_2D();
321  Window out_slice = window.first_slice_window_2D();
322 
323  do
324  {
325  unsigned int idx = 0;
326  add_2D_tensor_argument(idx, _input, in_slice);
327  add_2D_tensor_argument(idx, _output, out_slice);
328  enqueue(queue, *this, in_slice, lws_hint());
329  }
330  while(window_in.slide_window_slice_2D(in_slice) && window.slide_window_slice_2D(out_slice));
331  }
332  break;
333  case 2:
334  {
335  // Get first input and output slices
336  Window window_in{ window };
337  window_in.set(Window::DimZ, Window::Dimension(0, _input->info()->dimension(2), _input->info()->dimension(2)));
338  Window in_slice = window_in.first_slice_window_3D();
339  Window out_slice = window.first_slice_window_3D();
340 
341  do
342  {
343  unsigned int idx = 0;
344  add_3D_tensor_argument(idx, _input, in_slice);
345  add_3D_tensor_argument(idx, _output, out_slice);
346  enqueue(queue, *this, in_slice, lws_hint());
347  }
348  while(window_in.slide_window_slice_3D(in_slice) && window.slide_window_slice_3D(out_slice));
349  }
350  break;
351  case 3:
352  {
353  // Get first input and output slices
354  Window window_in{ window };
355  window_in.set(3, Window::Dimension(0, 1, 1));
356  Window in_slice = window_in.first_slice_window_4D();
357  Window out_slice = window.first_slice_window_4D();
358 
359  do
360  {
361  unsigned int idx = 0;
362  add_4D_tensor_argument(idx, _input, in_slice);
363  add_4D_tensor_argument(idx, _output, out_slice);
364  enqueue(queue, *this, in_slice, lws_hint());
365  }
366  while(window_in.slide_window_slice_4D(in_slice) && window.slide_window_slice_4D(out_slice));
367  }
368  break;
369  default:
370  ARM_COMPUTE_ERROR("Not supported");
371  }
372 }
Window first_slice_window_2D() const
First 2D slice of the window.
Definition: Window.h:283
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:453
const Window & window() const
The maximum window the kernel can be executed on.
Definition: IKernel.cpp:28
void enqueue(IGCKernel &kernel, const Window &window, const gles::NDRange &lws=gles::NDRange(1U, 1U, 1U))
Add the kernel to the command queue with the given window.
Definition: IGCKernel.cpp:41
virtual size_t dimension(size_t index) const =0
Return the size of the requested dimension.
#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:276
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&#39;s parameters to the object&#39;s kernel&#39;s arguments starting from the index idx...
Definition: ICLKernel.h:172
bool slide_window_slice_2D(Window &slice) const
Slide the passed 2D window slice.
Definition: Window.h:323
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&#39;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:206
bool slide_window_slice_3D(Window &slice) const
Slide the passed 3D window slice.
Definition: Window.h:335
#define ARM_COMPUTE_ERROR_ON_UNCONFIGURED_KERNEL(k)
Definition: Validate.h:941
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&#39;s parameters to the object&#39;s kernel&#39;s arguments starting from the index idx...
Definition: ICLKernel.h:148
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:299
bool slide_window_slice_4D(Window &slice) const
Slide the passed 4D window slice.
Definition: Window.h:347
constexpr int end() const
Return the end of the dimension.
Definition: Window.h:99
void add_1D_tensor_argument(unsigned int &idx, const ICLTensor *tensor, const Window &window)
Add the passed 1D tensor&#39;s parameters to the object&#39;s kernel&#39;s arguments starting from the index idx...
Definition: ICLKernel.h:124
Window first_slice_window_3D() const
First 3D slice of the window.
Definition: Window.h:291
void add_4D_tensor_argument(unsigned int &idx, const ICLTensor *tensor, const Window &window)
Add the passed 4D tensor&#39;s parameters to the object&#39;s kernel&#39;s arguments starting from the index idx...
Definition: ICLKernel.h:182
#define ARM_COMPUTE_ERROR_ON_INVALID_SUBWINDOW(f, s)
Definition: Validate.h:205
constexpr const Dimension & x() const
Alias to access the first dimension of the window.
Definition: Window.h:145

◆ 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/QASYMM8_SIGNED/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. Operations supported: MEAN_SUM, PROD, SUM_SQUARE, SUM, MIN, MAX
[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 246 of file CLReductionOperationKernel.cpp.

References ARM_COMPUTE_RETURN_ON_ERROR, ICloneable< T >::clone(), and arm_compute::validate_arguments().

Referenced by CLReductionOperation::validate().

247 {
248  ARM_COMPUTE_RETURN_ON_ERROR(validate_arguments(input, output, axis, op, width));
249  ARM_COMPUTE_RETURN_ON_ERROR(std::get<0>(validate_and_configure_window(input->clone().get(), output->clone().get(), axis, op)));
250 
251  return Status{};
252 }
#define ARM_COMPUTE_RETURN_ON_ERROR(status)
Checks if a status contains an error and returns it.
Definition: Error.h:204
Status validate_arguments(const ITensorInfo *input, const ITensorInfo *bias, const ITensorInfo *output, const GEMMLowpOutputStageInfo *output_stage)

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