24.02.1
|
Go to the documentation of this file.
51 const ITensorInfo *
dst,
52 const GEMMLHSMatrixInfo &lhs_info,
53 bool reinterpret_input_as_3d)
60 "Only 2,3,4,8,16 are supported for k0");
68 if (
dst->total_size() != 0)
81 configure_window(ITensorInfo *
src, ITensorInfo *
dst,
const GEMMLHSMatrixInfo &lhs_info,
bool reinterpret_input_as_3d)
83 const unsigned int num_elems_processed_per_iteration_x = lhs_info.k0;
84 const unsigned int num_elems_processed_per_iteration_y = lhs_info.m0;
86 TensorInfo tmp_info(*
src);
88 if (reinterpret_input_as_3d)
92 TensorShape tmp_shape(
src->tensor_shape());
93 tmp_shape.collapse(2U, 1U);
94 tmp_info.set_tensor_shape(tmp_shape);
99 *
src, lhs_info, reinterpret_input_as_3d)));
103 calculate_max_window(tmp_info, Steps(num_elems_processed_per_iteration_x, num_elems_processed_per_iteration_y));
122 bool reinterpret_input_as_3d)
131 const unsigned int src_w =
src->dimension(0);
132 const unsigned int m = reinterpret_input_as_3d ?
src->dimension(1) *
src->dimension(2) :
src->dimension(1);
133 const unsigned int partial_m0 = m % lhs_info.
m0;
134 const unsigned int partial_k0 = src_w % lhs_info.
k0;
146 std::string
kernel_name(
"gemm_reshape_lhs_matrix_");
153 auto win_config = configure_window(
src,
dst, lhs_info, reinterpret_input_as_3d);
154 ICLKernel::configure_internal(win_config);
157 _kernel.setArg<cl_int>(idx++, m);
158 _kernel.setArg<cl_int>(idx++, lhs_info.
v0);
161 _config_id =
"gemm_reshape_lhs_matrix_";
162 _config_id += (reinterpret_input_as_3d ?
"3d_" :
"");
187 bool reinterpret_input_as_3d)
208 unsigned int idx = 0;
std::string to_string(T &&value)
Convert integer and float values to string.
void add_option_if_else(bool cond, std::string option_true, std::string option_false)
Adds first option if condition is true else the second one.
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)
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)
bool interleave
True if the v0 (m0xk0) blocks have to be interleaved in the output row.
void configure(const ClCompileContext &compile_context, ITensorInfo *src, ITensorInfo *dst, const GEMMLHSMatrixInfo &lhs_info, bool reinterpret_src_as_3d=false)
Initialise the kernel's input and output.
TensorShape compute_lhs_reshaped_shape(const ITensorInfo &a, const GEMMLHSMatrixInfo &lhs_info, bool reinterpret_input_as_3d=false)
Calculate the Left Hand Side matrix reshaped shape.
void add_3d_tensor_nhw_argument(unsigned int &idx, const ICLTensor *tensor)
Add the passed NHW 3D tensor's parameters to the object's kernel's arguments by passing strides,...
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.
unsigned int v0
Number of vertical blocks of size (m0xk0) stored on the same output row.
#define ARM_COMPUTE_RETURN_ERROR_ON_MISMATCHING_DATA_TYPES(...)
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.
#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)
void add_option(std::string option)
Adds option to the existing build option list.
unsigned int m0
Number of rows processed by the matrix multiplication.
#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.
static Status validate(const ITensorInfo *src, const ITensorInfo *dst, const GEMMLHSMatrixInfo &lhs_info, bool reinterpret_src_as_3d)
Static function to check if given info will lead to a valid configuration.
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.
Wrapper to configure the Khronos OpenCL C++ header.
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.
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.
#define ARM_COMPUTE_RETURN_ERROR_ON_MISMATCHING_QUANTIZATION_INFO(...)
GEMM LHS (Left Hand Side) matrix information.
std::string get_cl_unsigned_type_from_element_size(size_t element_size)
Translates the element size to an unsigned integer data type.
Describe a multidimensional execution window.
@ ELEMENTWISE
Elementwise CL kernel type.
#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(...)
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.
bool transpose
True if the (m0xk0) block has to be transposed before been stored.
cl::NDRange lws_hint() const
Return the Local-Workgroup-Size hint.
#define ARM_COMPUTE_RETURN_ERROR_ON_NULLPTR(...)
constexpr static unsigned int num_arguments_per_3d_tensor_nhw()
Returns the number of arguments enqueued per NHW 3D Tensor object.
Store the tensor's metadata.
unsigned int k0
Number of partial accumulations performed by the matrix multiplication.
@ UNKNOWN
Unknown data type.
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)
ClGemmReshapeLhsMatrixKernel()
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.