Compute Library
 21.02
NEGaussian5x5VertKernel Class Reference

Neon kernel to perform a Gaussian 5x5 filter (vertical pass) More...

#include <NEGaussian5x5Kernel.h>

Collaboration diagram for NEGaussian5x5VertKernel:
[legend]

Public Member Functions

const char * name () const override
 Name of the kernel. More...
 
 NEGaussian5x5VertKernel ()
 Default constructor. More...
 
 NEGaussian5x5VertKernel (NEGaussian5x5VertKernel &)=delete
 Prevent instances of this class from being copied (As this class contains pointers) More...
 
NEGaussian5x5VertKerneloperator= (NEGaussian5x5VertKernel &)=delete
 Prevent instances of this class from being copied (As this class contains pointers) More...
 
 NEGaussian5x5VertKernel (NEGaussian5x5VertKernel &&)=default
 Allow instances of this class to be moved. More...
 
NEGaussian5x5VertKerneloperator= (NEGaussian5x5VertKernel &&)=default
 Allow instances of this class to be moved. More...
 
 ~NEGaussian5x5VertKernel ()=default
 Default destructor. More...
 
void configure (const ITensor *input, ITensor *output, bool border_undefined)
 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 Gaussian 5x5 filter (vertical pass)

Definition at line 71 of file NEGaussian5x5Kernel.h.

Constructor & Destructor Documentation

◆ NEGaussian5x5VertKernel() [1/3]

Default constructor.

Definition at line 115 of file NEGaussian5x5Kernel.cpp.

116 {
117 }

◆ NEGaussian5x5VertKernel() [2/3]

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

◆ NEGaussian5x5VertKernel() [3/3]

Allow instances of this class to be moved.

◆ ~NEGaussian5x5VertKernel()

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 119 of file NEGaussian5x5Kernel.cpp.

120 {
121  return BorderSize{ 2, 0 };
122 }
Container for 2D border size.
Definition: Types.h:273

◆ configure()

void configure ( const ITensor input,
ITensor output,
bool  border_undefined 
)

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

Parameters
[in]inputSource tensor. Data type supported: S16.
[out]outputDestination tensor, Data type supported: U8.
[in]border_undefinedTrue if the border mode is undefined. False if it's replicate or constant.

Definition at line 124 of file NEGaussian5x5Kernel.cpp.

References ARM_COMPUTE_ERROR_ON_DATA_TYPE_CHANNEL_NOT_IN, NEGaussian5x5HorKernel::border_size(), arm_compute::calculate_max_window(), ITensor::info(), arm_compute::test::validation::input, num_elems_processed_per_iteration, arm_compute::S16, BorderSize::top, arm_compute::U8, arm_compute::update_window_and_padding(), and ITensorInfo::valid_region().

125 {
128 
129  _input = input;
130  _output = output;
131 
132  // Configure kernel window
133  constexpr unsigned int num_elems_processed_per_iteration = 16;
134  constexpr unsigned int num_elems_read_per_iteration = 32;
135  constexpr unsigned int num_elems_written_per_iteration = 16;
136  constexpr unsigned int num_rows_read_per_iteration = 5;
137 
138  Window win = calculate_max_window(*input->info(), Steps(num_elems_processed_per_iteration), border_undefined, border_size());
139  AccessWindowHorizontal output_access(output->info(), 0, num_elems_written_per_iteration);
140 
142  AccessWindowRectangle(input->info(), 0, -border_size().top, num_elems_read_per_iteration, num_rows_read_per_iteration),
143  output_access);
144 
145  output_access.set_valid_region(win, input->info()->valid_region(), border_undefined, border_size());
146 
147  INEKernel::configure(win);
148 }
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)
BorderSize border_size() const override
The size of the border for that kernel.
1 channel, 1 U8 per channel
virtual ValidRegion valid_region() const =0
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
Class to describe a number of elements in each dimension.
Definition: Steps.h:40
Implementation of a row access pattern.
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
unsigned int num_elems_processed_per_iteration
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]

NEGaussian5x5VertKernel& operator= ( NEGaussian5x5VertKernel &&  )
default

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 150 of file NEGaussian5x5Kernel.cpp.

References ARM_COMPUTE_ERROR_ON_INVALID_SUBWINDOW, ARM_COMPUTE_ERROR_ON_UNCONFIGURED_KERNEL, ARM_COMPUTE_UNUSED, arm_compute::execute_window_loop(), arm_compute::test::validation::input, Iterator::offset(), Iterator::ptr(), and IKernel::window().

151 {
152  ARM_COMPUTE_UNUSED(info);
155 
156  Iterator input(_input, window);
157  Iterator output(_output, window);
158 
159  const uint8_t *input_top2_ptr = _input->ptr_to_element(Coordinates(0, -2));
160  const uint8_t *input_top_ptr = _input->ptr_to_element(Coordinates(0, -1));
161  const uint8_t *input_mid_ptr = _input->ptr_to_element(Coordinates(0, 0));
162  const uint8_t *input_low_ptr = _input->ptr_to_element(Coordinates(0, 1));
163  const uint8_t *input_low2_ptr = _input->ptr_to_element(Coordinates(0, 2));
164 
165  const uint16x8_t six = vdupq_n_u16(6);
166  const uint16x8_t four = vdupq_n_u16(4);
167 
168  execute_window_loop(window, [&](const Coordinates &)
169  {
170  const size_t input_offset_high_s16 = input.offset();
171  const size_t input_offset_low_s16 = input.offset() + 16;
172 
173  //HIGH DATA
174  //top2
175  uint16x8_t data_high = vreinterpretq_u16_s16(vld1q_s16(reinterpret_cast<const int16_t *>(input_top2_ptr + input_offset_high_s16)));
176  uint16x8_t out_high = data_high;
177  //top
178  data_high = vreinterpretq_u16_s16(vld1q_s16(reinterpret_cast<const int16_t *>(input_top_ptr + input_offset_high_s16)));
179  out_high = vmlaq_u16(out_high, data_high, four);
180  //mid
181  data_high = vreinterpretq_u16_s16(vld1q_s16(reinterpret_cast<const int16_t *>(input_mid_ptr + input_offset_high_s16)));
182  out_high = vmlaq_u16(out_high, data_high, six);
183  //low
184  data_high = vreinterpretq_u16_s16(vld1q_s16(reinterpret_cast<const int16_t *>(input_low_ptr + input_offset_high_s16)));
185  out_high = vmlaq_u16(out_high, data_high, four);
186  //low2
187  data_high = vreinterpretq_u16_s16(vld1q_s16(reinterpret_cast<const int16_t *>(input_low2_ptr + input_offset_high_s16)));
188  out_high = vaddq_u16(out_high, data_high);
189 
190  //LOW DATA
191  //top2
192  uint16x8_t data_low = vreinterpretq_u16_s16(vld1q_s16(reinterpret_cast<const int16_t *>(input_top2_ptr + input_offset_low_s16)));
193  uint16x8_t out_low = data_low;
194  //top
195  data_low = vreinterpretq_u16_s16(vld1q_s16(reinterpret_cast<const int16_t *>(input_top_ptr + input_offset_low_s16)));
196  out_low = vmlaq_u16(out_low, data_low, four);
197  //mid
198  data_low = vreinterpretq_u16_s16(vld1q_s16(reinterpret_cast<const int16_t *>(input_mid_ptr + input_offset_low_s16)));
199  out_low = vmlaq_u16(out_low, data_low, six);
200  //low
201  data_low = vreinterpretq_u16_s16(vld1q_s16(reinterpret_cast<const int16_t *>(input_low_ptr + input_offset_low_s16)));
202  out_low = vmlaq_u16(out_low, data_low, four);
203  //low2
204  data_low = vreinterpretq_u16_s16(vld1q_s16(reinterpret_cast<const int16_t *>(input_low2_ptr + input_offset_low_s16)));
205  out_low = vaddq_u16(out_low, data_low);
206 
207  vst1q_u8(output.ptr(), vcombine_u8(vqshrn_n_u16(out_high, 8),
208  vqshrn_n_u16(out_low, 8)));
209  },
210  input, output);
211 }
const Window & window() const
The maximum window the kernel can be executed on.
Definition: IKernel.cpp:28
#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
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
#define ARM_COMPUTE_ERROR_ON_INVALID_SUBWINDOW(f, s)
Definition: Validate.h:205

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