24.02.1
|
Go to the documentation of this file.
59 const ITensorInfo *
bias,
60 const ITensorInfo *output,
61 const WinogradInfo &winograd_info,
70 const PadStrideInfo
conv_info = winograd_info.convolution_info;
71 const Size2D output_tile_size = winograd_info.output_tile_size;
72 const Size2D kernel_size = winograd_info.kernel_size;
73 const Size2D input_dimensions = winograd_info.input_dimensions;
74 const unsigned int num_channels = (winograd_info.kernel_size.width + winograd_info.output_tile_size.width - 1) *
75 (winograd_info.kernel_size.height + winograd_info.output_tile_size.height - 1);
79 "Winograd output transform not supported");
84 const Size2D num_tiles =
96 if (output->total_size() != 0)
98 const TensorInfo tensor_info_output =
111 const Size2D &output_tile_size)
126 const size_t dim0 =
input->dimension(0);
135 bool window_changed =
false;
139 const int output_static_window_end_x =
ceil_to_multiple(output->dimension(0), output_tile_size.width);
140 const int output_static_window_end_y =
ceil_to_multiple(output->dimension(1), output_tile_size.height);
144 AccessWindowStatic output_access(output, 0, 0, output_static_window_end_x, output_static_window_end_y);
150 return std::make_pair(err, win);
177 IClKernel::configure_internal(win_config.second);
195 const size_t total_batches =
dst->tensor_shape().total_size_upper(3);
203 if ((output_tile_size.
x() == 2) || (output_tile_size.
x() == 1 && output_tile_size.
y() == 2))
207 else if ((output_tile_size.
x() == 4) || (output_tile_size.
x() == 1 && output_tile_size.
y() == 4))
212 _num_tiles_x = num_tiles.
width;
215 const GPUTarget gpu_target = get_target();
216 const auto act_function =
act_info.activation();
217 const auto src_data_type =
src->data_type();
220 (act_function == ActivationLayerInfo::ActivationFunction::BOUNDED_RELU ||
221 act_function == ActivationLayerInfo::ActivationFunction::LU_BOUNDED_RELU) &&
226 build_opts.
add_option(
"-cl-unsafe-math-optimizations");
230 build_opts.
add_option(
"-cl-fast-relaxed-math");
262 _src_height =
src->dimension(1);
302 (
bias !=
nullptr ?
bias->clone().get() :
nullptr),
331 unsigned int idx1 = 2 * num_arguments_per_4D_tensor();
334 add_1D_tensor_argument(idx1,
bias, slice_biases);
339 unsigned int idx2 = 2 * num_arguments_per_4D_tensor() + ((
bias !=
nullptr) ? num_arguments_per_1D_tensor() : 0);
340 _kernel.setArg(idx2++,
static_cast<int>(
dst->info()->total_size() -
dst->info()->strides_in_bytes().y()));
341 _kernel.setArg<cl_int>(idx2++, _src_height);
342 _kernel.setArg<cl_int>(idx2++, _dst_width);
343 _kernel.setArg<cl_int>(idx2++, _dst_height);
348 unsigned int idx = 0;
349 add_4D_tensor_argument(idx,
src,
slice);
350 add_4D_tensor_argument(idx,
dst, slice_out);
@ NCHW
Num samples, channels, height, width.
std::string to_string(T &&value)
Convert integer and float values to string.
size_t y() const
Semantic accessor for height as y.
SimpleTensor< float > src
DataLayout output_data_layout
Data layout to use for the output tensor once the convolution has been applied (NCHW or NHWC)
const StringSet & options() const
Gets the current options list set.
Window calculate_max_window(const ValidRegion &valid_region, const Steps &steps, bool skip_border, BorderSize border_size)
@ NHWC
Num samples, height, width, channels.
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.
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_ERROR_ON_UNCONFIGURED_KERNEL(k)
#define ARM_COMPUTE_RETURN_ERROR_ON_MISMATCHING_SHAPES(...)
Size2D output_tile_size
Width and height of the output tile.
static constexpr size_t DimX
Alias for dimension 0 also known as X dimension.
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.
Size2D input_dimensions
Width and height of the input tensor before the convolution is applied.
Class for specifying the size of an image or rectangle.
void use_tensor_dimensions(const TensorShape &shape, size_t first_dimension=Window::DimX)
Use the tensor's dimensions to fill the window dimensions.
size_t height
Height of the image region or rectangle.
bool update_window_and_padding(Window &win, Ts &&...patterns)
Update window and padding size for each of the access patterns.
ITensor * get_tensor(int id)
Get tensor of a given id from the pac.
@ WINOGRAD
Winograd CL kernel type.
const std::string & string_from_data_type(DataType dt)
Convert a data type identity into a string.
std::string upper_string(const std::string &val)
Raise a given string to upper case.
std::string to_string() const
#define ARM_COMPUTE_RETURN_ERROR_ON_MISMATCHING_DATA_TYPES(...)
#define ARM_COMPUTE_RETURN_ERROR_ON_DATA_TYPE_CHANNEL_NOT_IN(t, c,...)
Manages all the OpenCL kernels compilation and caching, provides accessors for the OpenCL Context.
#define ARM_COMPUTE_RETURN_ON_ERROR(status)
Checks if a status contains an error and returns it.
Activation Layer Information class.
@ RUNTIME_ERROR
Generic runtime error.
#define ARM_COMPUTE_ERROR_ON_NULLPTR(...)
#define ARM_COMPUTE_ERROR_ON(cond)
If the condition is true then an error message is printed and an exception thrown.
const ITensor * get_const_tensor(int id) const
Get constant tensor of a given id.
#define ARM_COMPUTE_ERROR_THROW_ON(status)
size_t width
Width of the image region or rectangle.
void add_option(std::string option)
Adds option to the existing build option list.
#define ARM_COMPUTE_RETURN_ERROR_ON(cond)
If the condition is true, an error is returned.
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...
#define ARM_COMPUTE_RETURN_ERROR_ON_F16_UNSUPPORTED(tensor)
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.
void add_option_if(bool cond, std::string option)
Adds option if a given condition is true;.
#define ARM_COMPUTE_ERROR_ON_INVALID_SUBWINDOW(f, s)
std::string float_to_string_with_full_precision(float val)
Create a string with the float in full precision.
bool slide_window_slice_3D(Window &slice) const
Slide the passed 3D window slice.
std::pair< Status, Window > validate_and_configure_window(ITensorInfo *src, ITensorInfo *dst)
TensorShape compute_winograd_output_transform_shape(const ITensorInfo &input, const WinogradInfo &winograd_info)
Calculate the winograd output transform shape.
size_t x() const
Semantic accessor for width as x.
#define ARM_COMPUTE_UNUSED(...)
To avoid unused variables warnings.
Describe one of the image's dimensions with a start, end and step.
void set(size_t dimension, const Dimension &dim)
Set the values of a given dimension.
static constexpr size_t DimY
Alias for dimension 1 also known as Y dimension.
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.
const Window & window() const
The maximum window the kernel can be executed on.
const std::string & string_from_data_layout(DataLayout dl)
Convert a data layout identity into a string.
std::string get_cl_type_from_data_type(const DataType &dt)
Translates a tensor data type to the appropriate OpenCL type.
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.
Describe a multidimensional execution window.
#define ARM_COMPUTE_RETURN_ERROR_ON_MSG(cond, msg)
If the condition is true, an error is returned.
Copyright (c) 2017-2024 Arm Limited.
@ F16
16-bit floating-point number
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.
static constexpr size_t DimZ
Alias for dimension 2 also known as Z dimension.
Size2D kernel_size
Width and height of the kernel.
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,...
const std::string & string_from_activation_func(const ActivationFunction &act)
Translates a given activation function to a string.
Store the tensor's metadata.
Window first_slice_window_4D() const
First 4D slice of the window.
@ F32
32-bit floating-point number
#define ARM_COMPUTE_CREATE_ERROR(error_code, msg)
Creates an error with a given message.
PadStrideInfo convolution_info
Convolution info (Pads, strides,...)
unsigned int num_elems_processed_per_iteration
DataType
Available data types.
std::unordered_map< const ITensorInfo *, PaddingSize > get_padding_info(std::initializer_list< const ITensorInfo * > infos)
Stores padding information before configuring a kernel.
SimpleTensor< T > slice(const SimpleTensor< T > &src, Coordinates starts, Coordinates ends)
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.