Compute Library
 21.02
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...
 
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 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 454 of file NENonMaximaSuppression3x3Kernel.cpp.

Referenced by NENonMaximaSuppression3x3Kernel::name().

455  : _func(nullptr), _input(nullptr), _output(nullptr)
456 {
457 }

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

Referenced by NENonMaximaSuppression3x3Kernel::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 459 of file NENonMaximaSuppression3x3Kernel.cpp.

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

460 {
461  return BorderSize(1);
462 }
Container for 2D border size.
Definition: Types.h:273

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

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(), arm_compute::test::validation::input, BorderSize::left, BorderSize::top, arm_compute::U8, arm_compute::update_window_and_padding(), and ITensorInfo::valid_region().

Referenced by NENonMaximaSuppression3x3Kernel::name().

465 {
469 
470  _input = input;
471  _output = output;
472 
473  if(input->info()->data_type() == DataType::U8)
474  {
475  _func = &non_maxima_suppression3x3_U8_U8;
476  }
477  else
478  {
479  _func = &non_maxima_suppression3x3_FLOAT_FLOAT;
480  }
481 
482  constexpr unsigned int num_elems_processed_per_iteration = 16;
483  const unsigned int num_elems_read_per_iteration = 16 + 2 * border_size().left + (input->info()->data_type() == DataType::U8 ? 0 : 3);
484  constexpr unsigned int num_elems_written_per_iteration = 16;
485  constexpr unsigned int num_rows_read_per_iteration = 3;
486 
487  // Configure kernel window
488  Window win = calculate_max_window(*input->info(), Steps(num_elems_processed_per_iteration), border_undefined, border_size());
489  AccessWindowHorizontal output_access(output->info(), 0, num_elems_written_per_iteration);
490 
492  AccessWindowRectangle(input->info(), -border_size().left, -border_size().top, num_elems_read_per_iteration, num_rows_read_per_iteration),
493  output_access);
494 
495  output_access.set_valid_region(win, input->info()->valid_region(), border_undefined, border_size());
496 
497  INEKernel::configure(win);
498 }
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
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.
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
#define ARM_COMPUTE_ERROR_ON_MISMATCHING_DATA_TYPES(...)
Definition: Validate.h:543
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
#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()

◆ operator=() [1/2]

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

Referenced by NENonMaximaSuppression3x3Kernel::name().

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

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::input, Iterator::ptr(), ITensorInfo::strides_in_bytes(), and IKernel::window().

Referenced by NENonMaximaSuppression3x3Kernel::name().

501 {
502  ARM_COMPUTE_UNUSED(info);
505  ARM_COMPUTE_ERROR_ON(_func == nullptr);
506  Iterator input(_input, window);
507  Iterator output(_output, window);
508 
509  const size_t input_stride = _input->info()->strides_in_bytes()[1] / element_size_from_data_type(_input->info()->data_type());
510 
511  execute_window_loop(window, [&](const Coordinates &)
512  {
513  _func(input.ptr(), output.ptr(), input_stride);
514  },
515  input, output);
516 }
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:185
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:466
#define ARM_COMPUTE_UNUSED(...)
To avoid unused variables warnings.
Definition: Error.h:152
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.
#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
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: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: