Compute Library
NEHarrisScoreKernel< block_size > Class Template Reference

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

#include <NEHarrisCornersKernel.h>

Collaboration diagram for NEHarrisScoreKernel< block_size >:

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

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 83 of file NEHarrisCornersKernel.h.

Constructor & Destructor Documentation

◆ NEHarrisScoreKernel()

Default constructor.

Definition at line 705 of file NEHarrisCornersKernel.cpp.

706  : INEHarrisScoreKernel(), _func(nullptr)
707 {
708 }

Member Function Documentation

◆ border_size()

BorderSize border_size ( ) const

The size of the border for that kernel.

The width in number of elements of the border.

Reimplemented from IKernel.

Definition at line 732 of file NEHarrisCornersKernel.cpp.

Referenced by NEHarrisScoreKernel< block_size >::configure().

733 {
734  return _border_size;
735 }

◆ configure()

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

Setup the kernel 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 738 of file NEHarrisCornersKernel.cpp.

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, NEHarrisScoreKernel< block_size >::border_size(), arm_compute::calculate_max_window(), ITensorInfo::data_type(), arm_compute::F32, ITensor::info(), arm_compute::intersect_valid_regions(), num_elems_processed_per_iteration, arm_compute::S16, arm_compute::S32, arm_compute::update_window_and_padding(), arm_compute::test::validation::valid_region, and ITensorInfo::valid_region().

740 {
748  ARM_COMPUTE_ERROR_ON(0.0f == norm_factor);
750  _input1 = input1;
751  _input2 = input2;
752  _output = output;
753  _sensitivity = sensitivity;
754  _strength_thresh = strength_thresh;
755  _norm_factor = norm_factor;
756  _border_size = BorderSize(block_size / 2);
758  if(input1->info()->data_type() == DataType::S16)
759  {
760  switch(block_size)
761  {
762  case 3:
763  _func = &harris_score3x3_S16_S16_FLOAT;
764  break;
765  case 5:
766  _func = &harris_score5x5_S16_S16_FLOAT;
767  break;
768  case 7:
769  _func = &harris_score7x7_S16_S16_FLOAT;
770  break;
771  default:
772  ARM_COMPUTE_ERROR("Invalid block size");
773  break;
774  }
775  }
776  else
777  {
778  switch(block_size)
779  {
780  case 3:
781  _func = &harris_score3x3_S32_S32_FLOAT;
782  break;
783  case 5:
784  _func = &harris_score5x5_S32_S32_FLOAT;
785  break;
786  case 7:
787  _func = &harris_score7x7_S32_S32_FLOAT;
788  break;
789  default:
790  ARM_COMPUTE_ERROR("Invalid block size");
791  break;
792  }
793  }
795  ARM_COMPUTE_ERROR_ON(nullptr == _func);
797  constexpr unsigned int num_elems_processed_per_iteration = block_size != 7 ? 8 : 4;
798  constexpr unsigned int num_elems_read_per_iteration = block_size != 7 ? 16 : 12;
799  constexpr unsigned int num_elems_written_per_iteration = block_size != 7 ? 8 : 4;
800  constexpr unsigned int num_rows_read_per_iteration = block_size;
802  // Configure kernel window
803  Window win = calculate_max_window(*input1->info(), Steps(num_elems_processed_per_iteration), border_undefined, border_size());
804  AccessWindowHorizontal output_access(output->info(), 0, num_elems_written_per_iteration);
807  AccessWindowRectangle(input1->info(), -_border_size.left,, num_elems_read_per_iteration, num_rows_read_per_iteration),
808  AccessWindowRectangle(input2->info(), -_border_size.left,, num_elems_read_per_iteration, num_rows_read_per_iteration),
809  output_access);
812  input2->info()->valid_region());
814  output_access.set_valid_region(win, valid_region, border_undefined, border_size());
816  INEKernel::configure(win);
817 }
Window calculate_max_window(const ValidRegion &valid_region, const Steps &steps, bool skip_border, BorderSize border_size)
Definition: Validate.h:856
Container for 2D border size.
Definition: Types.h:273
#define ARM_COMPUTE_ERROR(msg)
Print the given message then throw an std::runtime_error.
Definition: Error.h:352
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:466
const ValidRegion valid_region
Definition: Scale.cpp:221
virtual ValidRegion valid_region() const =0
Valid region of the tensor.
1 channel, 1 S32 per channel
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
Definition: Validate.h:543
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&#39;s metadata.
ValidRegion intersect_valid_regions(const Ts &... regions)
Intersect multiple valid regions.
Definition: WindowHelpers.h:74
1 channel, 1 S16 per channel
Definition: Validate.h:790
unsigned int num_elems_processed_per_iteration
Container for valid region of a window.
Definition: Types.h:188
Describe a multidimensional execution window.
Definition: Window.h:39

◆ name()

const char* name ( ) const

Name of the kernel.

Kernel name

Implements ICPPKernel.

Definition at line 86 of file NEHarrisCornersKernel.h.

References IKernel::border_size(), INEHarrisScoreKernel::configure(), arm_compute::test::validation::info, ICPPKernel::run(), and IKernel::window().

87  {
88  return "NEHarrisScoreKernel";
89  }

◆ run()

void run ( const Window window,
const ThreadInfo info 

Execute the kernel on the passed window.

If is_parallelisable() returns false then the passed window must be equal to window()
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().
[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 711 of file NEHarrisCornersKernel.cpp.

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

712 {
716  ARM_COMPUTE_ERROR_ON(_func == nullptr);
718  Iterator input1(_input1, window);
719  Iterator input2(_input2, window);
720  Iterator output(_output, window);
722  const size_t input_stride = _input1->info()->strides_in_bytes()[1] / element_size_from_data_type(_input1->info()->data_type());
724  execute_window_loop(window, [&](const Coordinates &)
725  {
726  (*_func)(input1.ptr(), input2.ptr(), output.ptr(), input_stride, _norm_factor, _sensitivity, _strength_thresh);
727  },
728  input1, input2, output);
729 }
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
#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
To avoid unused variables warnings.
Definition: Error.h:152
Coordinates of an item.
Definition: Coordinates.h:37
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
Definition: Validate.h:205

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