Compute Library
 21.02
CLGaussian5x5 Class Reference

Basic function to execute gaussian filter 5x5. More...

#include <CLGaussian5x5.h>

Collaboration diagram for CLGaussian5x5:
[legend]

Public Member Functions

 CLGaussian5x5 (std::shared_ptr< IMemoryManager > memory_manager=nullptr)
 Default Constructor. More...
 
 CLGaussian5x5 (const CLGaussian5x5 &)=delete
 Prevent instances of this class from being copied. More...
 
 CLGaussian5x5 (CLGaussian5x5 &&)=default
 Default move constructor. More...
 
CLGaussian5x5operator= (const CLGaussian5x5 &)=delete
 Prevent instances of this class from being copied. More...
 
CLGaussian5x5operator= (CLGaussian5x5 &&)=default
 Default move assignment operator. More...
 
 ~CLGaussian5x5 ()
 Default destructor. More...
 
void configure (ICLTensor *input, ICLTensor *output, BorderMode border_mode, uint8_t constant_border_value=0)
 Initialise the function's source, destinations and border mode. More...
 
void configure (const CLCompileContext &compile_context, ICLTensor *input, ICLTensor *output, BorderMode border_mode, uint8_t constant_border_value=0)
 Initialise the function's source, destinations and border mode. More...
 
void run () override
 Run the kernels contained in the function. More...
 
- Public Member Functions inherited from IFunction
virtual ~IFunction ()=default
 Destructor. More...
 
virtual void prepare ()
 Prepare the function for executing. More...
 

Detailed Description

Basic function to execute gaussian filter 5x5.

This function calls the following OpenCL kernels:

  1. CLFillBorderKernel (executed if border_mode == CONSTANT or border_mode == REPLICATE)
  2. CLGaussian5x5HorKernel
  3. CLGaussian5x5VertKernel
Deprecated:
This function is deprecated and is intended to be removed in 21.05 release

Definition at line 53 of file CLGaussian5x5.h.

Constructor & Destructor Documentation

◆ CLGaussian5x5() [1/3]

CLGaussian5x5 ( std::shared_ptr< IMemoryManager memory_manager = nullptr)

Default Constructor.

Parameters
[in]memory_manager(Optional) Memory manager.

Definition at line 39 of file CLGaussian5x5.cpp.

References CLGaussian5x5::~CLGaussian5x5().

40  : _memory_group(std::move(memory_manager)),
41  _kernel_hor(std::make_unique<CLGaussian5x5HorKernel>()),
42  _kernel_vert(std::make_unique<CLGaussian5x5VertKernel>()),
43  _border_handler(std::make_unique<CLFillBorderKernel>()),
44  _tmp()
45 {
46 }

◆ CLGaussian5x5() [2/3]

CLGaussian5x5 ( const CLGaussian5x5 )
delete

Prevent instances of this class from being copied.

◆ CLGaussian5x5() [3/3]

CLGaussian5x5 ( CLGaussian5x5 &&  )
default

Default move constructor.

◆ ~CLGaussian5x5()

~CLGaussian5x5 ( )
default

Default destructor.

Referenced by CLGaussian5x5::CLGaussian5x5().

Member Function Documentation

◆ configure() [1/2]

void configure ( ICLTensor input,
ICLTensor output,
BorderMode  border_mode,
uint8_t  constant_border_value = 0 
)

Initialise the function's source, destinations and border mode.

Parameters
[in,out]inputSource tensor. Data types supported: U8. (Written to only for border_mode != UNDEFINED)
[out]outputDestination tensor, Data types supported: U8.
[in]border_modeBorder mode to use for the convolution.
[in]constant_border_value(Optional) Constant value to use for borders if border_mode is set to CONSTANT.

Definition at line 50 of file CLGaussian5x5.cpp.

References CLKernelLibrary::get().

51 {
52  configure(CLKernelLibrary::get().get_compile_context(), input, output, border_mode, constant_border_value);
53 }
void configure(ICLTensor *input, ICLTensor *output, BorderMode border_mode, uint8_t constant_border_value=0)
Initialise the function&#39;s source, destinations and border mode.
static CLKernelLibrary & get()
Access the KernelLibrary singleton.

◆ configure() [2/2]

void configure ( const CLCompileContext compile_context,
ICLTensor input,
ICLTensor output,
BorderMode  border_mode,
uint8_t  constant_border_value = 0 
)

Initialise the function's source, destinations and border mode.

Parameters
[in]compile_contextThe compile context to be used.
[in,out]inputSource tensor. Data types supported: U8. (Written to only for border_mode != UNDEFINED)
[out]outputDestination tensor, Data types supported: U8.
[in]border_modeBorder mode to use for the convolution.
[in]constant_border_value(Optional) Constant value to use for borders if border_mode is set to CONSTANT.

Definition at line 55 of file CLGaussian5x5.cpp.

References CLTensorAllocator::allocate(), CLTensor::allocator(), ARM_COMPUTE_ERROR_ON_DATA_TYPE_CHANNEL_NOT_IN, ITensor::info(), ITensorAllocator::init(), MemoryGroup::manage(), ITensorInfo::tensor_shape(), arm_compute::U16, arm_compute::U8, and arm_compute::UNDEFINED.

56 {
58 
59  _tmp.allocator()->init(TensorInfo(input->info()->tensor_shape(), 1, DataType::U16));
60 
61  // Manage intermediate buffers
62  _memory_group.manage(&_tmp);
63 
64  // Configure kernels
65  _kernel_hor->configure(compile_context, input, &_tmp, border_mode == BorderMode::UNDEFINED);
66  _kernel_vert->configure(compile_context, &_tmp, output, border_mode == BorderMode::UNDEFINED);
67  _border_handler->configure(compile_context, input, _kernel_hor->border_size(), border_mode, PixelValue(constant_border_value));
68 
69  // Allocate intermediate buffers
70  _tmp.allocator()->allocate();
71 }
Class describing the value of a pixel for any image format.
Definition: PixelValue.h:34
1 channel, 1 U8 per channel
CLTensorAllocator * allocator()
Return a pointer to the tensor&#39;s allocator.
Definition: CLTensor.cpp:61
1 channel, 1 U16 per channel
void init(const TensorInfo &input, size_t alignment=0)
Initialize a tensor based on the passed TensorInfo.
void manage(IMemoryManageable *obj) override
Sets a object to be managed by the given memory group.
Definition: MemoryGroup.h:79
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&#39;s metadata.
#define ARM_COMPUTE_ERROR_ON_DATA_TYPE_CHANNEL_NOT_IN(t, c,...)
Definition: Validate.h:790
void allocate() override
Allocate size specified by TensorInfo of OpenCL memory.
Borders are left undefined.
Store the tensor&#39;s metadata.
Definition: TensorInfo.h:45

◆ operator=() [1/2]

CLGaussian5x5& operator= ( const CLGaussian5x5 )
delete

Prevent instances of this class from being copied.

◆ operator=() [2/2]

CLGaussian5x5& operator= ( CLGaussian5x5 &&  )
default

Default move assignment operator.

◆ run()

void run ( )
overridevirtual

Run the kernels contained in the function.

For Neon kernels:

  • Multi-threading is used for the kernels which are parallelisable.
  • By default std::thread::hardware_concurrency() threads are used.
Note
CPPScheduler::set_num_threads() can be used to manually set the number of threads

For OpenCL kernels:

  • All the kernels are enqueued on the queue associated with CLScheduler.
  • The queue is then flushed.
Note
The function will not block until the kernels are executed. It is the user's responsibility to wait.
Will call prepare() on first run if hasn't been done

Implements IFunction.

Definition at line 73 of file CLGaussian5x5.cpp.

References CLScheduler::enqueue(), and CLScheduler::get().

74 {
75  CLScheduler::get().enqueue(*_border_handler, false);
76 
77  MemoryGroupResourceScope scope_mg(_memory_group);
78 
79  CLScheduler::get().enqueue(*_kernel_hor, false);
80  CLScheduler::get().enqueue(*_kernel_vert);
81 }
static CLScheduler & get()
Access the scheduler singleton.
void enqueue(ICLKernel &kernel, bool flush=true)
Schedule the execution of the passed kernel if possible.
Memory group resources scope handling class.
Definition: IMemoryGroup.h:82

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