45 : _border_size(0), _input(), _output(), _weights(), _biases(), _conv_stride_x(0), _conv_stride_y(0), _conv_pad_left(0), _conv_pad_top(0), _lws(gles::NDRange(1
U, 1
U, 1
U))
55 unsigned int depth_multiplier)
84 _conv_stride_x = conv_info.
stride().first;
85 _conv_stride_y = conv_info.
stride().second;
86 _conv_pad_left = conv_info.
pad_left();
87 _conv_pad_top = conv_info.
pad_top();
92 std::set<std::string> options;
102 options.emplace((
"#define " + dt_name));
104 unsigned int num_elems_read_per_iteration_x = 8;
105 unsigned int num_elems_read_per_iteration_y = 1;
106 unsigned int num_elems_written_per_iteration_x = 4;
107 unsigned int num_elems_written_per_iteration_y = 1;
108 unsigned int num_elems_written_per_iteration_z = 1;
110 if((_conv_stride_x == 1) && (_conv_stride_y == 1))
114 #define PROCESS_4X_3Y_1Z 117 #if defined(PROCESS_4X_3Y_1Z) 118 options.emplace(
"#define PROCESS_4X_3Y_1Z");
119 num_elems_read_per_iteration_y = 5;
120 num_elems_written_per_iteration_y = 3;
122 #undef PROCESS_4X_3Y_1Z 135 options.emplace(
"#define PROCESS_4X_1Y_1Z");
144 if(_biases !=
nullptr)
146 options.emplace(
"#define BIAS");
150 std::string
kernel_name =
"depthwise_convolution_3x3";
156 const int output_padding_right =
ceil_to_multiple(output_width, num_elems_written_per_iteration_x * _lws[0]) - output_width;
157 const int output_padding_bottom =
ceil_to_multiple(output_height, num_elems_written_per_iteration_y * _lws[1]) - output_height;
163 const int input_total_width = std::max(
int(input->
info()->
padding().
left),
int(_conv_pad_left)) + input_width + std::max(
int(input->
info()->
padding().
right),
int(_conv_pad_left));
164 const int input_total_height = std::max(
int(input->
info()->
padding().
top),
int(_conv_pad_top)) + input_height + std::max(
int(input->
info()->
padding().
bottom),
int(_conv_pad_top));
166 const int input_padding_right =
ceil_to_multiple(input_total_width, num_elems_read_per_iteration_x * _lws[0]) - input_width - _conv_pad_left;
167 const int input_padding_bottom =
ceil_to_multiple(input_total_height, num_elems_read_per_iteration_y * _lws[1]) - input_height - _conv_pad_top;
173 AccessWindowStatic input_access(input->
info(), -_conv_pad_left, -_conv_pad_top, input_width + input_padding_right, input_height + input_padding_bottom);
181 if(_biases !=
nullptr)
192 AccessWindowStatic output_access(output->
info(), 0, 0, output_width + output_padding_right, output_height + output_padding_bottom);
194 if(_biases !=
nullptr)
205 IGCKernel::configure(win);
231 if(_biases !=
nullptr)
243 unsigned int idx = 0;
248 _kernel.update_shader_params();
249 enqueue(*
this, slice_out, _lws);
unsigned int top
top of the border
virtual size_t num_dimensions() const =0
The number of dimensions of the tensor (rank)
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...
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.
TensorShape compute_depthwise_convolution_shape(const ITensorInfo &input, const ITensorInfo &weights, PadStrideInfo conv_info, unsigned int depth_multiplier, const Size2D &dilation=Size2D(1U, 1U))
Calculate the depthwise convolution output shape of a tensor.
virtual size_t dimension(size_t index) const =0
Return the size of the requested dimension.
void shift(size_t dimension, int shift_value)
Shift the values of a given dimension by the given shift_value.
Container for 2D border size.
#define ARM_COMPUTE_ERROR(msg)
Print the given message then throw an std::runtime_error.
constexpr int step() const
Return the step of the dimension.
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.
Interface for GLES Compute tensor.
unsigned int bottom
bottom of the border
unsigned int pad_top() const
Get the top padding.
unsigned int num_arguments_per_3D_tensor() const
Returns the number of arguments enqueued per 3D tensor object.
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
Implementation of a static rectangular access pattern.
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.
virtual const TensorShape & tensor_shape() const =0
Size for each dimension of the tensor.
#define ARM_COMPUTE_ERROR_ON_MISMATCHING_DATA_TYPES(...)
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.
void set_needs_shifting(bool needs_shifting)
Set the flag indicating whether or not a tensor needs shifting.
std::pair< unsigned int, unsigned int > stride() const
Get the stride.
bool auto_init_if_empty(ITensorInfo &info, const TensorShape &shape, int num_channels, DataType data_type, QuantizationInfo quantization_info=QuantizationInfo())
Auto initialize the tensor info (shape, number of channels and data type) if the current assignment i...
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 PaddingSize padding() const =0
Padding of tensor.
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)
#define ARM_COMPUTE_ERROR_ON_DATA_TYPE_CHANNEL_NOT_IN(t, c,...)
static constexpr size_t DimY
Alias for dimension 1 also known as Y dimension.
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.
#define ARM_COMPUTE_ERROR_ON_MISMATCHING_DIMENSIONS(...)
constexpr const Dimension & y() const
Alias to access the second dimension of the window.
void configure(const IGCTensor *input, const IGCTensor *weights, const IGCTensor *biases, IGCTensor *output, const PadStrideInfo &conv_info, unsigned int depth_multiplier=1)
Initialize the function's source, destination, conv and border_size.
Window calculate_max_enlarged_window(const ValidRegion &valid_region, const Steps &steps, BorderSize border_size)
GCKernel create_kernel(const std::string &shader_name, const StringSet &build_options_set={}) const
Creates a kernel from the kernel library.
void run(const Window &window) override
Enqueue the OpenGL ES shader to process the given window.
BorderSize border_size() const override
The size of the border for that kernel.
GCDepthwiseConvolutionLayer3x3Kernel()
Default constructor.
Container for valid region of a window.
void adjust(size_t dimension, int adjust_value, bool is_at_start)
Adjust the start or end of a given dimension by the given value.
unsigned int pad_bottom() const
Get the bottom padding.
Window first_slice_window_3D() const
First 3D slice of the window.
unsigned int pad_left() const
Get the left padding.
Describe a multidimensional execution window.
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...
#define ARM_COMPUTE_ERROR_ON_INVALID_SUBWINDOW(f, s)
constexpr const Dimension & x() const
Alias to access the first dimension of the window.