Debian Codegraph @

src/qs8-f16-vcvt/gen/qs8-f16-vcvt-neonfp16arith-u16.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_u16(
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 >= 16 * sizeof(int8_t); batch -= 16 * sizeof(int8_t)) {
38 const int8x8_t vx01234567 = vld1_s8(input); input += 8;
39 const int8x8_t vx89ABCDEF = vld1_s8(input); input += 8;
40
41 const int16x8_t vhx01234567 = vaddw_s8(vminus_zero_point, vx01234567);
42 const int16x8_t vhx89ABCDEF = vaddw_s8(vminus_zero_point, vx89ABCDEF);
43
44 float16x8_t vy01234567 = vcvtq_f16_s16(vhx01234567);
45 float16x8_t vy89ABCDEF = vcvtq_f16_s16(vhx89ABCDEF);
46
47 vy01234567 = vmulq_f16(vy01234567, vscale);
48 vy89ABCDEF = vmulq_f16(vy89ABCDEF, vscale);
49
50 vst1q_u16(o, vreinterpretq_u16_f16(vy01234567)); o += 8;
51 vst1q_u16(o, vreinterpretq_u16_f16(vy89ABCDEF)); o += 8;
52 }
53 for (; batch >= 8 * sizeof(int8_t); batch -= 8 * sizeof(int8_t)) {
54 const int8x8_t vx = vld1_s8(input); input += 8;
55
56 const int16x8_t vhx = vaddw_s8(vminus_zero_point, vx);
57
58 float16x8_t vy = vcvtq_f16_s16(vhx);
59
60 vy = vmulq_f16(vy, vscale);
61
62 vst1q_u16(o, vreinterpretq_u16_f16(vy)); o += 8;
63 }
64 if XNN_UNLIKELY(batch != 0) {
65 assert(batch >= 1 * sizeof(int8_t));
66 assert(batch <= 7 * sizeof(int8_t));
67
68 const int8x8_t vx = vld1_s8(input);
69
70 const int16x8_t vhx = vaddw_s8(vminus_zero_point, vx);
71
72 float16x8_t vy = vcvtq_f16_s16(vhx);
73 vy = vmulq_f16(vy, vscale);
74
75 float16x4_t vy_lo = vget_low_f16(vy);
76 if (batch & (4 * sizeof(int8_t))) {
77 vst1_u16(o, vreinterpret_u16_f16(vy_lo)); o += 4;
78 vy_lo = vget_high_f16(vy);
79 }
80 if (batch & (2 * sizeof(int8_t))) {
81 vst1_lane_u32((void*) o, vreinterpret_u32_f16(vy_lo), 0); o += 2;
82
83 vy_lo = vext_f16(vy_lo, vy_lo, 2);
84 }
85 if (batch & (1 * sizeof(int8_t))) {
86 vst1_lane_u16(o, vreinterpret_u16_f16(vy_lo), 0);
87 }
88 }
89 }