Compute Library
 21.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)
 Set the input and output tensors. More...
 
void configure (const CLCompileContext &compile_context, const ICLTensor *input, ICLTensor *output, unsigned int axis, ReductionOperation op)
 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...
 
- Public Member Functions inherited from ICLKernel
 ICLKernel ()
 Constructor. More...
 
cl::Kernel & kernel ()
 Returns a reference to the OpenCL kernel of this object. More...
 
CLKernelType type () const
 Returns the CL kernel type. 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...
 
virtual BorderSize border_size () const
 The size of the border for that kernel. More...
 
const Windowwindow () const
 The maximum window the kernel can be executed on. More...
 
bool is_window_configured () const
 Function to check if the embedded window of this kernel has been configured. More...
 

Static Public Member Functions

static Status validate (const ITensorInfo *input, const ITensorInfo *output, unsigned int axis, ReductionOperation op)
 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 75 of file CLReductionOperationKernel.cpp.

References arm_compute::ELEMENTWISE, and arm_compute::SUM_SQUARE.

76  : _input(nullptr), _output(nullptr), _reduction_axis(0), _op(ReductionOperation::SUM_SQUARE)
77 {
79 }
Elementeise CL kernel type.
Definition: CLTypes.h:84

◆ 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

◆ configure() [1/2]

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

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

Definition at line 81 of file CLReductionOperationKernel.cpp.

References CLKernelLibrary::get().

82 {
83  configure(CLKernelLibrary::get().get_compile_context(), input, output, axis, op);
84 }
static CLKernelLibrary & get()
Access the KernelLibrary singleton.
void configure(const ICLTensor *input, ICLTensor *output, unsigned int axis, ReductionOperation op)
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 
)

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

Definition at line 86 of file CLReductionOperationKernel.cpp.

References arm_compute::adjust_vec_size(), ARM_COMPUTE_ERROR, ARM_COMPUTE_ERROR_ON, ARM_COMPUTE_ERROR_ON_NULLPTR, ARM_COMPUTE_ERROR_THROW_ON, arm_compute::auto_init_if_empty(), arm_compute::calculate_max_window(), ICloneable< T >::clone(), arm_compute::misc::shape_calculator::compute_reduced_shape(), arm_compute::create_kernel(), arm_compute::test::validation::data_type, ITensorInfo::data_type(), ITensorInfo::dimension(), Window::DimX, arm_compute::float_to_string_with_full_precision(), arm_compute::get_cl_type_from_data_type(), arm_compute::get_padding_info(), arm_compute::has_padding_changed(), ITensor::info(), arm_compute::test::validation::input, arm_compute::is_data_type_float(), arm_compute::is_data_type_quantized(), arm_compute::MAX, arm_compute::MEAN_SUM, arm_compute::MIN, arm_compute::needs_serialized_reduction(), ITensorInfo::num_channels(), UniformQuantizationInfo::offset, arm_compute::test::validation::output_shape, arm_compute::PROD, ITensorInfo::quantization_info(), UniformQuantizationInfo::scale, Window::set(), arm_compute::SUM, arm_compute::SUM_SQUARE, ITensorInfo::tensor_shape(), arm_compute::support::cpp11::to_string(), and QuantizationInfo::uniform().

87 {
89 
90  ARM_COMPUTE_ERROR_THROW_ON(validate_arguments(input->info(), output->info(), axis, op));
91 
92  auto padding_info = get_padding_info({ input, output });
93 
94  _input = input;
95  _output = output;
96  _reduction_axis = axis;
97  _op = op;
98 
99  const TensorShape output_shape = arm_compute::misc::shape_calculator::compute_reduced_shape(input->info()->tensor_shape(), axis, true);
100  auto_init_if_empty(*output->info(), input->info()->clone()->set_tensor_shape(output_shape).reset_padding().set_is_resizable(true));
101 
102  // Set build options
103  CLBuildOptions build_opts;
104  DataType data_type = input->info()->data_type();
105  std::string data_type_promoted{};
106 
107  if(is_data_type_quantized(data_type))
108  {
109  data_type_promoted = "int";
110  }
111  else
112  {
113  data_type_promoted = get_cl_type_from_data_type(data_type);
114  }
115 
116  const unsigned int width = input->info()->dimension(0) * input->info()->num_channels();
117  unsigned int vec_size = (is_data_type_quantized(input->info()->data_type()) && (axis == 0)) ? 1 : 16;
118  vec_size = adjust_vec_size(vec_size, width);
119  const unsigned int vec_size_leftover = width % vec_size;
120 
121  build_opts.add_option("-DDATA_TYPE=" + get_cl_type_from_data_type(data_type));
122  build_opts.add_option("-DDATA_TYPE_PROMOTED=" + data_type_promoted);
123  build_opts.add_option("-DVEC_SIZE=" + support::cpp11::to_string(vec_size));
124  build_opts.add_option("-DVEC_SIZE_LEFTOVER=" + support::cpp11::to_string(vec_size_leftover));
125  build_opts.add_option_if(is_data_type_float(data_type), "-DFLOAT_DATA_TYPE");
126  build_opts.add_option_if(op == ReductionOperation::SUM_SQUARE, "-DSUM_SQUARE");
127  build_opts.add_option_if(op == ReductionOperation::MEAN_SUM, "-DMEAN");
128  build_opts.add_option_if(op == ReductionOperation::SUM, "-DSUM");
129  build_opts.add_option_if(op == ReductionOperation::PROD, "-DPROD");
130  build_opts.add_option_if(op == ReductionOperation::MIN, "-DMIN");
131  build_opts.add_option_if(op == ReductionOperation::MAX, "-DMAX");
132  build_opts.add_option_if(is_data_type_quantized(data_type), "-DOFFSET=" + support::cpp11::to_string(input->info()->quantization_info().uniform().offset));
133  build_opts.add_option_if(is_data_type_quantized(data_type), "-DSCALE=" + float_to_string_with_full_precision(input->info()->quantization_info().uniform().scale));
134 
135  switch(op)
136  {
138  build_opts.add_option(("-DOPERATION=square_sum"));
139  break;
142  build_opts.add_option(("-DOPERATION=sum"));
143  break;
146  break;
148  build_opts.add_option(("-DOPERATION=product"));
149  break;
150  default:
151  ARM_COMPUTE_ERROR("Unsupported reduction operation");
152  }
153 
154  // Create kernel
155  std::string kernel_axis_name;
156  const bool is_serial_op = needs_serialized_reduction(_op, _input->info()->data_type(), _reduction_axis);
157 
158  switch(axis)
159  {
160  case 0:
161  {
162  build_opts.add_option("-DWIDTH=" + support::cpp11::to_string(width));
163  kernel_axis_name = ((is_serial_op) ? "non_parallel_x" : "x");
164  }
165  break;
166  case 1:
167  build_opts.add_option("-DHEIGHT=" + support::cpp11::to_string(input->info()->dimension(1)));
168  kernel_axis_name = "y";
169  break;
170  case 2:
171  build_opts.add_option("-DDEPTH=" + support::cpp11::to_string(input->info()->dimension(2)));
172  kernel_axis_name = "z";
173  break;
174  case 3:
175  build_opts.add_option("-DDEPTH=" + support::cpp11::to_string(input->info()->dimension(2)));
176  build_opts.add_option("-DBATCH=" + support::cpp11::to_string(input->info()->dimension(3)));
177  kernel_axis_name = "w";
178  break;
179  default:
180  ARM_COMPUTE_ERROR("Not supported");
181  }
182  _kernel = create_kernel(compile_context, "reduction_operation_" + kernel_axis_name, build_opts.options());
183 
184  // Configure kernel window
185  Window win = calculate_max_window(*input->info(), Steps(vec_size));
186  win.set(Window::DimX, Window::Dimension(win.x().start(), win.x().end() * _input->info()->num_channels(), win.x().step()));
187  ICLKernel::configure_internal(win);
188 
190 }
bool is_data_type_quantized(DataType dt)
Check if a given data type is of quantized type.
Definition: Utils.h:981
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:458
Window calculate_max_window(const ValidRegion &valid_region, const Steps &steps, bool skip_border, BorderSize border_size)
#define ARM_COMPUTE_ERROR(msg)
Print the given message then throw an std::runtime_error.
Definition: Error.h:352
std::string to_string(T &&value)
Convert integer and float values to string.
#define ARM_COMPUTE_ERROR_ON(cond)
If the condition is true then an error message is printed and an exception thrown.
Definition: Error.h:466
#define ARM_COMPUTE_ERROR_THROW_ON(status)
Definition: Error.h:455
const DataType data_type
Definition: Im2Col.cpp:150
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:391
static constexpr size_t DimX
Alias for dimension 0 also known as X dimension.
Definition: Window.h:43
std::string float_to_string_with_full_precision(float val)
Create a string with the float in full precision.
Definition: Utils.h:1075
TensorShape compute_reduced_shape(const TensorShape &input, unsigned int axis, bool keep_dims=true)
Calculate the reduced shape of a tensor given an axis.
std::string get_cl_type_from_data_type(const DataType &dt)
Translates a tensor data type to the appropriate OpenCL type.
Definition: CLHelpers.cpp:39
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...
void set(size_t dimension, const Dimension &dim)
Set the values of a given dimension.
Definition: Window.inl:49
bool has_padding_changed(const std::unordered_map< const ITensorInfo *, PaddingSize > &padding_map)
Check if the previously stored padding info has changed after configuring a kernel.
Definition: Utils.cpp:533
std::unordered_map< const ITensorInfo *, PaddingSize > get_padding_info(std::initializer_list< const ITensorInfo *> infos)
Stores padding information before configuring a kernel.
Definition: Utils.cpp:518
#define ARM_COMPUTE_ERROR_ON_NULLPTR(...)
Definition: Validate.h:157
unsigned int adjust_vec_size(unsigned int vec_size, size_t dim0)
Returns the adjusted vector size in case it is less than the input&#39;s first dimension, getting rounded down to its closest valid vector size.
Definition: Utils.h:1171
DataType
Available data types.
Definition: Types.h:79
bool is_data_type_float(DataType dt)
Check if a given data type is of floating point type.
Definition: Utils.h:961

◆ 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 198 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, ARM_COMPUTE_ERROR_ON_INVALID_SUBWINDOW, ARM_COMPUTE_ERROR_ON_UNCONFIGURED_KERNEL, Window::collapse_if_possible(), ITensorInfo::data_type(), ITensorInfo::dimension(), Window::DimX, Window::DimY, Window::DimZ, 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::needs_serialized_reduction(), Window::set(), Window::slide_window_slice_2D(), Window::slide_window_slice_3D(), Window::slide_window_slice_4D(), and IKernel::window().

199 {
202 
203  const bool is_serial_op = needs_serialized_reduction(_op, _input->info()->data_type(), _reduction_axis);
204  switch(_reduction_axis)
205  {
206  case 0:
207  {
208  // We use parallel reduction only in non quantized types
209  if(is_serial_op)
210  {
211  // Get first input and output slices
212  Window window_in{ window };
213  window_in.set(Window::DimX, Window::Dimension(0, _input->info()->dimension(0), _input->info()->dimension(0)));
214 
215  Window out_window{ window };
216  out_window.set(Window::DimX, Window::Dimension(0, 0, 0));
217 
218  Window in_slice = window_in.first_slice_window_1D();
219  Window out_slice = out_window.first_slice_window_1D();
220 
221  do
222  {
223  unsigned int idx = 0;
224  add_1D_tensor_argument(idx, _input, in_slice);
225  add_1D_tensor_argument(idx, _output, out_slice);
226  enqueue(queue, *this, in_slice);
227  }
228  while(window_in.slide_window_slice_1D(in_slice) && out_window.slide_window_slice_1D(out_slice));
229  }
230  else
231  {
232  // Set out window
233  bool has_collapsed = true;
234  Window window_in = window.collapse_if_possible(window, 2, &has_collapsed);
235  ARM_COMPUTE_ERROR_ON(!has_collapsed);
236 
237  Window window_out = window_in;
238  window_out.set(0, Window::Dimension());
239 
240  unsigned int idx = 0;
241  add_3D_tensor_argument(idx, _input, window_in);
242  add_3D_tensor_argument(idx, _output, window_out);
243  enqueue(queue, *this, window_in);
244  }
245  }
246  break;
247  case 1:
248  {
249  // Get first input and output slices
250  Window window_in{ window };
251  window_in.set(Window::DimY, Window::Dimension(0, _input->info()->dimension(1), _input->info()->dimension(1)));
252  Window in_slice = window_in.first_slice_window_2D();
253  Window out_slice = window.first_slice_window_2D();
254 
255  do
256  {
257  unsigned int idx = 0;
258  add_2D_tensor_argument(idx, _input, in_slice);
259  add_2D_tensor_argument(idx, _output, out_slice);
260  enqueue(queue, *this, in_slice);
261  }
262  while(window_in.slide_window_slice_2D(in_slice) && window.slide_window_slice_2D(out_slice));
263  }
264  break;
265  case 2:
266  {
267  // Get first input and output slices
268  Window window_in{ window };
269  window_in.set(Window::DimZ, Window::Dimension(0, _input->info()->dimension(2), _input->info()->dimension(2)));
270  Window in_slice = window_in.first_slice_window_3D();
271  Window out_slice = window.first_slice_window_3D();
272 
273  do
274  {
275  unsigned int idx = 0;
276  add_3D_tensor_argument(idx, _input, in_slice);
277  add_3D_tensor_argument(idx, _output, out_slice);
278  enqueue(queue, *this, in_slice);
279  }
280  while(window_in.slide_window_slice_3D(in_slice) && window.slide_window_slice_3D(out_slice));
281  }
282  break;
283  case 3:
284  {
285  // Get first input and output slices
286  Window window_in{ window };
287  window_in.set(3, Window::Dimension(0, 1, 1));
288  Window in_slice = window_in.first_slice_window_4D();
289  Window out_slice = window.first_slice_window_4D();
290 
291  do
292  {
293  unsigned int idx = 0;
294  add_4D_tensor_argument(idx, _input, in_slice);
295  add_4D_tensor_argument(idx, _output, out_slice);
296  enqueue(queue, *this, in_slice);
297  }
298  while(window_in.slide_window_slice_4D(in_slice) && window.slide_window_slice_4D(out_slice));
299  }
300  break;
301  default:
302  ARM_COMPUTE_ERROR("Not supported");
303  }
304 }
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:458
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:32
#define ARM_COMPUTE_ERROR(msg)
Print the given message then throw an std::runtime_error.
Definition: Error.h:352
virtual DataType data_type() const =0
Data type used for each element of the tensor.
#define ARM_COMPUTE_ERROR_ON(cond)
If the condition is true then an error message is printed and an exception thrown.
Definition: Error.h:466
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:214
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
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
virtual ITensorInfo * info() const =0
Interface to be implemented by the child class to return the tensor&#39;s metadata.
void set(size_t dimension, const Dimension &dim)
Set the values of a given dimension.
Definition: Window.inl:49
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:915
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:190
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
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:166
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:224
#define ARM_COMPUTE_ERROR_ON_INVALID_SUBWINDOW(f, s)
Definition: Validate.h:201

◆ validate()

Status validate ( const ITensorInfo input,
const ITensorInfo output,
unsigned int  axis,
ReductionOperation  op 
)
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
Returns
a status

Definition at line 192 of file CLReductionOperationKernel.cpp.

References ARM_COMPUTE_RETURN_ON_ERROR.

Referenced by CLReductionOperation::validate().

193 {
194  ARM_COMPUTE_RETURN_ON_ERROR(validate_arguments(input, output, axis, op));
195  return Status{};
196 }
#define ARM_COMPUTE_RETURN_ON_ERROR(status)
Checks if a status contains an error and returns it.
Definition: Error.h:204

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