Compute Library
 21.02
NEHistogramKernel Class Reference

Interface for the histogram kernel. More...

#include <NEHistogramKernel.h>

Collaboration diagram for NEHistogramKernel:
[legend]

Public Member Functions

const char * name () const override
 Name of the kernel. More...
 
 NEHistogramKernel ()
 Default constructor. More...
 
 NEHistogramKernel (const NEHistogramKernel &)=delete
 Prevent instances of this class from being copied (As this class contains pointers) More...
 
NEHistogramKerneloperator= (const NEHistogramKernel &)=delete
 Prevent instances of this class from being copied (As this class contains pointers) More...
 
 NEHistogramKernel (NEHistogramKernel &&)=delete
 Prevent instances of this class from being moved (As this class contains non movable objects) More...
 
NEHistogramKerneloperator= (NEHistogramKernel &&)=delete
 Prevent instances of this class from being moved (As this class contains non movable objects) More...
 
 ~NEHistogramKernel ()=default
 Default destructor. More...
 
void configure (const IImage *input, IDistribution1D *output, uint32_t *local_hist, uint32_t *window_lut)
 Set the input image and the distribution output. More...
 
void configure (const IImage *input, IDistribution1D *output)
 Set the input image and the distribution output. 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...
 
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...
 
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 histogram kernel.

Definition at line 40 of file NEHistogramKernel.h.

Constructor & Destructor Documentation

◆ NEHistogramKernel() [1/3]

Default constructor.

Definition at line 63 of file NEHistogramKernel.cpp.

Referenced by NEHistogramKernel::name().

64  : _func(nullptr), _input(nullptr), _output(nullptr), _local_hist(nullptr), _window_lut(nullptr), _hist_mtx()
65 {
66 }

◆ NEHistogramKernel() [2/3]

NEHistogramKernel ( const NEHistogramKernel )
delete

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

◆ NEHistogramKernel() [3/3]

Prevent instances of this class from being moved (As this class contains non movable objects)

◆ ~NEHistogramKernel()

~NEHistogramKernel ( )
default

Default destructor.

Referenced by NEHistogramKernel::name().

Member Function Documentation

◆ configure() [1/2]

void configure ( const IImage input,
IDistribution1D output,
uint32_t *  local_hist,
uint32_t *  window_lut 
)

Set the input image and the distribution output.

Parameters
[in]inputSource image. Data type supported: U8.
[out]outputDestination distribution.
[in,out]local_histArray that the threads use to save their local histograms. It's size should be equal to (number_of_threads * num_bins), and the Window::thread_id() is used to determine the part of the array used by each thread.
[out]window_lutLUT with pre-calculated possible window values. The size of the LUT should be equal to max_range_size and it will be filled during the configure stage, while it re-used in every run, therefore can be safely shared among threads.

Definition at line 194 of file NEHistogramKernel.cpp.

References ARM_COMPUTE_ERROR_ON, ARM_COMPUTE_ERROR_ON_DATA_TYPE_CHANNEL_NOT_IN, ARM_COMPUTE_ERROR_ON_TENSOR_NOT_2D, arm_compute::test::validation::input, and arm_compute::U8.

Referenced by NEHistogramKernel::name().

195 {
198  ARM_COMPUTE_ERROR_ON(nullptr == output);
199  ARM_COMPUTE_ERROR_ON(nullptr == local_hist);
200  ARM_COMPUTE_ERROR_ON(nullptr == window_lut);
201 
202  _input = input;
203  _output = output;
204  _local_hist = local_hist;
205  _window_lut = window_lut;
206 
207  //Check offset
208  ARM_COMPUTE_ERROR_ON_MSG(0 > _output->offset() || _output->offset() > static_cast<int32_t>(_max_range_size), "Offset is larger than the image value range.");
209 
210  //Check range
211  ARM_COMPUTE_ERROR_ON_MSG(static_cast<int32_t>(_output->range()) > static_cast<int32_t>(_max_range_size) /* max range */, "Range larger than the image value range.");
212 
213  // Calculate LUT
214  calculate_window_lut();
215 
216  // Set appropriate function
217  _func = &NEHistogramKernel::histogram_U8;
218 
219  Window win = calculate_max_window(*input->info(), Steps());
220 
221  INEKernel::configure(win);
222 }
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
1 channel, 1 U8 per channel
uint32_t range() const
Returns the range of the distribution.
#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_ERROR_ON_MSG(cond, msg)
Definition: Error.h:456
#define ARM_COMPUTE_ERROR_ON_DATA_TYPE_CHANNEL_NOT_IN(t, c,...)
Definition: Validate.h:790
int32_t offset() const
Returns the offset of the distribution.

◆ configure() [2/2]

void configure ( const IImage input,
IDistribution1D output 
)

Set the input image and the distribution output.

Note
Used for histogram of fixed size equal to 256
Parameters
[in]inputSource image. Data type supported: U8.
[out]outputDestination distribution which must be of 256 bins..

Definition at line 224 of file NEHistogramKernel.cpp.

References ARM_COMPUTE_ERROR_ON, ARM_COMPUTE_ERROR_ON_DATA_TYPE_CHANNEL_NOT_IN, ARM_COMPUTE_ERROR_ON_TENSOR_NOT_2D, arm_compute::test::validation::input, and arm_compute::U8.

225 {
228  ARM_COMPUTE_ERROR_ON(nullptr == output);
229 
230  _input = input;
231  _output = output;
232 
233  // Set appropriate function
234  _func = &NEHistogramKernel::histogram_fixed_U8;
235 
236  Window win = calculate_max_window(*input->info(), Steps());
237 
238  INEKernel::configure(win);
239 }
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
1 channel, 1 U8 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
#define ARM_COMPUTE_ERROR_ON_DATA_TYPE_CHANNEL_NOT_IN(t, c,...)
Definition: Validate.h:790

◆ name()

const char* name ( ) const
inlineoverridevirtual

◆ operator=() [1/2]

NEHistogramKernel& operator= ( const NEHistogramKernel )
delete

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

Referenced by NEHistogramKernel::name().

◆ operator=() [2/2]

NEHistogramKernel& operator= ( NEHistogramKernel &&  )
delete

Prevent instances of this class from being moved (As this class contains non movable objects)

◆ 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 241 of file NEHistogramKernel.cpp.

References ARM_COMPUTE_ERROR_ON, ARM_COMPUTE_ERROR_ON_INVALID_SUBWINDOW, ARM_COMPUTE_ERROR_ON_UNCONFIGURED_KERNEL, and IKernel::window().

Referenced by NEHistogramKernel::name().

242 {
245  ARM_COMPUTE_ERROR_ON(_func == nullptr);
246 
247  (this->*_func)(window, info);
248 }
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_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: