24.02.1
|
Go to the documentation of this file.
46 GEMMLowpOutputStageInfo calculate_output_stage_metadata(
const ITensorInfo *
src,
47 const ITensorInfo *weights,
48 const ITensorInfo *
dst,
49 const ActivationLayerInfo &act)
53 const QuantizationInfo iqinfo =
src->quantization_info();
54 const QuantizationInfo wqinfo = weights->quantization_info();
55 const QuantizationInfo oqinfo = (
dst->total_size() == 0) ? iqinfo :
dst->quantization_info();
56 const UniformQuantizationInfo uoqinfo = oqinfo.uniform();
59 const std::set<ActivationLayerInfo::ActivationFunction> supported_acts = {
60 ActivationLayerInfo::ActivationFunction::RELU, ActivationLayerInfo::ActivationFunction::BOUNDED_RELU,
61 ActivationLayerInfo::ActivationFunction::LU_BOUNDED_RELU};
62 PixelValue type_min{};
63 PixelValue type_max{};
65 int32_t min_activation = type_min.get<int32_t>();
66 int32_t max_activation = type_max.get<int32_t>();
67 if (supported_acts.count(act.activation()) != 0)
71 GEMMLowpOutputStageInfo os_info;
73 os_info.gemmlowp_offset = uoqinfo.offset;
74 os_info.gemmlowp_min_bound = min_activation;
75 os_info.gemmlowp_max_bound = max_activation;
80 cpu::AsmGemmInfo init_assembly_metadata(
const Conv2dInfo &
info,
bool is_indirect)
82 cpu::AsmGemmInfo asm_info;
84 asm_info.ps_info =
info.conv_info;
85 asm_info.activation_info =
info.act_info;
86 asm_info.depth_output_gemm3d =
true;
87 asm_info.reinterpret_input_as_3d =
true;
88 asm_info.padding_top =
info.conv_info.pad_top();
89 asm_info.padding_left =
info.conv_info.pad_left();
90 asm_info.padding_value = 0.f;
91 asm_info.negated_offsets =
false;
92 asm_info.fast_mode =
info.enable_fast_math;
94 asm_info.weight_format =
info.weights_info.weight_format();
102 _weights_permute_func(std::make_unique<
CpuPermute>()),
103 _aux_mem(AuxTensorIdx::Count),
105 _run_activation(false),
123 _run_activation =
info.act_info.enabled() && !_gemm_asm_func->is_activation_supported(
info.act_info);
124 _is_prepared =
false;
126 _weights_permute_func->configure(weights, &_perm_weights,
PermutationVector{3, 0, 1, 2});
134 _gemm_asm_func->configure(
src, &_perm_weights, biases,
dst, asm_info);
139 _activation_func->configure(
dst,
nullptr,
info.act_info);
143 const auto asm_mem_req = _gemm_asm_func->workspace();
144 for (
unsigned int slot = 0; slot < asm_mem_req.size(); ++slot)
146 _aux_mem[slot] = asm_mem_req[slot];
149 if (_aux_mem[Pretranspose].size > 0)
152 _aux_mem[PermutedWeights] =
159 _aux_mem[PermutedWeights] =
188 if (biases !=
nullptr)
214 _gemm_asm_func->run(tensors);
219 _activation_func->run(
pack);
228 if (_gemm_asm_func && _gemm_asm_func->isVarWeightsKernel())
230 _gemm_asm_func->prepare(tensors);
241 _weights_permute_func->run(permute_tensors);
245 _gemm_asm_func->prepare(tensors);
@ QSYMM8_PER_CHANNEL
quantized, symmetric per channel fixed-point 8-bit number
Tensor handler to wrap and handle tensor allocations on workspace buffers.
std::vector< MemoryInfo > MemoryRequirements
SimpleTensor< float > src
@ BFLOAT16
16-bit brain floating-point number
virtual const TensorShape & tensor_shape() const =0
Size for each dimension of the tensor.
@ NHWC
Num samples, height, width, channels.
@ QASYMM8
quantized, asymmetric fixed-point 8-bit number unsigned
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.
Class for specifying the size of an image or rectangle.
Interface for CPU tensor.
ITensor * get_tensor(int id)
Get tensor of a given id from the pac.
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,...)
Descriptor used by the 2d Convolution function.
#define ARM_COMPUTE_RETURN_ON_ERROR(status)
Checks if a status contains an error and returns it.
virtual size_t dimension(size_t index) const =0
Return the size of the requested dimension.
Strides of an item in bytes.
#define ARM_COMPUTE_ERROR_ON_NULLPTR(...)
static Status validate(const ITensorInfo *src, const ITensorInfo *weights, const ITensorInfo *biases, const ITensorInfo *dst, const Conv2dInfo &info)
Static function to check if given info will lead to a valid configuration of CpuGemmDirectConv2d.
Status calculate_quantized_multipliers(const QuantizationInfo &iq_info, const QuantizationInfo &wq_info, const QuantizationInfo &oq_info, GEMMLowpOutputStageInfo &stage_info)
Calculate quantized representation of per-channel multipliers.
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(cond)
If the condition is true, an error is returned.
void run(ITensorPack &tensors) override
Run the kernels contained in the function.
@ QASYMM8_SIGNED
quantized, asymmetric fixed-point 8-bit number signed
#define ARM_COMPUTE_RETURN_ERROR_ON_MISMATCHING_DATA_LAYOUT(...)
bool is_fixed_format(const WeightFormat &wf)
int offset_int_vec(int offset)
void prepare(ITensorPack &constants) override
Prepare the function for executing.
Basic function to run kernels::CpuPermuteKernel.
#define ARM_COMPUTE_RETURN_ERROR_ON_MSG(cond, msg)
If the condition is true, an error is returned.
Copyright (c) 2017-2024 Arm Limited.
@ F16
16-bit floating-point number
@ S32
signed 32-bit number
bool is_data_type_quantized_asymmetric(DataType dt)
Check if a given data type is of asymmetric quantized type.
#define ARM_COMPUTE_RETURN_ERROR_ON_NULLPTR(...)
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
std::tuple< PixelValue, PixelValue > get_min_max(DataType dt)
Compute the mininum and maximum values a data type can take.
ScaleKernelInfo info(interpolation_policy, default_border_mode, PixelValue(), sampling_policy, false)
Basic function to run kernels::CpuActivationKernel.
GEMMLowpOutputStageInfo output_stage
experimental::MemoryRequirements workspace() const override
Return the memory requirements required by the workspace.
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.
void configure(const ITensorInfo *src, const ITensorInfo *weights, const ITensorInfo *biases, ITensorInfo *dst, const Conv2dInfo &info)
Set the input and output tensors.
DataType
Available data types.
virtual size_t num_dimensions() const =0
The number of dimensions of the tensor (rank)