65 : _input(nullptr), _output(nullptr), _convolved_dims(), _kernel_dims(), _num_elems_processed_per_iteration(1), _run_func(nullptr)
80 std::set<std::string> build_opts;
85 build_opts.insert(
"#define " + dt_name);
89 build_opts.emplace(
"#define HAS_BIAS");
95 std::tie(stride_x, stride_y) = conv_info.
stride();
96 _kernel_dims = std::make_pair(kernel_dims.
width, kernel_dims.
height);
102 && ((stride_x == 1) && (stride_y == 1) && !conv_info.
has_padding())
106 if(!run_img2col_reduced)
110 build_opts.emplace(
"#define KERNEL_1x1");
113 build_opts.emplace(
"#define IM2COL_GENERIC");
135 _run_func = &GCIm2ColKernel::run_generic;
139 build_opts.emplace(
"#define IM2COL_REDUCED");
140 kernel_name =
"im2col_reduced";
152 if(input_width % 8 == 0)
154 _num_elems_processed_per_iteration = 8;
155 build_opts.emplace(
"#define IM2COL_REDUCED_8X");
157 else if(input_width % 4 == 0)
159 _num_elems_processed_per_iteration = 4;
160 build_opts.emplace(
"#define IM2COL_REDUCED_4X");
162 else if(input_width % 2 == 0)
164 _num_elems_processed_per_iteration = 2;
165 build_opts.emplace(
"#define IM2COL_REDUCED_2X");
169 _num_elems_processed_per_iteration = 2;
170 build_opts.emplace(
"#define IM2COL_REDUCED_GENERIC");
174 _run_func = &GCIm2ColKernel::run_reduced;
189 int input_padding_right =
ceil_to_multiple(input_total_width, _num_elems_processed_per_iteration) - input_total_width;
190 input_total_width = input_width + input_padding_right + input->
info()->
padding().
right;
196 const int output_padding_right =
ceil_to_multiple(output_width, _num_elems_processed_per_iteration) - output_width;
197 AccessWindowStatic output_access(output->
info(), 0, 0, output_width + output_padding_right, output_height);
204 if(!run_img2col_reduced)
210 IGCKernel::configure(win);
226 (this->*_run_func)(window);
264 unsigned int idx = 0;
269 _kernel.update_shader_params();
276 void GCIm2ColKernel::run_reduced(
const Window &window)
293 unsigned int idx = 0;
299 _kernel.update_shader_params();
void configure(const IGCTensor *input, IGCTensor *output, const Size2D &kernel_dims, const PadStrideInfo &conv_info, bool has_bias, const Size2D &dilation=Size2D(1U, 1U))
Set the input and output of the kernel.
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 add_3D_tensor_argument(unsigned int &idx, const IGCTensor *tensor, const unsigned int binding_point, const Window &window)
Add the passed 3D tensor's parameters to the object's kernel's arguments starting from the index idx...
static Status validate(const ITensorInfo *input, const ITensorInfo *output, const Size2D &kernel_dims, const PadStrideInfo &conv_info, bool has_bias, const Size2D &dilation=Size2D(1U, 1U))
Static function to check if given info will lead to a valid configuration of CLIm2ColKernel.
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.
virtual size_t dimension(size_t index) const =0
Return the size of the requested dimension.
#define ARM_COMPUTE_RETURN_ON_ERROR(status)
Checks if a status contains an error and returns it.
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.
1 channel, 1 F32 per channel
const size_t input_height
#define ARM_COMPUTE_ERROR_ON(cond)
If the condition is true then an error message is printed and an exception thrown.
void run(const Window &window) override
Enqueue the OpenGL ES shader to process the given window.
Store the tensor's metadata.
Interface for GLES Compute tensor.
#define ARM_COMPUTE_ERROR_THROW_ON(status)
Describe one of the image's dimensions with a start, end and step.
size_t x() const
Semantic accessor for width as x.
unsigned int pad_top() const
Get the top padding.
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.
virtual void set_valid_region(const ValidRegion &valid_region)=0
Set the valid region of the tensor.
size_t height
Height of the image region or rectangle.
1 channel, 1 F16 per channel
std::pair< unsigned int, unsigned int > scaled_dimensions(int width, int height, int kernel_width, int kernel_height, const PadStrideInfo &pad_stride_info, const Size2D &dilation=Size2D(1U, 1U))
Returns expected width and height of output scaled tensor depending on dimensions rounding mode...
Implementation of a static rectangular access pattern.
#define ARM_COMPUTE_RETURN_ERROR_ON_NULLPTR(...)
static constexpr size_t DimX
Alias for dimension 0 also known as X dimension.
bool update_window_and_padding(Window &win, Ts &&... patterns)
Update window and padding size for each of the access patterns.
#define ARM_COMPUTE_UNUSED(...)
To avoid unused variables warnings.
#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.
virtual const TensorShape & tensor_shape() const =0
Size for each dimension of the tensor.
auto ceil_to_multiple(S value, T divisor) -> decltype(((value+divisor - 1)/divisor) *divisor)
Computes the smallest number larger or equal to value that is a multiple of divisor.
Manages all the GLES kernels compilation and caching, provides accessors for the GLES Context...
Class to describe a number of elements in each dimension.
std::pair< unsigned int, unsigned int > stride() const
Get the stride.
GCIm2ColKernel()
Default constructor.
virtual ITensorInfo * info() const =0
Interface to be implemented by the child class to return the tensor's metadata.
unsigned int pad_right() const
Get the right padding.
Padding and stride information class.
virtual size_t element_size() const =0
Element size in bytes calculated as data_size() * num_channels()
void end(TokenStream &in, bool &valid)
void set(size_t dimension, const Dimension &dim)
Set the values of a given dimension.
virtual PaddingSize padding() const =0
Padding of tensor.
void add_2D_tensor_argument(unsigned int &idx, const IGCTensor *tensor, const unsigned int binding_point, const Window &window)
Add the passed 2D tensor's parameters to the object's kernel's arguments starting from the index idx...
unsigned int left
left of the border
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)
size_t y() const
Semantic accessor for height as y.
std::array< T, num_max_dimensions >::const_iterator cend() const
Returns a read-only (constant) iterator that points one past the last element in the dimension array...
static constexpr size_t DimY
Alias for dimension 1 also known as Y dimension.
Wrapper to configure the Khronos EGL and OpenGL ES C header.
static GCKernelLibrary & get()
Get the static instance of GCKernelLibrary.
void set_dimension_step(size_t dimension, int step)
Set the step of a given dimension.
std::array< T, num_max_dimensions >::const_iterator cbegin() const
Returns a read-only (constant) iterator that points to the first element in the dimension array...
virtual size_t total_size() const =0
Returns the total size of the tensor in bytes.
size_t width
Width of the image region or rectangle.
static constexpr size_t DimZ
Alias for dimension 2 also known as Z dimension.
Class for specifying the size of an image or rectangle.
#define ARM_COMPUTE_RETURN_ERROR_ON_MISMATCHING_DATA_TYPES(...)
#define ARM_COMPUTE_RETURN_ERROR_ON_DATA_TYPE_CHANNEL_NOT_IN(t, c,...)
Status validate_arguments(const ITensorInfo *input, const ITensorInfo *bias, const ITensorInfo *output, const GEMMLowpOutputStageInfo *output_stage)
GCKernel create_kernel(const std::string &shader_name, const StringSet &build_options_set={}) const
Creates a kernel from the kernel library.
#define ARM_COMPUTE_ERROR_ON_NULLPTR(...)
Store the tensor's metadata.
virtual const Strides & strides_in_bytes() const =0
The strides in bytes for accessing each dimension of the tensor.
Container for valid region of a window.
unsigned int pad_bottom() const
Get the bottom padding.
static constexpr size_t num_max_dimensions
Number of dimensions the tensor has.
Window first_slice_window_3D() const
First 3D slice of the window.
unsigned int pad_left() const
Get the left padding.
bool slide_window_slice_1D(Window &slice) const
Slide the passed 1D window slice.
Describe a multidimensional execution window.
virtual size_t num_channels() const =0
The number of channels for each tensor element.
void add_1D_tensor_argument(unsigned int &idx, const IGCTensor *tensor, const unsigned int binding_point, const Window &window)
Add the passed 1D tensor's parameters to the object's kernel's arguments starting from the index idx...
Window first_slice_window_1D() const
First 1D slice of the window.
SimpleTensor< T > slice(const SimpleTensor< T > &src, Coordinates starts, Coordinates ends)
bool has_padding() const
Check whether this has any padding.