Compute Library
 21.02
NEGaussian5x5 Class Reference

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

#include <NEGaussian5x5.h>

Collaboration diagram for NEGaussian5x5:
[legend]

Public Member Functions

 NEGaussian5x5 (std::shared_ptr< IMemoryManager > memory_manager=nullptr)
 Default constructor. More...
 
 NEGaussian5x5 (const NEGaussian5x5 &)=delete
 Prevent instances of this class from being copied (As this class contains pointers) More...
 
NEGaussian5x5operator= (const NEGaussian5x5 &)=delete
 Prevent instances of this class from being copied (As this class contains pointers) More...
 
 NEGaussian5x5 (NEGaussian5x5 &&)=default
 Allow instances of this class to be moved. More...
 
NEGaussian5x5operator= (NEGaussian5x5 &&)=default
 Allow instances of this class to be moved. More...
 
 ~NEGaussian5x5 ()
 Default destructor. More...
 
void configure (ITensor *input, ITensor *output, BorderMode border_mode, uint8_t constant_border_value=0)
 Initialise the function's input, output 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 Neon kernels:

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

Definition at line 52 of file NEGaussian5x5.h.

Constructor & Destructor Documentation

◆ NEGaussian5x5() [1/3]

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

Default constructor.

Definition at line 38 of file NEGaussian5x5.cpp.

39  : _memory_group(std::move(memory_manager)), _kernel_hor(), _kernel_vert(), _tmp(), _border_handler()
40 {
41 }

◆ NEGaussian5x5() [2/3]

NEGaussian5x5 ( const NEGaussian5x5 )
delete

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

◆ NEGaussian5x5() [3/3]

NEGaussian5x5 ( NEGaussian5x5 &&  )
default

Allow instances of this class to be moved.

◆ ~NEGaussian5x5()

~NEGaussian5x5 ( )
default

Default destructor.

Member Function Documentation

◆ configure()

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

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

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

Definition at line 43 of file NEGaussian5x5.cpp.

References TensorAllocator::allocate(), Tensor::allocator(), ITensor::info(), TensorAllocator::init(), MemoryGroup::manage(), arm_compute::S16, ITensorInfo::tensor_shape(), and arm_compute::UNDEFINED.

44 {
45  // Init temporary buffer
46  TensorInfo tensor_info(input->info()->tensor_shape(), 1, DataType::S16);
47  _tmp.allocator()->init(tensor_info);
48 
49  // Manage intermediate buffers
50  _memory_group.manage(&_tmp);
51 
52  _kernel_hor = std::make_unique<NEGaussian5x5HorKernel>();
53  _kernel_vert = std::make_unique<NEGaussian5x5VertKernel>();
54  _border_handler = std::make_unique<NEFillBorderKernel>();
55 
56  // Create and configure kernels for the two passes
57  _kernel_hor->configure(input, &_tmp, border_mode == BorderMode::UNDEFINED);
58  _kernel_vert->configure(&_tmp, output, border_mode == BorderMode::UNDEFINED);
59 
60  _tmp.allocator()->allocate();
61 
62  _border_handler->configure(input, _kernel_hor->border_size(), border_mode, PixelValue(constant_border_value));
63 }
void init(const TensorAllocator &allocator, const Coordinates &coords, TensorInfo &sub_info)
Shares the same backing memory with another tensor allocator, while the tensor info might be differen...
TensorAllocator * allocator()
Return a pointer to the tensor&#39;s allocator.
Definition: Tensor.cpp:48
void manage(IMemoryManageable *obj) override
Sets a object to be managed by the given memory group.
Definition: MemoryGroup.h:79
void allocate() override
Allocate size specified by TensorInfo of CPU memory.
1 channel, 1 S16 per channel
Borders are left undefined.

◆ operator=() [1/2]

NEGaussian5x5& operator= ( const NEGaussian5x5 )
delete

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

◆ operator=() [2/2]

NEGaussian5x5& operator= ( NEGaussian5x5 &&  )
default

Allow instances of this class to be moved.

◆ 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 65 of file NEGaussian5x5.cpp.

References Window::DimY, Window::DimZ, Scheduler::get(), and IScheduler::schedule().

66 {
67  NEScheduler::get().schedule(_border_handler.get(), Window::DimZ);
68 
69  MemoryGroupResourceScope scope_mg(_memory_group);
70 
71  NEScheduler::get().schedule(_kernel_hor.get(), Window::DimY);
72  NEScheduler::get().schedule(_kernel_vert.get(), Window::DimY);
73 }
static constexpr size_t DimY
Alias for dimension 1 also known as Y dimension.
Definition: Window.h:45
virtual void schedule(ICPPKernel *kernel, const Hints &hints)=0
Runs the kernel in the same thread as the caller synchronously.
static constexpr size_t DimZ
Alias for dimension 2 also known as Z dimension.
Definition: Window.h:47
static IScheduler & get()
Access the scheduler singleton.
Definition: Scheduler.cpp:94

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