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/intrinsics-polyfill.h>
15 #include <xnnpack/vmul.h>
16
17
xnn_qu8_vmulc_minmax_fp32_ukernel__neonv8_ld64_x8(size_t n,const uint8_t * input_a,const uint8_t * input_b,uint8_t * output,const union xnn_qu8_mul_minmax_params params[restrict XNN_MIN_ELEMENTS (1)])18 void xnn_qu8_vmulc_minmax_fp32_ukernel__neonv8_ld64_x8(
19 size_t n,
20 const uint8_t* input_a,
21 const uint8_t* input_b,
22 uint8_t* output,
23 const union xnn_qu8_mul_minmax_params params[restrict XNN_MIN_ELEMENTS(1)]) XNN_OOB_READS
24 {
25 const uint8x8_t va_zero_point = vld1_dup_u8(params->fp32_neonv8.a_zero_point);
26 const float32x4_t vscale = vld1q_dup_f32(¶ms->fp32_neonv8.scale);
27 const int16x8_t voutput_zero_point = vld1q_dup_s16(¶ms->fp32_neonv8.output_zero_point);
28 const uint8x8_t voutput_min = vld1_dup_u8(¶ms->fp32_neonv8.output_min);
29 const uint8x8_t voutput_max = vld1_dup_u8(¶ms->fp32_neonv8.output_max);
30
31 const uint8x8_t vb = vld1_dup_u8(input_b);
32 const uint8x8_t vb_zero_point = vld1_dup_u8(params->fp32_neonv8.b_zero_point);
33 const int16x8_t vxb = vreinterpretq_s16_u16(vsubl_u8(vb, vb_zero_point));
34 for (; n >= 8 * sizeof(uint8_t); n -= 8 * sizeof(uint8_t)) {
35 const uint8x8_t va01234567 = vld1_u8(input_a); input_a += 8;
36
37 const int16x8_t vxa01234567 = vreinterpretq_s16_u16(vsubl_u8(va01234567, va_zero_point));
38
39 int32x4_t vacc0123 = vmull_s16(vget_low_s16(vxa01234567), vget_low_s16(vxb));
40 int32x4_t vacc4567 = vmull_s16(vget_high_s16(vxa01234567), vget_high_s16(vxb));
41
42 float32x4_t vfpacc0123 = vcvtq_f32_s32(vacc0123);
43 float32x4_t vfpacc4567 = vcvtq_f32_s32(vacc4567);
44
45 vfpacc0123 = vmulq_f32(vfpacc0123, vscale);
46 vfpacc4567 = vmulq_f32(vfpacc4567, vscale);
47
48 vacc0123 = vcvtnq_s32_f32(vfpacc0123);
49 vacc4567 = vcvtnq_s32_f32(vfpacc4567);
50
51 #if XNN_ARCH_ARM64
52 int16x8_t vacc01234567 = vqmovn_high_s32(vqmovn_s32(vacc0123), vacc4567);
53 #else
54 int16x8_t vacc01234567 = vcombine_s16(vqmovn_s32(vacc0123), vqmovn_s32(vacc4567));
55 #endif
56
57 vacc01234567 = vqaddq_s16(vacc01234567, voutput_zero_point);
58
59 #if XNN_ARCH_ARM64
60 uint8x8_t vout01234567 = vqmovun_s16(vacc01234567);
61 #else
62 uint8x8_t vout01234567 = vqmovun_s16(vacc01234567);
63 #endif
64
65 vout01234567 = vmax_u8(vout01234567, voutput_min);
66
67 vout01234567 = vmin_u8(vout01234567, voutput_max);
68
69 vst1_u8(output, vout01234567); output += 8;
70 }
71 if XNN_UNLIKELY(n != 0) {
72 {
73 const uint8x8_t va01234567 = vld1_u8(input_a);
74
75 const int16x8_t vxa01234567 = vreinterpretq_s16_u16(vsubl_u8(va01234567, va_zero_point));
76
77 int32x4_t vacc0123 = vmull_s16(vget_low_s16(vxa01234567), vget_low_s16(vxb));
78 int32x4_t vacc4567 = vmull_s16(vget_high_s16(vxa01234567), vget_high_s16(vxb));
79
80 float32x4_t vfpacc0123 = vcvtq_f32_s32(vacc0123);
81 float32x4_t vfpacc4567 = vcvtq_f32_s32(vacc4567);
82
83 vfpacc0123 = vmulq_f32(vfpacc0123, vscale);
84 vfpacc4567 = vmulq_f32(vfpacc4567, vscale);
85
86 vacc0123 = vcvtnq_s32_f32(vfpacc0123);
87 vacc4567 = vcvtnq_s32_f32(vfpacc4567);
88
89 #if XNN_ARCH_ARM64
90 int16x8_t vacc01234567 = vqmovn_high_s32(vqmovn_s32(vacc0123), vacc4567);
91 #else
92 int16x8_t vacc01234567 = vcombine_s16(vqmovn_s32(vacc0123), vqmovn_s32(vacc4567));
93 #endif
94
95 vacc01234567 = vqaddq_s16(vacc01234567, voutput_zero_point);
96
97 uint8x8_t vout01234567 = vqmovun_s16(vacc01234567);
98
99 vout01234567 = vmax_u8(vout01234567, voutput_min);
100 vout01234567 = vmin_u8(vout01234567, voutput_max);
101 if (n & (4 * sizeof(uint8_t))) {
102 vst1_lane_u32((void*) output, vreinterpret_u32_u8(vout01234567), 0); output += 4;
103 vout01234567 = vext_u8(vout01234567, vout01234567, 4);
104 }
105 if (n & (2 * sizeof(uint8_t))) {
106 vst1_lane_u16((void*) output, vreinterpret_u16_u8(vout01234567), 0); output += 2;
107 vout01234567 = vext_u8(vout01234567, vout01234567, 2);
108 }
109 if (n & (1 * sizeof(uint8_t))) {
110 vst1_lane_u8(output, vout01234567, 0);
111 }
112 }
113 }
114 }
115