Compute Library
 19.08
CLComplexPixelWiseMultiplicationKernel Class Reference

Interface for the complex pixelwise multiplication kernel. More...

#include <CLPixelWiseMultiplicationKernel.h>

Collaboration diagram for CLComplexPixelWiseMultiplicationKernel:
[legend]

Public Member Functions

 CLComplexPixelWiseMultiplicationKernel ()
 Default constructor. More...
 
 CLComplexPixelWiseMultiplicationKernel (const CLComplexPixelWiseMultiplicationKernel &)=delete
 Prevent instances of this class from being copied (As this class contains pointers) More...
 
CLComplexPixelWiseMultiplicationKerneloperator= (const CLComplexPixelWiseMultiplicationKernel &)=delete
 Prevent instances of this class from being copied (As this class contains pointers) More...
 
 CLComplexPixelWiseMultiplicationKernel (CLComplexPixelWiseMultiplicationKernel &&)=default
 Allow instances of this class to be moved. More...
 
CLComplexPixelWiseMultiplicationKerneloperator= (CLComplexPixelWiseMultiplicationKernel &&)=default
 Allow instances of this class to be moved. More...
 
void configure (const ICLTensor *input1, const ICLTensor *input2, ICLTensor *output)
 Initialise the kernel's input, output and border mode. 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 *input1, const ITensorInfo *input2, const ITensorInfo *output)
 Static function to check if given info will lead to a valid configuration of CLComplexPixelWiseMultiplicationKernel. 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 complex pixelwise multiplication kernel.

Definition at line 87 of file CLPixelWiseMultiplicationKernel.h.

Constructor & Destructor Documentation

◆ CLComplexPixelWiseMultiplicationKernel() [1/3]

Default constructor.

Definition at line 344 of file CLPixelWiseMultiplicationKernel.cpp.

345  : _input1(nullptr), _input2(nullptr), _output(nullptr)
346 {
347 }

◆ CLComplexPixelWiseMultiplicationKernel() [2/3]

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

◆ CLComplexPixelWiseMultiplicationKernel() [3/3]

Allow instances of this class to be moved.

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 420 of file CLPixelWiseMultiplicationKernel.cpp.

421 {
422  const unsigned int replicateSize = _output->info()->dimension(0) - std::min(_input1->info()->dimension(0), _input2->info()->dimension(0));
423  const unsigned int border = std::min<unsigned int>(num_elems_processed_per_iteration_complex - 1U, replicateSize);
424  return BorderSize{ 0, border, 0, 0 };
425 }
virtual size_t dimension(size_t index) const =0
Return the size of the requested dimension.
virtual ITensorInfo * info() const =0
Interface to be implemented by the child class to return the tensor's metadata.

References ITensorInfo::dimension(), ITensor::info(), and arm_compute::U.

◆ configure()

void configure ( const ICLTensor input1,
const ICLTensor input2,
ICLTensor output 
)

Initialise the kernel's input, output and border mode.

Parameters
[in]input1An input tensor. Data types supported: F32. Number of channels supported: 2.
[in]input2An input tensor. Data types supported: same as input1. Number of channels supported: same as input1.
[out]outputThe output tensor, Data types supported: same as input1. Number of channels supported: same as input1.

Definition at line 349 of file CLPixelWiseMultiplicationKernel.cpp.

350 {
351  ARM_COMPUTE_ERROR_ON_NULLPTR(input1, input2, output);
352  ARM_COMPUTE_ERROR_THROW_ON(validate_arguments_complex(input1->info(), input2->info(), output->info()));
353 
354  // Configure kernel window
355  auto win_config = validate_and_configure_window_complex(input1->info(), input2->info(), output->info());
356  ARM_COMPUTE_ERROR_THROW_ON(win_config.first);
357 
358  _input1 = input1;
359  _input2 = input2;
360  _output = output;
361 
362  // Create kernel
363  _kernel = static_cast<cl::Kernel>(CLKernelLibrary::get().create_kernel("pixelwise_mul_complex"));
364 
365  ICLKernel::configure_internal(win_config.second);
366 }
static CLKernelLibrary & get()
Access the KernelLibrary singleton.
#define ARM_COMPUTE_ERROR_THROW_ON(status)
Definition: Error.h:327
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

References ARM_COMPUTE_ERROR_ON_NULLPTR, ARM_COMPUTE_ERROR_THROW_ON, arm_compute::create_kernel(), CLKernelLibrary::get(), and ITensor::info().

◆ operator=() [1/2]

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 377 of file CLPixelWiseMultiplicationKernel.cpp.

378 {
381 
382  const TensorShape &in_shape1 = _input1->info()->tensor_shape();
383  const TensorShape &in_shape2 = _input2->info()->tensor_shape();
384  const TensorShape &out_shape = _output->info()->tensor_shape();
385 
386  bool can_collapse = true;
387  if(std::min(in_shape1.total_size(), in_shape2.total_size()) > 1)
388  {
389  can_collapse = (std::min(in_shape1.num_dimensions(), in_shape2.num_dimensions()) > Window::DimZ);
390  for(size_t d = Window::DimZ; can_collapse && (d < out_shape.num_dimensions()); ++d)
391  {
392  can_collapse = (in_shape1[d] == in_shape2[d]);
393  }
394  }
395 
396  bool has_collapsed = false;
397  Window collapsed = can_collapse ? window.collapse_if_possible(ICLKernel::window(), Window::DimZ, &has_collapsed) : window;
398 
399  const TensorShape &in_shape1_collapsed = has_collapsed ? in_shape1.collapsed_from(Window::DimZ) : in_shape1;
400  const TensorShape &in_shape2_collapsed = has_collapsed ? in_shape2.collapsed_from(Window::DimZ) : in_shape2;
401 
402  Window slice = collapsed.first_slice_window_3D();
403  Window slice_input1 = slice.broadcast_if_dimension_le_one(in_shape1_collapsed);
404  Window slice_input2 = slice.broadcast_if_dimension_le_one(in_shape2_collapsed);
405 
406  do
407  {
408  unsigned int idx = 0;
409  add_3D_tensor_argument(idx, _input1, slice_input1);
410  add_3D_tensor_argument(idx, _input2, slice_input2);
411  add_3D_tensor_argument(idx, _output, slice);
412  enqueue(queue, *this, slice);
413 
414  ARM_COMPUTE_UNUSED(collapsed.slide_window_slice_3D(slice_input1));
415  ARM_COMPUTE_UNUSED(collapsed.slide_window_slice_3D(slice_input2));
416  }
417  while(collapsed.slide_window_slice_3D(slice));
418 }
const Window & window() const
The maximum window the kernel can be executed on.
Definition: IKernel.cpp:28
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
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
#define ARM_COMPUTE_UNUSED(...)
To avoid unused variables warnings.
Definition: Error.h:160
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:54
virtual const TensorShape & tensor_shape() const =0
Size for each dimension of the tensor.
virtual ITensorInfo * info() const =0
Interface to be implemented by the child class to return the tensor's metadata.
static constexpr size_t DimZ
Alias for dimension 2 also known as Z dimension.
Definition: Window.h:47
#define ARM_COMPUTE_ERROR_ON_INVALID_SUBWINDOW(f, s)
Definition: Validate.h:205
#define ARM_COMPUTE_ERROR_ON_UNCONFIGURED_KERNEL(k)
Definition: Validate.h:940
SimpleTensor< T > slice(const SimpleTensor< T > &src, Coordinates starts, Coordinates ends)

References ICLKernel::add_3D_tensor_argument(), ARM_COMPUTE_ERROR_ON_INVALID_SUBWINDOW, ARM_COMPUTE_ERROR_ON_UNCONFIGURED_KERNEL, ARM_COMPUTE_UNUSED, Window::collapse_if_possible(), TensorShape::collapsed_from(), Window::DimZ, arm_compute::enqueue(), Window::first_slice_window_3D(), ITensor::info(), Dimensions< T >::num_dimensions(), arm_compute::test::validation::reference::slice(), Window::slide_window_slice_3D(), ITensorInfo::tensor_shape(), TensorShape::total_size(), and IKernel::window().

◆ validate()

Status validate ( const ITensorInfo input1,
const ITensorInfo input2,
const ITensorInfo output 
)
static

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

Parameters
[in]input1An input tensor info. Data types supported: F32. Number of channels supported: 2.
[in]input2An input tensor info. Data types supported: same as input1. Number of channels supported: same as input1.
[in]outputThe output tensor info. Data types supported: same as input1. Number of channels supported: same as input1.
Returns
a status

Definition at line 368 of file CLPixelWiseMultiplicationKernel.cpp.

369 {
370  ARM_COMPUTE_ERROR_ON_NULLPTR(input1, input2, output);
371  ARM_COMPUTE_RETURN_ON_ERROR(validate_arguments_complex(input1, input2, output));
372  ARM_COMPUTE_RETURN_ON_ERROR(validate_and_configure_window_complex(input1->clone().get(), input2->clone().get(), output->clone().get()).first);
373 
374  return Status{};
375 }
#define ARM_COMPUTE_RETURN_ON_ERROR(status)
Checks if a status contains an error and returns it.
Definition: Error.h:193
#define ARM_COMPUTE_ERROR_ON_NULLPTR(...)
Definition: Validate.h:161

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

Referenced by CLComplexPixelWiseMultiplication::validate().


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