Debian Codegraph @

src/qs8-vmulc/gen/qs8-vmulc-minmax-rndnu-neon-ld64-u16.c

raw
1 // Auto-generated file. Do not edit!
2 // Template: src/qs8-vmulc/neon.c.in
3 // Generator: tools/xngen
4 //
5 // Copyright 2021 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/vbinary.h"
15
16
17 void xnn_qs8_vmulc_minmax_rndnu_ukernel__neon_ld64_u16(
18 size_t batch,
19 const int8_t* input_a,
20 const int8_t* input_b,
21 int8_t* output,
22 const union xnn_qs8_mul_minmax_params params[restrict XNN_MIN_ELEMENTS(1)]) XNN_OOB_READS
23 {
24 assert(batch != 0);
25 assert(batch % sizeof(int8_t) == 0);
26 assert(input_a != NULL);
27 assert(input_b != NULL);
28 assert(output != NULL);
29
30 const int8x8_t va_zero_point = vld1_dup_s8(&params->rndnu_neon.a_zero_point);
31 const int32x4_t vleft_pre_shift = vld1q_dup_s32(&params->rndnu_neon.left_pre_shift);
32 const int32x4_t vmultiplier = vld1q_dup_s32(&params->rndnu_neon.multiplier);
33 const int32x4_t vleft_post_shift = vld1q_dup_s32(&params->rndnu_neon.left_post_shift);
34 const int16x8_t voutput_zero_point = vld1q_dup_s16(&params->rndnu_neon.output_zero_point);
35 const int8x16_t voutput_min = vld1q_dup_s8(&params->rndnu_neon.output_min);
36 const int8x16_t voutput_max = vld1q_dup_s8(&params->rndnu_neon.output_max);
37
38 const int8x8_t vb = vld1_dup_s8(input_b);
39 const int8x8_t vb_zero_point = vld1_dup_s8(&params->rndnu_neon.b_zero_point);
40 const int16x8_t vxb = vsubl_s8(vb, vb_zero_point);
41 for (; batch >= 16 * sizeof(int8_t); batch -= 16 * sizeof(int8_t)) {
42 const int8x8_t va01234567 = vld1_s8(input_a); input_a += 8;
43 const int8x8_t va89ABCDEF = vld1_s8(input_a); input_a += 8;
44
45 const int16x8_t vxa01234567 = vsubl_s8(va01234567, va_zero_point);
46 const int16x8_t vxa89ABCDEF = vsubl_s8(va89ABCDEF, va_zero_point);
47
48 int32x4_t vacc0123 = vmull_s16(vget_low_s16(vxa01234567), vget_low_s16(vxb));
49 int32x4_t vacc4567 = vmull_s16(vget_high_s16(vxa01234567), vget_high_s16(vxb));
50 int32x4_t vacc89AB = vmull_s16(vget_low_s16(vxa89ABCDEF), vget_low_s16(vxb));
51 int32x4_t vaccCDEF = vmull_s16(vget_high_s16(vxa89ABCDEF), vget_high_s16(vxb));
52
53 vacc0123 = vqshlq_s32(vacc0123, vleft_pre_shift);
54 vacc4567 = vqshlq_s32(vacc4567, vleft_pre_shift);
55 vacc89AB = vqshlq_s32(vacc89AB, vleft_pre_shift);
56 vaccCDEF = vqshlq_s32(vaccCDEF, vleft_pre_shift);
57
58 vacc0123 = vqdmulhq_s32(vacc0123, vmultiplier);
59 vacc4567 = vqdmulhq_s32(vacc4567, vmultiplier);
60 vacc89AB = vqdmulhq_s32(vacc89AB, vmultiplier);
61 vaccCDEF = vqdmulhq_s32(vaccCDEF, vmultiplier);
62
63 vacc0123 = vrshlq_s32(vacc0123, vleft_post_shift);
64 vacc4567 = vrshlq_s32(vacc4567, vleft_post_shift);
65 vacc89AB = vrshlq_s32(vacc89AB, vleft_post_shift);
66 vaccCDEF = vrshlq_s32(vaccCDEF, vleft_post_shift);
67
68 #if XNN_ARCH_ARM64
69 int16x8_t vacc01234567 = vqmovn_high_s32(vqmovn_s32(vacc0123), vacc4567);
70 int16x8_t vacc89ABCDEF = vqmovn_high_s32(vqmovn_s32(vacc89AB), vaccCDEF);
71 #else
72 int16x8_t vacc01234567 = vcombine_s16(vqmovn_s32(vacc0123), vqmovn_s32(vacc4567));
73 int16x8_t vacc89ABCDEF = vcombine_s16(vqmovn_s32(vacc89AB), vqmovn_s32(vaccCDEF));
74 #endif
75
76 vacc01234567 = vqaddq_s16(vacc01234567, voutput_zero_point);
77 vacc89ABCDEF = vqaddq_s16(vacc89ABCDEF, voutput_zero_point);
78
79 #if XNN_ARCH_ARM64
80 int8x16_t vout0123456789ABCDEF = vqmovn_high_s16(vqmovn_s16(vacc01234567), vacc89ABCDEF);
81 #else
82 int8x16_t vout0123456789ABCDEF = vcombine_s8(vqmovn_s16(vacc01234567), vqmovn_s16(vacc89ABCDEF));
83 #endif
84
85 vout0123456789ABCDEF = vmaxq_s8(vout0123456789ABCDEF, voutput_min);
86
87 vout0123456789ABCDEF = vminq_s8(vout0123456789ABCDEF, voutput_max);
88
89 vst1q_s8(output, vout0123456789ABCDEF); output += 16;
90 }
91 if XNN_UNLIKELY(batch != 0) {
92 do {
93 const int8x8_t va01234567 = vld1_s8(input_a); input_a += 8;
94
95 const int16x8_t vxa01234567 = vsubl_s8(va01234567, va_zero_point);
96
97 int32x4_t vacc0123 = vmull_s16(vget_low_s16(vxa01234567), vget_low_s16(vxb));
98 int32x4_t vacc4567 = vmull_s16(vget_high_s16(vxa01234567), vget_high_s16(vxb));
99
100 vacc0123 = vqshlq_s32(vacc0123, vleft_pre_shift);
101 vacc4567 = vqshlq_s32(vacc4567, vleft_pre_shift);
102
103 vacc0123 = vqdmulhq_s32(vacc0123, vmultiplier);
104 vacc4567 = vqdmulhq_s32(vacc4567, vmultiplier);
105
106 vacc0123 = vrshlq_s32(vacc0123, vleft_post_shift);
107 vacc4567 = vrshlq_s32(vacc4567, vleft_post_shift);
108
109 #if XNN_ARCH_ARM64
110 int16x8_t vacc01234567 = vqmovn_high_s32(vqmovn_s32(vacc0123), vacc4567);
111 #else
112 int16x8_t vacc01234567 = vcombine_s16(vqmovn_s32(vacc0123), vqmovn_s32(vacc4567));
113 #endif
114
115 vacc01234567 = vqaddq_s16(vacc01234567, voutput_zero_point);
116
117 int8x8_t vout01234567 = vqmovn_s16(vacc01234567);
118
119 vout01234567 = vmax_s8(vout01234567, vget_low_s8(voutput_min));
120 vout01234567 = vmin_s8(vout01234567, vget_low_s8(voutput_max));
121 if XNN_LIKELY(batch >= (8 * sizeof(int8_t))) {
122 vst1_s8(output, vout01234567); output += 8;
123 batch -= 8 * sizeof(int8_t);
124 } else {
125 if (batch & (4 * sizeof(int8_t))) {
126 vst1_lane_u32((void*) output, vreinterpret_u32_s8(vout01234567), 0); output += 4;
127 vout01234567 = vext_s8(vout01234567, vout01234567, 4);
128 }
129 if (batch & (2 * sizeof(int8_t))) {
130 vst1_lane_u16((void*) output, vreinterpret_u16_s8(vout01234567), 0); output += 2;
131 vout01234567 = vext_s8(vout01234567, vout01234567, 2);
132 }
133 if (batch & (1 * sizeof(int8_t))) {
134 vst1_lane_s8(output, vout01234567, 0);
135 }
136 batch = 0;
137 }
138 } while (batch != 0);
139 }
140 }