Compute Library
 21.02
NEGaussian5x5HorKernel Class Reference

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

#include <NEGaussian5x5Kernel.h>

Collaboration diagram for NEGaussian5x5HorKernel:
[legend]

Public Member Functions

const char * name () const override
 Name of the kernel. More...
 
 NEGaussian5x5HorKernel ()
 Default constructor. More...
 
 NEGaussian5x5HorKernel (NEGaussian5x5HorKernel &)=delete
 Prevent instances of this class from being copied (As this class contains pointers) More...
 
NEGaussian5x5HorKerneloperator= (NEGaussian5x5HorKernel &)=delete
 Prevent instances of this class from being copied (As this class contains pointers) More...
 
 NEGaussian5x5HorKernel (NEGaussian5x5HorKernel &&)=default
 Allow instances of this class to be moved. More...
 
NEGaussian5x5HorKerneloperator= (NEGaussian5x5HorKernel &&)=default
 Allow instances of this class to be moved. More...
 
 ~NEGaussian5x5HorKernel ()=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 (horizontal pass)

Definition at line 34 of file NEGaussian5x5Kernel.h.

Constructor & Destructor Documentation

◆ NEGaussian5x5HorKernel() [1/3]

Default constructor.

Definition at line 42 of file NEGaussian5x5Kernel.cpp.

Referenced by NEGaussian5x5HorKernel::name().

43  : _border_size(0)
44 {
45 }

◆ NEGaussian5x5HorKernel() [2/3]

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

◆ NEGaussian5x5HorKernel() [3/3]

Allow instances of this class to be moved.

◆ ~NEGaussian5x5HorKernel()

~NEGaussian5x5HorKernel ( )
default

Default destructor.

Referenced by NEGaussian5x5HorKernel::name().

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

Referenced by NEGaussian5x5HorKernel::configure(), NEGaussian5x5VertKernel::configure(), NEGaussian5x5HorKernel::name(), and NEGaussian5x5VertKernel::name().

48 {
49  return _border_size;
50 }

◆ 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: U8.
[out]outputDestination tensor. Data type supported: S16.
[in]border_undefinedTrue if the border mode is undefined. False if it's replicate or constant.

Definition at line 52 of file NEGaussian5x5Kernel.cpp.

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

Referenced by NEGaussian5x5HorKernel::name(), and NEGaussian5x5VertKernel::name().

53 {
56 
57  _input = input;
58  _output = output;
59  _border_size = BorderSize(border_undefined ? 0 : 2, 2);
60 
61  // Configure kernel window
62  constexpr unsigned int num_elems_processed_per_iteration = 8;
63  constexpr unsigned int num_elems_read_per_iteration = 16;
64  constexpr unsigned int num_elems_written_per_iteration = 8;
65 
66  Window win = calculate_max_window_horizontal(*input->info(), Steps(num_elems_processed_per_iteration), border_undefined, border_size());
67  AccessWindowHorizontal output_access(output->info(), 0, num_elems_written_per_iteration);
68 
70  AccessWindowHorizontal(input->info(), -border_size().left, num_elems_read_per_iteration),
71  output_access);
72 
73  output_access.set_valid_region(win, input->info()->valid_region(), border_undefined, border_size());
74 
75  INEKernel::configure(win);
76 }
Container for 2D border size.
Definition: Types.h:273
1 channel, 1 U8 per channel
Window calculate_max_window_horizontal(const ValidRegion &valid_region, const Steps &steps, bool skip_border, BorderSize border_size)
virtual ValidRegion valid_region() const =0
Valid region of the tensor.
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.
unsigned int left
left of the border
Definition: Types.h:378
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
BorderSize border_size() const override
The size of the border for that kernel.

◆ name()

◆ operator=() [1/2]

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

Referenced by NEGaussian5x5HorKernel::name(), and NEGaussian5x5VertKernel::name().

◆ operator=() [2/2]

NEGaussian5x5HorKernel& operator= ( NEGaussian5x5HorKernel &&  )
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 78 of file NEGaussian5x5Kernel.cpp.

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

Referenced by NEGaussian5x5HorKernel::name(), and NEGaussian5x5VertKernel::name().

79 {
80  ARM_COMPUTE_UNUSED(info);
83 
84  Window win_in(window);
85  win_in.shift(Window::DimX, -2);
86 
87  Iterator input(_input, win_in);
88  Iterator output(_output, window);
89 
90  static const int16x8_t six = vdupq_n_s16(6);
91  static const int16x8_t four = vdupq_n_s16(4);
92 
93  execute_window_loop(window, [&](const Coordinates &)
94  {
95  uint8x16_t data = vld1q_u8(input.ptr());
96 
97  const int16x8x2_t data_s16 =
98  {
99  {
100  vreinterpretq_s16_u16(vmovl_u8(vget_low_u8(data))),
101  vreinterpretq_s16_u16(vmovl_u8(vget_high_u8(data)))
102  }
103  };
104 
105  int16x8_t out = vaddq_s16(data_s16.val[0], vextq_s16(data_s16.val[0], data_s16.val[1], 4));
106  out = vmlaq_s16(out, vextq_s16(data_s16.val[0], data_s16.val[1], 1), four);
107  out = vmlaq_s16(out, vextq_s16(data_s16.val[0], data_s16.val[1], 2), six);
108  out = vmlaq_s16(out, vextq_s16(data_s16.val[0], data_s16.val[1], 3), four);
109 
110  vst1q_s16(reinterpret_cast<int16_t *>(output.ptr()), out);
111  },
112  input, output);
113 }
const Window & window() const
The maximum window the kernel can be executed on.
Definition: IKernel.cpp:28
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
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

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