24.02.1
|
Go to the documentation of this file.
51 const ITensorInfo *weights,
52 const ITensorInfo *biases,
53 const ITensorInfo *indirect_buffer,
54 const ITensorInfo *
dst,
57 const DirectConvComputeKernelInfo &desc)
66 indirect_buffer->tensor_shape(),
68 weights->tensor_shape(),
conv_info, desc));
71 constexpr
int batch_idx = 3;
74 "Weights feature map dimension should match the respective src's one");
78 "M0 can only be greater than 0 and less than or equal to 8");
82 "N0 can only be: 1, 2, 3, 4, 8, and 16");
85 "K0 can only be: 1, 2, 3, 4, 8, and 16");
87 if (desc.export_weights_to_cl_image)
91 "Export to CLImage is not supported for this weight configuration");
94 if (biases !=
nullptr)
105 "Biases size and number of dst feature maps should match");
110 if (
dst->total_size() != 0)
164 const unsigned int partial_store_n0 =
dst->dimension(
channel_idx) % n0;
169 ICLKernel::configure_internal(win);
186 const unsigned int load_indirect_buf_size = m0 > 4 ? 8 : m0;
187 const unsigned int indirect_buf_width = indirect_buffer->
tensor_shape()[0];
188 const unsigned int round_up_width =
189 ((indirect_buf_width + load_indirect_buf_size - 1) / load_indirect_buf_size) * load_indirect_buf_size;
190 const unsigned int padding = round_up_width - indirect_buf_width;
193 if (biases !=
nullptr)
200 const auto act_function =
act_info.activation();
203 (act_function == ActivationLayerInfo::ActivationFunction::BOUNDED_RELU ||
204 act_function == ActivationLayerInfo::ActivationFunction::LU_BOUNDED_RELU) &&
298 const auto indirect_buffer =
302 cl::Image2D weights_cl_image;
306 const size_t image_w = weights->info()->dimension(0) / 4;
307 const size_t image_h =
308 weights->info()->dimension(1) * weights->info()->dimension(2) * weights->info()->dimension(3);
310 const size_t image_row_pitch = weights->info()->strides_in_bytes()[1];
318 unsigned int idx = 0;
324 _kernel.setArg(idx++, weights_cl_image);
327 if (biases !=
nullptr)
Class to describe a number of elements in each dimension.
std::string to_string(T &&value)
Convert integer and float values to string.
unsigned int right
right of the border
void add_1D_tensor_argument(unsigned int &idx, const ICLTensor *tensor, const Window &window)
Add the passed 1D tensor's parameters to the object's kernel's arguments starting from the index idx.
SimpleTensor< float > src
bool export_to_cl_image(const ITensorInfo *tensor)
virtual const TensorShape & tensor_shape() const =0
Size for each dimension of the tensor.
Window calculate_max_window(const ValidRegion &valid_region, const Steps &steps, bool skip_border, BorderSize border_size)
void configure(const CLCompileContext &compile_context, ITensorInfo *src, ITensorInfo *off, ITensorInfo *weights, ITensorInfo *biases, ITensorInfo *dst, const PadStrideInfo &conv_info, const ActivationLayerInfo &act_info, const DirectConvComputeKernelInfo &desc)
Set the src, offset, weights, biases and dst tensors info.
@ NHWC
Num samples, height, width, channels.
virtual bool extend_padding(const PaddingSize &padding)=0
Update the offset to the first element, the strides and the total size.
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)
TensorShape compute_indirect_buffer_shape(const TensorShape &input_shape, DataLayout input_data_layout, const TensorShape &weights_shape, const PadStrideInfo &conv_info, const DirectConvComputeKernelInfo &desc)
Calculate the indirect buffer output shape used by the indirect convolution function.
ITensor * get_tensor(int id)
Get tensor of a given id from the pac.
const std::string & string_from_data_type(DataType dt)
Convert a data type identity into a string.
GPUTarget get_target() const
Get the targeted GPU architecture.
std::string upper_string(const std::string &val)
Raise a given string to upper case.
int32_t get_ddk_version() const
Return the DDK version.
static Status validate(const ITensorInfo *src, const ITensorInfo *off, const ITensorInfo *weights, const ITensorInfo *biases, const ITensorInfo *dst, const PadStrideInfo &conv_info, const ActivationLayerInfo &act_info, const DirectConvComputeKernelInfo &desc)
Static function to check if given info will lead to a valid configuration.
static CLKernelLibrary & get()
Access the KernelLibrary singleton.
#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.
virtual size_t dimension(size_t index) const =0
Return the size of the requested dimension.
Activation Layer Information class.
@ DIRECT
Direct Convolution CL kernel type.
#define ARM_COMPUTE_ERROR_ON_NULLPTR(...)
int32_t n0
Number of columns to be processed by the kernel.
void run_op(ITensorPack &tensors, const Window &window, cl::CommandQueue &queue) override
Enqueue the OpenCL kernel to process the given window on the passed OpenCL command queue.
const ITensor * get_const_tensor(int id) const
Get constant tensor of a given id.
#define ARM_COMPUTE_ERROR_THROW_ON(status)
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.
#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.
virtual DataType data_type() const =0
Data type used for each element of the tensor.
int32_t m0
Number of rows to be processed by the kernel.
#define ARM_COMPUTE_UNUSED(...)
To avoid unused variables warnings.
#define ARM_COMPUTE_RETURN_ERROR_ON_DATA_LAYOUT_NOT_IN(t,...)
void update_padding_for_cl_image(ITensorInfo *tensor)
Update padding required to export the OpenCL buffer to OpenCL image2d.
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.
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.
void add_4d_tensor_nhwc_argument(unsigned int &idx, const ICLTensor *tensor)
Add the passed NHWC 4D tensor's parameters to the object's kernel's arguments by passing strides,...
Describe a multidimensional execution window.
BorderSize PaddingSize
Container for 2D padding size.
cl::Image2D create_image2d_from_buffer(const cl::Context &ctx, const cl::Buffer &buffer, const TensorShape &shape2d, DataType data_type, size_t image_row_pitch, CLImage2DType image_type)
Create a cl::Image2D object from an OpenCL buffer.
#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
unsigned int adjust_vec_size(unsigned int vec_size, size_t dim0)
Returns the adjusted vector size in case it is less than the input's first dimension,...
bool export_weights_to_cl_image
Flag to export the weights to cl_image.
@ S32
signed 32-bit number
cl::NDRange lws_hint() const
Return the Local-Workgroup-Size hint.
bool is_data_type_quantized_asymmetric(DataType dt)
Check if a given data type is of asymmetric quantized type.
const std::string & string_from_activation_func(const ActivationFunction &act)
Translates a given activation function to a string.
Store the tensor's metadata.
@ F32
32-bit floating-point number
TensorShape compute_deep_convolution_shape(const TensorShape &input_shape, DataLayout input_data_layout, const TensorShape &weights_shape, const PadStrideInfo &conv_info)
Calculate the deep convolution shape output shape of a tensor.
int32_t k0
Number of partial accumulations to be processed in a single iteration by the kernel.
DataType
Available data types.
SimpleTensor< T > slice(const SimpleTensor< T > &src, Coordinates starts, Coordinates ends)
Compute descriptor used by the direct convolution kernel.
std::set< std::string > build_options
void collapse(size_t n, size_t first=0)
Collapse the first n dimensions.
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.
virtual PaddingSize padding() const =0
Padding of tensor.