Compute Library
 21.02
NEMinMaxLocationKernel Class Reference

Interface for the kernel to find min max locations of an image. More...

#include <NEMinMaxLocationKernel.h>

Collaboration diagram for NEMinMaxLocationKernel:
[legend]

Public Member Functions

const char * name () const override
 Name of the kernel. More...
 
 NEMinMaxLocationKernel ()
 Default constructor. More...
 
 NEMinMaxLocationKernel (const NEMinMaxLocationKernel &)=delete
 Prevent instances of this class from being copied (As this class contains pointers) More...
 
NEMinMaxLocationKerneloperator= (const NEMinMaxLocationKernel &)=delete
 Prevent instances of this class from being copied (As this class contains pointers) More...
 
 NEMinMaxLocationKernel (NEMinMaxLocationKernel &&)=default
 Allow instances of this class to be moved. More...
 
NEMinMaxLocationKerneloperator= (NEMinMaxLocationKernel &&)=default
 Allow instances of this class to be moved. More...
 
 ~NEMinMaxLocationKernel ()=default
 Default destructor. More...
 
void configure (const IImage *input, void *min, void *max, ICoordinates2DArray *min_loc=nullptr, ICoordinates2DArray *max_loc=nullptr, uint32_t *min_count=nullptr, uint32_t *max_count=nullptr)
 Initialise the kernel's input and outputs. More...
 
void run (const Window &window, const ThreadInfo &info) override
 Execute the kernel on the passed window. More...
 
bool is_parallelisable () const override
 Indicates whether or not the kernel is parallelisable. 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 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

Interface for the kernel to find min max locations of an image.

Definition at line 106 of file NEMinMaxLocationKernel.h.

Constructor & Destructor Documentation

◆ NEMinMaxLocationKernel() [1/3]

Default constructor.

Definition at line 315 of file NEMinMaxLocationKernel.cpp.

316  : _func(nullptr), _input(nullptr), _min(nullptr), _max(nullptr), _min_count(nullptr), _max_count(nullptr), _min_loc(nullptr), _max_loc(nullptr)
317 {
318 }

◆ NEMinMaxLocationKernel() [2/3]

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

◆ NEMinMaxLocationKernel() [3/3]

Allow instances of this class to be moved.

◆ ~NEMinMaxLocationKernel()

~NEMinMaxLocationKernel ( )
default

Default destructor.

Member Function Documentation

◆ configure()

void configure ( const IImage input,
void *  min,
void *  max,
ICoordinates2DArray min_loc = nullptr,
ICoordinates2DArray max_loc = nullptr,
uint32_t *  min_count = nullptr,
uint32_t *  max_count = nullptr 
)

Initialise the kernel's input and outputs.

Parameters
[in]inputInput Image. Data types supported: U8/S16/F32.
[out]minMinimum value of image. Data types supported: S32 if input type is U8/S16, F32 if input type is F32.
[out]maxMaximum value of image. Data types supported: S32 if input type is U8/S16, F32 if input type is F32.
[out]min_locArray of minimum value locations.
[out]max_locArray of maximum value locations.
[out]min_countNumber of minimum value encounters.
[out]max_countNumber of maximum value encounters.

Definition at line 337 of file NEMinMaxLocationKernel.cpp.

References ARM_COMPUTE_ERROR, ARM_COMPUTE_ERROR_ON, ARM_COMPUTE_ERROR_ON_DATA_TYPE_CHANNEL_NOT_IN, ARM_COMPUTE_ERROR_ON_TENSOR_NOT_2D, arm_compute::calculate_max_window(), ITensorInfo::data_type(), arm_compute::F32, ITensor::info(), arm_compute::test::validation::input, num_elems_processed_per_iteration, arm_compute::S16, arm_compute::U8, and arm_compute::update_window_and_padding().

340 {
343  ARM_COMPUTE_ERROR_ON(nullptr == min);
344  ARM_COMPUTE_ERROR_ON(nullptr == max);
345 
346  _input = input;
347  _min = min;
348  _max = max;
349  _min_count = min_count;
350  _max_count = max_count;
351  _min_loc = min_loc;
352  _max_loc = max_loc;
353 
354  unsigned int count_min = (nullptr != min_count ? 1 : 0);
355  unsigned int count_max = (nullptr != max_count ? 1 : 0);
356  unsigned int loc_min = (nullptr != min_loc ? 1 : 0);
357  unsigned int loc_max = (nullptr != max_loc ? 1 : 0);
358 
359  unsigned int table_idx = (count_min << 3) | (count_max << 2) | (loc_min << 1) | loc_max;
360 
361  switch(input->info()->data_type())
362  {
363  case DataType::U8:
364  _func = create_func_table<uint8_t, utility::index_sequence_t<16>>::func_table[table_idx];
365  break;
366  case DataType::S16:
367  _func = create_func_table<int16_t, utility::index_sequence_t<16>>::func_table[table_idx];
368  break;
369  case DataType::F32:
370  _func = create_func_table<float, utility::index_sequence_t<16>>::func_table[table_idx];
371  break;
372  default:
373  ARM_COMPUTE_ERROR("Unsupported data type");
374  break;
375  }
376 
377  constexpr unsigned int num_elems_processed_per_iteration = 1;
378 
379  // Configure kernel window
380  Window win = calculate_max_window(*input->info(), Steps(num_elems_processed_per_iteration));
381 
382  update_window_and_padding(win, AccessWindowHorizontal(input->info(), 0, num_elems_processed_per_iteration));
383 
384  INEKernel::configure(win);
385 }
Window calculate_max_window(const ValidRegion &valid_region, const Steps &steps, bool skip_border, BorderSize border_size)
#define ARM_COMPUTE_ERROR_ON_TENSOR_NOT_2D(t)
Definition: Validate.h:856
#define ARM_COMPUTE_ERROR(msg)
Print the given message then throw an std::runtime_error.
Definition: Error.h:352
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:466
bool update_window_and_padding(Window &win, Ts &&... patterns)
Update window and padding size for each of the access patterns.
Definition: WindowHelpers.h:46
1 channel, 1 S16 per channel
#define ARM_COMPUTE_ERROR_ON_DATA_TYPE_CHANNEL_NOT_IN(t, c,...)
Definition: Validate.h:790
unsigned int num_elems_processed_per_iteration

◆ is_parallelisable()

bool is_parallelisable ( ) const
overridevirtual

Indicates whether or not the kernel is parallelisable.

If the kernel is parallelisable then the window returned by window() can be split into sub-windows which can then be run in parallel.

If the kernel is not parallelisable then only the window returned by window() can be passed to run()

Returns
True if the kernel is parallelisable

Reimplemented from IKernel.

Definition at line 320 of file NEMinMaxLocationKernel.cpp.

References N.

321 {
322  return false;
323 }

◆ name()

const char* name ( ) const
inlineoverridevirtual

Name of the kernel.

Returns
Kernel name

Implements ICPPKernel.

Definition at line 109 of file NEMinMaxLocationKernel.h.

References NEMinMaxKernel::configure(), arm_compute::test::validation::info, arm_compute::test::validation::input, IKernel::is_parallelisable(), NEMinMaxKernel::operator=(), NEMinMaxKernel::run(), and IKernel::window().

110  {
111  return "NEMinMaxLocationKernel";
112  }

◆ operator=() [1/2]

NEMinMaxLocationKernel& operator= ( const NEMinMaxLocationKernel )
delete

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

◆ operator=() [2/2]

NEMinMaxLocationKernel& operator= ( NEMinMaxLocationKernel &&  )
default

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 387 of file NEMinMaxLocationKernel.cpp.

References ARM_COMPUTE_ERROR_ON, ARM_COMPUTE_ERROR_ON_INVALID_SUBWINDOW, ARM_COMPUTE_ERROR_ON_UNCONFIGURED_KERNEL, ARM_COMPUTE_UNUSED, arm_compute::test::validation::input, type, and IKernel::window().

388 {
392  ARM_COMPUTE_ERROR_ON(_func == nullptr);
393 
394  (this->*_func)(window);
395 }
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:466
#define ARM_COMPUTE_UNUSED(...)
To avoid unused variables warnings.
Definition: Error.h:152
#define ARM_COMPUTE_ERROR_ON_UNCONFIGURED_KERNEL(k)
Definition: Validate.h:941
ScaleKernelInfo info(interpolation_policy, default_border_mode, PixelValue(), sampling_policy, false)
#define ARM_COMPUTE_ERROR_ON_INVALID_SUBWINDOW(f, s)
Definition: Validate.h:205

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