24.02.1
|
Go to the documentation of this file.
50 constexpr
int mmul_m0 = 4;
51 constexpr
int mmul_n0 = 4;
52 constexpr
int mmul_k0 = 4;
54 Status validate_matmul_kernel_info(
const MatMulKernelInfo &matmul_kernel_info)
56 const bool adj_lhs = matmul_kernel_info.adj_lhs;
57 const int m0 = matmul_kernel_info.m0;
58 const int n0 = matmul_kernel_info.n0;
59 const int k0 = matmul_kernel_info.k0;
67 "Only 1,2,3,4,8,16 are supported for M0 for Lhs transposed");
73 "Only 1,2,3,4,8,16 are supported for N0");
95 "The extension cl_arm_matrix_multiply is not supported on the target platform");
102 const size_t lhs_k = matmul_kernel_info.
adj_lhs ? lhs_shape.
y() : lhs_shape.
x();
108 if (
dst->total_size() != 0)
110 const TensorInfo tensor_info_dst =
dst->clone()->set_tensor_shape(expected_output_shape);
119 "First dimension of bias and output tensors must match.");
140 const int m =
dst->dimension(1);
141 const int n =
dst->dimension(0);
148 const int m0 = std::min(matmul_kernel_info.
m0, m);
152 const auto win_config =
155 IClKernel::configure_internal(win_config.second);
158 const unsigned int m0_leftover = m % m0;
159 const unsigned int n0_leftover = n % n0;
208 const ICLTensor *
bias = utils::cast::polymorphic_downcast<const ICLTensor *>(
213 unsigned int idx = 0;
224 _kernel.setArg<cl_int>(idx++, _m);
225 _kernel.setArg<cl_int>(idx++, _n);
226 _kernel.setArg<cl_int>(idx++, _k);
std::string to_string(T &&value)
Convert integer and float values to string.
TensorShape compute_matmul_shape(const TensorShape &input0, const TensorShape &input1, const MatMulKernelInfo &matmul_info)
Calculate the matrix multiplication output shape of two tensors.
virtual const TensorShape & tensor_shape() const =0
Size for each dimension of the tensor.
ClMatMulNativeMMULKernel()
const StringSet & options() const
Gets the current options list set.
#define ARM_COMPUTE_RETURN_ERROR_ON_MSG_VAR(cond, msg,...)
If the condition is true, an error is returned.
std::string lower_string(const std::string &val)
Lower a given string.
#define ARM_COMPUTE_ERROR_ON_UNCONFIGURED_KERNEL(k)
#define ARM_COMPUTE_RETURN_ERROR_ON_MISMATCHING_SHAPES(...)
bool arm_matrix_multiply_supported(const cl::Device &device)
Helper function to check whether the cl_arm_matrix_multiply extension is supported.
bool adj_rhs
Get Adjoint RHS flag value.
Interface for OpenCL tensor.
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.
std::string upper_string(const std::string &val)
Raise a given string to upper case.
int m0
Number of output rows processed by each work-item.
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,...)
void configure(const ClCompileContext &compile_context, ITensorInfo *lhs, ITensorInfo *rhs, ITensorInfo *bias, ITensorInfo *dst, const MatMulKernelInfo &matmul_info)
Initialize the kernel's input and output.
#define ARM_COMPUTE_RETURN_ON_ERROR(status)
Checks if a status contains an error and returns it.
Status validate_matmul_input_shapes(const TensorShape &lhs_shape, const TensorShape &rhs_shape, const MatMulKernelInfo &matmul_kernel_info)
Validate the input shapes of Matmul operation.
#define ARM_COMPUTE_ERROR_ON_NULLPTR(...)
int k0
Number of inner accumulations.
const ITensor * get_const_tensor(int id) const
Get constant tensor of a given id.
#define ARM_COMPUTE_ERROR_THROW_ON(status)
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.
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...
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)
virtual DataType data_type() const =0
Data type used for each element of the tensor.
T x() const
Alias to access the size of the first dimension.
std::pair< Status, Window > validate_and_configure_window_for_mmul_kernels(const ITensorInfo *lhs, const ITensorInfo *rhs, const ITensorInfo *dst, const MatMulKernelInfo &matmul_kernel_info, int mmul_m0, int mmul_n0)
Validate and configure window for Matmul MMUL kernels.
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.
bool adj_lhs
Get Adjoint LHS flag value.
virtual std::unique_ptr< T > clone() const =0
Provide a clone of the current object of class T.
Store the tensor's metadata.
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.
static Status validate(const ITensorInfo *lhs, const ITensorInfo *rhs, const ITensorInfo *bias, const ITensorInfo *dst, const MatMulKernelInfo &matmul_info)
Static function to check if given info will lead to a valid configuration.
@ 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,...
#define ARM_COMPUTE_RETURN_ERROR_ON_NULLPTR(...)
Store the tensor's metadata.
@ F32
32-bit floating-point number
T y() const
Alias to access the size of the second dimension.
int n0
Number of output columns processed by each work-item.
#define ARM_COMPUTE_LOG_PARAMS(...)
@ GEMM
GEMM CL kernel type.
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.