Compute Library
 19.08
NENonMaximaSuppression3x3Kernel Class Reference

Interface to perform Non-Maxima suppression over a 3x3 window using NEON. More...

#include <NENonMaximaSuppression3x3Kernel.h>

Collaboration diagram for NENonMaximaSuppression3x3Kernel:
[legend]

Public Member Functions

const char * name () const override
 Name of the kernel. More...
 
 NENonMaximaSuppression3x3Kernel ()
 Default constructor. More...
 
 NENonMaximaSuppression3x3Kernel (const NENonMaximaSuppression3x3Kernel &)=delete
 Prevent instances of this class from being copied (As this class contains pointers) More...
 
NENonMaximaSuppression3x3Kerneloperator= (const NENonMaximaSuppression3x3Kernel &)=delete
 Prevent instances of this class from being copied (As this class contains pointers) More...
 
 NENonMaximaSuppression3x3Kernel (NENonMaximaSuppression3x3Kernel &&)=default
 Allow instances of this class to be moved. More...
 
NENonMaximaSuppression3x3Kerneloperator= (NENonMaximaSuppression3x3Kernel &&)=default
 Allow instances of this class to be moved. More...
 
 ~NENonMaximaSuppression3x3Kernel ()=default
 Default destructor. More...
 
void configure (const ITensor *input, ITensor *output, bool border_undefined)
 Initialise the kernel's sources, destinations 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 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

Interface to perform Non-Maxima suppression over a 3x3 window using NEON.

Note
Used by NEFastCorners and NEHarrisCorners

Definition at line 39 of file NENonMaximaSuppression3x3Kernel.h.

Constructor & Destructor Documentation

◆ NENonMaximaSuppression3x3Kernel() [1/3]

Default constructor.

Definition at line 452 of file NENonMaximaSuppression3x3Kernel.cpp.

453  : _func(nullptr), _input(nullptr), _output(nullptr)
454 {
455 }

◆ NENonMaximaSuppression3x3Kernel() [2/3]

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

◆ NENonMaximaSuppression3x3Kernel() [3/3]

Allow instances of this class to be moved.

◆ ~NENonMaximaSuppression3x3Kernel()

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 457 of file NENonMaximaSuppression3x3Kernel.cpp.

458 {
459  return BorderSize(1);
460 }
Container for 2D border size.
Definition: Types.h:259

Referenced by NENonMaximaSuppression3x3Kernel::configure().

◆ configure()

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

Initialise the kernel's sources, destinations and border mode.

Parameters
[in]inputSource tensor. Data types supported: U8/F32
[out]outputDestination tensor. Data types supported: same as input
[in]border_undefinedTrue if the border mode is undefined. False if it's replicate or constant.

Definition at line 462 of file NENonMaximaSuppression3x3Kernel.cpp.

463 {
467 
468  _input = input;
469  _output = output;
470 
471  if(input->info()->data_type() == DataType::U8)
472  {
473  _func = &non_maxima_suppression3x3_U8_U8;
474  }
475  else
476  {
477  _func = &non_maxima_suppression3x3_FLOAT_FLOAT;
478  }
479 
480  constexpr unsigned int num_elems_processed_per_iteration = 16;
481  const unsigned int num_elems_read_per_iteration = 16 + 2 * border_size().left + (input->info()->data_type() == DataType::U8 ? 0 : 3);
482  constexpr unsigned int num_elems_written_per_iteration = 16;
483  constexpr unsigned int num_rows_read_per_iteration = 3;
484 
485  // Configure kernel window
486  Window win = calculate_max_window(*input->info(), Steps(num_elems_processed_per_iteration), border_undefined, border_size());
487  AccessWindowHorizontal output_access(output->info(), 0, num_elems_written_per_iteration);
488 
490  AccessWindowRectangle(input->info(), -border_size().left, -border_size().top, num_elems_read_per_iteration, num_rows_read_per_iteration),
491  output_access);
492 
493  output_access.set_valid_region(win, input->info()->valid_region(), border_undefined, border_size());
494 
495  INEKernel::configure(win);
496 }
unsigned int top
top of the border
Definition: Types.h:339
#define ARM_COMPUTE_ERROR_ON_MISMATCHING_DATA_TYPES(...)
Definition: Validate.h:543
1 channel, 1 U8 per channel
virtual DataType data_type() const =0
Data type used for each element of the tensor.
1 channel, 1 F32 per channel
BorderSize border_size() const override
The size of the border for that kernel.
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 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: Helpers.h:402
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's metadata.
unsigned int left
left of the border
Definition: Types.h:342
#define ARM_COMPUTE_ERROR_ON_DATA_TYPE_CHANNEL_NOT_IN(t, c,...)
Definition: Validate.h:789
Describe a multidimensional execution window.
Definition: Window.h:39

References ARM_COMPUTE_ERROR_ON_DATA_TYPE_CHANNEL_NOT_IN, ARM_COMPUTE_ERROR_ON_MISMATCHING_DATA_TYPES, NENonMaximaSuppression3x3Kernel::border_size(), arm_compute::calculate_max_window(), ITensorInfo::data_type(), arm_compute::F32, ITensor::info(), BorderSize::left, BorderSize::top, arm_compute::U8, arm_compute::update_window_and_padding(), and ITensorInfo::valid_region().

Referenced by NEFastCorners::configure().

◆ name()

const char* name ( ) const
inlineoverridevirtual

Name of the kernel.

Returns
Kernel name

Implements ICPPKernel.

Definition at line 42 of file NENonMaximaSuppression3x3Kernel.h.

43  {
44  return "NENonMaximaSuppression3x3Kernel";
45  }

◆ 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 498 of file NENonMaximaSuppression3x3Kernel.cpp.

499 {
503  ARM_COMPUTE_ERROR_ON(_func == nullptr);
504  Iterator input(_input, window);
505  Iterator output(_output, window);
506 
507  const size_t input_stride = _input->info()->strides_in_bytes()[1] / element_size_from_data_type(_input->info()->data_type());
508 
510  {
511  _func(input.ptr(), output.ptr(), input_stride);
512  },
513  input, output);
514 }
const Window & window() const
The maximum window the kernel can be executed on.
Definition: IKernel.cpp:28
size_t element_size_from_data_type(DataType dt)
The size in bytes of the data type.
Definition: Utils.h:184
virtual DataType data_type() const =0
Data type used for each element of the tensor.
#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
#define ARM_COMPUTE_UNUSED(...)
To avoid unused variables warnings.
Definition: Error.h:160
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.
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
virtual const Strides & strides_in_bytes() const =0
The strides in bytes for accessing each dimension of the tensor.
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
#define ARM_COMPUTE_ERROR_ON_UNCONFIGURED_KERNEL(k)
Definition: Validate.h:940

References ARM_COMPUTE_ERROR_ON, ARM_COMPUTE_ERROR_ON_INVALID_SUBWINDOW, ARM_COMPUTE_ERROR_ON_UNCONFIGURED_KERNEL, ARM_COMPUTE_UNUSED, ITensorInfo::data_type(), arm_compute::element_size_from_data_type(), arm_compute::execute_window_loop(), ITensor::info(), arm_compute::test::validation::info, Iterator::ptr(), ITensorInfo::strides_in_bytes(), and IKernel::window().


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