24.02.1
|
Go to the documentation of this file.
41 inline void fill_constant_value_single_channel_special(ITensor *
tensor,
45 const PixelValue &constant_border_value)
48 constant_border_value.get(border_value);
55 Window vertical(window);
56 vertical.set(
Window::DimY, Window::Dimension(0, height, 1));
58 Iterator vertical_it(
tensor, vertical);
62 [&](
const Coordinates &)
64 const auto row_start =
reinterpret_cast<float *
>(start_valid_region + vertical_it.offset());
67 *(row_start - 1) = border_value;
68 std::fill_n(row_start + width, right, border_value);
73 Iterator plane_it(
tensor, window);
78 [&](
const Coordinates &)
80 uint8_t *base_addr = start_valid_region + plane_it.offset();
82 const auto row_start =
reinterpret_cast<float *
>(base_addr - stridey);
84 std::fill_n(row_start - 1, 1 + width + right, border_value);
87 const unsigned low_border_size = height + bottom;
88 for (
unsigned int i = height; i < low_border_size; ++i)
90 const auto row_start =
reinterpret_cast<float *
>(base_addr + i * stridey);
93 std::fill_n(row_start - 1, 1 + width + right, border_value);
101 : _tensor(nullptr), _border_size(0), _mode(
BorderMode::
UNDEFINED), _constant_border_value(static_cast<float>(0.f))
126 _constant_border_value = constant_border_value;
134 INEKernel::configure(win);
142 if (_border_size.
empty())
156 fill_constant_value_single_channel_special(_tensor,
window, _border_size.
right, _border_size.
bottom,
157 _constant_border_value);
161 fill_constant_value_single_channel(
window);
167 fill_replicate_single_channel(
window);
183 void NEFillBorderKernel::fill_replicate_single_channel(
const Window &window)
193 Iterator vertical_it(_tensor, vertical);
199 uint8_t *base_addr = start_valid_region + vertical_it.offset();
201 for (
unsigned int i = 0; i < _border_size.
left; ++i)
203 std::memcpy(base_addr +
static_cast<int>(i - _border_size.
left) * element_size, vertical_it.ptr(),
207 for (
unsigned int i = 0; i < _border_size.
right; ++i)
209 std::memcpy(base_addr + (width + i) * element_size, vertical_it.ptr() + (width - 1) * element_size,
216 Iterator plane_it(_tensor,
window);
221 [&](
const Coordinates &)
223 uint8_t *base_addr = start_valid_region + plane_it.offset();
225 for (
int i = -_border_size.
top; i < 0; ++i)
228 std::memcpy(base_addr + i * static_cast<int>(_tensor->info()->strides_in_bytes()[1]) -
229 _border_size.left * element_size,
230 base_addr - _border_size.left * element_size,
231 (_border_size.left + width + _border_size.right) * element_size);
235 for (
unsigned int i = height; i < height + _border_size.
bottom; ++i)
240 _border_size.
left * element_size,
241 (_border_size.
left + width + _border_size.
right) * element_size);
247 void NEFillBorderKernel::fill_constant_value_single_channel(
const Window &window)
257 vertical.set(
Window::DimY, Window::Dimension(0, height, 1));
259 Iterator vertical_it(_tensor, vertical);
263 [&](
const Coordinates &)
265 uint8_t *base_addr = start_valid_region + vertical_it.offset();
267 for (
unsigned int i = 0; i < _border_size.
left; ++i)
269 std::memcpy(base_addr +
static_cast<int>(i - _border_size.
left) * element_size, &_constant_border_value,
273 for (
unsigned int i = 0; i < _border_size.
right; ++i)
275 std::memcpy(base_addr + (width + i) * element_size, &_constant_border_value, element_size);
281 Iterator plane_it(_tensor,
window);
286 [&](
const Coordinates &)
288 uint8_t *base_addr = start_valid_region + plane_it.offset();
290 for (
int i = -_border_size.
top; i < 0; ++i)
293 for (unsigned int j = 0; j < (_border_size.left + width + _border_size.right); ++j)
295 std::memcpy(base_addr + i * stridey + static_cast<int>(j - _border_size.left) * element_size,
296 &_constant_border_value, element_size);
301 const unsigned low_border_size = height + _border_size.
bottom;
302 for (
unsigned int i = height; i < low_border_size; ++i)
305 for (
unsigned int j = 0; j < (_border_size.
left + width + _border_size.
right); ++j)
307 std::memcpy(base_addr + i * stridey +
static_cast<int>(j - _border_size.
left) * element_size,
308 &_constant_border_value, element_size);
virtual ValidRegion valid_region() const =0
Valid region of the tensor.
unsigned int right
right of the border
@ CONSTANT
Pixels outside the image are assumed to have a constant value.
Class describing the value of a pixel for any image format.
Container for 2D border size.
@ UNDEFINED
Borders are left undefined.
void configure(ITensor *tensor, BorderSize border_size, BorderMode border_mode, const PixelValue &constant_border_value=PixelValue())
Initialise the function.
#define ARM_COMPUTE_ERROR_ON_UNCONFIGURED_KERNEL(k)
virtual size_t element_size() const =0
Element size in bytes calculated as data_size() * num_channels()
static constexpr size_t DimX
Alias for dimension 0 also known as X dimension.
ValidRegion valid_region() const override
Valid region of the tensor.
#define ARM_COMPUTE_ERROR(msg)
Print the given message then throw an std::runtime_error.
unsigned int top
top of the border
void use_tensor_dimensions(const TensorShape &shape, size_t first_dimension=Window::DimX)
Use the tensor's dimensions to fill the window dimensions.
Interface for CPU tensor.
const Strides & strides_in_bytes() const override
The strides in bytes for accessing each dimension of the tensor.
ITensor * get_tensor(int id)
Get tensor of a given id from the pac.
virtual BorderSize border_size() const
The size of the border for that kernel.
constexpr bool empty() const
Check if the entire border is zero.
#define ARM_COMPUTE_ERROR_ON_NULLPTR(...)
virtual ITensorInfo * info() const =0
Interface to be implemented by the child class to return the tensor's metadata.
#define ARM_COMPUTE_ERROR_ON(cond)
If the condition is true then an error message is printed and an exception thrown.
unsigned int bottom
bottom of the border
void limit(const BorderSize &limit)
Limit this border size.
void execute_window_loop(const Window &w, L &&lambda_function, Ts &&...iterators)
Iterate through the passed window, automatically adjusting the iterators and calling the lambda_funct...
Iterator updated by execute_window_loop for each window element.
@ REPLICATE
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)
virtual DataType data_type() const =0
Data type used for each element of the tensor.
for(size_t k=0;k< _target.size();++k)
#define ARM_COMPUTE_UNUSED(...)
To avoid unused variables warnings.
CLTensor * tensor
Pointer to the auxiliary tensor.
Describe one of the image's dimensions with a start, end and step.
void run(const Window &window, const ThreadInfo &info) override
Execute the kernel on the passed window.
void set(size_t dimension, const Dimension &dim)
Set the values of a given dimension.
static constexpr size_t DimY
Alias for dimension 1 also known as Y dimension.
const Window & window() const
The maximum window the kernel can be executed on.
Information about executing thread and CPU.
Describe a multidimensional execution window.
TensorShape shape
Shape of the valid region.
void run_op(ITensorPack &tensors, const Window &window, const ThreadInfo &info) override
Execute the kernel on the passed window.
Copyright (c) 2017-2024 Arm Limited.
uint8_t * ptr_to_element(const Coordinates &id) const
Return a pointer to the element at the passed coordinates.
unsigned int left
left of the border
static constexpr size_t DimZ
Alias for dimension 2 also known as Z dimension.
virtual const Strides & strides_in_bytes() const =0
The strides in bytes for accessing each dimension of the tensor.
BorderMode
Methods available to handle borders.
TensorInfo * info() const override
Interface to be implemented by the child class to return the tensor's metadata.
Store the tensor's metadata.
@ F32
32-bit floating-point number
ScaleKernelInfo info(interpolation_policy, default_border_mode, PixelValue(), sampling_policy, false)
@ UNKNOWN
Unknown data type.
NEFillBorderKernel()
Default Constructor.
Coordinates anchor
Anchor for the start of the valid region.