46 struct ActivationSelectorData
51 using ActivationSelectorPtr = std::add_pointer<bool(
const ActivationSelectorData &data)>
::type;
52 using ActivationKernelPtr = std::add_pointer<void(
const ITensor *, ITensor *,
const ActivationLayerInfo &,
const Window &)>
::type;
54 struct ActivationKernel
61 static const ActivationKernel available_kernels[] =
63 #if defined(__ARM_FEATURE_SVE) 65 "fp16_sve_activation",
66 [](
const ActivationSelectorData & data) {
return data.dt ==
DataType::F16; },
70 "fp32_sve_activation",
71 [](
const ActivationSelectorData & data) {
return data.dt ==
DataType::F32; },
76 "fp16_neon_activation",
77 [](
const ActivationSelectorData & data) {
return data.dt ==
DataType::F16; },
81 "fp32_neon_activation",
82 [](
const ActivationSelectorData & data) {
return data.dt ==
DataType::F32; },
87 #if defined(__ARM_FEATURE_SVE2) 89 "qasymm8_sve_activation",
94 "qasymm8_signed_sve_activation",
99 "qsymm16_sve_activation",
100 [](
const ActivationSelectorData & data) {
return data.dt ==
DataType::QSYMM16; },
105 "qasymm8_neon_activation",
106 [](
const ActivationSelectorData & data) {
return data.dt ==
DataType::QASYMM8; },
110 "qasymm8_signed_neon_activation",
115 "qsymm16_neon_activation",
116 [](
const ActivationSelectorData & data) {
return data.dt ==
DataType::QSYMM16; },
122 const ActivationKernel *get_implementation(
const ActivationSelectorData &data)
124 for(
const auto &uk : available_kernels)
126 if(uk.is_selected(data))
135 static const std::array<ActivationLayerInfo::ActivationFunction, 7> qasymm8_activations =
146 static const std::array<ActivationLayerInfo::ActivationFunction, 3> qsymm16_activations =
153 Status
validate_arguments(
const ITensorInfo *
src,
const ITensorInfo *
dst,
const ActivationLayerInfo &activation_info)
158 const auto *uk = get_implementation(ActivationSelectorData{
src->data_type() });
162 const QuantizationInfo &oq_info = (
dst !=
nullptr) ?
dst->quantization_info() :
src->quantization_info();
166 "For QASYMM8 only hard swish, leaky relu, tanh, logistic, relu and lower/upper bounded relu are supported");
169 "For QSYMM16 only tanh and logistic are supported");
171 && (oq_info != QuantizationInfo(1.f / 128.f, 128)));
173 && (oq_info != QuantizationInfo(1.f / 256.f, 0)));
182 if((
dst !=
nullptr) && (
dst->total_size() != 0))
191 std::pair<Status, Window> validate_and_configure_window(
const ITensorInfo *
src, ITensorInfo *
dst)
202 return std::make_pair(Status{}, win);
210 _act_info = activation_info;
215 auto win_config = validate_and_configure_window(
src,
dst);
217 ICPPKernel::configure(win_config.second);
246 const auto *uk = get_implementation(ActivationSelectorData{
src->info()->data_type() });
253 return "CpuActivationKernel";
Window calculate_max_window(const ValidRegion &valid_region, const Steps &steps, bool skip_border, BorderSize border_size)
void fp16_neon_activation(const ITensor *src, ITensor *dst, const ActivationLayerInfo &act_info, const Window &window)
const Window & window() const
The maximum window the kernel can be executed on.
void run_op(ITensorPack &tensors, const Window &window, const ThreadInfo &info) override
Execute the kernel on the passed window.
quantized, symmetric fixed-point 16-bit number
void configure(const ITensorInfo *src, ITensorInfo *dst, ActivationLayerInfo activation_info)
Configure kernel for a given list of arguments.
#define ARM_COMPUTE_RETURN_ERROR_ON_CPU_F16_UNSUPPORTED(tensor)
#define REGISTER_FP16_NEON(func_name)
bool enabled() const
Check if initialised.
void qasymm8_signed_sve_activation(const ITensor *src, ITensor *dst, const ActivationLayerInfo &act_info, const Window &window)
bool empty() const
Checks if pack is empty.
const ActivationSelectorPtr is_selected
#define REGISTER_FP32_NEON(func_name)
#define ARM_COMPUTE_RETURN_ON_ERROR(status)
Checks if a status contains an error and returns it.
1 channel, 1 F32 per channel
#define REGISTER_FP32_SVE(func_name)
void qasymm8_signed_neon_activation(const ITensor *src, ITensor *dst, const ActivationLayerInfo &act_info, const Window &window)
#define REGISTER_QASYMM8_SVE(func_name)
#define ARM_COMPUTE_ERROR_ON(cond)
If the condition is true then an error message is printed and an exception thrown.
#define REGISTER_QASYMM8_SIGNED_NEON(func_name)
Store the tensor's metadata.
#define ARM_COMPUTE_ERROR_THROW_ON(status)
quantized, asymmetric fixed-point 16-bit number
bool is_data_type_quantized_symmetric(DataType dt)
Check if a given data type is of symmetric quantized type.
#define ARM_COMPUTE_RETURN_ERROR_ON(cond)
If the condition is true, an error is returned.
Activation Layer Information class.
decltype(strategy::transforms) typedef type
Interface for CPU tensor.
SimpleTensor< float > src
const char * name() const override
Name of the kernel.
Copyright (c) 2017-2021 Arm Limited.
ActivationFunction
Available activation functions.
1 channel, 1 F16 per channel
#define REGISTER_QASYMM8_SIGNED_SVE(func_name)
const ITensor * get_const_tensor(int id) const
Get constant tensor of a given id.
#define ARM_COMPUTE_UNUSED(...)
To avoid unused variables warnings.
#define REGISTER_QASYMM8_NEON(func_name)
quantized, asymmetric fixed-point 8-bit number unsigned
#define REGISTER_QSYMM16_NEON(func_name)
void fp32_neon_activation(const ITensor *src, ITensor *dst, const ActivationLayerInfo &act_info, const Window &window)
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...
void fp16_sve_activation(const ITensor *src, ITensor *dst, const ActivationLayerInfo &act_info, const Window &window)
void qasymm8_neon_activation(const ITensor *src, ITensor *dst, const ActivationLayerInfo &act_info, const Window &window)
void end(TokenStream &in, bool &valid)
void qsymm16_neon_activation(const ITensor *src, ITensor *dst, const ActivationLayerInfo &act_info, const Window &window)
void qsymm16_sve_activation(const ITensor *src, ITensor *dst, const ActivationLayerInfo &act_info, const Window &window)
#define ARM_COMPUTE_ERROR_ON_UNCONFIGURED_KERNEL(k)
bool is_data_type_quantized_asymmetric(DataType dt)
Check if a given data type is of asymmetric quantized type.
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 ( )
Information about executing thread and CPU.
#define ARM_COMPUTE_RETURN_ERROR_ON_MISMATCHING_SHAPES(...)
#define REGISTER_QSYMM16_SVE(func_name)
#define REGISTER_FP16_SVE(func_name)
#define ARM_COMPUTE_RETURN_ERROR_ON_MISMATCHING_DATA_TYPES(...)
#define ARM_COMPUTE_RETURN_ERROR_ON_DATA_TYPE_CHANNEL_NOT_IN(t, c,...)
ActivationKernelPtr ukernel
Status validate_arguments(const ITensorInfo *input, const ITensorInfo *bias, const ITensorInfo *output, const GEMMLowpOutputStageInfo *output_stage)
#define ARM_COMPUTE_RETURN_ERROR_ON_MSG(cond, msg)
If the condition is true, an error is returned.
#define ARM_COMPUTE_ERROR_ON_NULLPTR(...)
void qasymm8_sve_activation(const ITensor *src, ITensor *dst, const ActivationLayerInfo &act_info, const Window &window)
void fp32_sve_activation(const ITensor *src, ITensor *dst, const ActivationLayerInfo &act_info, const Window &window)
quantized, asymmetric fixed-point 8-bit number signed
static Status validate(const ITensorInfo *src, const ITensorInfo *dst, const ActivationLayerInfo &act_info)
Static function to check if given info will lead to a valid configuration of CpuActivationKernel.
DataType
Available data types.
Describe a multidimensional execution window.
#define ARM_COMPUTE_ERROR_ON_INVALID_SUBWINDOW(f, s)