Compute Library
 21.02
INEWarpKernel Class Referenceabstract

Common interface for warp affine and warp perspective. More...

#include <NEWarpKernel.h>

Collaboration diagram for INEWarpKernel:
[legend]

Public Member Functions

 INEWarpKernel ()
 Default constructor. More...
 
 INEWarpKernel (const INEWarpKernel &)=delete
 Prevent instances of this class from being copied (As this class contains pointers) More...
 
INEWarpKerneloperator= (const INEWarpKernel &)=delete
 Prevent instances of this class from being copied (As this class contains pointers) More...
 
 INEWarpKernel (INEWarpKernel &&)=default
 Allow instances of this class to be moved. More...
 
INEWarpKerneloperator= (INEWarpKernel &&)=default
 Allow instances of this class to be moved. More...
 
 ~INEWarpKernel ()=default
 Default destructor. More...
 
virtual void configure (const ITensor *input, ITensor *output, const std::array< float, 9 > &matrix, BorderMode border_mode, uint8_t constant_border_value)
 Initialise 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...
 
virtual const char * name () const =0
 Name of the kernel. 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

Common interface for warp affine and warp perspective.

Definition at line 37 of file NEWarpKernel.h.

Constructor & Destructor Documentation

◆ INEWarpKernel() [1/3]

Default constructor.

Definition at line 50 of file NEWarpKernel.cpp.

51  : _func(nullptr), _input(nullptr), _output(nullptr), _constant_border_value(0), _matrix()
52 {
53 }

◆ INEWarpKernel() [2/3]

INEWarpKernel ( const INEWarpKernel )
delete

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

◆ INEWarpKernel() [3/3]

INEWarpKernel ( INEWarpKernel &&  )
default

Allow instances of this class to be moved.

◆ ~INEWarpKernel()

~INEWarpKernel ( )
default

Default destructor.

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 55 of file NEWarpKernel.cpp.

Referenced by INEWarpKernel::configure().

56 {
57  return BorderSize(1);
58 }
Container for 2D border size.
Definition: Types.h:273

◆ configure()

void configure ( const ITensor input,
ITensor output,
const std::array< float, 9 > &  matrix,
BorderMode  border_mode,
uint8_t  constant_border_value 
)
virtual

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

Parameters
[in]inputSource tensor. Data type supported: U8.
[out]outputDestination tensor. Data type supported: U8.
[in]matrixThe perspective or affine matrix to use. Must be 2x3 for affine and 3x3 for perspective of type float. The matrix argument requires 9 values, for the affine case the last 3 values are ignored.
[in]border_modeStrategy to use for borders
[in]constant_border_valueConstant value used for filling the border.

Definition at line 70 of file NEWarpKernel.cpp.

References ValidRegion::anchor, ARM_COMPUTE_ERROR, ARM_COMPUTE_ERROR_ON_DATA_TYPE_CHANNEL_NOT_IN, arm_compute::BILINEAR, INEWarpKernel::border_size(), BorderSize::bottom, arm_compute::calculate_max_window(), arm_compute::CONSTANT, Window::DimX, Window::DimY, arm_compute::execute_window_loop(), ITensor::info(), arm_compute::test::validation::input, BorderSize::left, arm_compute::NEAREST_NEIGHBOR, arm_compute::scale_helpers::pixel_bilinear_c1(), Iterator::ptr(), arm_compute::REPLICATE, BorderSize::right, Window::set(), ValidRegion::shape, Window::Dimension::start(), ITensorInfo::strides_in_bytes(), ITensorInfo::tensor_shape(), BorderSize::top, arm_compute::U, arm_compute::U8, arm_compute::UNDEFINED, arm_compute::update_window_and_padding(), ITensorInfo::valid_region(), IKernel::window(), Window::x(), Window::y(), and Window::z().

71 {
74 
75  _matrix = matrix;
76  _constant_border_value = constant_border_value;
77 
78  switch(border_mode)
79  {
81  _func = &INEWarpKernel::warp_undefined;
82  break;
84  _func = &INEWarpKernel::warp_constant;
85  break;
87  _func = &INEWarpKernel::warp_replicate;
88  break;
89  default:
90  ARM_COMPUTE_ERROR("Border mode not supported");
91  break;
92  }
93 
94  _input = input;
95  _output = output;
96 
97  // Configure kernel window
98  Window win = calculate_max_window(*output->info(), Steps(1U));
99 
100  const ValidRegion &input_valid_region = input->info()->valid_region();
101 
102  // Reads can occur within the valid region of the input
103  AccessWindowStatic input_access(input->info(),
104  input_valid_region.anchor[0] - border_size().left, input_valid_region.anchor[1] - border_size().top,
105  input_valid_region.anchor[0] + input_valid_region.shape[0] + border_size().right,
106  input_valid_region.anchor[1] + input_valid_region.shape[1] + border_size().bottom);
107  AccessWindowHorizontal output_access(output->info(), 0, 1);
108 
109  update_window_and_padding(win, input_access, output_access);
110 
111  output_access.set_valid_region(win, ValidRegion(Coordinates(), output->info()->tensor_shape()));
112 
113  INEKernel::configure(win);
114 }
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)
#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
unsigned int bottom
bottom of the border
Definition: Types.h:377
virtual ValidRegion valid_region() const =0
Valid region of the tensor.
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.
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
Borders are left undefined.
Pixels outside the image are assumed to have the same value as the closest image pixel.
Container for valid region of a window.
Definition: Types.h:188
Describe a multidimensional execution window.
Definition: Window.h:39

◆ operator=() [1/2]

INEWarpKernel& operator= ( const INEWarpKernel )
delete

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

◆ operator=() [2/2]

INEWarpKernel& operator= ( INEWarpKernel &&  )
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 60 of file NEWarpKernel.cpp.

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

61 {
62  ARM_COMPUTE_UNUSED(info);
65  ARM_COMPUTE_ERROR_ON(_func == nullptr);
66 
67  (this->*_func)(window);
68 }
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: