Debian Codegraph @

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