Compute Library
 21.08
NERemapKernel Class Reference

Kernel to perform a remap on a tensor. More...

#include <NERemapKernel.h>

Collaboration diagram for NERemapKernel:
[legend]

Public Member Functions

const char * name () const override
 Name of the kernel. More...
 
 NERemapKernel ()
 Default constructor. More...
 
 NERemapKernel (const NERemapKernel &)=delete
 Prevent instances of this class from being copied (As this class contains pointers) More...
 
NERemapKerneloperator= (const NERemapKernel &)=delete
 Prevent instances of this class from being copied (As this class contains pointers) More...
 
 NERemapKernel (NERemapKernel &&)=default
 Allow instances of this class to be moved. More...
 
NERemapKerneloperator= (NERemapKernel &&)=default
 Allow instances of this class to be moved. More...
 
 ~NERemapKernel ()=default
 Default destructor. More...
 
void configure (const ITensor *input, const ITensor *map_x, const ITensor *map_y, ITensor *output, InterpolationPolicy policy, BorderMode border_mode, uint8_t constant_border_value=0)
 Initialize the kernel's input, output and border mode. 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...
 
bool is_window_configured () const
 Function to check if the embedded window of this kernel has been configured. More...
 

Detailed Description

Kernel to perform a remap on a tensor.

Definition at line 35 of file NERemapKernel.h.

Constructor & Destructor Documentation

◆ NERemapKernel() [1/3]

Default constructor.

Definition at line 117 of file NERemapKernel.cpp.

References arm_compute::UNDEFINED.

Referenced by NERemapKernel::name().

118  : _func(nullptr), _input(nullptr), _output(nullptr), _map_x(nullptr), _map_y(nullptr), _border_mode(BorderMode::UNDEFINED), _constant_border_value(0)
119 {
120 }
Borders are left undefined.

◆ NERemapKernel() [2/3]

NERemapKernel ( const NERemapKernel )
delete

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

◆ NERemapKernel() [3/3]

NERemapKernel ( NERemapKernel &&  )
default

Allow instances of this class to be moved.

◆ ~NERemapKernel()

~NERemapKernel ( )
default

Default destructor.

Referenced by NERemapKernel::name().

Member Function Documentation

◆ configure()

void configure ( const ITensor input,
const ITensor map_x,
const ITensor map_y,
ITensor output,
InterpolationPolicy  policy,
BorderMode  border_mode,
uint8_t  constant_border_value = 0 
)

Initialize the kernel's input, output and border mode.

Parameters
[in]inputSource tensor. Data type supported: U8.
[in]map_xMap for X coordinates. Data type supported: F32.
[in]map_yMap for Y coordinates. Data type supported: F32.
[out]outputDestination tensor. Data types supported: U8. All but the lowest two dimensions must be the same size as in the input tensor, i.e. remapping is only performed within the XY-plane.
[in]policyThe interpolation type.
[in]border_modeBorder mode to use on the input tensor.
[in]constant_border_value(Optional) Constant value to use for borders if border_mode is set to CONSTANT. Defaults to 0.

Definition at line 122 of file NERemapKernel.cpp.

References ARM_COMPUTE_ERROR, ARM_COMPUTE_ERROR_ON_DATA_TYPE_CHANNEL_NOT_IN, arm_compute::BILINEAR, arm_compute::calculate_max_window(), arm_compute::test::validation::configure(), ITensorInfo::dimension(), Window::DimX, Window::DimY, Window::Dimension::end(), arm_compute::execute_window_loop(), arm_compute::F32, ITensor::info(), arm_compute::test::validation::input, arm_compute::NEAREST_NEIGHBOR, Iterator::ptr(), Window::set(), Window::Dimension::start(), ITensorInfo::strides_in_bytes(), arm_compute::U8, IKernel::window(), and Window::x().

Referenced by NERemapKernel::name().

123 {
128 
129  _input = input;
130  _output = output;
131  _map_x = map_x;
132  _map_y = map_y;
133  _border_mode = border_mode;
134  _constant_border_value = constant_border_value;
135 
136  switch(policy)
137  {
139  {
140  _func = &NERemapKernel::remap_nearest;
141  break;
142  }
144  {
145  _func = &NERemapKernel::remap_bilinear;
146  break;
147  }
148  default:
149  ARM_COMPUTE_ERROR("Unsupported interpolation mode");
150  break;
151  }
152 
153  // Configure kernel window
154  Window win = calculate_max_window(*output->info(), Steps());
155  INEKernel::configure(win);
156 }
Window calculate_max_window(const ValidRegion &valid_region, const Steps &steps, bool skip_border, BorderSize border_size)
#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
Output values are defined by bilinear interpolation between the pixels.
Output values are defined to match the source pixel whose center is nearest to the sample position...
#define ARM_COMPUTE_ERROR_ON_DATA_TYPE_CHANNEL_NOT_IN(t, c,...)
Definition: Validate.h:786

◆ name()

const char* name ( ) const
inlineoverridevirtual

◆ operator=() [1/2]

NERemapKernel& operator= ( const NERemapKernel )
delete

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

Referenced by NERemapKernel::name().

◆ operator=() [2/2]

NERemapKernel& operator= ( NERemapKernel &&  )
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 317 of file NERemapKernel.cpp.

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

Referenced by NERemapKernel::name().

318 {
322  ARM_COMPUTE_ERROR_ON(_func == nullptr);
323 
324  (this->*_func)(window);
325 }
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:915
ScaleKernelInfo info(interpolation_policy, default_border_mode, PixelValue(), sampling_policy, false)
#define ARM_COMPUTE_ERROR_ON_INVALID_SUBWINDOW(f, s)
Definition: Validate.h:201

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