Compute Library
 21.02
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...
 
virtual void run_nd (const Window &window, const ThreadInfo &info, const Window &thread_locator)
 legacy compatibility layer for implemantions which do not support thread_locator In these cases we simply narrow the interface down the legacy version More...
 
virtual void run_op (ITensorPack &tensors, const Window &window, const ThreadInfo &info)
 Execute the kernel on the passed window. 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 153 of file NEGaussianPyramidKernel.cpp.

154  : _t2_load_offset(0)
155 {
156 }

◆ 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 158 of file NEGaussianPyramidKernel.cpp.

Referenced by NEGaussianPyramidVertKernel::configure().

159 {
160  return BorderSize{ 2, 0 };
161 }
Container for 2D border size.
Definition: Types.h:273

◆ 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 163 of file NEGaussianPyramidKernel.cpp.

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(), arm_compute::test::validation::input, num_elems_processed_per_iteration, Dimensions< int >::num_max_dimensions, arm_compute::S16, arm_compute::test::validation::scale_y, ITensorInfo::set_valid_region(), ITensorInfo::tensor_shape(), BorderSize::top, arm_compute::U8, and arm_compute::update_window_and_padding().

164 {
167  ARM_COMPUTE_ERROR_ON(input->info()->dimension(0) != output->info()->dimension(0));
168 
169  for(size_t i = 2; i < Coordinates::num_max_dimensions; ++i)
170  {
171  ARM_COMPUTE_ERROR_ON(input->info()->dimension(i) != output->info()->dimension(i));
172  }
173 
174  _input = input;
175  _output = output;
176 
177  // Configure kernel window
178  constexpr unsigned int num_elems_processed_per_iteration = 16;
179  constexpr unsigned int num_rows_processed_per_iteration = 2;
180 
181  constexpr unsigned int num_elems_written_per_iteration = 16;
182  constexpr unsigned int num_rows_written_per_iteration = 1;
183 
184  constexpr unsigned int num_elems_read_per_iteration = 16;
185  constexpr unsigned int num_rows_read_per_iteration = 5;
186 
187  const float scale_y = static_cast<float>(output->info()->dimension(1)) / input->info()->dimension(1);
188 
189  Window win = calculate_max_window(*input->info(), Steps(num_elems_processed_per_iteration, num_rows_processed_per_iteration));
190  AccessWindowRectangle output_access(output->info(), 0, 0, num_elems_written_per_iteration, num_rows_written_per_iteration, 1.f, scale_y);
191 
192  // Determine whether we need to load even or odd rows. See above for a
193  // detailed explanation.
194  _t2_load_offset = -border_size().top;
195 
196  if((_input->info()->valid_region().anchor[1] + _input->info()->valid_region().shape[1]) % 2 == 0)
197  {
198  _t2_load_offset += 1;
199  }
200 
202  AccessWindowRectangle(input->info(), 0, _t2_load_offset, num_elems_read_per_iteration, num_rows_read_per_iteration),
203  output_access);
204 
205  output->info()->set_valid_region(ValidRegion(Coordinates(), output->info()->tensor_shape()));
206 
207  INEKernel::configure(win);
208 }
unsigned int top
top of the border
Definition: Types.h:375
Window calculate_max_window(const ValidRegion &valid_region, const Steps &steps, bool skip_border, BorderSize border_size)
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 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: WindowHelpers.h:46
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&#39;s metadata.
1 channel, 1 S16 per channel
#define ARM_COMPUTE_ERROR_ON_DATA_TYPE_CHANNEL_NOT_IN(t, c,...)
Definition: Validate.h:790
BorderSize border_size() const override
The size of the border for that kernel.
unsigned int num_elems_processed_per_iteration
Container for valid region of a window.
Definition: Types.h:188
static constexpr size_t num_max_dimensions
Number of dimensions the tensor has.
Definition: Dimensions.h:46
Describe a multidimensional execution window.
Definition: Window.h:39

◆ name()

const char* name ( ) const
inlineoverridevirtual

◆ 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.

Reimplemented from ICPPKernel.

Definition at line 210 of file NEGaussianPyramidKernel.cpp.

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(), Iterator::offset(), Iterator::ptr(), Window::scale(), Window::set_dimension_step(), Window::shift(), Window::Dimension::step(), IKernel::window(), Window::x(), and Window::y().

211 {
212  ARM_COMPUTE_UNUSED(info);
215  ARM_COMPUTE_ERROR_ON(window.x().step() != 16);
216  ARM_COMPUTE_ERROR_ON(window.y().step() % 2);
217  ARM_COMPUTE_ERROR_ON(_input->buffer() == nullptr);
218 
219  static const uint16x8_t six = vdupq_n_u16(6);
220  static const uint16x8_t four = vdupq_n_u16(4);
221 
222  Window win_in(window);
223  // Need to load two times 8 values instead of 16 values once
224  win_in.set_dimension_step(Window::DimX, 8);
225  win_in.shift(Window::DimY, _t2_load_offset);
226 
227  Iterator in(_input, win_in);
228 
229  // Output's height is half of input's
230  Window win_out(window);
231  win_out.scale(Window::DimY, 0.5f);
232 
233  Iterator out(_output, win_out);
234 
235  const uint8_t *input_top2_ptr = _input->buffer() + _input->info()->offset_element_in_bytes(Coordinates(0, 0));
236  const uint8_t *input_top_ptr = _input->buffer() + _input->info()->offset_element_in_bytes(Coordinates(0, 1));
237  const uint8_t *input_mid_ptr = _input->buffer() + _input->info()->offset_element_in_bytes(Coordinates(0, 2));
238  const uint8_t *input_low_ptr = _input->buffer() + _input->info()->offset_element_in_bytes(Coordinates(0, 3));
239  const uint8_t *input_low2_ptr = _input->buffer() + _input->info()->offset_element_in_bytes(Coordinates(0, 4));
240 
241  execute_window_loop(window, [&](const Coordinates &)
242  {
243  // Low data
244  const uint16x8_t data_low_t2 = vreinterpretq_u16_s16(vld1q_s16(reinterpret_cast<const int16_t *>(input_top2_ptr + in.offset())));
245  const uint16x8_t data_low_t1 = vreinterpretq_u16_s16(vld1q_s16(reinterpret_cast<const int16_t *>(input_top_ptr + in.offset())));
246  const uint16x8_t data_low_m = vreinterpretq_u16_s16(vld1q_s16(reinterpret_cast<const int16_t *>(input_mid_ptr + in.offset())));
247  const uint16x8_t data_low_b1 = vreinterpretq_u16_s16(vld1q_s16(reinterpret_cast<const int16_t *>(input_low_ptr + in.offset())));
248  const uint16x8_t data_low_b2 = vreinterpretq_u16_s16(vld1q_s16(reinterpret_cast<const int16_t *>(input_low2_ptr + in.offset())));
249 
250  uint16x8_t out_low = vaddq_u16(data_low_t2, data_low_b2);
251  out_low = vmlaq_u16(out_low, data_low_t1, four);
252  out_low = vmlaq_u16(out_low, data_low_m, six);
253  out_low = vmlaq_u16(out_low, data_low_b1, four);
254 
255  in.increment(Window::DimX);
256 
257  // High data
258  const uint16x8_t data_high_t2 = vreinterpretq_u16_s16(vld1q_s16(reinterpret_cast<const int16_t *>(input_top2_ptr + in.offset())));
259  const uint16x8_t data_high_t1 = vreinterpretq_u16_s16(vld1q_s16(reinterpret_cast<const int16_t *>(input_top_ptr + in.offset())));
260  const uint16x8_t data_high_m = vreinterpretq_u16_s16(vld1q_s16(reinterpret_cast<const int16_t *>(input_mid_ptr + in.offset())));
261  const uint16x8_t data_high_b1 = vreinterpretq_u16_s16(vld1q_s16(reinterpret_cast<const int16_t *>(input_low_ptr + in.offset())));
262  const uint16x8_t data_high_b2 = vreinterpretq_u16_s16(vld1q_s16(reinterpret_cast<const int16_t *>(input_low2_ptr + in.offset())));
263 
264  uint16x8_t out_high = vaddq_u16(data_high_t2, data_high_b2);
265  out_high = vmlaq_u16(out_high, data_high_t1, four);
266  out_high = vmlaq_u16(out_high, data_high_m, six);
267  out_high = vmlaq_u16(out_high, data_high_b1, four);
268 
269  vst1q_u8(out.ptr(), vcombine_u8(vqshrn_n_u16(out_low, 8), vqshrn_n_u16(out_high, 8)));
270  },
271  in, out);
272 }
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:104
#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
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:152
Coordinates of an item.
Definition: Coordinates.h:37
#define ARM_COMPUTE_ERROR_ON_UNCONFIGURED_KERNEL(k)
Definition: Validate.h:941
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:154
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:77
Iterator updated by execute_window_loop for each window element.
Definition: Helpers.h:46
Describe a multidimensional execution window.
Definition: Window.h:39
#define ARM_COMPUTE_ERROR_ON_INVALID_SUBWINDOW(f, s)
Definition: Validate.h:205
constexpr const Dimension & x() const
Alias to access the first dimension of the window.
Definition: Window.h:145

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