48 std::unique_ptr<uint8_t[]> q8_prepare_lut(
ElementWiseUnary op,
const ITensorInfo *
src,
const ITensorInfo *
dst)
54 auto lut = std::unique_ptr<uint8_t[]>(
new uint8_t[256]);
56 const auto src_qi = src->quantization_info().uniform();
57 const auto dst_qi = dst->quantization_info().uniform();
59 const auto dst_min_fp = (((is_signed) ? -128 : 0) - dst_qi.offset) * dst_qi.scale;
60 const auto dst_max_fp = (((is_signed) ? 127 : 255) - dst_qi.offset) * dst_qi.scale;
62 for(
int i = 0; i < 256; ++i)
70 result = 1 / sqrt(in);
74 result = std::exp(in);
82 result = std::log(in);
86 result = std::abs(in);
94 result = std::sin(in);
110 #endif // __aarch64__ 112 static const std::vector<CpuElementwiseUnaryKernel::ElementwiseUnaryKernel> available_kernels =
115 "sve_fp32_elementwise_unary",
116 [](
const DataTypeISASelectorData & data)
124 "sve_fp16_elementwise_unary",
125 [](
const DataTypeISASelectorData & data)
127 return (data.dt ==
DataType::F16 && data.isa.sve && data.isa.fp16);
133 "sve_s32_elementwise_unary",
134 [](
const DataTypeISASelectorData & data)
142 "neon_fp32_elementwise_unary",
143 [](
const DataTypeISASelectorData & data)
151 "neon_fp16_elementwise_unary",
152 [](
const DataTypeISASelectorData & data)
160 "neon_s32_elementwise_unary",
161 [](
const DataTypeISASelectorData & data)
170 "sve2_q8_elementwise_unary",
171 [](
const DataTypeISASelectorData & data)
179 "neon_q8_elementwise_unary",
180 [](
const DataTypeISASelectorData & data)
189 "neon_qasymm8_signed_elementwise_unary",
190 [](
const DataTypeISASelectorData & data)
198 "neon_qasymm8_elementwise_unary",
199 [](
const DataTypeISASelectorData & data)
206 #endif // __aarch64__ 218 _run_method = uk->ukernel;
219 _name = std::string(
"CpuElementwiseUnaryKernel").append(
"/").append(uk->name);
227 if(uk->prepare_func !=
nullptr)
229 _lut = uk->prepare_func(op, &src, &dst);
232 auto shape_and_window = compute_output_shape_and_window(src.
tensor_shape());
234 ICpuKernel::configure(shape_and_window.second);
277 _run_method(src, dst, window, _op, _lut.get());
282 return _name.c_str();
287 return available_kernels;
bool is_data_type_quantized(DataType dt)
Check if a given data type is of quantized type.
const Window & window() const
The maximum window the kernel can be executed on.
static const auto * get_implementation(const SelectorType &selector, KernelSelectionType selection_type=KernelSelectionType::Supported)
Micro-kernel selector.
#define ARM_COMPUTE_RETURN_ERROR_ON_CPU_F16_UNSUPPORTED(tensor)
float dequantize_qasymm8(uint8_t value, const INFO_TYPE &qinfo)
Dequantize a value given an unsigned 8-bit asymmetric quantization scheme.
#define REGISTER_FP16_NEON(func_name)
void neon_q8_elementwise_unary(const ITensor *in, ITensor *out, const Window &window, ElementWiseUnary op, const uint8_t *lut)
uint8_t quantize_qasymm8(float value, const INFO_TYPE &qinfo, RoundingPolicy rounding_policy=RoundingPolicy::TO_NEAREST_UP)
Quantize a value given an unsigned 8-bit asymmetric quantization scheme.
#define ARM_COMPUTE_ERROR(msg)
Print the given message then throw an std::runtime_error.
T nearbyint(T value)
Rounds the floating-point argument arg to an integer value in floating-point format, using the current rounding mode.
#define REGISTER_FP32_NEON(func_name)
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)
const char * name() const override
Name of the kernel.
#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)
virtual bool is_dynamic() const =0
Flag indicating whether the shape of the tensor is dynamic, meaning that it can change on kernel/func...
void sve2_q8_elementwise_unary(const ITensor *in, ITensor *out, const Window &window, ElementWiseUnary op, const uint8_t *lut)
#define ARM_COMPUTE_RETURN_ERROR_ON(cond)
If the condition is true, an error is returned.
void neon_qasymm8_signed_elementwise_unary(const ITensor *in, ITensor *out, const Window &window, ElementWiseUnary op, const uint8_t *lut)
SimpleTensor< float > src
Copyright (c) 2017-2023 Arm Limited.
1 channel, 1 F16 per channel
#define REGISTER_INTEGER_NEON(func_name)
DataType clamp(const DataType &n, const DataType &lower=std::numeric_limits< RangeType >::lowest(), const DataType &upper=std::numeric_limits< RangeType >::max())
Performs clamping among a lower and upper value.
1 channel, 1 S32 per channel
const ITensor * get_const_tensor(int id) const
Get constant tensor of a given id.
void run_op(ITensorPack &tensors, const Window &window, const ThreadInfo &info) override
Execute the kernel on the passed window.
void neon_fp32_elementwise_unary(const ITensor *in, ITensor *out, const Window &window, ElementWiseUnary op, const uint8_t *lut)
#define ARM_COMPUTE_UNUSED(...)
To avoid unused variables warnings.
#define REGISTER_QASYMM8_NEON(func_name)
virtual const TensorShape & tensor_shape() const =0
Size for each dimension of the tensor.
int8_t quantize_qasymm8_signed(float value, const INFO_TYPE &qinfo, RoundingPolicy rounding_policy=RoundingPolicy::TO_NEAREST_UP)
Quantize a value given a signed 8-bit asymmetric quantization scheme.
quantized, asymmetric fixed-point 8-bit number unsigned
void sve_fp32_elementwise_unary(const ITensor *in, ITensor *out, const Window &window, ElementWiseUnary op, const uint8_t *lut)
void neon_qasymm8_elementwise_unary(const ITensor *in, ITensor *out, const Window &window, ElementWiseUnary op, const uint8_t *lut)
#define REGISTER_INTEGER_SVE(func_name)
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 sve_fp16_elementwise_unary(const ITensor *in, ITensor *out, const Window &window, ElementWiseUnary op, const uint8_t *lut)
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.
Information about executing thread and CPU.
virtual size_t total_size() const =0
Returns the total size of the tensor in bytes.
#define REGISTER_FP16_SVE(func_name)
static Status validate(ElementWiseUnary op, const ITensorInfo &src, const ITensorInfo &dst)
Static function to check if given info will lead to a valid configuration.
void sve_s32_elementwise_unary(const ITensor *in, ITensor *out, const Window &window, ElementWiseUnary op, const uint8_t *lut)
#define ARM_COMPUTE_RETURN_ERROR_ON_MISMATCHING_DATA_TYPES(...)
#define ARM_COMPUTE_RETURN_ERROR_ON_DATA_TYPE_CHANNEL_NOT_IN(t, c,...)
void configure(ElementWiseUnary op, const ITensorInfo &src, ITensorInfo &dst)
Function to configure the CpuElementwiseUnaryKernel.
float dequantize_qasymm8_signed(int8_t value, const INFO_TYPE &qinfo)
Dequantize a value given a signed 8-bit asymmetric quantization scheme.
quantized, asymmetric fixed-point 8-bit number signed
static CPUInfo & get()
Access the KernelLibrary singleton.
#define REGISTER_QASYMM8_SVE2(func_name)
static const std::vector< ElementwiseUnaryKernel > & get_available_kernels()
ElementWiseUnary
Available element wise unary operations.
Describe a multidimensional execution window.
void neon_s32_elementwise_unary(const ITensor *in, ITensor *out, const Window &window, ElementWiseUnary op, const uint8_t *lut)
void neon_fp16_elementwise_unary(const ITensor *in, ITensor *out, const Window &window, ElementWiseUnary op, const uint8_t *lut)
cpuinfo::CpuIsaInfo get_isa() const
Gets the current cpu's ISA information.