Compute Library
 21.02
NEDilateKernel Class Reference

Interface for the kernel to perform boolean image dilatation. More...

#include <NEDilateKernel.h>

Collaboration diagram for NEDilateKernel:
[legend]

Public Member Functions

const char * name () const override
 Name of the kernel. More...
 
 NEDilateKernel ()=default
 Default constructor. More...
 
 NEDilateKernel (const NEDilateKernel &)=delete
 Prevent instances of this class from being copied (As this class contains pointers) More...
 
NEDilateKerneloperator= (const NEDilateKernel &)=delete
 Prevent instances of this class from being copied (As this class contains pointers) More...
 
 NEDilateKernel (NEDilateKernel &&)=default
 Allow instances of this class to be moved. More...
 
NEDilateKerneloperator= (NEDilateKernel &&)=default
 Allow instances of this class to be moved. More...
 
 ~NEDilateKernel ()=default
 Default destructor. More...
 
void configure (const ITensor *input, ITensor *output, bool border_undefined)
 Set the source, destination and border mode of the kernel. 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

Interface for the kernel to perform boolean image dilatation.

Definition at line 34 of file NEDilateKernel.h.

Constructor & Destructor Documentation

◆ NEDilateKernel() [1/3]

NEDilateKernel ( )
default

Default constructor.

Referenced by NEDilateKernel::name().

◆ NEDilateKernel() [2/3]

NEDilateKernel ( const NEDilateKernel )
delete

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

◆ NEDilateKernel() [3/3]

NEDilateKernel ( NEDilateKernel &&  )
default

Allow instances of this class to be moved.

◆ ~NEDilateKernel()

~NEDilateKernel ( )
default

Default destructor.

Referenced by NEDilateKernel::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 38 of file NEDilateKernel.cpp.

Referenced by NEDilateKernel::configure(), and NEDilateKernel::name().

39 {
40  return BorderSize(1);
41 }

◆ configure()

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

Set the source, destination and border mode of the kernel.

Parameters
[in]inputSource tensor. Data type supported: U8
[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 43 of file NEDilateKernel.cpp.

References ARM_COMPUTE_ERROR_ON_DATA_TYPE_CHANNEL_NOT_IN, ARM_COMPUTE_ERROR_ON_MISMATCHING_DATA_TYPES, ARM_COMPUTE_ERROR_ON_NULLPTR, NEDilateKernel::border_size(), arm_compute::calculate_max_window(), ITensor::info(), arm_compute::test::validation::input, BorderSize::left, num_elems_processed_per_iteration, BorderSize::top, arm_compute::U8, arm_compute::update_window_and_padding(), and ITensorInfo::valid_region().

Referenced by NEDilateKernel::name().

44 {
48 
49  _input = input;
50  _output = output;
51 
52  constexpr unsigned int num_elems_processed_per_iteration = 8;
53  constexpr unsigned int num_elems_read_per_iteration = 16;
54  constexpr unsigned int num_elems_written_per_iteration = 8;
55  constexpr unsigned int num_rows_read_per_iteration = 3;
56 
57  // Configure kernel window
58  Window win = calculate_max_window(*input->info(), Steps(num_elems_processed_per_iteration), border_undefined, border_size());
59  AccessWindowHorizontal output_access(output->info(), 0, num_elems_written_per_iteration);
60  AccessWindowRectangle input_access(input->info(), -border_size().left, -border_size().top, num_elems_read_per_iteration, num_rows_read_per_iteration);
61 
62  update_window_and_padding(win, input_access, output_access);
63 
64  output_access.set_valid_region(win, input->info()->valid_region(), border_undefined, border_size());
65 
66  INEKernel::configure(win);
67 }
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)
1 channel, 1 U8 per channel
bool update_window_and_padding(Window &win, Ts &&... patterns)
Update window and padding size for each of the access patterns.
Definition: WindowHelpers.h:46
#define ARM_COMPUTE_ERROR_ON_MISMATCHING_DATA_TYPES(...)
Definition: Validate.h:543
unsigned int left
left of the border
Definition: Types.h:378
#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
#define ARM_COMPUTE_ERROR_ON_NULLPTR(...)
Definition: Validate.h:161

◆ name()

const char* name ( ) const
inlineoverridevirtual

◆ operator=() [1/2]

NEDilateKernel& operator= ( const NEDilateKernel )
delete

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

Referenced by NEDilateKernel::name().

◆ operator=() [2/2]

NEDilateKernel& operator= ( NEDilateKernel &&  )
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 69 of file NEDilateKernel.cpp.

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

Referenced by NEDilateKernel::name().

70 {
74 
75  Iterator in(_input, window);
76  Iterator out(_output, window);
77 
78  const size_t in_stride = _input->info()->strides_in_bytes()[1];
79 
80  execute_window_loop(window, [&](const Coordinates &)
81  {
82  uint8_t *in_ptr = in.ptr() - 1;
83  const uint8x16_t top_data = vld1q_u8(in_ptr - in_stride);
84  const uint8x16_t mid_data = vld1q_u8(in_ptr);
85  const uint8x16_t bot_data = vld1q_u8(in_ptr + in_stride);
86 
87  uint8x8_t top_high_data = vget_high_u8(top_data);
88  uint8x8_t top_low_data = vget_low_u8(top_data);
89 
90  uint8x8_t mid_high_data = vget_high_u8(mid_data);
91  uint8x8_t mid_low_data = vget_low_u8(mid_data);
92 
93  uint8x8_t bot_high_data = vget_high_u8(bot_data);
94  uint8x8_t bot_low_data = vget_low_u8(bot_data);
95 
96  uint8x8_t p0;
97  uint8x8_t p1;
98 
99  p0 = top_low_data;
100  p1 = vext_u8(top_low_data, top_high_data, 1);
101  p0 = vmax_u8(p0, p1);
102 
103  p1 = vext_u8(top_low_data, top_high_data, 2);
104  p0 = vmax_u8(p0, p1);
105 
106  p1 = mid_low_data;
107  p0 = vmax_u8(p0, p1);
108 
109  p1 = vext_u8(mid_low_data, mid_high_data, 1);
110  p0 = vmax_u8(p0, p1);
111 
112  p1 = vext_u8(mid_low_data, mid_high_data, 2);
113  p0 = vmax_u8(p0, p1);
114 
115  p1 = bot_low_data;
116  p0 = vmax_u8(p0, p1);
117 
118  p1 = vext_u8(bot_low_data, bot_high_data, 1);
119  p0 = vmax_u8(p0, p1);
120 
121  p1 = vext_u8(bot_low_data, bot_high_data, 2);
122  p0 = vmax_u8(p0, p1);
123 
124  vst1_u8(out.ptr(), p0);
125  },
126  in, out);
127 }
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
#define ARM_COMPUTE_ERROR_ON_UNCONFIGURED_KERNEL(k)
Definition: Validate.h:941
ScaleKernelInfo info(interpolation_policy, default_border_mode, PixelValue(), sampling_policy, false)
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
#define ARM_COMPUTE_ERROR_ON_INVALID_SUBWINDOW(f, s)
Definition: Validate.h:205

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