24.02.1
|
Go to the documentation of this file.
51 Status
validate_arguments(
const ITensorInfo *
input,
const ITensorInfo *output,
const WinogradInfo &winograd_info)
56 const PadStrideInfo
conv_info = winograd_info.convolution_info;
57 const Size2D output_tile_size = winograd_info.output_tile_size;
58 const Size2D kernel_size = winograd_info.kernel_size;
60 "Winograd input transform only supports unit strides");
63 "Winograd input transform not supported");
70 if (output->total_size() != 0)
82 std::pair<Status, Window>
88 bool window_changed =
false;
100 const size_t dim0 =
input->dimension(0);
101 const size_t k_sz = winograd_info.kernel_size.area();
105 if (k_sz == 3 || k_sz == 9)
115 const PadStrideInfo
conv_info = winograd_info.convolution_info;
116 const Size2D output_tile_size = winograd_info.output_tile_size;
117 const Size2D kernel_size = winograd_info.kernel_size;
119 unsigned int num_elems_read_per_iteration_x = output_tile_size.width + kernel_size.width - 1;
120 unsigned int num_elems_read_per_iteration_y = output_tile_size.height + kernel_size.height - 1;
123 num_elems_read_per_iteration_x, num_elems_read_per_iteration_y);
129 return std::make_pair(err, win);
157 _data_layout =
src->data_layout();
164 kernel_size, output_tile_size,
conv_info);
166 _num_tiles_x = num_tiles.
width;
167 _num_tiles_y = num_tiles.
height;
176 const size_t total_batches =
src->tensor_shape().total_size_upper(3);
181 IClKernel::configure_internal(win_config.second, cl::NDRange(1, 1, 8));
183 _src_width =
src->dimension(idx_w);
184 _src_height =
src->dimension(idx_h);
215 "winograd_input_transform_" + output_tile_size.
to_string() +
"_" + kernel_size.
to_string();
218 const unsigned int tile_max_dim = std::max(output_tile_size.
width, output_tile_size.
height);
223 _step_z = (
src->dimension(2) % 2) != 0 ? 1 : 2;
286 unsigned int idx = 0;
289 _kernel.setArg<cl_uint>(idx++, _src_width);
290 _kernel.setArg<cl_uint>(idx++, _src_height);
291 _kernel.setArg<cl_uint>(idx++, _num_tiles_x);
292 _kernel.setArg<cl_uint>(idx++, _num_tiles_y);
305 _kernel.setArg<cl_uint>(idx++,
static_cast<unsigned int>(
src->info()->strides_in_bytes()[3]));
306 _kernel.setArg<cl_uint>(idx++,
static_cast<unsigned int>(
dst->info()->strides_in_bytes()[3]));
310 unsigned int idx = 0;
@ NCHW
Num samples, channels, height, width.
std::string to_string(T &&value)
Convert integer and float values to string.
TensorShape compute_winograd_input_transform_shape(const ITensorInfo &input, const WinogradInfo &winograd_info)
Calculate the winograd input transform shape.
SimpleTensor< float > src
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)
Container for 2D 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)
Size2D output_tile_size
Width and height of the output tile.
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.
Class for specifying the size of an image or rectangle.
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.
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.
size_t total_size_upper(size_t dimension) const
Collapses given dimension and above.
@ 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.
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.
TensorShape shape() const
Return the shape of the window in number of steps.
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)
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)
Wrapper to configure the Khronos OpenCL C++ header.
#define ARM_COMPUTE_UNUSED(...)
To avoid unused variables warnings.
void add_4D_tensor_argument(unsigned int &idx, const ICLTensor *tensor, const Window &window)
Add the passed 4D tensor's parameters to the object's kernel's arguments starting from the index idx.
Describe one of the image's dimensions with a start, end and step.
Window first_slice_window_3D() const
First 3D slice of the window.
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.
void add_3D_tensor_argument(unsigned int &idx, const ICLTensor *tensor, const Window &window)
Add the passed 3D tensor's parameters to the object's kernel's arguments starting from the index idx.
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.
constexpr static unsigned int num_arguments_per_3D_tensor()
Returns the number of arguments enqueued per 3D tensor object.
#define ARM_COMPUTE_RETURN_ERROR_ON_MSG(cond, msg)
If the condition is true, an error is returned.
Copyright (c) 2017-2024 Arm Limited.
#define ARM_COMPUTE_RETURN_ERROR_ON_MISMATCHING_DIMENSIONS(...)
@ 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.
cl::NDRange lws_hint() const
Return the Local-Workgroup-Size hint.
void end(TokenStream &in, bool &valid)
#define ARM_COMPUTE_RETURN_ERROR_ON_NULLPTR(...)
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,...
Store the tensor's metadata.
@ 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.