24.02.1
|
Go to the documentation of this file.
51 Status get_gemmlowp_output_stage_info(
const ITensorInfo *
src,
52 const ITensorInfo *weights,
53 const ITensorInfo *
dst,
54 const ActivationLayerInfo &act,
55 GEMMLowpOutputStageInfo &gemmlowp_output_stage_info)
58 const QuantizationInfo oq_info =
dst->quantization_info();
59 const UniformQuantizationInfo iq_unif =
src->quantization_info().uniform();
60 const UniformQuantizationInfo wq_unif = weights->quantization_info().uniform();
61 const UniformQuantizationInfo oq_unif = oq_info.uniform();
63 float multiplier = (iq_unif.scale * wq_unif.scale) / oq_unif.scale;
64 int32_t output_multiplier;
74 gemmlowp_output_stage_info.gemmlowp_multiplier = output_multiplier;
75 gemmlowp_output_stage_info.gemmlowp_shift = output_shift;
76 gemmlowp_output_stage_info.gemmlowp_offset = oq_unif.offset;
78 gemmlowp_output_stage_info.gemmlowp_min_bound = type_min;
79 gemmlowp_output_stage_info.gemmlowp_max_bound = type_max;
85 CpuMatMul::CpuMatMul()
86 : _transpose_kernel_lhs(),
87 _transpose_kernel_rhs(),
91 _original_lhs_shape(),
92 _original_rhs_shape(),
112 const auto adj_lhs =
info.adj_lhs();
113 const auto adj_rhs =
info.adj_rhs();
121 gemm_info.activation_info =
act_info;
122 gemm_info.fast_mode = settings.
fast_math();
131 lhs_to_use = &lhs_transposed;
139 rhs_to_use = &rhs_transposed;
143 "The product AB is defined only if the number of columns in A is equal to the "
144 "number of rows in B (after transpose)");
150 "Broadcasting in Batch dimension is unsupported by this operator.");
157 gemm_info.activation_info, gemm_info.output_stage));
176 _adj_lhs =
info.adj_lhs();
177 _adj_rhs =
info.adj_rhs();
207 _transpose_kernel_lhs = std::make_unique<cpu::kernels::CpuTransposeKernel>();
208 _transpose_kernel_lhs->configure(&lhs_to_use, &_lhs_transposed);
214 _transpose_kernel_rhs = std::make_unique<cpu::kernels::CpuTransposeKernel>();
215 _transpose_kernel_rhs->configure(&rhs_to_use, &_rhs_transposed);
226 lhs_to_use = (_adj_lhs) ? _lhs_transposed : lhs_to_use;
227 rhs_to_use = (_adj_rhs) ? _rhs_transposed : rhs_to_use;
232 get_gemmlowp_output_stage_info(&lhs_to_use, &rhs_to_use, &dst_to_use, _gemm_info.
activation_info,
237 _asm_glue = std::make_unique<cpu::CpuGemmAssemblyDispatch>();
238 _asm_glue->configure(&lhs_to_use, &rhs_to_use,
nullptr, &dst_to_use,
242 auto asm_mem_req = _asm_glue->workspace();
245 for (
const auto &aux : asm_mem_req)
265 TensorShape(_original_lhs_shape.
x(), _original_lhs_shape.
y(), 1,
267 dst->info()->set_tensor_shape(
268 TensorShape(_original_dst_shape.
x(), _original_dst_shape.
y(), 1,
270 rhs->info()->set_tensor_shape(_original_rhs_shape.
collapsed_from(2));
296 _asm_glue->run(asm_tensors);
299 dst->info()->set_tensor_shape(_original_dst_shape);
300 lhs->info()->set_tensor_shape(_original_lhs_shape);
301 rhs->info()->set_tensor_shape(_original_rhs_shape);
#define ARM_COMPUTE_RETURN_ERROR_ON_CPU_BF16_UNSUPPORTED(tensor)
Tensor handler to wrap and handle tensor allocations on workspace buffers.
std::vector< MemoryInfo > MemoryRequirements
experimental::MemoryRequirements workspace() const override
Return the memory requirements required by the workspace.
static Status validate(const ITensorInfo *lhs, const ITensorInfo *rhs, const ITensorInfo *dst, const MatMulInfo &info, const CpuMatMulSettings &settings, const ActivationLayerInfo &act_info=ActivationLayerInfo())
Static function to check if given info will lead to a valid configuration.
SimpleTensor< float > src
@ QASYMM8
quantized, asymmetric fixed-point 8-bit number unsigned
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.
virtual ITensorInfo & set_tensor_shape(const TensorShape &shape)=0
Set the shape of an already initialized tensor.
void configure(ITensorInfo *lhs, ITensorInfo *rhs, ITensorInfo *dst, const MatMulInfo &info, const CpuMatMulSettings &settings, const ActivationLayerInfo &act_info=ActivationLayerInfo())
Configure operator for a given list of arguments.
ITensor * get_tensor(int id)
Get tensor of a given id from the pac.
TensorShape compute_transposed_shape(const ITensorInfo &input)
Calculate the transposed shape of a tensor.
void add_const_tensor(int id, const ITensor *tensor)
Add const tensor to the pack.
#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.
T z() const
Alias to access the size of the third dimension.
virtual size_t dimension(size_t index) const =0
Return the size of the requested dimension.
Activation Layer Information class.
#define ARM_COMPUTE_ERROR_ON_NULLPTR(...)
static Status validate(const ITensorInfo *src, const ITensorInfo *dst)
Static function to check if given info will lead to a valid configuration.
virtual ITensorInfo * info() const =0
Interface to be implemented by the child class to return the tensor's metadata.
const ITensor * get_const_tensor(int id) const
Get constant tensor of a given id.
#define ARM_COMPUTE_ERROR_THROW_ON(status)
#define ARM_COMPUTE_RETURN_ERROR_ON_CPU_F16_UNSUPPORTED(tensor)
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...
static IScheduler & get()
Access the scheduler singleton.
@ QASYMM8_SIGNED
quantized, asymmetric fixed-point 8-bit number signed
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::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.
void run(ITensorPack &tensors) override
Run the kernels contained in the function.
static constexpr size_t DimY
Alias for dimension 1 also known as Y dimension.
virtual std::unique_ptr< T > clone() const =0
Provide a clone of the current object of class T.
Store the tensor's metadata.
int offset_int_vec(int offset)
ActivationLayerInfo activation_info
#define ARM_COMPUTE_RETURN_ERROR_ON_MSG(cond, msg)
If the condition is true, an error is returned.
Settings for MatMul Cpu implementation.
Copyright (c) 2017-2024 Arm Limited.
@ F16
16-bit floating-point number
Status calculate_quantized_multiplier(float multiplier, int32_t *quant_multiplier, int32_t *shift, bool ignore_epsilon=false)
Calculate quantized representation of multiplier.
bool is_data_type_quantized(DataType dt)
Check if a given data type is of quantized type.
Store the tensor's metadata.
@ F32
32-bit floating-point number
virtual bool are_values_constant() const =0
Flag indicating whether the values of the tensor are constant, meaning that they can change on kernel...
ITensorInfo & set_tensor_shape(const TensorShape &shape) override
Set the shape of an already initialized tensor.
ScaleKernelInfo info(interpolation_policy, default_border_mode, PixelValue(), sampling_policy, false)
GEMMLowpOutputStageInfo output_stage
T y() const
Alias to access the size of the second dimension.
TensorShape collapsed_from(size_t start) const
Return a copy with collapsed dimensions starting from a given point.
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.
#define ARM_COMPUTE_LOG_PARAMS(...)
@ QUANTIZE_DOWN_FIXEDPOINT
Quantize using a fixed point multiplication.
virtual size_t total_size() const =0
Returns the total size of the tensor in bytes.
Class for holding information related to matrix multiplication function.
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.