24.02.1
|
Go to the documentation of this file.
53 Status validate_matmul_kernel_info(
const MatMulKernelInfo &matmul_kernel_info)
55 const bool adj_lhs = matmul_kernel_info.adj_lhs;
56 const bool adj_rhs = matmul_kernel_info.adj_rhs;
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");
77 if (!adj_lhs || adj_rhs)
80 "Only 1,2,3,4,8,16 are supported for K0");
108 "Activation Function specified is unsupported.");
112 if (
dst->total_size() != 0)
114 const TensorInfo tensor_info_output =
dst->clone()->set_tensor_shape(expected_output_shape);
144 const int m =
dst->dimension(1);
145 const int n =
dst->dimension(0);
147 const bool adj_lhs = matmul_kernel_info.
adj_lhs;
149 int m0 = adj_lhs ?
adjust_vec_size(matmul_kernel_info.
m0, m) : std::min(matmul_kernel_info.
m0, m);
155 IClKernel::configure_internal(win);
158 const unsigned int partial_store_m0 = m % m0;
159 const unsigned int partial_store_n0 = n % n0;
175 int output_multiplier = 0;
176 int output_shift = 0;
199 std::string
kernel_name(
"mat_mul_native_quantized");
210 const size_t number_of_batches =
dst->tensor_shape().total_size() / (m * n);
246 unsigned int idx = 0;
Class to describe a number of elements in each dimension.
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.
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)
@ QASYMM8
quantized, asymmetric fixed-point 8-bit number unsigned
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(...)
std::pair< int32_t, int32_t > get_quantized_activation_min_max(const ActivationLayerInfo &act_info, DataType data_type, UniformQuantizationInfo oq_info)
Returns a pair of minimum and maximum values for a quantized activation.
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.
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.
@ BOUNDED_RELU
Upper Bounded Rectifier ( )
#define ARM_COMPUTE_RETURN_ERROR_ON_MISMATCHING_DATA_TYPES(...)
#define ARM_COMPUTE_RETURN_ERROR_ON_DATA_TYPE_CHANNEL_NOT_IN(t, c,...)
#define ARM_COMPUTE_RETURN_ON_ERROR(status)
Checks if a status contains an error and returns it.
Activation Layer Information class.
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 add_option(std::string option)
Adds option to the existing build option list.
Window collapse(const Window &full_window, size_t first, size_t last=Coordinates::num_max_dimensions) const
Collapse the dimensions between first and last.
#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...
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.
@ QASYMM8_SIGNED
quantized, asymmetric fixed-point 8-bit number signed
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.
ClMatMulLowpNativeKernel()
UniformQuantizationInfo uniform() const
Return per layer quantization info.
virtual QuantizationInfo quantization_info() const =0
Get the quantization settings (scale and offset) of the tensor.
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.
@ LU_BOUNDED_RELU
Lower and Upper Bounded Rectifier ( )
#define ARM_COMPUTE_RETURN_ERROR_ON_MSG(cond, msg)
If the condition is true, an error is returned.
Copyright (c) 2017-2024 Arm Limited.
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,...
static constexpr size_t DimZ
Alias for dimension 2 also known as Z dimension.
@ S32
signed 32-bit number
cl::NDRange lws_hint() const
Return the Local-Workgroup-Size hint.
#define ARM_COMPUTE_RETURN_ERROR_ON_NULLPTR(...)
Status calculate_quantized_multiplier(float multiplier, int32_t *quant_multiplier, int32_t *shift, bool ignore_epsilon=false)
Calculate quantized representation of multiplier.
const std::string & string_from_activation_func(const ActivationFunction &act)
Translates a given activation function to a string.
static Status validate(const ITensorInfo *lhs, const ITensorInfo *rhs, const ITensorInfo *bias, const ITensorInfo *dst, const MatMulKernelInfo &matmul_kernel_info, const ActivationLayerInfo &act_info=ActivationLayerInfo())
Static function to check if given info will lead to a valid configuration.
Store the tensor's metadata.
void configure(const ClCompileContext &compile_context, ITensorInfo *lhs, ITensorInfo *rhs, ITensorInfo *bias, ITensorInfo *dst, const MatMulKernelInfo &matmul_kernel_info, const ActivationLayerInfo &act_info=ActivationLayerInfo())
Initialise the kernel's input and output.
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.