Compute Library
 19.08
CLLaplacianPyramid Class Reference

Basic function to execute laplacian pyramid. More...

#include <CLLaplacianPyramid.h>

Collaboration diagram for CLLaplacianPyramid:
[legend]

Public Member Functions

 CLLaplacianPyramid ()
 Constructor. More...
 
void configure (ICLTensor *input, CLPyramid *pyramid, ICLTensor *output, BorderMode border_mode, uint8_t constant_border_value)
 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 laplacian pyramid.

This function calls the following OpenCL kernels and functions:

  1. CLGaussianPyramidHalf
  2. CLGaussian5x5
  3. CLArithmeticSubtraction

    First a Gaussian pyramid is created. Then, for each level i, the corresponding tensor I(i) is blurred with the Gaussian 5x5 filter, and then difference between the two tensors is the corresponding level L(i) of the Laplacian pyramid. L(i) = I(i) - Gaussian5x5(I(i)) Level 0 has always the same first two dimensions as the input tensor.

Definition at line 54 of file CLLaplacianPyramid.h.

Constructor & Destructor Documentation

◆ CLLaplacianPyramid()

Constructor.

Definition at line 39 of file CLLaplacianPyramid.cpp.

40  : _num_levels(0),
41  _gaussian_pyr_function(),
42  _convf(),
43  _subf(),
44  _depth_function(),
45  _gauss_pyr(),
46  _conv_pyr()
47 {
48 }

Member Function Documentation

◆ configure()

void configure ( ICLTensor input,
CLPyramid pyramid,
ICLTensor output,
BorderMode  border_mode,
uint8_t  constant_border_value 
)

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

Parameters
[in]inputSource tensor. Data types supported: U8.
[out]pyramidDestination pyramid tensors, Data types supported at each level: S16.
[out]outputThe lowest resolution tensor necessary to reconstruct the input tensor from the pyramid. Data types supported: S16. The first two dimensions of this tensor must match the first two dimensions of the tensor in the last level of the pyramid, that is: output.width = input.width() / pow(2,pyramid_levels-1) and out.height = in.height() / pow(2,pyramid_levels-1)
[in]border_modeBorder mode to use.
[in]constant_border_value(Optional) Constant value to use for borders if border_mode is set to CONSTANT.

Definition at line 50 of file CLLaplacianPyramid.cpp.

51 {
52  ARM_COMPUTE_ERROR_ON(nullptr == pyramid);
55  ARM_COMPUTE_ERROR_ON(0 == pyramid->info()->num_levels());
56  ARM_COMPUTE_ERROR_ON(input->info()->dimension(0) != pyramid->info()->width());
57  ARM_COMPUTE_ERROR_ON(input->info()->dimension(1) != pyramid->info()->height());
58  ARM_COMPUTE_ERROR_ON(output->info()->dimension(0) != pyramid->get_pyramid_level(pyramid->info()->num_levels() - 1)->info()->dimension(0));
59  ARM_COMPUTE_ERROR_ON(output->info()->dimension(1) != pyramid->get_pyramid_level(pyramid->info()->num_levels() - 1)->info()->dimension(1));
60 
61  _num_levels = pyramid->info()->num_levels();
62 
63  // Create and initialize the gaussian pyramid and the convoluted pyramid
64  PyramidInfo pyramid_info;
65  pyramid_info.init(_num_levels, 0.5f, pyramid->info()->tensor_shape(), arm_compute::Format::U8);
66 
67  _gauss_pyr.init(pyramid_info);
68  _conv_pyr.init(pyramid_info);
69 
70  // Create Gaussian Pyramid function
71  _gaussian_pyr_function.configure(input, &_gauss_pyr, border_mode, constant_border_value);
72 
73  _convf.resize(_num_levels);
74  _subf.resize(_num_levels);
75 
76  for(unsigned int i = 0; i < _num_levels; ++i)
77  {
78  _convf[i].configure(_gauss_pyr.get_pyramid_level(i), _conv_pyr.get_pyramid_level(i), border_mode, constant_border_value);
79  _subf[i].configure(_gauss_pyr.get_pyramid_level(i), _conv_pyr.get_pyramid_level(i), pyramid->get_pyramid_level(i), ConvertPolicy::WRAP);
80  }
81 
82  _depth_function.configure(_conv_pyr.get_pyramid_level(_num_levels - 1), output, ConvertPolicy::WRAP, 0);
83 
84  _gauss_pyr.allocate();
85  _conv_pyr.allocate();
86 }
const TensorShape & tensor_shape() const
Return the TensorShape of the o-th level tensor.
Definition: PyramidInfo.cpp:92
virtual size_t dimension(size_t index) const =0
Return the size of the requested dimension.
1 channel, 1 U8 per channel
const PyramidInfo * info() const override
Interface to be implemented by the child class to return the Pyramid's metadata.
Definition: CLPyramid.cpp:118
void init(size_t num_levels, float scale, size_t width, size_t height, Format format)
Initialize pyramid's metadata for 2D tensors.
Definition: PyramidInfo.cpp:50
#define ARM_COMPUTE_ERROR_ON(cond)
If the condition is true then an error message is printed and an exception thrown.
Definition: Error.h:337
void init(const PyramidInfo &info)
Initialize pyramid data-object using the given Pyramid's metadata.
Definition: CLPyramid.cpp:42
void allocate()
Allocate the planes in the pyramid.
Definition: CLPyramid.cpp:110
virtual ITensorInfo * info() const =0
Interface to be implemented by the child class to return the tensor's metadata.
1 channel, 1 S16 per channel
void configure(const ICLTensor *input, ICLTensor *output, ConvertPolicy policy, uint32_t shift)
Initialize the function's source, destination.
#define ARM_COMPUTE_ERROR_ON_DATA_TYPE_CHANNEL_NOT_IN(t, c,...)
Definition: Validate.h:789
Store the Pyramid's metadata.
Definition: PyramidInfo.h:35
CLTensor * get_pyramid_level(size_t index) const override
Retrieves a level of the pyramid as a ITensor pointer.
Definition: CLPyramid.cpp:123
size_t width() const
Return the width of the 0th level tensor.
Definition: PyramidInfo.cpp:82
size_t num_levels() const
Return the number of the pyramid levels.
Definition: PyramidInfo.cpp:77
size_t height() const
Return the height of the 0th level tensor.
Definition: PyramidInfo.cpp:87
void configure(ICLTensor *input, CLPyramid *pyramid, BorderMode border_mode, uint8_t constant_border_value) override
Initialise the function's source, destinations and border mode.

References CLPyramid::allocate(), ARM_COMPUTE_ERROR_ON, ARM_COMPUTE_ERROR_ON_DATA_TYPE_CHANNEL_NOT_IN, arm_compute::test::validation::border_mode, CLDepthConvertLayer::configure(), CLGaussianPyramidHalf::configure(), ITensorInfo::dimension(), CLPyramid::get_pyramid_level(), PyramidInfo::height(), ITensor::info(), CLPyramid::info(), arm_compute::test::validation::info, CLPyramid::init(), PyramidInfo::init(), PyramidInfo::num_levels(), arm_compute::S16, PyramidInfo::tensor_shape(), arm_compute::U8, PyramidInfo::width(), and arm_compute::WRAP.

◆ 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 88 of file CLLaplacianPyramid.cpp.

89 {
90  ARM_COMPUTE_ERROR_ON_MSG(0 == _num_levels, "Unconfigured function");
91 
92  _gaussian_pyr_function.run(); // compute gaussian pyramid
93 
94  for(unsigned int i = 0; i < _num_levels; ++i)
95  {
96  _convf[i].run(); // convolute gaussian pyramid
97  }
98 
99  for(unsigned int i = 0; i < _num_levels; ++i)
100  {
101  _subf[i].run(); // compute laplacian image
102  }
103 
104  _depth_function.run();
105 }
void run() override final
Run the kernels contained in the function.
void run() override
Run the kernels contained in the function.
#define ARM_COMPUTE_ERROR_ON_MSG(cond,...)
Definition: Error.h:328

References ARM_COMPUTE_ERROR_ON_MSG, ICLSimpleFunction::run(), and CLGaussianPyramidHalf::run().


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