Compute Library
 21.02
NELaplacianPyramid Class Reference

Basic function to execute laplacian pyramid. More...

#include <NELaplacianPyramid.h>

Collaboration diagram for NELaplacianPyramid:
[legend]

Public Member Functions

 NELaplacianPyramid ()
 Constructor. More...
 
 NELaplacianPyramid (const NELaplacianPyramid &)=delete
 Prevent instances of this class from being copied (As this class contains pointers) More...
 
NELaplacianPyramidoperator= (const NELaplacianPyramid &)=delete
 Prevent instances of this class from being copied (As this class contains pointers) More...
 
 NELaplacianPyramid (NELaplacianPyramid &&)=delete
 Prevent instances of this class from being moved (As this class contains non movable objects) More...
 
NELaplacianPyramidoperator= (NELaplacianPyramid &&)=delete
 Prevent instances of this class from being moved (As this class contains non movable objects) More...
 
 ~NELaplacianPyramid ()
 Default destructor. More...
 
void configure (const ITensor *input, IPyramid *pyramid, ITensor *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 Neon kernels and functions:

  1. NEGaussianPyramidHalf
  2. NEGaussian5x5
  3. NEArithmeticSubtraction

    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.

Deprecated:
This function is deprecated and is intended to be removed in 21.05 release

Definition at line 57 of file NELaplacianPyramid.h.

Constructor & Destructor Documentation

◆ NELaplacianPyramid() [1/3]

Constructor.

Definition at line 42 of file NELaplacianPyramid.cpp.

43  : _num_levels(0),
44  _gaussian_pyr_function(),
45  _convf(),
46  _subf(),
47  _gauss_pyr(),
48  _conv_pyr(),
49  _depth_function()
50 {
51 }

◆ NELaplacianPyramid() [2/3]

NELaplacianPyramid ( const NELaplacianPyramid )
delete

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

◆ NELaplacianPyramid() [3/3]

Prevent instances of this class from being moved (As this class contains non movable objects)

◆ ~NELaplacianPyramid()

~NELaplacianPyramid ( )
default

Default destructor.

Member Function Documentation

◆ configure()

void configure ( const ITensor input,
IPyramid pyramid,
ITensor output,
BorderMode  border_mode,
uint8_t  constant_border_value 
)

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

Parameters
[in]inputSource tensor. Data type supported: U8.
[out]pyramidDestination pyramid tensors, Data type supported at each level: S16.
[out]outputThe lowest resolution tensor necessary to reconstruct the input tensor from the pyramid. Data type 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: out.width = in.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 75 of file NELaplacianPyramid.cpp.

References Pyramid::allocate(), ARM_COMPUTE_ERROR_ON, ARM_COMPUTE_ERROR_ON_DATA_TYPE_CHANNEL_NOT_IN, NEDepthConvertLayer::configure(), NEGaussianPyramidHalf::configure(), ITensorInfo::dimension(), IPyramid::get_pyramid_level(), Pyramid::get_pyramid_level(), PyramidInfo::height(), ITensor::info(), IPyramid::info(), arm_compute::test::validation::info, Pyramid::init(), PyramidInfo::init(), PyramidInfo::num_levels(), arm_compute::S16, PyramidInfo::tensor_shape(), arm_compute::U8, PyramidInfo::width(), and arm_compute::WRAP.

76 {
77  ARM_COMPUTE_ERROR_ON(nullptr == pyramid);
80  ARM_COMPUTE_ERROR_ON(0 == pyramid->info()->num_levels());
81  ARM_COMPUTE_ERROR_ON(input->info()->dimension(0) != pyramid->info()->width());
82  ARM_COMPUTE_ERROR_ON(input->info()->dimension(1) != pyramid->info()->height());
83  ARM_COMPUTE_ERROR_ON(output->info()->dimension(0) != pyramid->get_pyramid_level(pyramid->info()->num_levels() - 1)->info()->dimension(0));
84  ARM_COMPUTE_ERROR_ON(output->info()->dimension(1) != pyramid->get_pyramid_level(pyramid->info()->num_levels() - 1)->info()->dimension(1));
85 
86  _num_levels = pyramid->info()->num_levels();
87 
88  // Create and initialize the gaussian pyramid and the convoluted pyramid
89  PyramidInfo pyramid_info;
90  pyramid_info.init(_num_levels, 0.5f, pyramid->info()->tensor_shape(), arm_compute::Format::U8);
91 
92  _gauss_pyr.init(pyramid_info);
93  _conv_pyr.init(pyramid_info);
94 
95  // Create Gaussian Pyramid function
96  _gaussian_pyr_function.configure(input, &_gauss_pyr, border_mode, constant_border_value);
97 
98  _convf.resize(_num_levels);
99  _subf.resize(_num_levels);
100 
101  for(unsigned int i = 0; i < _num_levels; ++i)
102  {
103  _convf[i].configure(_gauss_pyr.get_pyramid_level(i), _conv_pyr.get_pyramid_level(i), border_mode, constant_border_value);
104  _subf[i].configure(_gauss_pyr.get_pyramid_level(i), _conv_pyr.get_pyramid_level(i), pyramid->get_pyramid_level(i), ConvertPolicy::WRAP);
105  }
106 
107  _depth_function.configure(_conv_pyr.get_pyramid_level(_num_levels - 1), output, ConvertPolicy::WRAP, 0);
108 
109  _gauss_pyr.allocate();
110  _conv_pyr.allocate();
111 }
void configure(const ITensor *input, IPyramid *pyramid, BorderMode border_mode, uint8_t constant_border_value) override
Initialise the function&#39;s source, destinations and border mode.
Tensor * get_pyramid_level(size_t index) const override
Retrieves a level of the pyramid as a ITensor pointer.
Definition: Pyramid.cpp:112
1 channel, 1 U8 per channel
#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 init(const PyramidInfo &info)
Initialize pyramid data-object using the given Pyramid&#39;s metadata.
Definition: Pyramid.cpp:35
void allocate()
Allocate the planes in the pyramid.
Definition: Pyramid.cpp:99
1 channel, 1 S16 per channel
#define ARM_COMPUTE_ERROR_ON_DATA_TYPE_CHANNEL_NOT_IN(t, c,...)
Definition: Validate.h:790
ScaleKernelInfo info(interpolation_policy, default_border_mode, PixelValue(), sampling_policy, false)
void configure(const ITensor *input, ITensor *output, ConvertPolicy policy, uint32_t shift=0)
Initialize the function&#39;s source, destination.

◆ operator=() [1/2]

NELaplacianPyramid& operator= ( const NELaplacianPyramid )
delete

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

◆ operator=() [2/2]

NELaplacianPyramid& operator= ( NELaplacianPyramid &&  )
delete

Prevent instances of this class from being moved (As this class contains non movable objects)

◆ 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 53 of file NELaplacianPyramid.cpp.

References ARM_COMPUTE_ERROR_ON_MSG, INESimpleFunctionNoBorder::run(), and NEGaussianPyramidHalf::run().

54 {
55  ARM_COMPUTE_ERROR_ON_MSG(0 == _num_levels, "Unconfigured function");
56 
57  // Compute Gaussian Pyramid
58  _gaussian_pyr_function.run();
59 
60  for(unsigned int i = 0; i < _num_levels; ++i)
61  {
62  // Apply Gaussian filter to gaussian pyramid image
63  _convf[i].run();
64  }
65 
66  for(unsigned int i = 0; i < _num_levels; ++i)
67  {
68  // Compute laplacian image
69  _subf[i].run();
70  }
71 
72  _depth_function.run();
73 }
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, msg)
Definition: Error.h:456

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