Compute Library
 19.08
NEHOGOrientationBinningKernel Class Reference

NEON kernel to perform HOG Orientation Binning. More...

#include <NEHOGDescriptorKernel.h>

Collaboration diagram for NEHOGOrientationBinningKernel:
[legend]

Public Member Functions

const char * name () const override
 Name of the kernel. More...
 
 NEHOGOrientationBinningKernel ()
 Default constructor. More...
 
 NEHOGOrientationBinningKernel (const NEHOGOrientationBinningKernel &)=delete
 Prevent instances of this class from being copied (As this class contains pointers) More...
 
NEHOGOrientationBinningKerneloperator= (const NEHOGOrientationBinningKernel &)=delete
 Prevent instances of this class from being copied (As this class contains pointers) More...
 
 NEHOGOrientationBinningKernel (NEHOGOrientationBinningKernel &&)=default
 Allow instances of this class to be moved. More...
 
NEHOGOrientationBinningKerneloperator= (NEHOGOrientationBinningKernel &&)=default
 Allow instances of this class to be moved. More...
 
 ~NEHOGOrientationBinningKernel ()=default
 Default destructor. More...
 
void configure (const ITensor *input_magnitude, const ITensor *input_phase, ITensor *output, const HOGInfo *hog_info)
 Initialise the kernel's inputs, output and HOG's metadata. More...
 
void run (const Window &window, const ThreadInfo &info) override
 Execute the kernel on the passed window. 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...
 
virtual BorderSize border_size () const
 The size of the border for that kernel. More...
 
const Windowwindow () const
 The maximum window the kernel can be executed on. More...
 

Detailed Description

NEON kernel to perform HOG Orientation Binning.

Definition at line 36 of file NEHOGDescriptorKernel.h.

Constructor & Destructor Documentation

◆ NEHOGOrientationBinningKernel() [1/3]

Default constructor.

Definition at line 627 of file NEHOGDescriptorKernel.cpp.

628  : _func(nullptr), _input_magnitude(nullptr), _input_phase(nullptr), _output(nullptr), _cell_width(0), _cell_height(0), _num_bins(0), _phase_scale(0)
629 {
630 }

◆ NEHOGOrientationBinningKernel() [2/3]

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

◆ NEHOGOrientationBinningKernel() [3/3]

Allow instances of this class to be moved.

◆ ~NEHOGOrientationBinningKernel()

Default destructor.

Member Function Documentation

◆ configure()

void configure ( const ITensor input_magnitude,
const ITensor input_phase,
ITensor output,
const HOGInfo hog_info 
)

Initialise the kernel's inputs, output and HOG's metadata.

Parameters
[in]input_magnitudeInput tensor which stores the magnitude of the gradient for each pixel. Data type supported: S16.
[in]input_phaseInput tensor which stores the phase of the gradient for each pixel. Data type supported: U8
[out]outputOutput tensor which stores the local HOG for each cell. Data type supported: F32. Number of channels supported: equal to the number of histogram bins per cell
[in]hog_infoHOG's metadata

Definition at line 632 of file NEHOGDescriptorKernel.cpp.

633 {
636  ARM_COMPUTE_ERROR_ON(hog_info == nullptr);
638  ARM_COMPUTE_ERROR_ON(input_magnitude->info()->dimension(Window::DimX) != input_phase->info()->dimension(Window::DimX));
639  ARM_COMPUTE_ERROR_ON(input_magnitude->info()->dimension(Window::DimY) != input_phase->info()->dimension(Window::DimY));
640 
641  _input_magnitude = input_magnitude;
642  _input_phase = input_phase;
643  _output = output;
644  _cell_width = hog_info->cell_size().width;
645  _cell_height = hog_info->cell_size().height;
646  _num_bins = hog_info->num_bins();
647  _phase_scale = (PhaseType::SIGNED == hog_info->phase_type() ? _num_bins / 360.0f : _num_bins / 180.0f);
648  _phase_scale *= (PhaseType::SIGNED == hog_info->phase_type() ? 360.0f / 255.0f : 1.0f);
649 
650  if(_cell_width < 8)
651  {
652  _func = &cell_width_lt8;
653  }
654  else
655  {
656  _func = &cell_width_ge8;
657  }
658 
659  constexpr unsigned int num_elems_processed_per_iteration = 1;
660  const unsigned int num_elems_read_per_iteration = 1;
661  const unsigned int num_rows_read_per_iteration = _cell_height;
662  const unsigned int num_elems_written_per_iteration = 1;
663 
664  // Configure kernel window
665  Window win = calculate_max_window(*output->info(), Steps(num_elems_processed_per_iteration));
666  AccessWindowHorizontal output_access(output->info(), 0, num_elems_written_per_iteration);
667 
669  AccessWindowRectangle(input_magnitude->info(), 0, 0, num_elems_read_per_iteration, num_rows_read_per_iteration),
670  AccessWindowRectangle(input_phase->info(), 0, 0, num_elems_read_per_iteration, num_rows_read_per_iteration),
671  output_access);
672 
673  output->info()->set_valid_region(ValidRegion(Coordinates(), output->info()->tensor_shape()));
674 
675  INEKernel::configure(win);
676 }
size_t num_bins() const
The number of histogram bins for each cell.
Definition: HOGInfo.cpp:111
virtual size_t dimension(size_t index) const =0
Return the size of the requested dimension.
const Size2D & cell_size() const
The cell size in pixels.
Definition: HOGInfo.cpp:91
Angle range: [0, 360].
1 channel, 1 U8 per channel
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
PhaseType phase_type() const
The type of PhaseType.
Definition: HOGInfo.cpp:126
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 void set_valid_region(const ValidRegion &valid_region)=0
Set the valid region of the tensor.
size_t height
Height of the image region or rectangle.
Definition: Size2D.h:93
Implementation of a rectangular access pattern.
static constexpr size_t DimX
Alias for dimension 0 also known as X dimension.
Definition: Window.h:43
bool update_window_and_padding(Window &win, Ts &&... patterns)
Update window and padding size for each of the access patterns.
Definition: Helpers.h:402
virtual const TensorShape & tensor_shape() const =0
Size for each dimension of the tensor.
Class to describe a number of elements in each dimension.
Definition: Steps.h:40
Coordinates of an item.
Definition: Coordinates.h:37
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.
1 channel, 1 S16 per channel
#define ARM_COMPUTE_ERROR_ON_DATA_TYPE_CHANNEL_NOT_IN(t, c,...)
Definition: Validate.h:789
static constexpr size_t DimY
Alias for dimension 1 also known as Y dimension.
Definition: Window.h:45
size_t width
Width of the image region or rectangle.
Definition: Size2D.h:92
Container for valid region of a window.
Definition: Types.h:174
Describe a multidimensional execution window.
Definition: Window.h:39

References ARM_COMPUTE_ERROR_ON, ARM_COMPUTE_ERROR_ON_DATA_TYPE_CHANNEL_NOT_IN, arm_compute::calculate_max_window(), HOGInfo::cell_size(), ITensorInfo::dimension(), Window::DimX, Window::DimY, arm_compute::F32, Size2D::height, ITensor::info(), HOGInfo::num_bins(), HOGInfo::phase_type(), arm_compute::S16, ITensorInfo::set_valid_region(), arm_compute::SIGNED, ITensorInfo::tensor_shape(), arm_compute::U8, arm_compute::update_window_and_padding(), and Size2D::width.

Referenced by NEHOGDescriptor::configure().

◆ name()

const char* name ( ) const
inlineoverridevirtual

Name of the kernel.

Returns
Kernel name

Implements ICPPKernel.

Definition at line 39 of file NEHOGDescriptorKernel.h.

40  {
41  return "NEHOGOrientationBinningKernel";
42  }

◆ 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 678 of file NEHOGDescriptorKernel.cpp.

679 {
683  ARM_COMPUTE_ERROR_ON(_func == nullptr);
684 
685  const size_t mag_stride = _input_magnitude->info()->strides_in_bytes()[Window::DimY] / pixel_size_from_format(_input_magnitude->info()->format());
686  const size_t phase_stride = _input_phase->info()->strides_in_bytes()[Window::DimY] / pixel_size_from_format(_input_phase->info()->format());
687 
688  Window win_mag(window);
689  win_mag.set(Window::DimX, Window::Dimension(window.x().start() * _cell_width, window.x().start() * _cell_width, _cell_width));
690  win_mag.set(Window::DimY, Window::Dimension(window.y().start() * _cell_height, window.y().start() * _cell_height, _cell_height));
691 
692  Window win_phase(win_mag);
693 
694  Iterator mag(_input_magnitude, win_mag);
695  Iterator phase(_input_phase, win_phase);
696  Iterator out(_output, window);
697 
699  {
700  const auto mag_row_ptr = reinterpret_cast<const int16_t *>(mag.ptr());
701  const auto phase_row_ptr = reinterpret_cast<const uint8_t *>(phase.ptr());
702  const auto out_row_ptr = reinterpret_cast<float *>(out.ptr());
703 
704  (*_func)(mag_row_ptr, phase_row_ptr, out_row_ptr, mag_stride, phase_stride, _cell_width, _cell_height, _num_bins, _phase_scale);
705  },
706  mag, phase, out);
707 }
const Window & window() const
The maximum window the kernel can be executed on.
Definition: IKernel.cpp:28
#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
SimpleTensor< uint8_t > phase(const SimpleTensor< T > &gx, const SimpleTensor< T > &gy, PhaseType phase_type)
Definition: Phase.cpp:35
Describe one of the image's dimensions with a start, end and step.
Definition: Window.h:75
virtual Format format() const =0
Colour format of the image.
static constexpr size_t DimX
Alias for dimension 0 also known as X dimension.
Definition: Window.h:43
#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.
static constexpr size_t DimY
Alias for dimension 1 also known as Y dimension.
Definition: Window.h:45
size_t pixel_size_from_format(Format format)
The size in bytes of the pixel format.
Definition: Utils.h:146
constexpr const Dimension & y() const
Alias to access the second dimension of the window.
Definition: Window.h:152
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
constexpr int start() const
Return the start of the dimension.
Definition: Window.h:92
Describe a multidimensional execution window.
Definition: Window.h:39
#define ARM_COMPUTE_ERROR_ON_UNCONFIGURED_KERNEL(k)
Definition: Validate.h:940
constexpr const Dimension & x() const
Alias to access the first dimension of the window.
Definition: Window.h:143

References ARM_COMPUTE_ERROR_ON, ARM_COMPUTE_ERROR_ON_INVALID_SUBWINDOW, ARM_COMPUTE_ERROR_ON_UNCONFIGURED_KERNEL, ARM_COMPUTE_UNUSED, Window::DimX, Window::DimY, arm_compute::execute_window_loop(), ITensorInfo::format(), ITensor::info(), arm_compute::test::validation::info, arm_compute::test::validation::reference::phase(), arm_compute::pixel_size_from_format(), Iterator::ptr(), Window::Dimension::start(), ITensorInfo::strides_in_bytes(), IKernel::window(), Window::x(), and Window::y().


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