47 constexpr
unsigned int max_matrix_size = 81;
54 template <
unsigned int matrix_size>
60 template <
unsigned int matrix_size>
66 template <
unsigned int matrix_size>
78 kernel_name <<
"convolution" << matrix_size <<
"x" << matrix_size <<
"_static";
85 for(
unsigned int i = 0; i < matrix_size * matrix_size; i++)
87 std::stringstream mat_str;
88 mat_str <<
"-DMAT" << i <<
"=" << conv[i];
97 std::stringstream out_type;
105 constexpr
unsigned int num_elems_written_per_iteration = 8;
106 constexpr
unsigned int num_elems_read_per_iteration = 16;
107 constexpr
unsigned int num_rows_read_per_iteration = matrix_size;
111 AccessWindowRectangle input_access(input->
info(), -border_size().left, -border_size().top, num_elems_read_per_iteration, num_rows_read_per_iteration);
116 output_access.set_valid_region(win, input->
info()->
valid_region(), border_undefined, border_size());
118 ICLKernel::configure_internal(win);
124 template <
unsigned int matrix_size>
130 template <
unsigned int matrix_size>
136 template <
unsigned int matrix_size>
142 template <
unsigned int matrix_size>
152 _border_size =
BorderSize(border_undefined ? 0 : matrix_size / 2, matrix_size / 2);
155 std::set<std::string> build_opts;
157 std::array<int16_t, matrix_size *matrix_size> mat = { 0 };
158 memcpy(mat.data(), conv, matrix_size *
sizeof(int16_t));
160 for(
unsigned int j = 0; j < matrix_size * matrix_size; j++)
165 build_opts.insert(
"-DSCALE=0");
171 _kernel =
create_kernel(compile_context, kernel_name, build_opts);
175 constexpr
unsigned int num_elems_read_per_iteration = 16;
176 constexpr
unsigned int num_elems_written_per_iteration = 8;
187 ICLKernel::configure_internal(win);
205 template <
unsigned int matrix_size>
211 template <
unsigned int matrix_size>
218 template <
unsigned int matrix_size>
230 std::set<std::string> build_opts;
232 std::array<int16_t, matrix_size *matrix_size> mat = { 0 };
233 memcpy(mat.data() + matrix_size, conv, matrix_size *
sizeof(int16_t));
235 for(
unsigned int j = 0; j < matrix_size * matrix_size; j++)
246 std::stringstream out_type;
248 build_opts.insert(out_type.str());
252 _kernel =
create_kernel(compile_context, kernel_name, build_opts);
256 constexpr
unsigned int num_elems_written_per_iteration = 8;
257 constexpr
unsigned int num_elems_read_per_iteration = 8;
258 constexpr
unsigned int num_rows_read_per_iteration = matrix_size;
269 ICLKernel::configure_internal(win);
292 : _border_size(0), _input(nullptr), _output(nullptr)
307 bool border_undefined)
318 _border_size =
BorderSize(height / 2, width / 2);
320 std::set<std::string> options;
322 std::stringstream output_type;
324 options.insert(output_type.str());
326 uint32_t matrix_size = width * height;
328 std::array<int16_t, max_matrix_size> mat = { 0 };
330 memcpy(mat.data(), conv, matrix_size *
sizeof(int16_t));
332 for(
unsigned int j = 0; j < max_matrix_size; j++)
345 _kernel =
create_kernel(compile_context,
"convolution_rectangle", options);
349 constexpr
unsigned int num_elems_read_per_iteration = 16;
350 constexpr
unsigned int num_elems_written_per_iteration = 8;
351 const unsigned int num_rows_read_per_iteration = height;
362 ICLKernel::configure_internal(win);
374 unsigned int idx = 0;
Window first_slice_window_2D() const
First 2D slice of the window.
unsigned int top
top of the border
Window calculate_max_window(const ValidRegion &valid_region, const Steps &steps, bool skip_border, BorderSize border_size)
const Window & window() const
The maximum window the kernel can be executed on.
void enqueue(IGCKernel &kernel, const Window &window, const gles::NDRange &lws=gles::NDRange(1U, 1U, 1U))
Add the kernel to the command queue with the given window.
Kernel for the Horizontal pass of a Separable Convolution.
virtual size_t dimension(size_t index) const =0
Return the size of the requested dimension.
Container for 2D border size.
const StringSet & options() const
Gets the current options list set.
cl::NDRange lws_hint() const
Return the Local-Workgroup-Size hint.
1 channel, 1 U8 per channel
std::string to_string(T &&value)
Convert integer and float values to string.
void configure(const ICLTensor *input, ICLTensor *output, const int16_t *conv, uint32_t scale, bool border_undefined)
Initialise the kernel's input, output and border mode.
virtual DataType data_type() const =0
Data type used for each element of the tensor.
BorderSize border_size() const override
The size of the border for that kernel.
#define ARM_COMPUTE_ERROR_ON(cond)
If the condition is true then an error message is printed and an exception thrown.
static CLKernelLibrary & get()
Access the KernelLibrary singleton.
1 channel, 1 U16 per channel
std::string lower_string(const std::string &val)
Lower a given string.
uint32_t calculate_matrix_scale(const int16_t *matrix, unsigned int matrix_size)
Calculate the scale of the given square matrix.
Window calculate_max_window_horizontal(const ValidRegion &valid_region, const Steps &steps, bool skip_border, BorderSize border_size)
bool slide_window_slice_2D(Window &slice) const
Slide the passed 2D window slice.
Copyright (c) 2017-2021 Arm Limited.
virtual ValidRegion valid_region() const =0
Valid region of the tensor.
1 channel, 1 S32 per channel
void add_option(std::string option)
Adds option to the existing build option list.
void configure(const ICLTensor *input, ICLTensor *output, const int16_t *conv, uint32_t scale, bool border_undefined, DataType data_type=DataType::S32)
Initialise the kernel's input, output and border mode.
Implementation of a rectangular access pattern.
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.
bool update_window_and_padding(Window &win, Ts &&... patterns)
Update window and padding size for each of the access patterns.
Class to describe a number of elements in each dimension.
BorderSize border_size() const override
The size of the border for that kernel.
Implementation of a row access pattern.
std::string get_cl_type_from_data_type(const DataType &dt)
Translates a tensor data type to the appropriate OpenCL type.
virtual ITensorInfo * info() const =0
Interface to be implemented by the child class to return the tensor's metadata.
Interface for the kernel to run an arbitrary size convolution on a tensor.
unsigned int left
left of the border
BorderSize border_size() const override
The size of the border for that kernel.
#define ARM_COMPUTE_ERROR_ON_UNCONFIGURED_KERNEL(k)
1 channel, 1 S16 per channel
Kernel for the Vertical pass of a Separable Convolution.
#define ARM_COMPUTE_ERROR_ON_DATA_TYPE_CHANNEL_NOT_IN(t, c,...)
CLConvolutionRectangleKernel()
Default constructor.
void configure(const ICLTensor *input, ICLTensor *output, const int16_t *conv, bool border_undefined)
Initialise the kernel's input, output and border mode.
CLSeparableConvolutionHorKernel()
Default Constructor.
void add_2D_tensor_argument(unsigned int &idx, const ICLTensor *tensor, const Window &window)
Add the passed 2D tensor's parameters to the object's kernel's arguments starting from the index idx...
Interface for OpenCL tensor.
Manages all the OpenCL kernels compilation and caching, provides accessors for the OpenCL Context...
Wrapper to configure the Khronos OpenCL C++ header.
BorderSize border_size() const override
The size of the border for that kernel.
void configure(const ICLTensor *input, ICLTensor *output, const int16_t *conv, uint32_t width, uint32_t height, uint32_t scale, bool border_undefined)
Initialise the kernel's input, output and border mode.
unsigned int num_elems_processed_per_iteration
void run(const Window &window, cl::CommandQueue &queue) override
Enqueue the OpenCL kernel to process the given window on the passed OpenCL command queue...
DataType
Available data types.
Describe a multidimensional execution window.
#define ARM_COMPUTE_ERROR_ON_INVALID_SUBWINDOW(f, s)
SimpleTensor< T > slice(const SimpleTensor< T > &src, Coordinates starts, Coordinates ends)
DataType data_type_for_convolution_matrix(const int16_t *conv, size_t size)
Calculate the accuracy required by the squared convolution calculation.