Compute Library
 21.02
NERemapKernel Class Reference

Neon 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)
 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...
 
BorderSize border_size () const override
 The size of the border for that kernel. 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

Neon 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 69 of file NERemapKernel.cpp.

Referenced by NERemapKernel::name().

70  : _func(nullptr), _input(nullptr), _output(nullptr), _map_x(nullptr), _map_y(nullptr)
71 {
72 }

◆ 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

◆ border_size()

BorderSize border_size ( ) const
overridevirtual

The size of the border for that kernel.

Returns
The width in number of elements of the border.

Reimplemented from IKernel.

Definition at line 74 of file NERemapKernel.cpp.

Referenced by NERemapKernel::name().

75 {
76  return BorderSize(1);
77 }
Container for 2D border size.
Definition: Types.h:273

◆ configure()

void configure ( const ITensor input,
const ITensor map_x,
const ITensor map_y,
ITensor output,
InterpolationPolicy  policy 
)

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.

Definition at line 79 of file NERemapKernel.cpp.

References ARM_COMPUTE_ERROR_ON_DATA_TYPE_CHANNEL_NOT_IN, arm_compute::F32, arm_compute::test::validation::input, and arm_compute::U8.

Referenced by NERemapKernel::name().

80 {
85 
86  _input = input;
87  _output = output;
88  _map_x = map_x;
89  _map_y = map_y;
90 
91  switch(policy)
92  {
94  {
95  _func = &NERemapKernel::remap_nearest;
96  break;
97  }
99  {
100  _func = &NERemapKernel::remap_bilinear;
101  break;
102  }
103  default:
104  ARM_COMPUTE_ERROR("Unsupported interpolation mode");
105  break;
106  }
107 
108  constexpr unsigned int num_elems_processed_per_iteration = 16;
109 
110  // Configure kernel window
111  Window win = calculate_max_window(*output->info(), Steps(num_elems_processed_per_iteration));
112 
113  const int total_right = ceil_to_multiple(input->info()->dimension(0), num_elems_processed_per_iteration);
114  const int access_right = total_right + (((total_right - input->info()->dimension(0)) == 0) ? border_size().right : 0);
115 
116  AccessWindowStatic input_access(input->info(), -border_size().left, -border_size().top, access_right, input->info()->dimension(1) + border_size().bottom);
117 
121 
122  update_window_and_padding(win, input_access, mapx_access, mapy_access, output_access);
123 
124  output_access.set_valid_region(win, ValidRegion(Coordinates(), output->info()->tensor_shape()));
125 
126  INEKernel::configure(win);
127 }
unsigned int top
top of the border
Definition: Types.h:375
Window calculate_max_window(const ValidRegion &valid_region, const Steps &steps, bool skip_border, BorderSize border_size)
virtual size_t dimension(size_t index) const =0
Return the size of the requested dimension.
#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.
unsigned int bottom
bottom of the border
Definition: Types.h:377
Output values are defined to match the source pixel whose center is nearest to the sample position...
Implementation of a static 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
virtual const TensorShape & tensor_shape() const =0
Size for each dimension of the tensor.
auto ceil_to_multiple(S value, T divisor) -> decltype(((value+divisor - 1)/divisor) *divisor)
Computes the smallest number larger or equal to value that is a multiple of divisor.
Definition: Utils.h:71
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&#39;s metadata.
BorderSize border_size() const override
The size of the border for that kernel.
unsigned int left
left of the border
Definition: Types.h:378
unsigned int right
right of the border
Definition: Types.h:376
#define ARM_COMPUTE_ERROR_ON_DATA_TYPE_CHANNEL_NOT_IN(t, c,...)
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
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 229 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().

230 {
231  ARM_COMPUTE_UNUSED(info);
234  ARM_COMPUTE_ERROR_ON(_func == nullptr);
235 
236  (this->*_func)(window);
237 }
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
#define ARM_COMPUTE_ERROR_ON_INVALID_SUBWINDOW(f, s)
Definition: Validate.h:205

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