Compute Library
 21.02
NEGaussianPyramidHalf Class Reference

Basic function to execute gaussian pyramid with HALF scale factor. More...

#include <NEGaussianPyramid.h>

Collaboration diagram for NEGaussianPyramidHalf:
[legend]

Public Member Functions

 NEGaussianPyramidHalf ()
 Constructor. More...
 
 NEGaussianPyramidHalf (const NEGaussianPyramidHalf &)=delete
 Prevent instances of this class from being copied (As this class contains pointers) More...
 
NEGaussianPyramidHalfoperator= (const NEGaussianPyramidHalf &)=delete
 Prevent instances of this class from being copied (As this class contains pointers) More...
 
 NEGaussianPyramidHalf (NEGaussianPyramidHalf &&)=default
 Allow instances of this class to be moved. More...
 
NEGaussianPyramidHalfoperator= (NEGaussianPyramidHalf &&)=default
 Allow instances of this class to be moved. More...
 
 ~NEGaussianPyramidHalf ()
 Default destructor. More...
 
void configure (const ITensor *input, IPyramid *pyramid, BorderMode border_mode, uint8_t constant_border_value) override
 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 NEGaussianPyramid
 NEGaussianPyramid ()
 Default constructor. More...
 
 NEGaussianPyramid (const NEGaussianPyramid &)=delete
 Prevent instances of this class from being copied (As this class contains pointers) More...
 
NEGaussianPyramidoperator= (const NEGaussianPyramid &)=delete
 Prevent instances of this class from being copied (As this class contains pointers) More...
 
 NEGaussianPyramid (NEGaussianPyramid &&)=default
 Allow instances of this class to be moved. More...
 
NEGaussianPyramidoperator= (NEGaussianPyramid &&)=default
 Allow instances of this class to be moved. More...
 
virtual ~NEGaussianPyramid ()=default
 Default destructor. 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 pyramid with HALF scale factor.

This function calls the following Neon kernels:

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

Definition at line 92 of file NEGaussianPyramid.h.

Constructor & Destructor Documentation

◆ NEGaussianPyramidHalf() [1/3]

Constructor.

Definition at line 51 of file NEGaussianPyramid.cpp.

52  : _horizontal_border_handler(),
53  _vertical_border_handler(),
54  _horizontal_reduction(),
55  _vertical_reduction()
56 {
57 }

◆ NEGaussianPyramidHalf() [2/3]

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

◆ NEGaussianPyramidHalf() [3/3]

Allow instances of this class to be moved.

◆ ~NEGaussianPyramidHalf()

~NEGaussianPyramidHalf ( )
default

Default destructor.

Referenced by NEGaussianPyramid::NEGaussianPyramid().

Member Function Documentation

◆ configure()

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

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: U8.
[in]border_modeBorder mode to use.
[in]constant_border_value(Optional) Constant value to use for borders if border_mode is set to CONSTANT.

Implements NEGaussianPyramid.

Definition at line 59 of file NEGaussianPyramid.cpp.

References ARM_COMPUTE_ERROR_ON, ARM_COMPUTE_ERROR_ON_DATA_TYPE_CHANNEL_NOT_IN, ITensorInfo::dimension(), IPyramid::get_pyramid_level(), PyramidInfo::height(), ITensor::info(), IPyramid::info(), arm_compute::test::validation::input, ITensorInfo::num_dimensions(), PyramidInfo::num_levels(), arm_compute::S16, PyramidInfo::scale(), arm_compute::SCALE_PYRAMID_HALF, TensorShape::set(), PyramidInfo::tensor_shape(), arm_compute::U8, and PyramidInfo::width().

Referenced by NELaplacianPyramid::configure().

60 {
62  ARM_COMPUTE_ERROR_ON(nullptr == pyramid);
64  ARM_COMPUTE_ERROR_ON(input->info()->dimension(0) != pyramid->info()->width());
65  ARM_COMPUTE_ERROR_ON(input->info()->dimension(1) != pyramid->info()->height());
67 
68  // Constant value to use for vertical fill border when the border mode is CONSTANT
69  const uint16_t pixel_value_u16 = static_cast<uint16_t>(constant_border_value) * 2 + static_cast<uint16_t>(constant_border_value) * 8 + static_cast<uint16_t>(constant_border_value) * 6;
70 
71  /* Get number of pyramid levels */
72  const size_t num_levels = pyramid->info()->num_levels();
73  const size_t num_stages = num_levels - 1;
74 
75  _input = input;
76  _pyramid = pyramid;
77 
78  if(num_levels > 1)
79  {
80  // Apply half scale to the X dimension of the tensor shape
81  TensorShape tensor_shape = pyramid->info()->tensor_shape();
82  tensor_shape.set(0, (pyramid->info()->width() + 1) * SCALE_PYRAMID_HALF);
83 
84  PyramidInfo pyramid_info(num_levels - 1, SCALE_PYRAMID_HALF, tensor_shape, Format::S16);
85  _tmp.init(pyramid_info);
86 
87  _horizontal_reduction.clear();
88  _vertical_reduction.clear();
89  _horizontal_border_handler.clear();
90  _vertical_border_handler.clear();
91 
92  _horizontal_reduction.resize(num_stages);
93  _vertical_reduction.resize(num_stages);
94  _horizontal_border_handler.resize(num_stages);
95  _vertical_border_handler.resize(num_stages);
96 
97  for(size_t i = 0; i < num_stages; ++i)
98  {
99  /* Configure horizontal kernel */
100  _horizontal_reduction[i] = std::make_unique<NEGaussianPyramidHorKernel>();
101  _horizontal_reduction[i]->configure(_pyramid->get_pyramid_level(i), _tmp.get_pyramid_level(i));
102 
103  /* Configure vertical kernel */
104  _vertical_reduction[i] = std::make_unique<NEGaussianPyramidVertKernel>();
105  _vertical_reduction[i]->configure(_tmp.get_pyramid_level(i), _pyramid->get_pyramid_level(i + 1));
106 
107  /* Configure border */
108  _horizontal_border_handler[i] = std::make_unique<NEFillBorderKernel>();
109  _horizontal_border_handler[i]->configure(_pyramid->get_pyramid_level(i), _horizontal_reduction[i]->border_size(), border_mode, PixelValue(constant_border_value));
110 
111  /* Configure border */
112  _vertical_border_handler[i] = std::make_unique<NEFillBorderKernel>();
113  _vertical_border_handler[i]->configure(_tmp.get_pyramid_level(i), _vertical_reduction[i]->border_size(), border_mode, PixelValue(pixel_value_u16));
114  }
115 
116  _tmp.allocate();
117  }
118 }
constexpr float SCALE_PYRAMID_HALF
Constant value used to indicate a half-scale pyramid.
Definition: Types.h:112
virtual size_t num_dimensions() const =0
The number of dimensions of the tensor (rank)
const TensorShape & tensor_shape() const
Return the TensorShape of the o-th level tensor.
Definition: PyramidInfo.cpp:92
Class describing the value of a pixel for any image format.
Definition: PixelValue.h:34
Shape of a tensor.
Definition: TensorShape.h:39
virtual const PyramidInfo * info() const =0
Interface to be implemented by the child class to return the Pyramid&#39;s metadata.
virtual size_t dimension(size_t index) const =0
Return the size of the requested dimension.
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
virtual ITensor * get_pyramid_level(size_t index) const =0
Retrieves a level of the pyramid as a ITensor pointer.
virtual ITensorInfo * info() const =0
Interface to be implemented by the child class to return the tensor&#39;s metadata.
float scale() const
Return the scale factor of the pyramid.
1 channel, 1 S16 per channel
#define ARM_COMPUTE_ERROR_ON_DATA_TYPE_CHANNEL_NOT_IN(t, c,...)
Definition: Validate.h:790
Store the Pyramid&#39;s metadata.
Definition: PyramidInfo.h:35
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
TensorShape & set(size_t dimension, size_t value, bool apply_dim_correction=true, bool increase_dim_unit=true)
Accessor to set the value of one of the dimensions.
Definition: TensorShape.h:79

◆ operator=() [1/2]

NEGaussianPyramidHalf& operator= ( const NEGaussianPyramidHalf )
delete

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

◆ operator=() [2/2]

NEGaussianPyramidHalf& operator= ( NEGaussianPyramidHalf &&  )
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 120 of file NEGaussianPyramid.cpp.

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

Referenced by NELaplacianPyramid::run().

121 {
122  ARM_COMPUTE_ERROR_ON_MSG(_pyramid == nullptr, "Unconfigured function");
123 
124  /* Get number of pyramid levels */
125  const unsigned int num_levels = _pyramid->info()->num_levels();
126 
127  /* The first level of the pyramid has the input image */
128  _pyramid->get_pyramid_level(0)->copy_from(*_input);
129 
130  for(unsigned int i = 0; i < num_levels - 1; ++i)
131  {
132  NEScheduler::get().schedule(_horizontal_border_handler[i].get(), Window::DimZ);
133  NEScheduler::get().schedule(_horizontal_reduction[i].get(), Window::DimY);
134  NEScheduler::get().schedule(_vertical_border_handler[i].get(), Window::DimZ);
135  NEScheduler::get().schedule(_vertical_reduction[i].get(), Window::DimY);
136  }
137 }
#define ARM_COMPUTE_ERROR_ON_MSG(cond, msg)
Definition: Error.h:456
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: