Debian Codegraph @

src/qs8-vmulc/gen/qs8-vmulc-minmax-rndnu-neon-ld64-u8.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_u8(
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 int8x8_t voutput_min = vld1_dup_s8(&params->rndnu_neon.output_min);
36 const int8x8_t voutput_max = vld1_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 >= 8 * sizeof(int8_t); batch -= 8 * sizeof(int8_t)) {
42 const int8x8_t va01234567 = vld1_s8(input_a); input_a += 8;
43
44 const int16x8_t vxa01234567 = vsubl_s8(va01234567, va_zero_point);
45
46 int32x4_t vacc0123 = vmull_s16(vget_low_s16(vxa01234567), vget_low_s16(vxb));
47 int32x4_t vacc4567 = vmull_s16(vget_high_s16(vxa01234567), vget_high_s16(vxb));
48
49 vacc0123 = vqshlq_s32(vacc0123, vleft_pre_shift);
50 vacc4567 = vqshlq_s32(vacc4567, vleft_pre_shift);
51
52 vacc0123 = vqdmulhq_s32(vacc0123, vmultiplier);
53 vacc4567 = vqdmulhq_s32(vacc4567, vmultiplier);
54
55 vacc0123 = vrshlq_s32(vacc0123, vleft_post_shift);
56 vacc4567 = vrshlq_s32(vacc4567, vleft_post_shift);
57
58 #if XNN_ARCH_ARM64
59 int16x8_t vacc01234567 = vqmovn_high_s32(vqmovn_s32(vacc0123), vacc4567);
60 #else
61 int16x8_t vacc01234567 = vcombine_s16(vqmovn_s32(vacc0123), vqmovn_s32(vacc4567));
62 #endif
63
64 vacc01234567 = vqaddq_s16(vacc01234567, voutput_zero_point);
65
66 #if XNN_ARCH_ARM64
67 int8x8_t vout01234567 = vqmovn_s16(vacc01234567);
68 #else
69 int8x8_t vout01234567 = vqmovn_s16(vacc01234567);
70 #endif
71
72 vout01234567 = vmax_s8(vout01234567, voutput_min);
73
74 vout01234567 = vmin_s8(vout01234567, voutput_max);
75
76 vst1_s8(output, vout01234567); output += 8;
77 }
78 if XNN_UNLIKELY(batch != 0) {
79 {
80 const int8x8_t va01234567 = vld1_s8(input_a);
81
82 const int16x8_t vxa01234567 = vsubl_s8(va01234567, va_zero_point);
83
84 int32x4_t vacc0123 = vmull_s16(vget_low_s16(vxa01234567), vget_low_s16(vxb));
85 int32x4_t vacc4567 = vmull_s16(vget_high_s16(vxa01234567), vget_high_s16(vxb));
86
87 vacc0123 = vqshlq_s32(vacc0123, vleft_pre_shift);
88 vacc4567 = vqshlq_s32(vacc4567, vleft_pre_shift);
89
90 vacc0123 = vqdmulhq_s32(vacc0123, vmultiplier);
91 vacc4567 = vqdmulhq_s32(vacc4567, vmultiplier);
92
93 vacc0123 = vrshlq_s32(vacc0123, vleft_post_shift);
94 vacc4567 = vrshlq_s32(vacc4567, vleft_post_shift);
95
96 #if XNN_ARCH_ARM64
97 int16x8_t vacc01234567 = vqmovn_high_s32(vqmovn_s32(vacc0123), vacc4567);
98 #else
99 int16x8_t vacc01234567 = vcombine_s16(vqmovn_s32(vacc0123), vqmovn_s32(vacc4567));
100 #endif
101
102 vacc01234567 = vqaddq_s16(vacc01234567, voutput_zero_point);
103
104 int8x8_t vout01234567 = vqmovn_s16(vacc01234567);
105
106 vout01234567 = vmax_s8(vout01234567, voutput_min);
107 vout01234567 = vmin_s8(vout01234567, voutput_max);
108 if (batch & (4 * sizeof(int8_t))) {
109 vst1_lane_u32((void*) output, vreinterpret_u32_s8(vout01234567), 0); output += 4;
110 vout01234567 = vext_s8(vout01234567, vout01234567, 4);
111 }
112 if (batch & (2 * sizeof(int8_t))) {
113 vst1_lane_u16((void*) output, vreinterpret_u16_s8(vout01234567), 0); output += 2;
114 vout01234567 = vext_s8(vout01234567, vout01234567, 2);
115 }
116 if (batch & (1 * sizeof(int8_t))) {
117 vst1_lane_s8(output, vout01234567, 0);
118 }
119 }
120 }
121 }