46 struct ActivationSelectorData
55 struct ActivationKernel
62 static const ActivationKernel available_kernels[] =
64 #if defined(ARM_COMPUTE_ENABLE_SVE) 66 "sve_fp16_activation",
67 [](
const ActivationSelectorData & data) {
return data.dt ==
DataType::F16 && data.ci.has_sve(); },
71 "sve_fp32_activation",
72 [](
const ActivationSelectorData & data) {
return data.dt ==
DataType::F32 && data.ci.has_sve(); },
76 #if defined(ARM_COMPUTE_ENABLE_NEON) 78 "neon_fp16_activation",
79 [](
const ActivationSelectorData & data) {
return data.dt ==
DataType::F16; },
83 "neon_fp32_activation",
84 [](
const ActivationSelectorData & data) {
return data.dt ==
DataType::F32; },
88 #if defined(ARM_COMPUTE_ENABLE_SVE2) 91 [](
const ActivationSelectorData & data) {
return data.dt ==
DataType::QASYMM8 && data.ci.has_sve2(); },
100 "sve_qs16_activation",
101 [](
const ActivationSelectorData & data) {
return data.dt ==
DataType::QSYMM16 && data.ci.has_sve2(); },
106 "neon_qu8_activation",
107 [](
const ActivationSelectorData & data) {
return data.dt ==
DataType::QASYMM8; },
111 "neon_qs8_activation",
116 "neon_qs16_activation",
117 [](
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(),
CPUInfo::get() });
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);
214 _act_info = activation_info;
215 _run_method = uk->ukernel;
216 _name = std::string(
"CpuActivationKernel").append(
"/").append(uk->name);
219 auto win_config = validate_and_configure_window(src, dst);
221 ICPPKernel::configure(win_config.second);
236 if(!_act_info.enabled())
251 _run_method(src, dst, _act_info, window);
256 return _name.c_str();
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)
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.
virtual DataType data_type() const =0
Data type used for each element of the tensor.
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...
virtual std::unique_ptr< T > clone() const =0
Provide a clone of the current object of class T.
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
#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 CPUInfo & get()
Access the KernelLibrary singleton.
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.
DataType
Available data types.
Describe a multidimensional execution window.
#define ARM_COMPUTE_ERROR_ON_INVALID_SUBWINDOW(f, s)