Compute Library
 19.08
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 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...
 
- 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 36 of file NEFillBorderKernel.h.

Constructor & Destructor Documentation

◆ NEFillBorderKernel() [1/3]

Default Constructor.

Definition at line 93 of file NEFillBorderKernel.cpp.

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

References arm_compute::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.

Member Function Documentation

◆ configure()

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: U8/S8/QASYMM8/S16/S32/F32.
[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 98 of file NEFillBorderKernel.cpp.

99 {
100  //Note: ARM_COMPUTE_RETURN_ERROR_ON_CPU_F16_UNSUPPORTED(input) is not needed here as this kernel doesn't use NEON FP16 instructions.
105 
106  _tensor = tensor;
107  _border_size = border_size;
108  _mode = border_mode;
109  _constant_border_value = constant_border_value;
110 
111  _border_size.limit(tensor->info()->padding());
112 
113  Window win;
114  win.set(Window::DimX, Window::Dimension(0, 1, 1));
115  win.set(Window::DimY, Window::Dimension(0, 1, 1));
116  win.use_tensor_dimensions(_tensor->info()->tensor_shape(), Window::DimZ);
117  INEKernel::configure(win);
118 }
1 channel, 1 U8 per channel
1 channel, 1 F32 per channel
1 channel, 1 U16 per channel
1 channel, 1 F16 per channel
1 channel, 1 S32 per channel
static constexpr size_t DimX
Alias for dimension 0 also known as X dimension.
Definition: Window.h:43
1 channel, 1 U32 per channel
virtual const TensorShape & tensor_shape() const =0
Size for each dimension of the tensor.
quantized, asymmetric fixed-point 8-bit number
virtual ITensorInfo * info() const =0
Interface to be implemented by the child class to return the tensor's metadata.
virtual BorderSize border_size() const
The size of the border for that kernel.
Definition: IKernel.cpp:46
1 channel, 1 S16 per channel
#define ARM_COMPUTE_ERROR_ON_DATA_TYPE_CHANNEL_NOT_IN(t, c,...)
Definition: Validate.h:789
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
void limit(const BorderSize &limit)
Limit this border size.
Definition: Types.h:331

References ARM_COMPUTE_ERROR_ON_DATA_TYPE_CHANNEL_NOT_IN, arm_compute::test::validation::border_mode, IKernel::border_size(), Window::DimX, Window::DimY, Window::DimZ, arm_compute::F16, arm_compute::F32, ITensor::info(), BorderSize::limit(), ITensorInfo::padding(), arm_compute::QASYMM8, arm_compute::S16, arm_compute::S32, Window::set(), ITensorInfo::tensor_shape(), arm_compute::U16, arm_compute::U32, arm_compute::U8, and Window::use_tensor_dimensions().

Referenced by NEFillBorder::configure(), NEMeanStdDev::configure(), NEPoolingLayer::configure(), NEReductionOperation::configure(), NEArgMinMaxLayer::configure(), NEScale::configure(), NEDerivative::configure(), NEGaussian5x5::configure(), NENormalizationLayer::configure(), NESobel7x7::configure(), NESobel5x5::configure(), NEFastCorners::configure(), NEDirectConvolutionLayer::configure(), NESoftmaxLayer::configure(), NECannyEdge::configure(), NEHarrisCorners::configure(), and NEDepthwiseConvolutionLayer::configure().

◆ name()

const char* name ( ) const
inlineoverridevirtual

Name of the kernel.

Returns
Kernel name

Implements ICPPKernel.

Definition at line 39 of file NEFillBorderKernel.h.

40  {
41  return "NEFillBorderKernel";
42  }

◆ operator=() [1/2]

NEFillBorderKernel& operator= ( const NEFillBorderKernel )
delete

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

◆ 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.

Implements ICPPKernel.

Definition at line 120 of file NEFillBorderKernel.cpp.

121 {
123 
124  // If there is no border: early exit
125  if(_border_size.empty())
126  {
127  return;
128  }
129 
132 
133  switch(_mode)
134  {
136  {
137  if(_border_size.left == 1 && _border_size.top == 1 && _tensor->info()->data_type() == DataType::F32)
138  {
139  fill_constant_value_single_channel_special(_tensor, window, _border_size.right, _border_size.bottom, _constant_border_value);
140  }
141  else
142  {
143  fill_constant_value_single_channel(window);
144  }
145  break;
146  }
148  {
149  fill_replicate_single_channel(window);
150  break;
151  }
153  break; // Nothing to do here
154  default:
155  ARM_COMPUTE_ERROR("Unknown border mode");
156  }
157 }
#define ARM_COMPUTE_ERROR(...)
Print the given message then throw an std::runtime_error.
Definition: Error.h:261
unsigned int top
top of the border
Definition: Types.h:339
const Window & window() const
The maximum window the kernel can be executed on.
Definition: IKernel.cpp:28
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:341
#define ARM_COMPUTE_UNUSED(...)
To avoid unused variables warnings.
Definition: Error.h:160
virtual ITensorInfo * info() const =0
Interface to be implemented by the child class to return the tensor's metadata.
unsigned int left
left of the border
Definition: Types.h:342
unsigned int right
right of the border
Definition: Types.h:340
constexpr bool empty() const
Check if the entire border is zero.
Definition: Types.h:286
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
#define ARM_COMPUTE_ERROR_ON_UNCONFIGURED_KERNEL(k)
Definition: Validate.h:940

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(), arm_compute::test::validation::info, BorderSize::left, arm_compute::REPLICATE, BorderSize::right, BorderSize::top, arm_compute::UNDEFINED, and IKernel::window().


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