24.02.1
|
Go to the documentation of this file.
49 std::unique_ptr<uint8_t[]> q8_prepare_lut(
ElementWiseUnary op,
const ITensorInfo *
src,
const ITensorInfo *
dst)
55 auto lut = std::unique_ptr<uint8_t[]>(
new uint8_t[256]);
57 const auto src_qi =
src->quantization_info().uniform();
58 const auto dst_qi =
dst->quantization_info().uniform();
60 const auto dst_min_fp = (((is_signed) ? -128 : 0) - dst_qi.offset) * dst_qi.scale;
61 const auto dst_max_fp = (((is_signed) ? 127 : 255) - dst_qi.offset) * dst_qi.scale;
63 for (
int i = 0; i < 256; ++i)
72 result = 1 / sqrt(in);
76 result = std::exp(in);
84 result = std::log(in);
88 result = std::abs(in);
96 result = std::sin(in);
113 #endif // __aarch64__
115 static const std::vector<CpuElementwiseUnaryKernel::ElementwiseUnaryKernel> available_kernels = {
117 "sve_fp32_elementwise_unary",
118 [](
const DataTypeISASelectorData &data) {
return (data.dt ==
DataType::F32 && data.isa.sve); },
123 "sve_fp16_elementwise_unary",
124 [](
const DataTypeISASelectorData &data) {
return (data.dt ==
DataType::F16 && data.isa.sve && data.isa.fp16); },
129 "sve_s32_elementwise_unary",
130 [](
const DataTypeISASelectorData &data) {
return (data.dt ==
DataType::S32 && data.isa.sve); },
135 "neon_fp32_elementwise_unary",
136 [](
const DataTypeISASelectorData &data) {
return data.dt ==
DataType::F32; },
141 "neon_fp16_elementwise_unary",
142 [](
const DataTypeISASelectorData &data) {
return data.dt ==
DataType::F16 && data.isa.fp16; },
147 "neon_s32_elementwise_unary",
148 [](
const DataTypeISASelectorData &data) {
return data.dt ==
DataType::S32; },
154 "sve2_q8_elementwise_unary",
155 [](
const DataTypeISASelectorData &data)
161 "neon_q8_elementwise_unary",
162 [](
const DataTypeISASelectorData &data)
169 "neon_qasymm8_signed_elementwise_unary",
175 "neon_qasymm8_elementwise_unary",
176 [](
const DataTypeISASelectorData &data) {
return data.dt ==
DataType::QASYMM8; },
180 #endif // __aarch64__
193 _run_method = uk->ukernel;
194 _name = std::string(
"CpuElementwiseUnaryKernel").append(
"/").append(uk->name);
197 if (
src.is_dynamic())
202 if (uk->prepare_func !=
nullptr)
204 _lut = uk->prepare_func(op, &
src, &
dst);
207 auto shape_and_window = compute_output_shape_and_window(
src.tensor_shape());
209 ICpuKernel::configure(shape_and_window.second);
240 if (
dst.total_size() > 0)
260 return _name.c_str();
265 return available_kernels;
float dequantize_qasymm8(uint8_t value, const INFO_TYPE &qinfo)
Dequantize a value given an unsigned 8-bit asymmetric quantization scheme.
void neon_fp32_elementwise_unary(const ITensor *in, ITensor *out, const Window &window, ElementWiseUnary op, const uint8_t *lut)
SimpleTensor< float > src
void run_op(ITensorPack &tensors, const Window &window, const ThreadInfo &info) override
Execute the kernel on the passed window.
@ QASYMM8
quantized, asymmetric fixed-point 8-bit number unsigned
void neon_qasymm8_elementwise_unary(const ITensor *in, ITensor *out, const Window &window, ElementWiseUnary op, const uint8_t *lut)
void sve_fp16_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 REGISTER_QASYMM8_SIGNED_NEON(func_name)
#define ARM_COMPUTE_ERROR(msg)
Print the given message then throw an std::runtime_error.
static CPUInfo & get()
Access the KernelLibrary singleton.
ITensor * get_tensor(int id)
Get tensor of a given id from the pac.
#define REGISTER_FP16_NEON(func_name)
@ RSQRT
Reverse square root.
#define REGISTER_QASYMM8_NEON(func_name)
#define ARM_COMPUTE_RETURN_ERROR_ON_MISMATCHING_DATA_TYPES(...)
#define ARM_COMPUTE_RETURN_ERROR_ON_DATA_TYPE_CHANNEL_NOT_IN(t, c,...)
#define REGISTER_FP32_NEON(func_name)
void sve_fp32_elementwise_unary(const ITensor *in, ITensor *out, const Window &window, ElementWiseUnary op, const uint8_t *lut)
#define REGISTER_FP32_SVE(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.
#define ARM_COMPUTE_ERROR_ON(cond)
If the condition is true then an error message is printed and an exception thrown.
const ITensor * get_const_tensor(int id) const
Get constant tensor of a given id.
#define ARM_COMPUTE_ERROR_THROW_ON(status)
void configure(ElementWiseUnary op, const ITensorInfo &src, ITensorInfo &dst)
Function to configure the CpuElementwiseUnaryKernel.
void sve_s32_elementwise_unary(const ITensor *in, ITensor *out, const Window &window, ElementWiseUnary op, const uint8_t *lut)
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.
#define ARM_COMPUTE_RETURN_ERROR_ON(cond)
If the condition is true, an error is returned.
#define ARM_COMPUTE_RETURN_ERROR_ON_CPU_F16_UNSUPPORTED(tensor)
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...
static Status validate(ElementWiseUnary op, const ITensorInfo &src, const ITensorInfo &dst)
Static function to check if given info will lead to a valid configuration.
@ QASYMM8_SIGNED
quantized, asymmetric fixed-point 8-bit number signed
void sve2_q8_elementwise_unary(const ITensor *in, ITensor *out, const Window &window, ElementWiseUnary op, const uint8_t *lut)
#define REGISTER_INTEGER_NEON(func_name)
T nearbyint(T value)
Rounds the floating-point argument arg to an integer value in floating-point format,...
#define ARM_COMPUTE_UNUSED(...)
To avoid unused variables warnings.
static const auto * get_implementation(const SelectorType &selector, KernelSelectionType selection_type=KernelSelectionType::Supported)
Micro-kernel selector.
static const std::vector< ElementwiseUnaryKernel > & get_available_kernels()
const Window & window() const
The maximum window the kernel can be executed on.
Information about executing thread and CPU.
#define REGISTER_INTEGER_SVE(func_name)
Describe a multidimensional execution window.
float dequantize_qasymm8_signed(int8_t value, const INFO_TYPE &qinfo)
Dequantize a value given a signed 8-bit asymmetric quantization scheme.
void neon_fp16_elementwise_unary(const ITensor *in, ITensor *out, const Window &window, ElementWiseUnary op, const uint8_t *lut)
Copyright (c) 2017-2024 Arm Limited.
#define REGISTER_FP16_SVE(func_name)
@ F16
16-bit floating-point number
@ S32
signed 32-bit number
void neon_s32_elementwise_unary(const ITensor *in, ITensor *out, const Window &window, ElementWiseUnary op, const uint8_t *lut)
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
const char * name() const override
Name of the kernel.
ScaleKernelInfo info(interpolation_policy, default_border_mode, PixelValue(), sampling_policy, false)
void neon_q8_elementwise_unary(const ITensor *in, ITensor *out, const Window &window, ElementWiseUnary op, const uint8_t *lut)
void neon_qasymm8_signed_elementwise_unary(const ITensor *in, ITensor *out, const Window &window, ElementWiseUnary op, const uint8_t *lut)
#define REGISTER_QASYMM8_SVE2(func_name)
ElementWiseUnary
Available element wise unary operations.