45 GEMMLowpOutputStageInfo calculate_output_stage_metadata(
const ITensorInfo *
src,
const ITensorInfo *weights,
const ITensorInfo *
dst,
const ActivationLayerInfo &act)
49 const QuantizationInfo iqinfo = src->quantization_info();
50 const QuantizationInfo wqinfo = weights->quantization_info();
51 const QuantizationInfo oqinfo = (dst->total_size() == 0) ? iqinfo : dst->quantization_info();
52 const UniformQuantizationInfo uoqinfo = oqinfo.uniform();
59 PixelValue type_min{};
60 PixelValue type_max{};
61 std::tie(type_min, type_max) =
get_min_max(data_type);
62 int32_t min_activation = type_min.get<int32_t>();
63 int32_t max_activation = type_max.get<int32_t>();
64 if(supported_acts.count(act.activation()) != 0)
68 GEMMLowpOutputStageInfo os_info;
70 os_info.gemmlowp_offset = uoqinfo.offset;
71 os_info.gemmlowp_min_bound = min_activation;
72 os_info.gemmlowp_max_bound = max_activation;
77 cpu::AsmGemmInfo init_assembly_metadata(
const Conv2dInfo &
info,
bool is_indirect)
79 cpu::AsmGemmInfo asm_info;
81 asm_info.ps_info = info.conv_info;
82 asm_info.activation_info = info.act_info;
83 asm_info.depth_output_gemm3d =
true;
84 asm_info.reinterpret_input_as_3d =
true;
85 asm_info.padding_top = info.conv_info.pad_top();
86 asm_info.padding_left = info.conv_info.pad_left();
87 asm_info.padding_value = 0.f;
88 asm_info.negated_offsets =
false;
89 asm_info.fast_mode = info.enable_fast_math;
98 _aux_mem(AuxTensorIdx::Count),
100 _run_activation(false),
112 biases !=
nullptr ? biases :
nullptr,
116 _is_prepared =
false;
118 _weights_permute_func->configure(weights, &_perm_weights,
PermutationVector{ 3, 0, 1, 2 });
126 _gemm_asm_func->configure(src, &_perm_weights, biases, dst, asm_info);
131 _activation_func->configure(dst,
nullptr, info.
act_info);
135 auto asm_mem_req = _gemm_asm_func->workspace();
136 _aux_mem[AsmGemmWorkspace] = asm_mem_req[AsmGemmWorkspace];
137 _aux_mem[Pretranspose] = asm_mem_req[Pretranspose];
139 if(_aux_mem[Pretranspose].size > 0)
164 if(biases !=
nullptr)
190 _gemm_asm_func->run(tensors);
193 _activation_func->run(tensors);
207 _weights_permute_func->run(permute_tensors);
211 _gemm_asm_func->prepare(tensors);
bool is_data_type_quantized(DataType dt)
Check if a given data type is of quantized type.
experimental::MemoryRequirements workspace() const override
Return the memory requirements required by the workspace.
virtual size_t num_dimensions() const =0
The number of dimensions of the tensor (rank)
Basic function to run kernels::CpuActivationKernel.
Quantize using a fixed point multiplication.
#define ARM_COMPUTE_RETURN_ERROR_ON_MISMATCHING_DATA_LAYOUT(...)
bool enabled() const
Check if initialised.
virtual size_t dimension(size_t index) const =0
Return the size of the requested dimension.
void add_const_tensor(int id, const ITensor *tensor)
Add const tensor to the pack.
ActivationLayerInfo act_info
void configure(const ITensorInfo *src, const ITensorInfo *weights, const ITensorInfo *biases, ITensorInfo *dst, const Conv2dInfo &info)
Set the input and output tensors.
#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.
1 channel, 1 F32 per channel
Store the tensor's metadata.
#define ARM_COMPUTE_ERROR_THROW_ON(status)
GEMMLowpOutputStageInfo output_stage
#define ARM_COMPUTE_RETURN_ERROR_ON(cond)
If the condition is true, an error is returned.
Interface for CPU tensor.
SimpleTensor< float > src
Copyright (c) 2017-2021 Arm Limited.
std::vector< MemoryInfo > MemoryRequirements
1 channel, 1 F16 per channel
#define ARM_COMPUTE_RETURN_ERROR_ON_NULLPTR(...)
1 channel, 1 S32 per channel
16-bit brain floating-point number
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.
virtual const TensorShape & tensor_shape() const =0
Size for each dimension of the tensor.
std::pair< int32_t, int32_t > get_quantized_activation_min_max(ActivationLayerInfo act_info, DataType data_type, UniformQuantizationInfo oq_info)
Returns a pair of minimum and maximum values for a quantized activation.
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.
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.
quantized, asymmetric fixed-point 8-bit number unsigned
Basic function to run kernels::CpuPermuteKernel.
void prepare(ITensorPack &constants) override
Prepare the function for executing.
Descriptor used by the Convolution function.
bool is_data_type_quantized_asymmetric(DataType dt)
Check if a given data type is of asymmetric quantized type.
Strides of an item in bytes.
quantized, symmetric per channel fixed-point 8-bit number
void run(ITensorPack &tensors) override
Run the kernels contained in the function.
Lower and Upper Bounded Rectifier ( )
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.
Upper Bounded Rectifier ( )
virtual size_t total_size() const =0
Returns the total size of the tensor in bytes.
Target polymorphic_cast(Source *v)
Polymorphic cast between two types.
Class for specifying the size of an image or rectangle.
#define ARM_COMPUTE_RETURN_ERROR_ON_MISMATCHING_DATA_TYPES(...)
Num samples, height, width, channels.
#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_ERROR_ON_NULLPTR(...)
int offset_int_vec(int offset)
quantized, asymmetric fixed-point 8-bit number signed
DataType
Available data types.
std::tuple< PixelValue, PixelValue > get_min_max(DataType dt)
Compute the mininum and maximum values a data type can take.
virtual DataLayout data_layout() const =0
Get the data layout of the tensor.