Compute Library
 21.02
NEFillBorderKernel Class Reference

Interface for the kernel to fill borders. More...

#include <NEFillBorderKernel.h>

Collaboration diagram for NEFillBorderKernel:
[legend]

Public Member Functions

const char * name () const override
 Name of the kernel. More...
 
 NEFillBorderKernel ()
 Default Constructor. More...
 
 NEFillBorderKernel (const NEFillBorderKernel &)=delete
 Prevent instances of this class from being copied (As this class contains pointers) More...
 
NEFillBorderKerneloperator= (const NEFillBorderKernel &)=delete
 Prevent instances of this class from being copied (As this class contains pointers) More...
 
 NEFillBorderKernel (NEFillBorderKernel &&)=default
 Allow instances of this class to be moved. More...
 
NEFillBorderKerneloperator= (NEFillBorderKernel &&)=default
 Allow instances of this class to be moved. More...
 
 ~NEFillBorderKernel ()=default
 Default destructor. More...
 
void configure (ITensor *tensor, BorderSize border_size, BorderMode border_mode, const PixelValue &constant_border_value=PixelValue())
 Initialise the function. More...
 
void configure (ITensorInfo *tensor, BorderSize border_size, BorderMode border_mode, const PixelValue &constant_border_value=PixelValue())
 Initialise the function. More...
 
void run (const Window &window, const ThreadInfo &info) override
 Execute the kernel on the passed window. More...
 
void run_op (ITensorPack &tensors, 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...
 
- 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 kernel to fill borders.

Definition at line 37 of file NEFillBorderKernel.h.

Constructor & Destructor Documentation

◆ NEFillBorderKernel() [1/3]

Default Constructor.

Definition at line 91 of file NEFillBorderKernel.cpp.

References arm_compute::UNDEFINED.

Referenced by NEFillBorderKernel::name().

92  : _tensor(nullptr), _border_size(0), _mode(BorderMode::UNDEFINED), _constant_border_value(static_cast<float>(0.f))
93 {
94 }
Borders are left undefined.

◆ NEFillBorderKernel() [2/3]

NEFillBorderKernel ( const NEFillBorderKernel )
delete

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

◆ NEFillBorderKernel() [3/3]

Allow instances of this class to be moved.

◆ ~NEFillBorderKernel()

~NEFillBorderKernel ( )
default

Default destructor.

Referenced by NEFillBorderKernel::name().

Member Function Documentation

◆ configure() [1/2]

void configure ( ITensor tensor,
BorderSize  border_size,
BorderMode  border_mode,
const PixelValue constant_border_value = PixelValue() 
)

Initialise the function.

Note
This kernel fills the borders within the XY-planes.
Parameters
[in,out]tensorTensor to process. Data types supported: All.
[in]border_sizeSize of the border to fill in elements.
[in]border_modeBorder mode to use for the convolution.
[in]constant_border_value(Optional) Constant value to use for borders if border_mode is set to CONSTANT.

Definition at line 96 of file NEFillBorderKernel.cpp.

References ARM_COMPUTE_ERROR_ON_NULLPTR, IKernel::border_size(), and ITensor::info().

Referenced by NEFillBorderKernel::name().

97 {
99  _tensor = tensor;
100  configure(tensor->info(), border_size, border_mode, constant_border_value);
101 }
void configure(ITensor *tensor, BorderSize border_size, BorderMode border_mode, const PixelValue &constant_border_value=PixelValue())
Initialise the function.
virtual BorderSize border_size() const
The size of the border for that kernel.
Definition: IKernel.cpp:46
#define ARM_COMPUTE_ERROR_ON_NULLPTR(...)
Definition: Validate.h:161

◆ configure() [2/2]

void configure ( ITensorInfo tensor,
BorderSize  border_size,
BorderMode  border_mode,
const PixelValue constant_border_value = PixelValue() 
)

Initialise the function.

Note
This kernel fills the borders within the XY-planes.
Parameters
[in,out]tensorTensor info to process. Data types supported: All.
[in]border_sizeSize of the border to fill in elements.
[in]border_modeBorder mode to use for the convolution.
[in]constant_border_value(Optional) Constant value to use for borders if border_mode is set to CONSTANT.

Definition at line 103 of file NEFillBorderKernel.cpp.

References ARM_COMPUTE_ERROR_ON, ARM_COMPUTE_ERROR_ON_NULLPTR, IKernel::border_size(), ITensorInfo::data_type(), Window::DimX, Window::DimY, Window::DimZ, ITensorInfo::padding(), Window::set(), ITensorInfo::tensor_shape(), arm_compute::UNKNOWN, and Window::use_tensor_dimensions().

104 {
106  //Note: ARM_COMPUTE_RETURN_ERROR_ON_CPU_F16_UNSUPPORTED(input) is not needed here as this kernel doesn't use Neon FP16 instructions.
107  ARM_COMPUTE_ERROR_ON(tensor->data_type() == DataType::UNKNOWN);
108 
109  _border_size = border_size;
110  _mode = border_mode;
111  _constant_border_value = constant_border_value;
112 
113  _border_size.limit(tensor->padding());
114 
115  Window win;
116  win.set(Window::DimX, Window::Dimension(0, 1, 1));
117  win.set(Window::DimY, Window::Dimension(0, 1, 1));
118  win.use_tensor_dimensions(tensor->tensor_shape(), Window::DimZ);
119  INEKernel::configure(win);
120 }
#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
static constexpr size_t DimX
Alias for dimension 0 also known as X dimension.
Definition: Window.h:43
virtual BorderSize border_size() const
The size of the border for that kernel.
Definition: IKernel.cpp:46
static constexpr size_t DimY
Alias for dimension 1 also known as Y dimension.
Definition: Window.h:45
static constexpr size_t DimZ
Alias for dimension 2 also known as Z dimension.
Definition: Window.h:47
#define ARM_COMPUTE_ERROR_ON_NULLPTR(...)
Definition: Validate.h:161

◆ name()

const char* name ( ) const
inlineoverridevirtual

◆ operator=() [1/2]

NEFillBorderKernel& operator= ( const NEFillBorderKernel )
delete

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

Referenced by NEFillBorderKernel::name().

◆ operator=() [2/2]

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

References ARM_COMPUTE_ERROR, ARM_COMPUTE_ERROR_ON_INVALID_SUBWINDOW, ARM_COMPUTE_ERROR_ON_UNCONFIGURED_KERNEL, ARM_COMPUTE_UNUSED, BorderSize::bottom, arm_compute::CONSTANT, ITensorInfo::data_type(), BorderSize::empty(), arm_compute::F32, ITensor::info(), BorderSize::left, arm_compute::REPLICATE, BorderSize::right, BorderSize::top, arm_compute::UNDEFINED, and IKernel::window().

Referenced by NEFillBorderKernel::name(), and NEFillBorderKernel::run_op().

123 {
125 
126  // If there is no border: early exit
127  if(_border_size.empty())
128  {
129  return;
130  }
131 
134 
135  switch(_mode)
136  {
138  {
139  if(_border_size.left == 1 && _border_size.top == 1 && _tensor->info()->data_type() == DataType::F32)
140  {
141  fill_constant_value_single_channel_special(_tensor, window, _border_size.right, _border_size.bottom, _constant_border_value);
142  }
143  else
144  {
145  fill_constant_value_single_channel(window);
146  }
147  break;
148  }
150  {
151  fill_replicate_single_channel(window);
152  break;
153  }
155  break; // Nothing to do here
156  default:
157  ARM_COMPUTE_ERROR("Unknown border mode");
158  }
159 }
unsigned int top
top of the border
Definition: Types.h:375
const Window & window() const
The maximum window the kernel can be executed on.
Definition: IKernel.cpp:28
#define ARM_COMPUTE_ERROR(msg)
Print the given message then throw an std::runtime_error.
Definition: Error.h:352
virtual DataType data_type() const =0
Data type used for each element of the tensor.
1 channel, 1 F32 per channel
unsigned int bottom
bottom of the border
Definition: Types.h:377
#define ARM_COMPUTE_UNUSED(...)
To avoid unused variables warnings.
Definition: Error.h:152
virtual ITensorInfo * info() const =0
Interface to be implemented by the child class to return the tensor&#39;s metadata.
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_UNCONFIGURED_KERNEL(k)
Definition: Validate.h:941
ScaleKernelInfo info(interpolation_policy, default_border_mode, PixelValue(), sampling_policy, false)
constexpr bool empty() const
Check if the entire border is zero.
Definition: Types.h:300
Borders are left undefined.
Pixels outside the image are assumed to have the same value as the closest image pixel.
#define ARM_COMPUTE_ERROR_ON_INVALID_SUBWINDOW(f, s)
Definition: Validate.h:205

◆ run_op()

void run_op ( ITensorPack tensors,
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]tensorsA vector containing the tensors to operate on.
[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 161 of file NEFillBorderKernel.cpp.

References arm_compute::ACL_SRC_DST, ValidRegion::anchor, BorderSize::bottom, Window::DimY, ITensorInfo::element_size(), arm_compute::execute_window_loop(), ITensorPack::get_tensor(), ITensor::info(), BorderSize::left, Iterator::offset(), Iterator::ptr(), ITensor::ptr_to_element(), BorderSize::right, NEFillBorderKernel::run(), Window::set(), ValidRegion::shape, ITensorInfo::strides_in_bytes(), BorderSize::top, and ITensorInfo::valid_region().

Referenced by NEFillBorderKernel::name().

162 {
163  _tensor = tensors.get_tensor(TensorType::ACL_SRC_DST);
164  run(window, info);
165 }
const Window & window() const
The maximum window the kernel can be executed on.
Definition: IKernel.cpp:28
void run(const Window &window, const ThreadInfo &info) override
Execute the kernel on the passed window.
ScaleKernelInfo info(interpolation_policy, default_border_mode, PixelValue(), sampling_policy, false)

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