| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
#include <assert.h> |
| 11 |
|
| 12 |
#include <riscv_vector.h> |
| 13 |
|
| 14 |
#include "xnnpack/common.h" |
| 15 |
#include "xnnpack/intrinsics-polyfill.h" |
| 16 |
#include "xnnpack/vcvt.h" |
| 17 |
|
| 18 |
|
| 19 |
void xnn_qs8_f32_vcvt_ukernel__rvv_u2v( |
| 20 |
size_t batch, |
| 21 |
const int8_t* input, |
| 22 |
float* output, |
| 23 |
const struct xnn_qs8_f32_cvt_params params[restrict XNN_MIN_ELEMENTS(1)]) |
| 24 |
{ |
| 25 |
assert(batch != 0); |
| 26 |
assert(batch % sizeof(int8_t) == 0); |
| 27 |
assert(input != NULL); |
| 28 |
assert(output != NULL); |
| 29 |
|
| 30 |
batch >>= XNN_LOG2_SIZEOF_INT8_T; |
| 31 |
|
| 32 |
const float scale = params->scalar.scale; |
| 33 |
const int32_t minus_zero_point = -params->scalar.zero_point; |
| 34 |
|
| 35 |
for (; batch > 0; ) { |
| 36 |
const int32_t n = __riscv_vsetvl_e8m2(batch); batch -= n; |
| 37 |
|
| 38 |
vint8m2_t x_i8v = __riscv_vle8_v_i8m2(input, n); input += n; |
| 39 |
|
| 40 |
vint32m8_t wx_i32v = __riscv_vsext_vf4_i32m8(x_i8v, n); |
| 41 |
wx_i32v = __riscv_vadd_vx_i32m8(wx_i32v, minus_zero_point, n); |
| 42 |
vfloat32m8_t y_f32v = __riscv_vfcvt_f_x_v_f32m8(wx_i32v, n); |
| 43 |
y_f32v = __riscv_vfmul_vf_f32m8(y_f32v, scale, n); |
| 44 |
|
| 45 |
__riscv_vse32_v_f32m8(output, y_f32v, n); output += n; |
| 46 |
} |
| 47 |
} |