Debian Codegraph @

src/qs8-f16-vcvt/gen/qs8-f16-vcvt-neonfp16arith-u8.c

raw symbols SCIP
1 // Auto-generated file. Do not edit!
2 // Template: src/qs8-f16-vcvt/neon.c.in
3 // Generator: tools/xngen
4 //
5 // Copyright 2023 Google LLC
6 //
7 // This source code is licensed under the BSD-style license found in the
8 // LICENSE file in the root directory of this source tree.
9
10 #include <assert.h>
11
12 #include <arm_neon.h>
13
14 #include "xnnpack/common.h"
15 #include "xnnpack/intrinsics-polyfill.h"
16 #include "xnnpack/vcvt.h"
17
18
19 void xnn_qs8_f16_vcvt_ukernel__neonfp16arith_u8(
20 size_t batch,
21 const int8_t* input,
22 xnn_float16* output,
23 const struct xnn_qs8_f16_cvt_params params[restrict XNN_MIN_ELEMENTS(1)]) XNN_OOB_READS
24 {
25 assert(batch != 0);
26 assert(batch % sizeof(int8_t) == 0);
27 assert(input != NULL);
28 assert(output != NULL);
29
30 uint16_t* o = (uint16_t*) output;
31 const int16x8_t vminus_zero_point = vdupq_n_s16(-params->scalar.zero_point);
32 #ifdef XNN_COMPILER_MSVC
33 const float16x8_t vscale = vreinterpretq_f16_u16(vdupq_n_u16(*(const uint16_t*) &params->scalar.scale));
34 #else
35 const float16x8_t vscale = vreinterpretq_f16_u16(vld1q_dup_u16((const uint16_t*) &params->scalar.scale));
36 #endif
37 for (; batch >= 8 * sizeof(int8_t); batch -= 8 * sizeof(int8_t)) {
38 const int8x8_t vx = vld1_s8(input); input += 8;
39
40 const int16x8_t vhx = vaddw_s8(vminus_zero_point, vx);
41
42 float16x8_t vy = vcvtq_f16_s16(vhx);
43
44 vy = vmulq_f16(vy, vscale);
45
46 vst1q_u16(o, vreinterpretq_u16_f16(vy)); o += 8;
47 }
48 if XNN_UNLIKELY(batch != 0) {
49 assert(batch >= 1 * sizeof(int8_t));
50 assert(batch <= 7 * sizeof(int8_t));
51
52 const int8x8_t vx = vld1_s8(input);
53
54 const int16x8_t vhx = vaddw_s8(vminus_zero_point, vx);
55
56 float16x8_t vy = vcvtq_f16_s16(vhx);
57 vy = vmulq_f16(vy, vscale);
58
59 float16x4_t vy_lo = vget_low_f16(vy);
60 if (batch & (4 * sizeof(int8_t))) {
61 vst1_u16(o, vreinterpret_u16_f16(vy_lo)); o += 4;
62 vy_lo = vget_high_f16(vy);
63 }
64 if (batch & (2 * sizeof(int8_t))) {
65 vst1_lane_u32((void*) o, vreinterpret_u32_f16(vy_lo), 0); o += 2;
66
67 vy_lo = vext_f16(vy_lo, vy_lo, 2);
68 }
69 if (batch & (1 * sizeof(int8_t))) {
70 vst1_lane_u16(o, vreinterpret_u16_f16(vy_lo), 0);
71 }
72 }
73 }