38static const char*
s_tag =
"NPUQ";
98 int32_t q = (int32_t)rounded + zero_point;
117 for (
size_t i = 0U; i < count; i++) {
132 for (
size_t i = 0U; i < count; i++) {
133 out[i] = scale * (float)((int32_t)in[i] - zero_point);
147 for (
size_t i = 0U; i < count; i++) {
162 for (
size_t i = 0U; i < count; i++) {
163 out[i] = scale * (float)((int32_t)in[i] - zero_point);
static const char * s_tag
Logging / check tag.
Annotation-attribute framework macros for ra8-firmware.
#define RA8_INTERNAL
Marker that a function is intended to be static (file-local).
Validation and Error-Checking Macros for ra8-firmware.
#define RA8_CHECK_NULL_PTR(ptr, tag, message)
Reject nullptr pointer, returning k_ra8_err_null_ptr.
Error Code Definitions for ra8-firmware.
@ k_ra8_err_invalid_arg
Invalid function argument.
@ k_ra8_ok
Success – operation completed with all postconditions satisfied.
ra8_err_codes_t ra8_err_t
Canonical error-return type used by every ra8-firmware API.
Lightweight Logging Interface for ra8-firmware.
#define ra8_log_error(tag, message)
RA8 log error.
ra8_err_t ra8_npu_dequantize_u8(const uint8_t *in, float *out, size_t count, float scale, int32_t zero_point)
Dequantize a UINT8 tensor into a float arena (affine).
static const float s_quant_half
The half-step used for half-away-from-zero rounding without libm.
static int32_t internal_quant_round_clamp(float scaled, int32_t zero_point, int32_t qmin, int32_t qmax)
Round scaled half-away-from-zero, add the zero-point, and clamp.
ra8_err_t ra8_npu_quantize_i8(const float *in, int8_t *out, size_t count, float scale, int32_t zero_point)
Quantize a float arena into an INT8 tensor (affine, saturating).
ra8_err_t ra8_npu_quantize_u8(const float *in, uint8_t *out, size_t count, float scale, int32_t zero_point)
Quantize a float arena into a UINT8 tensor (affine, saturating).
ra8_err_t ra8_npu_dequantize_i8(const int8_t *in, float *out, size_t count, float scale, int32_t zero_point)
Dequantize an INT8 tensor into a float arena (affine).
static const float s_quant_round_cap
Magnitude the pre-cast rounded value is clamped to (float, no libm).
Affine (scale + zero-point) tensor quantization for the NPU runtime.
@ k_ra8_npu_quant_i8_min
INT8 lower saturation bound.
@ k_ra8_npu_quant_u8_max
UINT8 upper saturation bound.
@ k_ra8_npu_quant_i8_max
INT8 upper saturation bound.
@ k_ra8_npu_quant_u8_min
UINT8 lower saturation bound.