49 Status get_gemmlowp_output_stage_info(
const ITensorInfo *
src,
const ITensorInfo *weights,
const ITensorInfo *
dst,
const ActivationLayerInfo &act,
50 GEMMLowpOutputStageInfo &gemmlowp_output_stage_info)
53 const QuantizationInfo oq_info = dst->quantization_info();
54 const UniformQuantizationInfo iq_unif = src->quantization_info().uniform();
55 const UniformQuantizationInfo wq_unif = weights->quantization_info().uniform();
56 const UniformQuantizationInfo oq_unif = oq_info.uniform();
58 float multiplier = (iq_unif.scale * wq_unif.scale) / oq_unif.scale;
59 int32_t output_multiplier;
68 gemmlowp_output_stage_info.gemmlowp_multiplier = output_multiplier;
69 gemmlowp_output_stage_info.gemmlowp_shift = output_shift;
70 gemmlowp_output_stage_info.gemmlowp_offset = oq_unif.offset;
72 gemmlowp_output_stage_info.gemmlowp_min_bound = type_min;
73 gemmlowp_output_stage_info.gemmlowp_max_bound = type_max;
80 CpuMatMul::CpuMatMul()
81 : _transpose_kernel_lhs(), _transpose_kernel_rhs(), _asm_glue(), _lhs_transposed(), _rhs_transposed(), _original_lhs_shape(), _original_rhs_shape(), _original_dst_shape()
94 const auto adj_lhs = info.
adj_lhs();
95 const auto adj_rhs = info.
adj_rhs();
112 lhs_to_use = &lhs_transposed;
119 rhs_to_use = &rhs_transposed;
123 "The product AB is defined only if the number of columns in A is equal to the number of rows in B (after transpose)");
177 _transpose_kernel_lhs = std::make_unique<cpu::kernels::CpuTransposeKernel>();
178 _transpose_kernel_lhs->configure(&lhs_to_use, &_lhs_transposed);
184 _transpose_kernel_rhs = std::make_unique<cpu::kernels::CpuTransposeKernel>();
185 _transpose_kernel_rhs->configure(&rhs_to_use, &_rhs_transposed);
196 lhs_to_use = (_adj_lhs) ? _lhs_transposed : lhs_to_use;
197 rhs_to_use = (_adj_rhs) ? _rhs_transposed : rhs_to_use;
206 _asm_glue = std::make_unique<cpu::CpuGemmAssemblyDispatch>();
207 _asm_glue->configure(&lhs_to_use, &rhs_to_use,
nullptr, &dst_to_use, _gemm_info);
210 auto asm_mem_req = _asm_glue->workspace();
213 for(
const auto &aux : asm_mem_req)
258 _asm_glue->run(asm_tensors);
261 dst->info()->set_tensor_shape(_original_dst_shape);
262 lhs->info()->set_tensor_shape(_original_lhs_shape);
263 rhs->info()->set_tensor_shape(_original_rhs_shape);
bool is_data_type_quantized(DataType dt)
Check if a given data type is of quantized type.
std::tuple< int32_t, int32_t > get_quantized_asymmetric_output_min_max(const QuantizationInfo &q_info, const ActivationLayerInfo &act_info, DataType data_type)
Get minimum and maximum output of the activation function after quantization.
Class for holding information related to matrix multiplication function.
ActivationLayerInfo activation_info
Quantize using a fixed point multiplication.
#define ARM_COMPUTE_RETURN_ERROR_ON_CPU_F16_UNSUPPORTED(tensor)
virtual size_t dimension(size_t index) const =0
Return the size of the requested dimension.
#define ARM_COMPUTE_RETURN_ERROR_ON_CPU_BF16_UNSUPPORTED(tensor)
void add_const_tensor(int id, const ITensor *tensor)
Add const tensor to the pack.
virtual ITensorInfo & set_tensor_shape(const TensorShape &shape)=0
Set the shape of an already initialized tensor.
TensorShape collapsed_from(size_t start) const
Return a copy with collapsed dimensions starting from a given point.
#define ARM_COMPUTE_RETURN_ON_ERROR(status)
Checks if a status contains an error and returns it.
virtual DataType data_type() const =0
Data type used for each element of the tensor.
virtual void schedule_op(ICPPKernel *kernel, const Hints &hints, const Window &window, ITensorPack &tensors)=0
Runs the kernel in the same thread as the caller synchronously.
1 channel, 1 F32 per channel
Store the tensor's metadata.
#define ARM_COMPUTE_ERROR_THROW_ON(status)
GEMMLowpOutputStageInfo output_stage
Status calculate_quantized_multiplier(float multiplier, int32_t *quant_multiplier, int32_t *shift, bool ignore_epsilon=false)
Calculate quantized representation of multiplier.
Settings for MatMul Cpu implementation.
SimpleTensor< float > src
Copyright (c) 2017-2023 Arm Limited.
std::vector< MemoryInfo > MemoryRequirements
1 channel, 1 F16 per channel
TensorShape compute_transposed_shape(const ITensorInfo &input)
Calculate the transposed shape of a tensor.
T x() const
Alias to access the size of the first dimension.
const ITensor * get_const_tensor(int id) const
Get constant tensor of a given id.
static Status validate(const ITensorInfo *a, const ITensorInfo *b, const ITensorInfo *c, const ITensorInfo *d, const AsmGemmInfo &info)
Indicates whether or not this function can be used to process the given parameters.
static Status validate(const ITensorInfo *src, const ITensorInfo *dst)
Static function to check if given info will lead to a valid configuration.
ActivationLayerInfo fused_activation() const
quantized, asymmetric fixed-point 8-bit number unsigned
T z() const
Alias to access the size of the third dimension.
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...
virtual std::unique_ptr< T > clone() const =0
Provide a clone of the current object of class T.
virtual bool are_values_constant() const =0
Flag indicating whether the values of the tensor are constant, meaning that they can change on kernel...
virtual ITensorInfo * info() const =0
Interface to be implemented by the child class to return the tensor's metadata.
void run(ITensorPack &tensors) override
Run the kernels contained in the function.
static Status validate(const ITensorInfo *lhs, const ITensorInfo *rhs, const ITensorInfo *dst, const MatMulInfo &info, const CpuMatMulSettings &settings)
Static function to check if given info will lead to a valid configuration.
static constexpr size_t DimY
Alias for dimension 1 also known as Y dimension.
ScaleKernelInfo info(interpolation_policy, default_border_mode, PixelValue(), sampling_policy, false)
ITensor * get_tensor(int id)
Get tensor of a given id from the pac.
virtual size_t total_size() const =0
Returns the total size of the tensor in bytes.
#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_ERROR_ON_MSG(cond, msg)
If the condition is true, an error is returned.
#define ARM_COMPUTE_LOG_PARAMS(...)
#define ARM_COMPUTE_ERROR_ON_NULLPTR(...)
Store the tensor's metadata.
experimental::MemoryRequirements workspace() const override
Return the memory requirements required by the workspace.
ITensorInfo & set_tensor_shape(const TensorShape &shape) override
Set the shape of an already initialized tensor.
int offset_int_vec(int offset)
T y() const
Alias to access the size of the second dimension.
quantized, asymmetric fixed-point 8-bit number signed
const TensorShape & tensor_shape() const override
Size for each dimension of the tensor.
static constexpr size_t num_max_dimensions
Number of dimensions the tensor has.
void configure(ITensorInfo *lhs, ITensorInfo *rhs, ITensorInfo *dst, const MatMulInfo &info, const CpuMatMulSettings &settings)
Configure operator for a given list of arguments.
static IScheduler & get()
Access the scheduler singleton.