Compute Library
 19.08
NEGaussianPyramidVertKernel Class Reference

NEON kernel to perform a GaussianPyramid (vertical pass) More...

#include <NEGaussianPyramidKernel.h>

Collaboration diagram for NEGaussianPyramidVertKernel:
[legend]

Public Member Functions

const char * name () const override
 Name of the kernel. More...
 
 NEGaussianPyramidVertKernel ()
 Default constructor. More...
 
 NEGaussianPyramidVertKernel (NEGaussianPyramidVertKernel &)=delete
 Prevent instances of this class from being copied (As this class contains pointers) More...
 
NEGaussianPyramidVertKerneloperator= (NEGaussianPyramidVertKernel &)=delete
 Prevent instances of this class from being copied (As this class contains pointers) More...
 
 NEGaussianPyramidVertKernel (NEGaussianPyramidVertKernel &&)=default
 Allow instances of this class to be moved. More...
 
NEGaussianPyramidVertKerneloperator= (NEGaussianPyramidVertKernel &&)=default
 Allow instances of this class to be moved. More...
 
 ~NEGaussianPyramidVertKernel ()=default
 Default destructor. More...
 
void configure (const ITensor *input, ITensor *output)
 Initialise the kernel's source, destination and border mode. More...
 
void run (const Window &window, const ThreadInfo &info) override
 Execute the kernel on the passed window. More...
 
BorderSize border_size () const override
 The size of the border for that kernel. More...
 
- Public Member Functions inherited from ICPPSimpleKernel
 ICPPSimpleKernel ()
 Constructor. More...
 
 ICPPSimpleKernel (const ICPPSimpleKernel &)=delete
 Prevent instances of this class from being copied (As this class contains pointers) More...
 
ICPPSimpleKerneloperator= (const ICPPSimpleKernel &)=delete
 Prevent instances of this class from being copied (As this class contains pointers) More...
 
 ICPPSimpleKernel (ICPPSimpleKernel &&)=default
 Allow instances of this class to be moved. More...
 
ICPPSimpleKerneloperator= (ICPPSimpleKernel &&)=default
 Allow instances of this class to be moved. More...
 
 ~ICPPSimpleKernel ()=default
 Default destructor. More...
 
- Public Member Functions inherited from ICPPKernel
virtual ~ICPPKernel ()=default
 Default destructor. More...
 
- Public Member Functions inherited from IKernel
 IKernel ()
 Constructor. More...
 
virtual ~IKernel ()=default
 Destructor. More...
 
virtual bool is_parallelisable () const
 Indicates whether or not the kernel is parallelisable. More...
 
const Windowwindow () const
 The maximum window the kernel can be executed on. More...
 

Detailed Description

NEON kernel to perform a GaussianPyramid (vertical pass)

Definition at line 70 of file NEGaussianPyramidKernel.h.

Constructor & Destructor Documentation

◆ NEGaussianPyramidVertKernel() [1/3]

Default constructor.

Definition at line 151 of file NEGaussianPyramidKernel.cpp.

152  : _t2_load_offset(0)
153 {
154 }

◆ NEGaussianPyramidVertKernel() [2/3]

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

◆ NEGaussianPyramidVertKernel() [3/3]

Allow instances of this class to be moved.

◆ ~NEGaussianPyramidVertKernel()

Default destructor.

Member Function Documentation

◆ border_size()

BorderSize border_size ( ) const
overridevirtual

The size of the border for that kernel.

Returns
The width in number of elements of the border.

Reimplemented from IKernel.

Definition at line 156 of file NEGaussianPyramidKernel.cpp.

157 {
158  return BorderSize{ 2, 0 };
159 }
Container for 2D border size.
Definition: Types.h:259

Referenced by NEGaussianPyramidVertKernel::configure().

◆ configure()

void configure ( const ITensor input,
ITensor output 
)

Initialise the kernel's source, destination and border mode.

Parameters
[in]inputSource tensor. Data type supported: S16.
[out]outputDestination tensor. Output should have half the input height. Data type supported: U8.

Definition at line 161 of file NEGaussianPyramidKernel.cpp.

162 {
165  ARM_COMPUTE_ERROR_ON(input->info()->dimension(0) != output->info()->dimension(0));
166 
167  for(size_t i = 2; i < Coordinates::num_max_dimensions; ++i)
168  {
169  ARM_COMPUTE_ERROR_ON(input->info()->dimension(i) != output->info()->dimension(i));
170  }
171 
172  _input = input;
173  _output = output;
174 
175  // Configure kernel window
176  constexpr unsigned int num_elems_processed_per_iteration = 16;
177  constexpr unsigned int num_rows_processed_per_iteration = 2;
178 
179  constexpr unsigned int num_elems_written_per_iteration = 16;
180  constexpr unsigned int num_rows_written_per_iteration = 1;
181 
182  constexpr unsigned int num_elems_read_per_iteration = 16;
183  constexpr unsigned int num_rows_read_per_iteration = 5;
184 
185  const float scale_y = static_cast<float>(output->info()->dimension(1)) / input->info()->dimension(1);
186 
187  Window win = calculate_max_window(*input->info(), Steps(num_elems_processed_per_iteration, num_rows_processed_per_iteration));
188  AccessWindowRectangle output_access(output->info(), 0, 0, num_elems_written_per_iteration, num_rows_written_per_iteration, 1.f, scale_y);
189 
190  // Determine whether we need to load even or odd rows. See above for a
191  // detailed explanation.
192  _t2_load_offset = -border_size().top;
193 
194  if((_input->info()->valid_region().anchor[1] + _input->info()->valid_region().shape[1]) % 2 == 0)
195  {
196  _t2_load_offset += 1;
197  }
198 
200  AccessWindowRectangle(input->info(), 0, _t2_load_offset, num_elems_read_per_iteration, num_rows_read_per_iteration),
201  output_access);
202 
203  output->info()->set_valid_region(ValidRegion(Coordinates(), output->info()->tensor_shape()));
204 
205  INEKernel::configure(win);
206 }
unsigned int top
top of the border
Definition: Types.h:339
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:337
Window calculate_max_window(const ValidRegion &valid_region, const Steps &steps=Steps(), bool skip_border=false, BorderSize border_size=BorderSize())
Calculate the maximum window for a given tensor shape and border setting.
Definition: Helpers.cpp:28
virtual void set_valid_region(const ValidRegion &valid_region)=0
Set the valid region of the tensor.
Implementation of a rectangular access pattern.
bool update_window_and_padding(Window &win, Ts &&... patterns)
Update window and padding size for each of the access patterns.
Definition: Helpers.h:402
virtual const TensorShape & tensor_shape() const =0
Size for each dimension of the tensor.
Class to describe a number of elements in each dimension.
Definition: Steps.h:40
Coordinates of an item.
Definition: Coordinates.h:37
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
#define ARM_COMPUTE_ERROR_ON_DATA_TYPE_CHANNEL_NOT_IN(t, c,...)
Definition: Validate.h:789
BorderSize border_size() const override
The size of the border for that kernel.
Container for valid region of a window.
Definition: Types.h:174
static constexpr size_t num_max_dimensions
Number of dimensions the tensor has.
Definition: Dimensions.h:45
Describe a multidimensional execution window.
Definition: Window.h:39

References ARM_COMPUTE_ERROR_ON, ARM_COMPUTE_ERROR_ON_DATA_TYPE_CHANNEL_NOT_IN, NEGaussianPyramidVertKernel::border_size(), arm_compute::calculate_max_window(), ITensorInfo::dimension(), ITensor::info(), Dimensions< int >::num_max_dimensions, arm_compute::S16, ITensorInfo::set_valid_region(), ITensorInfo::tensor_shape(), BorderSize::top, arm_compute::U8, and arm_compute::update_window_and_padding().

◆ name()

const char* name ( ) const
inlineoverridevirtual

Name of the kernel.

Returns
Kernel name

Implements ICPPKernel.

Definition at line 73 of file NEGaussianPyramidKernel.h.

74  {
75  return "NEGaussianPyramidVertKernel";
76  }

◆ operator=() [1/2]

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

◆ operator=() [2/2]

Allow instances of this class to be moved.

◆ run()

void run ( const Window window,
const ThreadInfo info 
)
overridevirtual

Execute the kernel on the passed window.

Warning
If is_parallelisable() returns false then the passed window must be equal to window()
Note
The window has to be a region within the window returned by the window() method
The width of the window has to be a multiple of num_elems_processed_per_iteration().
Parameters
[in]windowRegion on which to execute the kernel. (Must be a region of the window returned by window())
[in]infoInfo about executing thread and CPU.

Implements ICPPKernel.

Definition at line 208 of file NEGaussianPyramidKernel.cpp.

209 {
213  ARM_COMPUTE_ERROR_ON(window.x().step() != 16);
215  ARM_COMPUTE_ERROR_ON(_input->buffer() == nullptr);
216 
217  static const uint16x8_t six = vdupq_n_u16(6);
218  static const uint16x8_t four = vdupq_n_u16(4);
219 
220  Window win_in(window);
221  // Need to load two times 8 values instead of 16 values once
222  win_in.set_dimension_step(Window::DimX, 8);
223  win_in.shift(Window::DimY, _t2_load_offset);
224 
225  Iterator in(_input, win_in);
226 
227  // Output's height is half of input's
228  Window win_out(window);
229  win_out.scale(Window::DimY, 0.5f);
230 
231  Iterator out(_output, win_out);
232 
233  const uint8_t *input_top2_ptr = _input->buffer() + _input->info()->offset_element_in_bytes(Coordinates(0, 0));
234  const uint8_t *input_top_ptr = _input->buffer() + _input->info()->offset_element_in_bytes(Coordinates(0, 1));
235  const uint8_t *input_mid_ptr = _input->buffer() + _input->info()->offset_element_in_bytes(Coordinates(0, 2));
236  const uint8_t *input_low_ptr = _input->buffer() + _input->info()->offset_element_in_bytes(Coordinates(0, 3));
237  const uint8_t *input_low2_ptr = _input->buffer() + _input->info()->offset_element_in_bytes(Coordinates(0, 4));
238 
240  {
241  // Low data
242  const uint16x8_t data_low_t2 = vreinterpretq_u16_s16(vld1q_s16(reinterpret_cast<const int16_t *>(input_top2_ptr + in.offset())));
243  const uint16x8_t data_low_t1 = vreinterpretq_u16_s16(vld1q_s16(reinterpret_cast<const int16_t *>(input_top_ptr + in.offset())));
244  const uint16x8_t data_low_m = vreinterpretq_u16_s16(vld1q_s16(reinterpret_cast<const int16_t *>(input_mid_ptr + in.offset())));
245  const uint16x8_t data_low_b1 = vreinterpretq_u16_s16(vld1q_s16(reinterpret_cast<const int16_t *>(input_low_ptr + in.offset())));
246  const uint16x8_t data_low_b2 = vreinterpretq_u16_s16(vld1q_s16(reinterpret_cast<const int16_t *>(input_low2_ptr + in.offset())));
247 
248  uint16x8_t out_low = vaddq_u16(data_low_t2, data_low_b2);
249  out_low = vmlaq_u16(out_low, data_low_t1, four);
250  out_low = vmlaq_u16(out_low, data_low_m, six);
251  out_low = vmlaq_u16(out_low, data_low_b1, four);
252 
253  in.increment(Window::DimX);
254 
255  // High data
256  const uint16x8_t data_high_t2 = vreinterpretq_u16_s16(vld1q_s16(reinterpret_cast<const int16_t *>(input_top2_ptr + in.offset())));
257  const uint16x8_t data_high_t1 = vreinterpretq_u16_s16(vld1q_s16(reinterpret_cast<const int16_t *>(input_top_ptr + in.offset())));
258  const uint16x8_t data_high_m = vreinterpretq_u16_s16(vld1q_s16(reinterpret_cast<const int16_t *>(input_mid_ptr + in.offset())));
259  const uint16x8_t data_high_b1 = vreinterpretq_u16_s16(vld1q_s16(reinterpret_cast<const int16_t *>(input_low_ptr + in.offset())));
260  const uint16x8_t data_high_b2 = vreinterpretq_u16_s16(vld1q_s16(reinterpret_cast<const int16_t *>(input_low2_ptr + in.offset())));
261 
262  uint16x8_t out_high = vaddq_u16(data_high_t2, data_high_b2);
263  out_high = vmlaq_u16(out_high, data_high_t1, four);
264  out_high = vmlaq_u16(out_high, data_high_m, six);
265  out_high = vmlaq_u16(out_high, data_high_b1, four);
266 
267  vst1q_u8(out.ptr(), vcombine_u8(vqshrn_n_u16(out_low, 8), vqshrn_n_u16(out_high, 8)));
268  },
269  in, out);
270 }
const Window & window() const
The maximum window the kernel can be executed on.
Definition: IKernel.cpp:28
constexpr int step() const
Return the step of the dimension.
Definition: Window.h:102
#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
static constexpr size_t DimX
Alias for dimension 0 also known as X dimension.
Definition: Window.h:43
#define ARM_COMPUTE_UNUSED(...)
To avoid unused variables warnings.
Definition: Error.h:160
Coordinates of an item.
Definition: Coordinates.h:37
static constexpr size_t DimY
Alias for dimension 1 also known as Y dimension.
Definition: Window.h:45
constexpr const Dimension & y() const
Alias to access the second dimension of the window.
Definition: Window.h:152
void execute_window_loop(const Window &w, L &&lambda_function, Ts &&... iterators)
Iterate through the passed window, automatically adjusting the iterators and calling the lambda_funct...
Definition: Helpers.inl:122
Iterator updated by execute_window_loop for each window element.
Definition: Helpers.h:318
#define ARM_COMPUTE_ERROR_ON_INVALID_SUBWINDOW(f, s)
Definition: Validate.h:205
Describe a multidimensional execution window.
Definition: Window.h:39
#define ARM_COMPUTE_ERROR_ON_UNCONFIGURED_KERNEL(k)
Definition: Validate.h:940
constexpr const Dimension & x() const
Alias to access the first dimension of the window.
Definition: Window.h:143

References ARM_COMPUTE_ERROR_ON, ARM_COMPUTE_ERROR_ON_INVALID_SUBWINDOW, ARM_COMPUTE_ERROR_ON_UNCONFIGURED_KERNEL, ARM_COMPUTE_UNUSED, Window::DimX, Window::DimY, arm_compute::execute_window_loop(), Iterator::increment(), arm_compute::test::validation::info, Iterator::offset(), Iterator::ptr(), Window::scale(), Window::set_dimension_step(), Window::shift(), Window::Dimension::step(), IKernel::window(), Window::x(), and Window::y().


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