54 constant_border_value.
get(value);
55 ICLKernel::add_argument<T>(idx,
static_cast<T
>(value));
102 const cl_int2 valid_region_coords =
109 const unsigned int total_valid_width = border_size.
left + valid_width + border_size.
right;
113 ICLKernel::add_argument<cl_uint>(idx, valid_width);
114 ICLKernel::add_argument<cl_uint>(idx, valid_height);
115 ICLKernel::add_argument<cl_int2>(idx, valid_region_coords);
122 set_constant_border<uint8_t>(idx, constant_border_value);
126 set_constant_border<int8_t>(idx, constant_border_value);
129 set_constant_border<uint16_t>(idx, constant_border_value);
132 set_constant_border<int16_t>(idx, constant_border_value);
135 set_constant_border<uint32_t>(idx, constant_border_value);
138 set_constant_border<int32_t>(idx, constant_border_value);
141 static_assert(
sizeof(
float) == 4,
"Float must be 32 bit");
142 set_constant_border<float>(idx, constant_border_value);
145 static_assert(
sizeof(cl_half) ==
sizeof(
half),
"Half must be same size as cl_half");
146 static_assert(
sizeof(cl_half) == 2,
"Half must be 16 bit");
147 set_constant_border<half>(idx, constant_border_value);
159 ICLKernel::configure_internal(win);
177 if(_kernel() ==
nullptr)
192 unsigned int idx = 0;
202 if(_kernel() ==
nullptr)
215 unsigned int idx = 0;
BorderMode
Methods available to handle borders.
void run_op(ITensorPack &tensors, const Window &window, cl::CommandQueue &queue) override
Enqueue the OpenCL kernel to process the given window on the passed OpenCL command queue...
unsigned int top
top of the border
Class describing the value of a pixel for any image format.
void configure(const CLCompileContext &compile_context, ICLTensor *tensor, BorderSize border_size, BorderMode border_mode, const PixelValue &constant_border_value=PixelValue())
Initialise the kernel's input, output and border mode.
const Window & window() const
The maximum window the kernel can be executed on.
TensorShape shape
Shape of the valid region.
virtual size_t dimension(size_t index) const =0
Return the size of the requested dimension.
Container for 2D border size.
void enqueue(cl::CommandQueue &queue, ICLKernel &kernel, const Window &window, const cl::NDRange &lws_hint=CLKernelLibrary::get().default_ndrange(), bool use_dummy_work_items=false)
Add the kernel to the command queue with the given window.
const StringSet & options() const
Gets the current options list set.
#define ARM_COMPUTE_ERROR(msg)
Print the given message then throw an std::runtime_error.
cl::NDRange lws_hint() const
Return the Local-Workgroup-Size hint.
1 channel, 1 U8 per channel
void get(uint8_t &v) const
Interpret the pixel value as a U8.
std::string to_string(T &&value)
Convert integer and float values to string.
virtual DataType data_type() const =0
Data type used for each element of the tensor.
half_float::half half
16-bit floating point type
1 channel, 1 F32 per channel
#define ARM_COMPUTE_ERROR_ON(cond)
If the condition is true then an error message is printed and an exception thrown.
bool is_parallelisable() const override
Indicates whether or not the kernel is parallelisable.
static CLKernelLibrary & get()
Access the KernelLibrary singleton.
Store the tensor's metadata.
Describe one of the image's dimensions with a start, end and step.
1 channel, 1 U16 per channel
unsigned int bottom
bottom of the border
Manages all the OpenCL kernels compilation and caching, provides accessors for the OpenCL Context...
std::string lower_string(const std::string &val)
Lower a given string.
Common interface for all the OpenCL kernels.
void set_constant_border(unsigned int idx, const PixelValue &constant_border_value)
Function to set the constant value on fill border kernel depending on type.
void add_3D_tensor_argument(unsigned int &idx, const ICLTensor *tensor, const Window &window)
Add the passed 3D tensor's parameters to the object's kernel's arguments starting from the index idx...
void use_tensor_dimensions(const TensorShape &shape, size_t first_dimension=Window::DimX)
Use the tensor's dimensions to fill the window dimensions.
Copyright (c) 2017-2021 Arm Limited.
1 channel, 1 F16 per channel
virtual ValidRegion valid_region() const =0
Valid region of the tensor.
const std::string & string_from_border_mode(BorderMode border_mode)
Translates a given border mode policy to a string.
1 channel, 1 S32 per channel
void add_option(std::string option)
Adds option to the existing build option list.
const ITensor * get_const_tensor(int id) const
Get constant tensor of a given id.
cl::Kernel create_kernel(const CLCompileContext &ctx, const std::string &kernel_name, const std::set< std::string > &build_opts=std::set< std::string >())
Creates an opencl kernel using a compile context.
const std::string & string_from_data_type(DataType dt)
Convert a data type identity into a string.
static constexpr size_t DimX
Alias for dimension 0 also known as X dimension.
static constexpr unsigned int num_arguments_per_3D_tensor()
Returns the number of arguments enqueued per 3D tensor object.
#define ARM_COMPUTE_ERROR_ON_MISMATCHING_WINDOWS(f, w)
Window collapse_if_possible(const Window &full_window, size_t first, size_t last, bool *has_collapsed=nullptr) const
Collapse the dimensions between first and last if possible.
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 unsigned
std::string get_cl_type_from_data_type(const DataType &dt)
Translates a tensor data type to the appropriate OpenCL type.
CLFillBorderKernel()
Default constructor.
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.
void set(size_t dimension, const Dimension &dim)
Set the values of a given dimension.
virtual PaddingSize padding() const =0
Padding of tensor.
unsigned int left
left of the border
Elementeise CL kernel type.
bool slide_window_slice_3D(Window &slice) const
Slide the passed 3D window slice.
unsigned int right
right of the border
#define ARM_COMPUTE_ERROR_ON_UNCONFIGURED_KERNEL(k)
1 channel, 1 S16 per channel
bool has_padding_changed(const std::unordered_map< const ITensorInfo *, PaddingSize > &padding_map)
Check if the previously stored padding info has changed after configuring a kernel.
void run(const Window &window, cl::CommandQueue &queue) override
Enqueue the OpenCL kernel to process the given window on the passed OpenCL command queue...
static constexpr size_t DimY
Alias for dimension 1 also known as Y dimension.
Interface for OpenCL tensor.
constexpr bool empty() const
Check if the entire border is zero.
static constexpr size_t DimZ
Alias for dimension 2 also known as Z dimension.
Borders are left undefined.
std::unordered_map< const ITensorInfo *, PaddingSize > get_padding_info(std::initializer_list< const ITensorInfo *> infos)
Stores padding information before configuring a kernel.
Wrapper to configure the Khronos OpenCL C++ header.
quantized, asymmetric fixed-point 8-bit number signed
Window first_slice_window_3D() const
First 3D slice of the window.
DataType
Available data types.
Describe a multidimensional execution window.
virtual size_t num_channels() const =0
The number of channels for each tensor element.
void limit(const BorderSize &limit)
Limit this border size.
Coordinates anchor
Anchor for the start of the valid region.
SimpleTensor< T > slice(const SimpleTensor< T > &src, Coordinates starts, Coordinates ends)