Compute Library
 19.08
NEHarrisScoreKernel< block_size > Class Template Reference

Template NEON kernel to perform Harris Score. More...

#include <NEHarrisCornersKernel.h>

Collaboration diagram for NEHarrisScoreKernel< block_size >:
[legend]

Public Member Functions

const char * name () const override
 Name of the kernel. More...
 
 NEHarrisScoreKernel ()
 Default constructor. More...
 
void configure (const IImage *input1, const IImage *input2, IImage *output, float norm_factor, float strength_thresh, float sensitivity, bool border_undefined) override
 Setup the kernel parameters. More...
 
BorderSize border_size () const override
 The size of the border for that kernel. More...
 
void run (const Window &window, const ThreadInfo &info) override
 Execute the kernel on the passed window. More...
 
- Public Member Functions inherited from INEHarrisScoreKernel
 INEHarrisScoreKernel ()
 Default constructor. More...
 
 INEHarrisScoreKernel (const INEHarrisScoreKernel &)=delete
 Prevent instances of this class from being copied (As this class contains pointers) More...
 
INEHarrisScoreKerneloperator= (const INEHarrisScoreKernel &)=delete
 Prevent instances of this class from being copied (As this class contains pointers) More...
 
 INEHarrisScoreKernel (INEHarrisScoreKernel &&)=default
 Allow instances of this class to be moved. More...
 
INEHarrisScoreKerneloperator= (INEHarrisScoreKernel &&)=default
 Allow instances of this class to be moved. More...
 
 ~INEHarrisScoreKernel ()=default
 Default destructor. 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

template<int32_t block_size>
class arm_compute::NEHarrisScoreKernel< block_size >

Template NEON kernel to perform Harris Score.

The implementation supports 3, 5, and 7 for the block_size

Definition at line 84 of file NEHarrisCornersKernel.h.

Constructor & Destructor Documentation

◆ NEHarrisScoreKernel()

Default constructor.

Definition at line 703 of file NEHarrisCornersKernel.cpp.

704  : INEHarrisScoreKernel(), _func(nullptr)
705 {
706 }

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 730 of file NEHarrisCornersKernel.cpp.

731 {
732  return _border_size;
733 }

◆ configure()

void configure ( const IImage input1,
const IImage input2,
IImage output,
float  norm_factor,
float  strength_thresh,
float  sensitivity,
bool  border_undefined 
)
overridevirtual

Setup the kernel parameters.

Parameters
[in]input1Source image (gradient X). Data types supported: S16/S32
[in]input2Source image (gradient Y). Data types supported: same as @ input1
[out]outputDestination image (harris score). Data types supported: F32
[in]norm_factorNormalization factor to use accordingly with the gradient size (Must be different from 0)
[in]strength_threshMinimum threshold with which to eliminate Harris Corner scores (computed using the normalized Sobel kernel).
[in]sensitivitySensitivity threshold k from the Harris-Stephens equation
[in]border_undefinedTrue if the border mode is undefined. False if it's replicate or constant.

Implements INEHarrisScoreKernel.

Definition at line 736 of file NEHarrisCornersKernel.cpp.

738 {
746  ARM_COMPUTE_ERROR_ON(0.0f == norm_factor);
747 
748  _input1 = input1;
749  _input2 = input2;
750  _output = output;
751  _sensitivity = sensitivity;
752  _strength_thresh = strength_thresh;
753  _norm_factor = norm_factor;
754  _border_size = BorderSize(block_size / 2);
755 
756  if(input1->info()->data_type() == DataType::S16)
757  {
758  switch(block_size)
759  {
760  case 3:
761  _func = &harris_score3x3_S16_S16_FLOAT;
762  break;
763  case 5:
764  _func = &harris_score5x5_S16_S16_FLOAT;
765  break;
766  case 7:
767  _func = &harris_score7x7_S16_S16_FLOAT;
768  break;
769  default:
770  ARM_COMPUTE_ERROR("Invalid block size");
771  break;
772  }
773  }
774  else
775  {
776  switch(block_size)
777  {
778  case 3:
779  _func = &harris_score3x3_S32_S32_FLOAT;
780  break;
781  case 5:
782  _func = &harris_score5x5_S32_S32_FLOAT;
783  break;
784  case 7:
785  _func = &harris_score7x7_S32_S32_FLOAT;
786  break;
787  default:
788  ARM_COMPUTE_ERROR("Invalid block size");
789  break;
790  }
791  }
792 
793  ARM_COMPUTE_ERROR_ON(nullptr == _func);
794 
795  constexpr unsigned int num_elems_processed_per_iteration = block_size != 7 ? 8 : 4;
796  constexpr unsigned int num_elems_read_per_iteration = block_size != 7 ? 16 : 12;
797  constexpr unsigned int num_elems_written_per_iteration = block_size != 7 ? 8 : 4;
798  constexpr unsigned int num_rows_read_per_iteration = block_size;
799 
800  // Configure kernel window
801  Window win = calculate_max_window(*input1->info(), Steps(num_elems_processed_per_iteration), border_undefined, border_size());
802  AccessWindowHorizontal output_access(output->info(), 0, num_elems_written_per_iteration);
803 
805  AccessWindowRectangle(input1->info(), -_border_size.left, -_border_size.top, num_elems_read_per_iteration, num_rows_read_per_iteration),
806  AccessWindowRectangle(input2->info(), -_border_size.left, -_border_size.top, num_elems_read_per_iteration, num_rows_read_per_iteration),
807  output_access);
808 
810  input2->info()->valid_region());
811 
812  output_access.set_valid_region(win, valid_region, border_undefined, border_size());
813 
814  INEKernel::configure(win);
815 }
#define ARM_COMPUTE_ERROR(...)
Print the given message then throw an std::runtime_error.
Definition: Error.h:261
#define ARM_COMPUTE_ERROR_ON_MISMATCHING_DATA_TYPES(...)
Definition: Validate.h:543
Container for 2D border size.
Definition: Types.h:259
virtual DataType data_type() const =0
Data type used for each element of the tensor.
1 channel, 1 F32 per channel
#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
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.
1 channel, 1 S32 per channel
#define ARM_COMPUTE_ERROR_ON_TENSOR_NOT_2D(t)
Definition: Validate.h:855
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
BorderSize border_size() const override
The size of the border for that kernel.
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.
ValidRegion intersect_valid_regions(const Ts &... regions)
Intersect multiple valid regions.
Definition: Helpers.h:503
1 channel, 1 S16 per channel
#define ARM_COMPUTE_ERROR_ON_DATA_TYPE_CHANNEL_NOT_IN(t, c,...)
Definition: Validate.h:789
Container for valid region of a window.
Definition: Types.h:174
Describe a multidimensional execution window.
Definition: Window.h:39

References ARM_COMPUTE_ERROR, ARM_COMPUTE_ERROR_ON, ARM_COMPUTE_ERROR_ON_DATA_TYPE_CHANNEL_NOT_IN, ARM_COMPUTE_ERROR_ON_MISMATCHING_DATA_TYPES, ARM_COMPUTE_ERROR_ON_TENSOR_NOT_2D, arm_compute::calculate_max_window(), ITensorInfo::data_type(), arm_compute::F32, ITensor::info(), arm_compute::intersect_valid_regions(), arm_compute::S16, arm_compute::S32, arm_compute::update_window_and_padding(), arm_compute::test::validation::valid_region, and ITensorInfo::valid_region().

◆ name()

const char* name ( ) const
inlineoverridevirtual

Name of the kernel.

Returns
Kernel name

Implements ICPPKernel.

Definition at line 87 of file NEHarrisCornersKernel.h.

88  {
89  return "NEHarrisScoreKernel";
90  }

◆ 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 709 of file NEHarrisCornersKernel.cpp.

710 {
714  ARM_COMPUTE_ERROR_ON(_func == nullptr);
715 
716  Iterator input1(_input1, window);
717  Iterator input2(_input2, window);
718  Iterator output(_output, window);
719 
720  const size_t input_stride = _input1->info()->strides_in_bytes()[1] / element_size_from_data_type(_input1->info()->data_type());
721 
723  {
724  (*_func)(input1.ptr(), input2.ptr(), output.ptr(), input_stride, _norm_factor, _sensitivity, _strength_thresh);
725  },
726  input1, input2, output);
727 }
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
#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
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
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, arm_compute::element_size_from_data_type(), arm_compute::execute_window_loop(), arm_compute::test::validation::info, Iterator::ptr(), and IKernel::window().


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