56 Status
validate_arguments(
const ITensorInfo *
input,
const ITensorInfo *
bias,
const ITensorInfo *output,
const WinogradInfo &winograd_info,
const ActivationLayerInfo &act_info)
64 const PadStrideInfo
conv_info = winograd_info.convolution_info;
65 const Size2D output_tile_size = winograd_info.output_tile_size;
66 const Size2D kernel_size = winograd_info.kernel_size;
67 const Size2D input_dimensions = winograd_info.input_dimensions;
68 const unsigned int num_channels = (winograd_info.kernel_size.width + winograd_info.output_tile_size.width - 1) * (winograd_info.kernel_size.height + winograd_info.output_tile_size.height - 1);
89 if(output->total_size() != 0)
100 std::pair<Status, Window>
validate_and_configure_window(ITensorInfo *input, ITensorInfo *bias, ITensorInfo *output,
const Size2D &output_tile_size)
108 bool window_changed =
false;
112 const int output_static_window_end_x =
ceil_to_multiple(output->dimension(0), output_tile_size.width);
113 const int output_static_window_end_y =
ceil_to_multiple(output->dimension(1), output_tile_size.height);
115 AccessWindowRectangle input_access(input, 0, 0, num_elems_processed_per_iteration, num_elems_processed_per_iteration);
116 AccessWindowStatic output_access(output, 0, 0, output_static_window_end_x, output_static_window_end_y);
121 return std::make_pair(err, win);
143 IClKernel::configure_internal(win_config.second);
170 if((output_tile_size.
x() == 2) || (output_tile_size.
x() == 1 && output_tile_size.
y() == 2))
174 else if((output_tile_size.
x() == 4) || (output_tile_size.
x() == 1 && output_tile_size.
y() == 4))
179 _num_tiles_x = num_tiles.
width;
182 const GPUTarget gpu_target = get_target();
183 const auto act_function = act_info.
activation();
184 const auto src_data_type = src->
data_type();
192 build_opts.
add_option(
"-cl-unsafe-math-optimizations");
196 build_opts.
add_option(
"-cl-fast-relaxed-math");
201 build_opts.
add_option_if(bias !=
nullptr, std::string(
"-DHAS_BIAS"));
213 build_opts.
add_option_if(bias !=
nullptr, std::string(
"-DHAS_BIAS"));
230 _dst_height = dst->
dimension(idx_height);
277 Window slice = window_collapsed.first_slice_window_4D();
287 unsigned int idx1 = 2 * num_arguments_per_4D_tensor();
290 add_1D_tensor_argument(idx1, bias, slice_biases);
295 unsigned int idx2 = 2 * num_arguments_per_4D_tensor() + ((bias !=
nullptr) ? num_arguments_per_1D_tensor() : 0);
296 _kernel.setArg(idx2++, static_cast<int>(dst->info()->total_size() - dst->info()->strides_in_bytes().y()));
297 _kernel.setArg<cl_int>(idx2++, _src_height);
298 _kernel.setArg<cl_int>(idx2++, _dst_width);
299 _kernel.setArg<cl_int>(idx2++, _dst_height);
304 unsigned int idx = 0;
305 add_4D_tensor_argument(idx,
src, slice);
306 add_4D_tensor_argument(idx, dst, slice_out);
307 enqueue(queue, *
this, slice, lws_hint());
Window calculate_max_window(const ValidRegion &valid_region, const Steps &steps, bool skip_border, BorderSize border_size)
#define ARM_COMPUTE_RETURN_ERROR_ON_F16_UNSUPPORTED(tensor)
DataLayout output_data_layout
Data layout to use for the output tensor once the convolution has been applied (NCHW or NHWC) ...
bool enabled() const
Check if initialised.
virtual size_t dimension(size_t index) const =0
Return the size of the requested dimension.
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.
float a() const
Get the alpha value.
PadStrideInfo convolution_info
Convolution info (Pads, strides,...)
#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
#define ARM_COMPUTE_ERROR_ON(cond)
If the condition is true then an error message is printed and an exception thrown.
const std::string & string_from_activation_func(ActivationLayerInfo::ActivationFunction act)
Translates a given activation function to a string.
size_t total_size_upper(size_t dimension) const
Collapses given dimension and above.
Store the tensor's metadata.
#define ARM_COMPUTE_ERROR_THROW_ON(status)
Describe one of the image's dimensions with a start, end and step.
Size2D compute_winograd_convolution_tiles(const Size2D &in_dims, const Size2D &kernel_size, const Size2D &output_tile_size, const PadStrideInfo &conv_info)
Calculate the number of output tiles required by Winograd Convolution layer.
Manages all the OpenCL kernels compilation and caching, provides accessors for the OpenCL Context...
size_t x() const
Semantic accessor for width as x.
std::string lower_string(const std::string &val)
Lower a given string.
Status validate_arguments(const ITensorInfo *src, const ITensorInfo *weights, const ITensorInfo *dst, const PadStrideInfo &conv_info)
#define ARM_COMPUTE_RETURN_ERROR_ON(cond)
If the condition is true, an error is returned.
Activation Layer Information class.
void use_tensor_dimensions(const TensorShape &shape, size_t first_dimension=Window::DimX)
Use the tensor's dimensions to fill the window dimensions.
SimpleTensor< float > src
Copyright (c) 2017-2022 Arm Limited.
size_t height
Height of the image region or rectangle.
1 channel, 1 F16 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.
std::string upper_string(const std::string &val)
Raise a given string to upper case.
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.
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.
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.
std::string float_to_string_with_full_precision(float val)
Create a string with the float in full precision.
virtual const TensorShape & tensor_shape() const =0
Size for each dimension of the tensor.
Size2D output_tile_size
Width and height of the output tile.
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.
unsigned int num_elems_processed_per_iteration
std::string get_cl_type_from_data_type(const DataType &dt)
Translates a tensor data type to the appropriate OpenCL type.
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 std::unique_ptr< T > clone() const =0
Provide a clone of the current object of class T.
void add_option_if(bool cond, std::string option)
Adds option if a given condition is true;.
Padding and stride information class.
void set(size_t dimension, const Dimension &dim)
Set the values of a given dimension.
bool slide_window_slice_3D(Window &slice) const
Slide the passed 3D window slice.
#define ARM_COMPUTE_ERROR_ON_UNCONFIGURED_KERNEL(k)
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.
Num samples, channels, height, width.
size_t y() const
Semantic accessor for height as y.
Convolution using Winograd.
Lower and Upper Bounded Rectifier ( )
static constexpr size_t DimY
Alias for dimension 1 also known as Y dimension.
std::pair< Status, Window > validate_and_configure_window(ITensorInfo *src, ITensorInfo *dst)
ITensor * get_tensor(int id)
Get tensor of a given id from the pac.
const std::string & string_from_data_layout(DataLayout dl)
Convert a data layout identity into a string.
Upper Bounded Rectifier ( )
TensorShape compute_winograd_output_transform_shape(const ITensorInfo &input, const WinogradInfo &winograd_info)
Calculate the winograd output transform shape.
#define ARM_COMPUTE_RETURN_ERROR_ON_MISMATCHING_SHAPES(...)
#define ARM_COMPUTE_CREATE_ERROR(error_code, msg)
Creates an error with a given message.
size_t width
Width of the image region or rectangle.
static constexpr size_t DimZ
Alias for dimension 2 also known as Z dimension.
GPUTarget
Available GPU Targets.
size_t get_data_layout_dimension_index(const DataLayout &data_layout, const DataLayoutDimension &data_layout_dimension)
Get the index of the given dimension.
Class for specifying the size of an image or rectangle.
#define ARM_COMPUTE_RETURN_ERROR_ON_MISMATCHING_DATA_TYPES(...)
Num samples, height, width, channels.
#define ARM_COMPUTE_RETURN_ERROR_ON_DATA_TYPE_CHANNEL_NOT_IN(t, c,...)
std::unordered_map< const ITensorInfo *, PaddingSize > get_padding_info(std::initializer_list< const ITensorInfo *> infos)
Stores padding information before configuring a kernel.
#define ARM_COMPUTE_RETURN_ERROR_ON_MSG(cond, msg)
If the condition is true, an error is returned.
Size2D kernel_size
Width and height of the kernel.
#define ARM_COMPUTE_ERROR_ON_NULLPTR(...)
ActivationFunction activation() const
Get the type of activation function.
float b() const
Get the beta value.
bool cl_winograd_convolution_layer_supported(const Size2D &output_tile, const Size2D &kernel_size, DataLayout data_layout)
This function checks if the Winograd configuration (defined through the output tile, kernel size and the data layout) is supported on OpenCL.
Size2D input_dimensions
Width and height of the input tensor before the convolution is applied.
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)
std::string to_string() const