Debian Codegraph @

src/qs8-vmulc/gen/qs8-vmulc-minmax-fp32-neonv8-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/intrinsics-polyfill.h"
15 #include "xnnpack/vbinary.h"
16
17
18 void xnn_qs8_vmulc_minmax_fp32_ukernel__neonv8_ld64_u8(
19 size_t batch,
20 const int8_t* input_a,
21 const int8_t* input_b,
22 int8_t* output,
23 const union xnn_qs8_mul_minmax_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_a != NULL);
28 assert(input_b != NULL);
29 assert(output != NULL);
30
31 const int8x8_t va_zero_point = vld1_dup_s8(&params->scalar.a_zero_point);
32 const float32x4_t vscale = vld1q_dup_f32(&params->scalar.scale);
33 const int16x8_t voutput_zero_point = vld1q_dup_s16(&params->scalar.output_zero_point);
34 const int8x8_t voutput_min = vld1_dup_s8(&params->scalar.output_min);
35 const int8x8_t voutput_max = vld1_dup_s8(&params->scalar.output_max);
36
37 const int8x8_t vb = vld1_dup_s8(input_b);
38 const int8x8_t vb_zero_point = vld1_dup_s8(&params->scalar.b_zero_point);
39 const int16x8_t vxb = vsubl_s8(vb, vb_zero_point);
40 for (; batch >= 8 * sizeof(int8_t); batch -= 8 * sizeof(int8_t)) {
41 const int8x8_t va01234567 = vld1_s8(input_a); input_a += 8;
42
43 const int16x8_t vxa01234567 = vsubl_s8(va01234567, va_zero_point);
44
45 int32x4_t vacc0123 = vmull_s16(vget_low_s16(vxa01234567), vget_low_s16(vxb));
46 int32x4_t vacc4567 = vmull_s16(vget_high_s16(vxa01234567), vget_high_s16(vxb));
47
48 float32x4_t vfpacc0123 = vcvtq_f32_s32(vacc0123);
49 float32x4_t vfpacc4567 = vcvtq_f32_s32(vacc4567);
50
51 vfpacc0123 = vmulq_f32(vfpacc0123, vscale);
52 vfpacc4567 = vmulq_f32(vfpacc4567, vscale);
53
54 vacc0123 = vcvtnq_s32_f32(vfpacc0123);
55 vacc4567 = vcvtnq_s32_f32(vfpacc4567);
56
57 #if XNN_ARCH_ARM64
58 int16x8_t vacc01234567 = vqmovn_high_s32(vqmovn_s32(vacc0123), vacc4567);
59 #else
60 int16x8_t vacc01234567 = vcombine_s16(vqmovn_s32(vacc0123), vqmovn_s32(vacc4567));
61 #endif
62
63 vacc01234567 = vqaddq_s16(vacc01234567, voutput_zero_point);
64
65 #if XNN_ARCH_ARM64
66 int8x8_t vout01234567 = vqmovn_s16(vacc01234567);
67 #else
68 int8x8_t vout01234567 = vqmovn_s16(vacc01234567);
69 #endif
70
71 vout01234567 = vmax_s8(vout01234567, voutput_min);
72
73 vout01234567 = vmin_s8(vout01234567, voutput_max);
74
75 vst1_s8(output, vout01234567); output += 8;
76 }
77 if XNN_UNLIKELY(batch != 0) {
78 {
79 const int8x8_t va01234567 = vld1_s8(input_a);
80
81 const int16x8_t vxa01234567 = vsubl_s8(va01234567, va_zero_point);
82
83 int32x4_t vacc0123 = vmull_s16(vget_low_s16(vxa01234567), vget_low_s16(vxb));
84 int32x4_t vacc4567 = vmull_s16(vget_high_s16(vxa01234567), vget_high_s16(vxb));
85
86 float32x4_t vfpacc0123 = vcvtq_f32_s32(vacc0123);
87 float32x4_t vfpacc4567 = vcvtq_f32_s32(vacc4567);
88
89 vfpacc0123 = vmulq_f32(vfpacc0123, vscale);
90 vfpacc4567 = vmulq_f32(vfpacc4567, vscale);
91
92 vacc0123 = vcvtnq_s32_f32(vfpacc0123);
93 vacc4567 = vcvtnq_s32_f32(vfpacc4567);
94
95 #if XNN_ARCH_ARM64
96 int16x8_t vacc01234567 = vqmovn_high_s32(vqmovn_s32(vacc0123), vacc4567);
97 #else
98 int16x8_t vacc01234567 = vcombine_s16(vqmovn_s32(vacc0123), vqmovn_s32(vacc4567));
99 #endif
100
101 vacc01234567 = vqaddq_s16(vacc01234567, voutput_zero_point);
102
103 int8x8_t vout01234567 = vqmovn_s16(vacc01234567);
104
105 vout01234567 = vmax_s8(vout01234567, voutput_min);
106 vout01234567 = vmin_s8(vout01234567, voutput_max);
107 if (batch & (4 * sizeof(int8_t))) {
108 vst1_lane_u32((void*) output, vreinterpret_u32_s8(vout01234567), 0); output += 4;
109 vout01234567 = vext_s8(vout01234567, vout01234567, 4);
110 }
111 if (batch & (2 * sizeof(int8_t))) {
112 vst1_lane_u16((void*) output, vreinterpret_u16_s8(vout01234567), 0); output += 2;
113 vout01234567 = vext_s8(vout01234567, vout01234567, 2);
114 }
115 if (batch & (1 * sizeof(int8_t))) {
116 vst1_lane_s8(output, vout01234567, 0);
117 }
118 }
119 }
120 }