Debian Codegraph @

src/qd8-f32-qc8w-gemm/gen/qd8-f32-qc8w-gemm-4x32-minmax-neoni8mm.c

raw
1 // Auto-generated file. Do not edit!
2 // Template: src/qs8-gemm/c8-neoni8mm.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/gemm.h"
15 #include "xnnpack/math.h"
16
17
18 void xnn_qd8_f32_qc8w_gemm_minmax_ukernel_4x32c8__neoni8mm(
19 size_t mr,
20 size_t nc,
21 size_t kc,
22 const int8_t* restrict a,
23 size_t a_stride,
24 const void* restrict w,
25 float* restrict c,
26 size_t cm_stride,
27 size_t cn_stride,
28 const union xnn_f32_minmax_params params[restrict XNN_MIN_ELEMENTS(1)],
29 const struct xnn_qd8_quantization_params quantization_params[restrict XNN_MIN_ELEMENTS(1)]) XNN_OOB_READS
30 {
31 assert(mr != 0);
32 assert(mr <= 4);
33 assert(nc != 0);
34 assert(kc != 0);
35 assert(kc % sizeof(int8_t) == 0);
36 assert(a != NULL);
37 assert(w != NULL);
38 assert(c != NULL);
39
40 kc = round_up_po2(kc, 8 * sizeof(int8_t));
41 const int8_t* a0 = a;
42 float* c0 = c;
43 const int8_t* a1 = (const int8_t*) ((uintptr_t) a0 + a_stride);
44 float* c1 = (float*) ((uintptr_t) c0 + cm_stride);
45 if XNN_UNPREDICTABLE(mr < 2) {
46 a1 = a0;
47 c1 = c0;
48 }
49 const int8_t* a2 = (const int8_t*) ((uintptr_t) a1 + a_stride);
50 float* c2 = (float*) ((uintptr_t) c1 + cm_stride);
51 if XNN_UNPREDICTABLE(mr <= 2) {
52 a2 = a1;
53 c2 = c1;
54 }
55 const int8_t* a3 = (const int8_t*) ((uintptr_t) a2 + a_stride);
56 float* c3 = (float*) ((uintptr_t) c2 + cm_stride);
57 if XNN_UNPREDICTABLE(mr != 4) {
58 a3 = a2;
59 c3 = c2;
60 }
61
62 // Loop over groups of 32 columns.
63 do {
64 // Initialize accumulators with bias. 32 bias values are loaded from the
65 // weight matrix, at the start of the group of 32 columns.
66 const int32x4_t vinput_zero_point01 = vld1q_s32(&quantization_params[0].zero_point);
67 const int32x4_t vksum0123 = vld1q_s32(w); w = (const int32_t*) w + 4;
68 const int32x4_t vksumzp0x0123 = vmulq_lane_s32(vksum0123, vget_low_s32(vinput_zero_point01), 0);
69 const int32x4_t vksumzp1x0123 = vmulq_lane_s32(vksum0123, vget_high_s32(vinput_zero_point01), 0);
70 const int32x4_t vksum4567 = vld1q_s32(w); w = (const int32_t*) w + 4;
71 const int32x4_t vksumzp0x4567 = vmulq_lane_s32(vksum4567, vget_low_s32(vinput_zero_point01), 0);
72 const int32x4_t vksumzp1x4567 = vmulq_lane_s32(vksum4567, vget_high_s32(vinput_zero_point01), 0);
73 const int32x4_t vksum89AB = vld1q_s32(w); w = (const int32_t*) w + 4;
74 const int32x4_t vksumzp0x89AB = vmulq_lane_s32(vksum89AB, vget_low_s32(vinput_zero_point01), 0);
75 const int32x4_t vksumzp1x89AB = vmulq_lane_s32(vksum89AB, vget_high_s32(vinput_zero_point01), 0);
76 const int32x4_t vksumCDEF = vld1q_s32(w); w = (const int32_t*) w + 4;
77 const int32x4_t vksumzp0xCDEF = vmulq_lane_s32(vksumCDEF, vget_low_s32(vinput_zero_point01), 0);
78 const int32x4_t vksumzp1xCDEF = vmulq_lane_s32(vksumCDEF, vget_high_s32(vinput_zero_point01), 0);
79 const int32x4_t vksumGHIJ = vld1q_s32(w); w = (const int32_t*) w + 4;
80 const int32x4_t vksumzp0xGHIJ = vmulq_lane_s32(vksumGHIJ, vget_low_s32(vinput_zero_point01), 0);
81 const int32x4_t vksumzp1xGHIJ = vmulq_lane_s32(vksumGHIJ, vget_high_s32(vinput_zero_point01), 0);
82 const int32x4_t vksumKLMN = vld1q_s32(w); w = (const int32_t*) w + 4;
83 const int32x4_t vksumzp0xKLMN = vmulq_lane_s32(vksumKLMN, vget_low_s32(vinput_zero_point01), 0);
84 const int32x4_t vksumzp1xKLMN = vmulq_lane_s32(vksumKLMN, vget_high_s32(vinput_zero_point01), 0);
85 const int32x4_t vksumOPQR = vld1q_s32(w); w = (const int32_t*) w + 4;
86 const int32x4_t vksumzp0xOPQR = vmulq_lane_s32(vksumOPQR, vget_low_s32(vinput_zero_point01), 0);
87 const int32x4_t vksumzp1xOPQR = vmulq_lane_s32(vksumOPQR, vget_high_s32(vinput_zero_point01), 0);
88 const int32x4_t vksumSTUV = vld1q_s32(w); w = (const int32_t*) w + 4;
89 const int32x4_t vksumzp0xSTUV = vmulq_lane_s32(vksumSTUV, vget_low_s32(vinput_zero_point01), 0);
90 const int32x4_t vksumzp1xSTUV = vmulq_lane_s32(vksumSTUV, vget_high_s32(vinput_zero_point01), 0);
91 const int32x4_t vinput_zero_point23 = vld1q_s32(&quantization_params[2].zero_point);
92 const int32x4_t vksumzp2x0123 = vmulq_lane_s32(vksum0123, vget_low_s32(vinput_zero_point23), 0);
93 const int32x4_t vksumzp3x0123 = vmulq_lane_s32(vksum0123, vget_high_s32(vinput_zero_point23), 0);
94 const int32x4_t vksumzp2x4567 = vmulq_lane_s32(vksum4567, vget_low_s32(vinput_zero_point23), 0);
95 const int32x4_t vksumzp3x4567 = vmulq_lane_s32(vksum4567, vget_high_s32(vinput_zero_point23), 0);
96 const int32x4_t vksumzp2x89AB = vmulq_lane_s32(vksum89AB, vget_low_s32(vinput_zero_point23), 0);
97 const int32x4_t vksumzp3x89AB = vmulq_lane_s32(vksum89AB, vget_high_s32(vinput_zero_point23), 0);
98 const int32x4_t vksumzp2xCDEF = vmulq_lane_s32(vksumCDEF, vget_low_s32(vinput_zero_point23), 0);
99 const int32x4_t vksumzp3xCDEF = vmulq_lane_s32(vksumCDEF, vget_high_s32(vinput_zero_point23), 0);
100 const int32x4_t vksumzp2xGHIJ = vmulq_lane_s32(vksumGHIJ, vget_low_s32(vinput_zero_point23), 0);
101 const int32x4_t vksumzp3xGHIJ = vmulq_lane_s32(vksumGHIJ, vget_high_s32(vinput_zero_point23), 0);
102 const int32x4_t vksumzp2xKLMN = vmulq_lane_s32(vksumKLMN, vget_low_s32(vinput_zero_point23), 0);
103 const int32x4_t vksumzp3xKLMN = vmulq_lane_s32(vksumKLMN, vget_high_s32(vinput_zero_point23), 0);
104 const int32x4_t vksumzp2xOPQR = vmulq_lane_s32(vksumOPQR, vget_low_s32(vinput_zero_point23), 0);
105 const int32x4_t vksumzp3xOPQR = vmulq_lane_s32(vksumOPQR, vget_high_s32(vinput_zero_point23), 0);
106 const int32x4_t vksumzp2xSTUV = vmulq_lane_s32(vksumSTUV, vget_low_s32(vinput_zero_point23), 0);
107 const int32x4_t vksumzp3xSTUV = vmulq_lane_s32(vksumSTUV, vget_high_s32(vinput_zero_point23), 0);
108
109 int32x4_t vacc01x01 = vreinterpretq_s32_u64(vtrn1q_u64(vreinterpretq_u64_s32(vksumzp0x0123), vreinterpretq_u64_s32(vksumzp1x0123)));
110 int32x4_t vacc01x23 = vreinterpretq_s32_u64(vtrn2q_u64(vreinterpretq_u64_s32(vksumzp0x0123), vreinterpretq_u64_s32(vksumzp1x0123)));
111 int32x4_t vacc01x45 = vreinterpretq_s32_u64(vtrn1q_u64(vreinterpretq_u64_s32(vksumzp0x4567), vreinterpretq_u64_s32(vksumzp1x4567)));
112 int32x4_t vacc01x67 = vreinterpretq_s32_u64(vtrn2q_u64(vreinterpretq_u64_s32(vksumzp0x4567), vreinterpretq_u64_s32(vksumzp1x4567)));
113 int32x4_t vacc01x89 = vreinterpretq_s32_u64(vtrn1q_u64(vreinterpretq_u64_s32(vksumzp0x89AB), vreinterpretq_u64_s32(vksumzp1x89AB)));
114 int32x4_t vacc01xAB = vreinterpretq_s32_u64(vtrn2q_u64(vreinterpretq_u64_s32(vksumzp0x89AB), vreinterpretq_u64_s32(vksumzp1x89AB)));
115 int32x4_t vacc01xCD = vreinterpretq_s32_u64(vtrn1q_u64(vreinterpretq_u64_s32(vksumzp0xCDEF), vreinterpretq_u64_s32(vksumzp1xCDEF)));
116 int32x4_t vacc01xEF = vreinterpretq_s32_u64(vtrn2q_u64(vreinterpretq_u64_s32(vksumzp0xCDEF), vreinterpretq_u64_s32(vksumzp1xCDEF)));
117 int32x4_t vacc01xGH = vreinterpretq_s32_u64(vtrn1q_u64(vreinterpretq_u64_s32(vksumzp0xGHIJ), vreinterpretq_u64_s32(vksumzp1xGHIJ)));
118 int32x4_t vacc01xIJ = vreinterpretq_s32_u64(vtrn2q_u64(vreinterpretq_u64_s32(vksumzp0xGHIJ), vreinterpretq_u64_s32(vksumzp1xGHIJ)));
119 int32x4_t vacc01xKL = vreinterpretq_s32_u64(vtrn1q_u64(vreinterpretq_u64_s32(vksumzp0xKLMN), vreinterpretq_u64_s32(vksumzp1xKLMN)));
120 int32x4_t vacc01xMN = vreinterpretq_s32_u64(vtrn2q_u64(vreinterpretq_u64_s32(vksumzp0xKLMN), vreinterpretq_u64_s32(vksumzp1xKLMN)));
121 int32x4_t vacc01xOP = vreinterpretq_s32_u64(vtrn1q_u64(vreinterpretq_u64_s32(vksumzp0xOPQR), vreinterpretq_u64_s32(vksumzp1xOPQR)));
122 int32x4_t vacc01xQR = vreinterpretq_s32_u64(vtrn2q_u64(vreinterpretq_u64_s32(vksumzp0xOPQR), vreinterpretq_u64_s32(vksumzp1xOPQR)));
123 int32x4_t vacc01xST = vreinterpretq_s32_u64(vtrn1q_u64(vreinterpretq_u64_s32(vksumzp0xSTUV), vreinterpretq_u64_s32(vksumzp1xSTUV)));
124 int32x4_t vacc01xUV = vreinterpretq_s32_u64(vtrn2q_u64(vreinterpretq_u64_s32(vksumzp0xSTUV), vreinterpretq_u64_s32(vksumzp1xSTUV)));
125 int32x4_t vacc23x01 = vreinterpretq_s32_u64(vtrn1q_u64(vreinterpretq_u64_s32(vksumzp2x0123), vreinterpretq_u64_s32(vksumzp3x0123)));
126 int32x4_t vacc23x23 = vreinterpretq_s32_u64(vtrn2q_u64(vreinterpretq_u64_s32(vksumzp2x0123), vreinterpretq_u64_s32(vksumzp3x0123)));
127 int32x4_t vacc23x45 = vreinterpretq_s32_u64(vtrn1q_u64(vreinterpretq_u64_s32(vksumzp2x4567), vreinterpretq_u64_s32(vksumzp3x4567)));
128 int32x4_t vacc23x67 = vreinterpretq_s32_u64(vtrn2q_u64(vreinterpretq_u64_s32(vksumzp2x4567), vreinterpretq_u64_s32(vksumzp3x4567)));
129 int32x4_t vacc23x89 = vreinterpretq_s32_u64(vtrn1q_u64(vreinterpretq_u64_s32(vksumzp2x89AB), vreinterpretq_u64_s32(vksumzp3x89AB)));
130 int32x4_t vacc23xAB = vreinterpretq_s32_u64(vtrn2q_u64(vreinterpretq_u64_s32(vksumzp2x89AB), vreinterpretq_u64_s32(vksumzp3x89AB)));
131 int32x4_t vacc23xCD = vreinterpretq_s32_u64(vtrn1q_u64(vreinterpretq_u64_s32(vksumzp2xCDEF), vreinterpretq_u64_s32(vksumzp3xCDEF)));
132 int32x4_t vacc23xEF = vreinterpretq_s32_u64(vtrn2q_u64(vreinterpretq_u64_s32(vksumzp2xCDEF), vreinterpretq_u64_s32(vksumzp3xCDEF)));
133 int32x4_t vacc23xGH = vreinterpretq_s32_u64(vtrn1q_u64(vreinterpretq_u64_s32(vksumzp2xGHIJ), vreinterpretq_u64_s32(vksumzp3xGHIJ)));
134 int32x4_t vacc23xIJ = vreinterpretq_s32_u64(vtrn2q_u64(vreinterpretq_u64_s32(vksumzp2xGHIJ), vreinterpretq_u64_s32(vksumzp3xGHIJ)));
135 int32x4_t vacc23xKL = vreinterpretq_s32_u64(vtrn1q_u64(vreinterpretq_u64_s32(vksumzp2xKLMN), vreinterpretq_u64_s32(vksumzp3xKLMN)));
136 int32x4_t vacc23xMN = vreinterpretq_s32_u64(vtrn2q_u64(vreinterpretq_u64_s32(vksumzp2xKLMN), vreinterpretq_u64_s32(vksumzp3xKLMN)));
137 int32x4_t vacc23xOP = vreinterpretq_s32_u64(vtrn1q_u64(vreinterpretq_u64_s32(vksumzp2xOPQR), vreinterpretq_u64_s32(vksumzp3xOPQR)));
138 int32x4_t vacc23xQR = vreinterpretq_s32_u64(vtrn2q_u64(vreinterpretq_u64_s32(vksumzp2xOPQR), vreinterpretq_u64_s32(vksumzp3xOPQR)));
139 int32x4_t vacc23xST = vreinterpretq_s32_u64(vtrn1q_u64(vreinterpretq_u64_s32(vksumzp2xSTUV), vreinterpretq_u64_s32(vksumzp3xSTUV)));
140 int32x4_t vacc23xUV = vreinterpretq_s32_u64(vtrn2q_u64(vreinterpretq_u64_s32(vksumzp2xSTUV), vreinterpretq_u64_s32(vksumzp3xSTUV)));
141
142 // Inner accumulation loop along the 32 columns.
143 size_t k = kc;
144 // 2x partial unrolled loop to load 8 bytes at a time.
145
146 uint64x2x2_t va01x0123456789ABCDEF;
147 va01x0123456789ABCDEF.val[0] = vdupq_n_u64(0);
148 va01x0123456789ABCDEF.val[1] = vdupq_n_u64(0);
149 uint64x2x2_t va23x0123456789ABCDEF;
150 va23x0123456789ABCDEF.val[0] = vdupq_n_u64(0);
151 va23x0123456789ABCDEF.val[1] = vdupq_n_u64(0);
152
153 while (k >= 16 * sizeof(int8_t)) {
154 // Load a 4x16 block of activations.
155 va01x0123456789ABCDEF = vld2q_lane_u64((const void*) a0, va01x0123456789ABCDEF, 0); a0 += 16;
156 va23x0123456789ABCDEF = vld2q_lane_u64((const void*) a2, va23x0123456789ABCDEF, 0); a2 += 16;
157 va01x0123456789ABCDEF = vld2q_lane_u64((const void*) a1, va01x0123456789ABCDEF, 1); a1 += 16;
158 va23x0123456789ABCDEF = vld2q_lane_u64((const void*) a3, va23x0123456789ABCDEF, 1); a3 += 16;
159
160 const int8x16_t va01x01234567 = vreinterpretq_s8_u64(va01x0123456789ABCDEF.val[0]);
161 const int8x16_t va01x89ABCDEF = vreinterpretq_s8_u64(va01x0123456789ABCDEF.val[1]);
162 const int8x16_t va23x01234567 = vreinterpretq_s8_u64(va23x0123456789ABCDEF.val[0]);
163 const int8x16_t va23x89ABCDEF = vreinterpretq_s8_u64(va23x0123456789ABCDEF.val[1]);
164
165 // Load a 16x32 block of weights.
166 const int8x16_t vb01x01234567 = vld1q_s8(w); w = (const int8_t*) w + 16;
167 const int8x16_t vb23x01234567 = vld1q_s8(w); w = (const int8_t*) w + 16;
168 const int8x16_t vb45x01234567 = vld1q_s8(w); w = (const int8_t*) w + 16;
169 const int8x16_t vb67x01234567 = vld1q_s8(w); w = (const int8_t*) w + 16;
170 const int8x16_t vb89x01234567 = vld1q_s8(w); w = (const int8_t*) w + 16;
171 const int8x16_t vbABx01234567 = vld1q_s8(w); w = (const int8_t*) w + 16;
172 const int8x16_t vbCDx01234567 = vld1q_s8(w); w = (const int8_t*) w + 16;
173 const int8x16_t vbEFx01234567 = vld1q_s8(w); w = (const int8_t*) w + 16;
174 const int8x16_t vbGHx01234567 = vld1q_s8(w); w = (const int8_t*) w + 16;
175 const int8x16_t vbIJx01234567 = vld1q_s8(w); w = (const int8_t*) w + 16;
176 const int8x16_t vbKLx01234567 = vld1q_s8(w); w = (const int8_t*) w + 16;
177 const int8x16_t vbMNx01234567 = vld1q_s8(w); w = (const int8_t*) w + 16;
178 const int8x16_t vbOPx01234567 = vld1q_s8(w); w = (const int8_t*) w + 16;
179 const int8x16_t vbQRx01234567 = vld1q_s8(w); w = (const int8_t*) w + 16;
180 const int8x16_t vbSTx01234567 = vld1q_s8(w); w = (const int8_t*) w + 16;
181 const int8x16_t vbUVx01234567 = vld1q_s8(w); w = (const int8_t*) w + 16;
182 const int8x16_t vb01x89ABCDEF = vld1q_s8(w); w = (const int8_t*) w + 16;
183 const int8x16_t vb23x89ABCDEF = vld1q_s8(w); w = (const int8_t*) w + 16;
184 const int8x16_t vb45x89ABCDEF = vld1q_s8(w); w = (const int8_t*) w + 16;
185 const int8x16_t vb67x89ABCDEF = vld1q_s8(w); w = (const int8_t*) w + 16;
186 const int8x16_t vb89x89ABCDEF = vld1q_s8(w); w = (const int8_t*) w + 16;
187 const int8x16_t vbABx89ABCDEF = vld1q_s8(w); w = (const int8_t*) w + 16;
188 const int8x16_t vbCDx89ABCDEF = vld1q_s8(w); w = (const int8_t*) w + 16;
189 const int8x16_t vbEFx89ABCDEF = vld1q_s8(w); w = (const int8_t*) w + 16;
190 const int8x16_t vbGHx89ABCDEF = vld1q_s8(w); w = (const int8_t*) w + 16;
191 const int8x16_t vbIJx89ABCDEF = vld1q_s8(w); w = (const int8_t*) w + 16;
192 const int8x16_t vbKLx89ABCDEF = vld1q_s8(w); w = (const int8_t*) w + 16;
193 const int8x16_t vbMNx89ABCDEF = vld1q_s8(w); w = (const int8_t*) w + 16;
194 const int8x16_t vbOPx89ABCDEF = vld1q_s8(w); w = (const int8_t*) w + 16;
195 const int8x16_t vbQRx89ABCDEF = vld1q_s8(w); w = (const int8_t*) w + 16;
196 const int8x16_t vbSTx89ABCDEF = vld1q_s8(w); w = (const int8_t*) w + 16;
197 const int8x16_t vbUVx89ABCDEF = vld1q_s8(w); w = (const int8_t*) w + 16;
198
199 // Multiply-accumulate: 4x8 * 8x32 --> 4x32.
200 vacc01x01 = vmmlaq_s32(vacc01x01, va01x01234567, vb01x01234567);
201 vacc01x23 = vmmlaq_s32(vacc01x23, va01x01234567, vb23x01234567);
202 vacc01x45 = vmmlaq_s32(vacc01x45, va01x01234567, vb45x01234567);
203 vacc01x67 = vmmlaq_s32(vacc01x67, va01x01234567, vb67x01234567);
204 vacc01x89 = vmmlaq_s32(vacc01x89, va01x01234567, vb89x01234567);
205 vacc01xAB = vmmlaq_s32(vacc01xAB, va01x01234567, vbABx01234567);
206 vacc01xCD = vmmlaq_s32(vacc01xCD, va01x01234567, vbCDx01234567);
207 vacc01xEF = vmmlaq_s32(vacc01xEF, va01x01234567, vbEFx01234567);
208 vacc01xGH = vmmlaq_s32(vacc01xGH, va01x01234567, vbGHx01234567);
209 vacc01xIJ = vmmlaq_s32(vacc01xIJ, va01x01234567, vbIJx01234567);
210 vacc01xKL = vmmlaq_s32(vacc01xKL, va01x01234567, vbKLx01234567);
211 vacc01xMN = vmmlaq_s32(vacc01xMN, va01x01234567, vbMNx01234567);
212 vacc01xOP = vmmlaq_s32(vacc01xOP, va01x01234567, vbOPx01234567);
213 vacc01xQR = vmmlaq_s32(vacc01xQR, va01x01234567, vbQRx01234567);
214 vacc01xST = vmmlaq_s32(vacc01xST, va01x01234567, vbSTx01234567);
215 vacc01xUV = vmmlaq_s32(vacc01xUV, va01x01234567, vbUVx01234567);
216 vacc23x01 = vmmlaq_s32(vacc23x01, va23x01234567, vb01x01234567);
217 vacc23x23 = vmmlaq_s32(vacc23x23, va23x01234567, vb23x01234567);
218 vacc23x45 = vmmlaq_s32(vacc23x45, va23x01234567, vb45x01234567);
219 vacc23x67 = vmmlaq_s32(vacc23x67, va23x01234567, vb67x01234567);
220 vacc23x89 = vmmlaq_s32(vacc23x89, va23x01234567, vb89x01234567);
221 vacc23xAB = vmmlaq_s32(vacc23xAB, va23x01234567, vbABx01234567);
222 vacc23xCD = vmmlaq_s32(vacc23xCD, va23x01234567, vbCDx01234567);
223 vacc23xEF = vmmlaq_s32(vacc23xEF, va23x01234567, vbEFx01234567);
224 vacc23xGH = vmmlaq_s32(vacc23xGH, va23x01234567, vbGHx01234567);
225 vacc23xIJ = vmmlaq_s32(vacc23xIJ, va23x01234567, vbIJx01234567);
226 vacc23xKL = vmmlaq_s32(vacc23xKL, va23x01234567, vbKLx01234567);
227 vacc23xMN = vmmlaq_s32(vacc23xMN, va23x01234567, vbMNx01234567);
228 vacc23xOP = vmmlaq_s32(vacc23xOP, va23x01234567, vbOPx01234567);
229 vacc23xQR = vmmlaq_s32(vacc23xQR, va23x01234567, vbQRx01234567);
230 vacc23xST = vmmlaq_s32(vacc23xST, va23x01234567, vbSTx01234567);
231 vacc23xUV = vmmlaq_s32(vacc23xUV, va23x01234567, vbUVx01234567);
232 vacc01x01 = vmmlaq_s32(vacc01x01, va01x89ABCDEF, vb01x89ABCDEF);
233 vacc01x23 = vmmlaq_s32(vacc01x23, va01x89ABCDEF, vb23x89ABCDEF);
234 vacc01x45 = vmmlaq_s32(vacc01x45, va01x89ABCDEF, vb45x89ABCDEF);
235 vacc01x67 = vmmlaq_s32(vacc01x67, va01x89ABCDEF, vb67x89ABCDEF);
236 vacc01x89 = vmmlaq_s32(vacc01x89, va01x89ABCDEF, vb89x89ABCDEF);
237 vacc01xAB = vmmlaq_s32(vacc01xAB, va01x89ABCDEF, vbABx89ABCDEF);
238 vacc01xCD = vmmlaq_s32(vacc01xCD, va01x89ABCDEF, vbCDx89ABCDEF);
239 vacc01xEF = vmmlaq_s32(vacc01xEF, va01x89ABCDEF, vbEFx89ABCDEF);
240 vacc01xGH = vmmlaq_s32(vacc01xGH, va01x89ABCDEF, vbGHx89ABCDEF);
241 vacc01xIJ = vmmlaq_s32(vacc01xIJ, va01x89ABCDEF, vbIJx89ABCDEF);
242 vacc01xKL = vmmlaq_s32(vacc01xKL, va01x89ABCDEF, vbKLx89ABCDEF);
243 vacc01xMN = vmmlaq_s32(vacc01xMN, va01x89ABCDEF, vbMNx89ABCDEF);
244 vacc01xOP = vmmlaq_s32(vacc01xOP, va01x89ABCDEF, vbOPx89ABCDEF);
245 vacc01xQR = vmmlaq_s32(vacc01xQR, va01x89ABCDEF, vbQRx89ABCDEF);
246 vacc01xST = vmmlaq_s32(vacc01xST, va01x89ABCDEF, vbSTx89ABCDEF);
247 vacc01xUV = vmmlaq_s32(vacc01xUV, va01x89ABCDEF, vbUVx89ABCDEF);
248 vacc23x01 = vmmlaq_s32(vacc23x01, va23x89ABCDEF, vb01x89ABCDEF);
249 vacc23x23 = vmmlaq_s32(vacc23x23, va23x89ABCDEF, vb23x89ABCDEF);
250 vacc23x45 = vmmlaq_s32(vacc23x45, va23x89ABCDEF, vb45x89ABCDEF);
251 vacc23x67 = vmmlaq_s32(vacc23x67, va23x89ABCDEF, vb67x89ABCDEF);
252 vacc23x89 = vmmlaq_s32(vacc23x89, va23x89ABCDEF, vb89x89ABCDEF);
253 vacc23xAB = vmmlaq_s32(vacc23xAB, va23x89ABCDEF, vbABx89ABCDEF);
254 vacc23xCD = vmmlaq_s32(vacc23xCD, va23x89ABCDEF, vbCDx89ABCDEF);
255 vacc23xEF = vmmlaq_s32(vacc23xEF, va23x89ABCDEF, vbEFx89ABCDEF);
256 vacc23xGH = vmmlaq_s32(vacc23xGH, va23x89ABCDEF, vbGHx89ABCDEF);
257 vacc23xIJ = vmmlaq_s32(vacc23xIJ, va23x89ABCDEF, vbIJx89ABCDEF);
258 vacc23xKL = vmmlaq_s32(vacc23xKL, va23x89ABCDEF, vbKLx89ABCDEF);
259 vacc23xMN = vmmlaq_s32(vacc23xMN, va23x89ABCDEF, vbMNx89ABCDEF);
260 vacc23xOP = vmmlaq_s32(vacc23xOP, va23x89ABCDEF, vbOPx89ABCDEF);
261 vacc23xQR = vmmlaq_s32(vacc23xQR, va23x89ABCDEF, vbQRx89ABCDEF);
262 vacc23xST = vmmlaq_s32(vacc23xST, va23x89ABCDEF, vbSTx89ABCDEF);
263 vacc23xUV = vmmlaq_s32(vacc23xUV, va23x89ABCDEF, vbUVx89ABCDEF);
264
265 k -= 16 * sizeof(int8_t);
266 }
267 // Handle up to 8 final positions of `k`
268 if XNN_UNLIKELY(k != 0) {
269 // Load a 4x8 block of activations.
270 uint64x2_t va01x01234567 = vld1q_dup_u64((const void*) a0); a0 += 8;
271 uint64x2_t va23x01234567 = vld1q_dup_u64((const void*) a2); a2 += 8;
272 va01x01234567 = vld1q_lane_u64((const void*) a1, va01x01234567, 1); a1 += 8;
273 va23x01234567 = vld1q_lane_u64((const void*) a3, va23x01234567, 1); a3 += 8;
274
275 // Load a 16x32 block of weights.
276 const int8x16_t vb01x01234567 = vld1q_s8(w); w = (const int8_t*) w + 16;
277 const int8x16_t vb23x01234567 = vld1q_s8(w); w = (const int8_t*) w + 16;
278 const int8x16_t vb45x01234567 = vld1q_s8(w); w = (const int8_t*) w + 16;
279 const int8x16_t vb67x01234567 = vld1q_s8(w); w = (const int8_t*) w + 16;
280 const int8x16_t vb89x01234567 = vld1q_s8(w); w = (const int8_t*) w + 16;
281 const int8x16_t vbABx01234567 = vld1q_s8(w); w = (const int8_t*) w + 16;
282 const int8x16_t vbCDx01234567 = vld1q_s8(w); w = (const int8_t*) w + 16;
283 const int8x16_t vbEFx01234567 = vld1q_s8(w); w = (const int8_t*) w + 16;
284 const int8x16_t vbGHx01234567 = vld1q_s8(w); w = (const int8_t*) w + 16;
285 const int8x16_t vbIJx01234567 = vld1q_s8(w); w = (const int8_t*) w + 16;
286 const int8x16_t vbKLx01234567 = vld1q_s8(w); w = (const int8_t*) w + 16;
287 const int8x16_t vbMNx01234567 = vld1q_s8(w); w = (const int8_t*) w + 16;
288 const int8x16_t vbOPx01234567 = vld1q_s8(w); w = (const int8_t*) w + 16;
289 const int8x16_t vbQRx01234567 = vld1q_s8(w); w = (const int8_t*) w + 16;
290 const int8x16_t vbSTx01234567 = vld1q_s8(w); w = (const int8_t*) w + 16;
291 const int8x16_t vbUVx01234567 = vld1q_s8(w); w = (const int8_t*) w + 16;
292
293 // Multiply-accumulate: 4x4 * 4x32 --> 4x32.
294 vacc01x01 = vmmlaq_s32(vacc01x01, vreinterpretq_s8_u64(va01x01234567), vb01x01234567);
295 vacc01x23 = vmmlaq_s32(vacc01x23, vreinterpretq_s8_u64(va01x01234567), vb23x01234567);
296 vacc01x45 = vmmlaq_s32(vacc01x45, vreinterpretq_s8_u64(va01x01234567), vb45x01234567);
297 vacc01x67 = vmmlaq_s32(vacc01x67, vreinterpretq_s8_u64(va01x01234567), vb67x01234567);
298 vacc01x89 = vmmlaq_s32(vacc01x89, vreinterpretq_s8_u64(va01x01234567), vb89x01234567);
299 vacc01xAB = vmmlaq_s32(vacc01xAB, vreinterpretq_s8_u64(va01x01234567), vbABx01234567);
300 vacc01xCD = vmmlaq_s32(vacc01xCD, vreinterpretq_s8_u64(va01x01234567), vbCDx01234567);
301 vacc01xEF = vmmlaq_s32(vacc01xEF, vreinterpretq_s8_u64(va01x01234567), vbEFx01234567);
302 vacc01xGH = vmmlaq_s32(vacc01xGH, vreinterpretq_s8_u64(va01x01234567), vbGHx01234567);
303 vacc01xIJ = vmmlaq_s32(vacc01xIJ, vreinterpretq_s8_u64(va01x01234567), vbIJx01234567);
304 vacc01xKL = vmmlaq_s32(vacc01xKL, vreinterpretq_s8_u64(va01x01234567), vbKLx01234567);
305 vacc01xMN = vmmlaq_s32(vacc01xMN, vreinterpretq_s8_u64(va01x01234567), vbMNx01234567);
306 vacc01xOP = vmmlaq_s32(vacc01xOP, vreinterpretq_s8_u64(va01x01234567), vbOPx01234567);
307 vacc01xQR = vmmlaq_s32(vacc01xQR, vreinterpretq_s8_u64(va01x01234567), vbQRx01234567);
308 vacc01xST = vmmlaq_s32(vacc01xST, vreinterpretq_s8_u64(va01x01234567), vbSTx01234567);
309 vacc01xUV = vmmlaq_s32(vacc01xUV, vreinterpretq_s8_u64(va01x01234567), vbUVx01234567);
310 vacc23x01 = vmmlaq_s32(vacc23x01, vreinterpretq_s8_u64(va23x01234567), vb01x01234567);
311 vacc23x23 = vmmlaq_s32(vacc23x23, vreinterpretq_s8_u64(va23x01234567), vb23x01234567);
312 vacc23x45 = vmmlaq_s32(vacc23x45, vreinterpretq_s8_u64(va23x01234567), vb45x01234567);
313 vacc23x67 = vmmlaq_s32(vacc23x67, vreinterpretq_s8_u64(va23x01234567), vb67x01234567);
314 vacc23x89 = vmmlaq_s32(vacc23x89, vreinterpretq_s8_u64(va23x01234567), vb89x01234567);
315 vacc23xAB = vmmlaq_s32(vacc23xAB, vreinterpretq_s8_u64(va23x01234567), vbABx01234567);
316 vacc23xCD = vmmlaq_s32(vacc23xCD, vreinterpretq_s8_u64(va23x01234567), vbCDx01234567);
317 vacc23xEF = vmmlaq_s32(vacc23xEF, vreinterpretq_s8_u64(va23x01234567), vbEFx01234567);
318 vacc23xGH = vmmlaq_s32(vacc23xGH, vreinterpretq_s8_u64(va23x01234567), vbGHx01234567);
319 vacc23xIJ = vmmlaq_s32(vacc23xIJ, vreinterpretq_s8_u64(va23x01234567), vbIJx01234567);
320 vacc23xKL = vmmlaq_s32(vacc23xKL, vreinterpretq_s8_u64(va23x01234567), vbKLx01234567);
321 vacc23xMN = vmmlaq_s32(vacc23xMN, vreinterpretq_s8_u64(va23x01234567), vbMNx01234567);
322 vacc23xOP = vmmlaq_s32(vacc23xOP, vreinterpretq_s8_u64(va23x01234567), vbOPx01234567);
323 vacc23xQR = vmmlaq_s32(vacc23xQR, vreinterpretq_s8_u64(va23x01234567), vbQRx01234567);
324 vacc23xST = vmmlaq_s32(vacc23xST, vreinterpretq_s8_u64(va23x01234567), vbSTx01234567);
325 vacc23xUV = vmmlaq_s32(vacc23xUV, vreinterpretq_s8_u64(va23x01234567), vbUVx01234567);
326 }
327
328 int32x4_t vacc0x0123 = vreinterpretq_s32_u64(vtrn1q_u64(vreinterpretq_u64_s32(vacc01x01), vreinterpretq_u64_s32(vacc01x23)));
329 int32x4_t vacc1x0123 = vreinterpretq_s32_u64(vtrn2q_u64(vreinterpretq_u64_s32(vacc01x01), vreinterpretq_u64_s32(vacc01x23)));
330 int32x4_t vacc0x4567 = vreinterpretq_s32_u64(vtrn1q_u64(vreinterpretq_u64_s32(vacc01x45), vreinterpretq_u64_s32(vacc01x67)));
331 int32x4_t vacc1x4567 = vreinterpretq_s32_u64(vtrn2q_u64(vreinterpretq_u64_s32(vacc01x45), vreinterpretq_u64_s32(vacc01x67)));
332 int32x4_t vacc0x89AB = vreinterpretq_s32_u64(vtrn1q_u64(vreinterpretq_u64_s32(vacc01x89), vreinterpretq_u64_s32(vacc01xAB)));
333 int32x4_t vacc1x89AB = vreinterpretq_s32_u64(vtrn2q_u64(vreinterpretq_u64_s32(vacc01x89), vreinterpretq_u64_s32(vacc01xAB)));
334 int32x4_t vacc0xCDEF = vreinterpretq_s32_u64(vtrn1q_u64(vreinterpretq_u64_s32(vacc01xCD), vreinterpretq_u64_s32(vacc01xEF)));
335 int32x4_t vacc1xCDEF = vreinterpretq_s32_u64(vtrn2q_u64(vreinterpretq_u64_s32(vacc01xCD), vreinterpretq_u64_s32(vacc01xEF)));
336 int32x4_t vacc0xGHIJ = vreinterpretq_s32_u64(vtrn1q_u64(vreinterpretq_u64_s32(vacc01xGH), vreinterpretq_u64_s32(vacc01xIJ)));
337 int32x4_t vacc1xGHIJ = vreinterpretq_s32_u64(vtrn2q_u64(vreinterpretq_u64_s32(vacc01xGH), vreinterpretq_u64_s32(vacc01xIJ)));
338 int32x4_t vacc0xKLMN = vreinterpretq_s32_u64(vtrn1q_u64(vreinterpretq_u64_s32(vacc01xKL), vreinterpretq_u64_s32(vacc01xMN)));
339 int32x4_t vacc1xKLMN = vreinterpretq_s32_u64(vtrn2q_u64(vreinterpretq_u64_s32(vacc01xKL), vreinterpretq_u64_s32(vacc01xMN)));
340 int32x4_t vacc0xOPQR = vreinterpretq_s32_u64(vtrn1q_u64(vreinterpretq_u64_s32(vacc01xOP), vreinterpretq_u64_s32(vacc01xQR)));
341 int32x4_t vacc1xOPQR = vreinterpretq_s32_u64(vtrn2q_u64(vreinterpretq_u64_s32(vacc01xOP), vreinterpretq_u64_s32(vacc01xQR)));
342 int32x4_t vacc0xSTUV = vreinterpretq_s32_u64(vtrn1q_u64(vreinterpretq_u64_s32(vacc01xST), vreinterpretq_u64_s32(vacc01xUV)));
343 int32x4_t vacc1xSTUV = vreinterpretq_s32_u64(vtrn2q_u64(vreinterpretq_u64_s32(vacc01xST), vreinterpretq_u64_s32(vacc01xUV)));
344 int32x4_t vacc2x0123 = vreinterpretq_s32_u64(vtrn1q_u64(vreinterpretq_u64_s32(vacc23x01), vreinterpretq_u64_s32(vacc23x23)));
345 int32x4_t vacc3x0123 = vreinterpretq_s32_u64(vtrn2q_u64(vreinterpretq_u64_s32(vacc23x01), vreinterpretq_u64_s32(vacc23x23)));
346 int32x4_t vacc2x4567 = vreinterpretq_s32_u64(vtrn1q_u64(vreinterpretq_u64_s32(vacc23x45), vreinterpretq_u64_s32(vacc23x67)));
347 int32x4_t vacc3x4567 = vreinterpretq_s32_u64(vtrn2q_u64(vreinterpretq_u64_s32(vacc23x45), vreinterpretq_u64_s32(vacc23x67)));
348 int32x4_t vacc2x89AB = vreinterpretq_s32_u64(vtrn1q_u64(vreinterpretq_u64_s32(vacc23x89), vreinterpretq_u64_s32(vacc23xAB)));
349 int32x4_t vacc3x89AB = vreinterpretq_s32_u64(vtrn2q_u64(vreinterpretq_u64_s32(vacc23x89), vreinterpretq_u64_s32(vacc23xAB)));
350 int32x4_t vacc2xCDEF = vreinterpretq_s32_u64(vtrn1q_u64(vreinterpretq_u64_s32(vacc23xCD), vreinterpretq_u64_s32(vacc23xEF)));
351 int32x4_t vacc3xCDEF = vreinterpretq_s32_u64(vtrn2q_u64(vreinterpretq_u64_s32(vacc23xCD), vreinterpretq_u64_s32(vacc23xEF)));
352 int32x4_t vacc2xGHIJ = vreinterpretq_s32_u64(vtrn1q_u64(vreinterpretq_u64_s32(vacc23xGH), vreinterpretq_u64_s32(vacc23xIJ)));
353 int32x4_t vacc3xGHIJ = vreinterpretq_s32_u64(vtrn2q_u64(vreinterpretq_u64_s32(vacc23xGH), vreinterpretq_u64_s32(vacc23xIJ)));
354 int32x4_t vacc2xKLMN = vreinterpretq_s32_u64(vtrn1q_u64(vreinterpretq_u64_s32(vacc23xKL), vreinterpretq_u64_s32(vacc23xMN)));
355 int32x4_t vacc3xKLMN = vreinterpretq_s32_u64(vtrn2q_u64(vreinterpretq_u64_s32(vacc23xKL), vreinterpretq_u64_s32(vacc23xMN)));
356 int32x4_t vacc2xOPQR = vreinterpretq_s32_u64(vtrn1q_u64(vreinterpretq_u64_s32(vacc23xOP), vreinterpretq_u64_s32(vacc23xQR)));
357 int32x4_t vacc3xOPQR = vreinterpretq_s32_u64(vtrn2q_u64(vreinterpretq_u64_s32(vacc23xOP), vreinterpretq_u64_s32(vacc23xQR)));
358 int32x4_t vacc2xSTUV = vreinterpretq_s32_u64(vtrn1q_u64(vreinterpretq_u64_s32(vacc23xST), vreinterpretq_u64_s32(vacc23xUV)));
359 int32x4_t vacc3xSTUV = vreinterpretq_s32_u64(vtrn2q_u64(vreinterpretq_u64_s32(vacc23xST), vreinterpretq_u64_s32(vacc23xUV)));
360 float32x4_t vout0x0123 = vcvtq_f32_s32(vacc0x0123);
361 float32x4_t vout0x4567 = vcvtq_f32_s32(vacc0x4567);
362 float32x4_t vout0x89AB = vcvtq_f32_s32(vacc0x89AB);
363 float32x4_t vout0xCDEF = vcvtq_f32_s32(vacc0xCDEF);
364 float32x4_t vout0xGHIJ = vcvtq_f32_s32(vacc0xGHIJ);
365 float32x4_t vout0xKLMN = vcvtq_f32_s32(vacc0xKLMN);
366 float32x4_t vout0xOPQR = vcvtq_f32_s32(vacc0xOPQR);
367 float32x4_t vout0xSTUV = vcvtq_f32_s32(vacc0xSTUV);
368 float32x4_t vout1x0123 = vcvtq_f32_s32(vacc1x0123);
369 float32x4_t vout1x4567 = vcvtq_f32_s32(vacc1x4567);
370 float32x4_t vout1x89AB = vcvtq_f32_s32(vacc1x89AB);
371 float32x4_t vout1xCDEF = vcvtq_f32_s32(vacc1xCDEF);
372 float32x4_t vout1xGHIJ = vcvtq_f32_s32(vacc1xGHIJ);
373 float32x4_t vout1xKLMN = vcvtq_f32_s32(vacc1xKLMN);
374 float32x4_t vout1xOPQR = vcvtq_f32_s32(vacc1xOPQR);
375 float32x4_t vout1xSTUV = vcvtq_f32_s32(vacc1xSTUV);
376 float32x4_t vout2x0123 = vcvtq_f32_s32(vacc2x0123);
377 float32x4_t vout2x4567 = vcvtq_f32_s32(vacc2x4567);
378 float32x4_t vout2x89AB = vcvtq_f32_s32(vacc2x89AB);
379 float32x4_t vout2xCDEF = vcvtq_f32_s32(vacc2xCDEF);
380 float32x4_t vout2xGHIJ = vcvtq_f32_s32(vacc2xGHIJ);
381 float32x4_t vout2xKLMN = vcvtq_f32_s32(vacc2xKLMN);
382 float32x4_t vout2xOPQR = vcvtq_f32_s32(vacc2xOPQR);
383 float32x4_t vout2xSTUV = vcvtq_f32_s32(vacc2xSTUV);
384 float32x4_t vout3x0123 = vcvtq_f32_s32(vacc3x0123);
385 float32x4_t vout3x4567 = vcvtq_f32_s32(vacc3x4567);
386 float32x4_t vout3x89AB = vcvtq_f32_s32(vacc3x89AB);
387 float32x4_t vout3xCDEF = vcvtq_f32_s32(vacc3xCDEF);
388 float32x4_t vout3xGHIJ = vcvtq_f32_s32(vacc3xGHIJ);
389 float32x4_t vout3xKLMN = vcvtq_f32_s32(vacc3xKLMN);
390 float32x4_t vout3xOPQR = vcvtq_f32_s32(vacc3xOPQR);
391 float32x4_t vout3xSTUV = vcvtq_f32_s32(vacc3xSTUV);
392
393 const float32x4_t vinput_scale01 = vreinterpretq_f32_s32(vld1q_s32(&quantization_params[0].zero_point));
394 vout0x0123 = vmulq_lane_f32(vout0x0123, vget_low_f32(vinput_scale01), 1);
395 vout1x0123 = vmulq_lane_f32(vout1x0123, vget_high_f32(vinput_scale01), 1);
396 vout0x4567 = vmulq_lane_f32(vout0x4567, vget_low_f32(vinput_scale01), 1);
397 vout1x4567 = vmulq_lane_f32(vout1x4567, vget_high_f32(vinput_scale01), 1);
398 vout0x89AB = vmulq_lane_f32(vout0x89AB, vget_low_f32(vinput_scale01), 1);
399 vout1x89AB = vmulq_lane_f32(vout1x89AB, vget_high_f32(vinput_scale01), 1);
400 vout0xCDEF = vmulq_lane_f32(vout0xCDEF, vget_low_f32(vinput_scale01), 1);
401 vout1xCDEF = vmulq_lane_f32(vout1xCDEF, vget_high_f32(vinput_scale01), 1);
402 vout0xGHIJ = vmulq_lane_f32(vout0xGHIJ, vget_low_f32(vinput_scale01), 1);
403 vout1xGHIJ = vmulq_lane_f32(vout1xGHIJ, vget_high_f32(vinput_scale01), 1);
404 vout0xKLMN = vmulq_lane_f32(vout0xKLMN, vget_low_f32(vinput_scale01), 1);
405 vout1xKLMN = vmulq_lane_f32(vout1xKLMN, vget_high_f32(vinput_scale01), 1);
406 vout0xOPQR = vmulq_lane_f32(vout0xOPQR, vget_low_f32(vinput_scale01), 1);
407 vout1xOPQR = vmulq_lane_f32(vout1xOPQR, vget_high_f32(vinput_scale01), 1);
408 vout0xSTUV = vmulq_lane_f32(vout0xSTUV, vget_low_f32(vinput_scale01), 1);
409 vout1xSTUV = vmulq_lane_f32(vout1xSTUV, vget_high_f32(vinput_scale01), 1);
410 const float32x4_t vinput_scale23 = vreinterpretq_f32_s32(vld1q_s32(&quantization_params[2].zero_point));
411 vout2x0123 = vmulq_lane_f32(vout2x0123, vget_low_f32(vinput_scale23), 1);
412 vout3x0123 = vmulq_lane_f32(vout3x0123, vget_high_f32(vinput_scale23), 1);
413 vout2x4567 = vmulq_lane_f32(vout2x4567, vget_low_f32(vinput_scale23), 1);
414 vout3x4567 = vmulq_lane_f32(vout3x4567, vget_high_f32(vinput_scale23), 1);
415 vout2x89AB = vmulq_lane_f32(vout2x89AB, vget_low_f32(vinput_scale23), 1);
416 vout3x89AB = vmulq_lane_f32(vout3x89AB, vget_high_f32(vinput_scale23), 1);
417 vout2xCDEF = vmulq_lane_f32(vout2xCDEF, vget_low_f32(vinput_scale23), 1);
418 vout3xCDEF = vmulq_lane_f32(vout3xCDEF, vget_high_f32(vinput_scale23), 1);
419 vout2xGHIJ = vmulq_lane_f32(vout2xGHIJ, vget_low_f32(vinput_scale23), 1);
420 vout3xGHIJ = vmulq_lane_f32(vout3xGHIJ, vget_high_f32(vinput_scale23), 1);
421 vout2xKLMN = vmulq_lane_f32(vout2xKLMN, vget_low_f32(vinput_scale23), 1);
422 vout3xKLMN = vmulq_lane_f32(vout3xKLMN, vget_high_f32(vinput_scale23), 1);
423 vout2xOPQR = vmulq_lane_f32(vout2xOPQR, vget_low_f32(vinput_scale23), 1);
424 vout3xOPQR = vmulq_lane_f32(vout3xOPQR, vget_high_f32(vinput_scale23), 1);
425 vout2xSTUV = vmulq_lane_f32(vout2xSTUV, vget_low_f32(vinput_scale23), 1);
426 vout3xSTUV = vmulq_lane_f32(vout3xSTUV, vget_high_f32(vinput_scale23), 1);
427
428 const float32x4_t vfilter_output_scale0123 = vld1q_f32(w); w = (const float*) w + 4;
429 const float32x4_t vfilter_output_scale4567 = vld1q_f32(w); w = (const float*) w + 4;
430 const float32x4_t vfilter_output_scale89AB = vld1q_f32(w); w = (const float*) w + 4;
431 const float32x4_t vfilter_output_scaleCDEF = vld1q_f32(w); w = (const float*) w + 4;
432 const float32x4_t vfilter_output_scaleGHIJ = vld1q_f32(w); w = (const float*) w + 4;
433 const float32x4_t vfilter_output_scaleKLMN = vld1q_f32(w); w = (const float*) w + 4;
434 const float32x4_t vfilter_output_scaleOPQR = vld1q_f32(w); w = (const float*) w + 4;
435 const float32x4_t vfilter_output_scaleSTUV = vld1q_f32(w); w = (const float*) w + 4;
436
437 const float32x4_t vbias0123 = vld1q_f32(w); w = (const float*) w + 4;
438 vout0x0123 = vfmaq_f32(vbias0123, vout0x0123, vfilter_output_scale0123);
439 vout1x0123 = vfmaq_f32(vbias0123, vout1x0123, vfilter_output_scale0123);
440 vout2x0123 = vfmaq_f32(vbias0123, vout2x0123, vfilter_output_scale0123);
441 vout3x0123 = vfmaq_f32(vbias0123, vout3x0123, vfilter_output_scale0123);
442 const float32x4_t vbias4567 = vld1q_f32(w); w = (const float*) w + 4;
443 vout0x4567 = vfmaq_f32(vbias4567, vout0x4567, vfilter_output_scale4567);
444 vout1x4567 = vfmaq_f32(vbias4567, vout1x4567, vfilter_output_scale4567);
445 vout2x4567 = vfmaq_f32(vbias4567, vout2x4567, vfilter_output_scale4567);
446 vout3x4567 = vfmaq_f32(vbias4567, vout3x4567, vfilter_output_scale4567);
447 const float32x4_t vbias89AB = vld1q_f32(w); w = (const float*) w + 4;
448 vout0x89AB = vfmaq_f32(vbias89AB, vout0x89AB, vfilter_output_scale89AB);
449 vout1x89AB = vfmaq_f32(vbias89AB, vout1x89AB, vfilter_output_scale89AB);
450 vout2x89AB = vfmaq_f32(vbias89AB, vout2x89AB, vfilter_output_scale89AB);
451 vout3x89AB = vfmaq_f32(vbias89AB, vout3x89AB, vfilter_output_scale89AB);
452 const float32x4_t vbiasCDEF = vld1q_f32(w); w = (const float*) w + 4;
453 vout0xCDEF = vfmaq_f32(vbiasCDEF, vout0xCDEF, vfilter_output_scaleCDEF);
454 vout1xCDEF = vfmaq_f32(vbiasCDEF, vout1xCDEF, vfilter_output_scaleCDEF);
455 vout2xCDEF = vfmaq_f32(vbiasCDEF, vout2xCDEF, vfilter_output_scaleCDEF);
456 vout3xCDEF = vfmaq_f32(vbiasCDEF, vout3xCDEF, vfilter_output_scaleCDEF);
457 const float32x4_t vbiasGHIJ = vld1q_f32(w); w = (const float*) w + 4;
458 vout0xGHIJ = vfmaq_f32(vbiasGHIJ, vout0xGHIJ, vfilter_output_scaleGHIJ);
459 vout1xGHIJ = vfmaq_f32(vbiasGHIJ, vout1xGHIJ, vfilter_output_scaleGHIJ);
460 vout2xGHIJ = vfmaq_f32(vbiasGHIJ, vout2xGHIJ, vfilter_output_scaleGHIJ);
461 vout3xGHIJ = vfmaq_f32(vbiasGHIJ, vout3xGHIJ, vfilter_output_scaleGHIJ);
462 const float32x4_t vbiasKLMN = vld1q_f32(w); w = (const float*) w + 4;
463 vout0xKLMN = vfmaq_f32(vbiasKLMN, vout0xKLMN, vfilter_output_scaleKLMN);
464 vout1xKLMN = vfmaq_f32(vbiasKLMN, vout1xKLMN, vfilter_output_scaleKLMN);
465 vout2xKLMN = vfmaq_f32(vbiasKLMN, vout2xKLMN, vfilter_output_scaleKLMN);
466 vout3xKLMN = vfmaq_f32(vbiasKLMN, vout3xKLMN, vfilter_output_scaleKLMN);
467 const float32x4_t vbiasOPQR = vld1q_f32(w); w = (const float*) w + 4;
468 vout0xOPQR = vfmaq_f32(vbiasOPQR, vout0xOPQR, vfilter_output_scaleOPQR);
469 vout1xOPQR = vfmaq_f32(vbiasOPQR, vout1xOPQR, vfilter_output_scaleOPQR);
470 vout2xOPQR = vfmaq_f32(vbiasOPQR, vout2xOPQR, vfilter_output_scaleOPQR);
471 vout3xOPQR = vfmaq_f32(vbiasOPQR, vout3xOPQR, vfilter_output_scaleOPQR);
472 const float32x4_t vbiasSTUV = vld1q_f32(w); w = (const float*) w + 4;
473 vout0xSTUV = vfmaq_f32(vbiasSTUV, vout0xSTUV, vfilter_output_scaleSTUV);
474 vout1xSTUV = vfmaq_f32(vbiasSTUV, vout1xSTUV, vfilter_output_scaleSTUV);
475 vout2xSTUV = vfmaq_f32(vbiasSTUV, vout2xSTUV, vfilter_output_scaleSTUV);
476 vout3xSTUV = vfmaq_f32(vbiasSTUV, vout3xSTUV, vfilter_output_scaleSTUV);
477
478 const float32x4_t voutput_min = vld1q_dup_f32(&params->scalar.min);
479 vout0x0123 = vmaxq_f32(vout0x0123, voutput_min);
480 vout0x4567 = vmaxq_f32(vout0x4567, voutput_min);
481 vout0x89AB = vmaxq_f32(vout0x89AB, voutput_min);
482 vout0xCDEF = vmaxq_f32(vout0xCDEF, voutput_min);
483 vout0xGHIJ = vmaxq_f32(vout0xGHIJ, voutput_min);
484 vout0xKLMN = vmaxq_f32(vout0xKLMN, voutput_min);
485 vout0xOPQR = vmaxq_f32(vout0xOPQR, voutput_min);
486 vout0xSTUV = vmaxq_f32(vout0xSTUV, voutput_min);
487 vout1x0123 = vmaxq_f32(vout1x0123, voutput_min);
488 vout1x4567 = vmaxq_f32(vout1x4567, voutput_min);
489 vout1x89AB = vmaxq_f32(vout1x89AB, voutput_min);
490 vout1xCDEF = vmaxq_f32(vout1xCDEF, voutput_min);
491 vout1xGHIJ = vmaxq_f32(vout1xGHIJ, voutput_min);
492 vout1xKLMN = vmaxq_f32(vout1xKLMN, voutput_min);
493 vout1xOPQR = vmaxq_f32(vout1xOPQR, voutput_min);
494 vout1xSTUV = vmaxq_f32(vout1xSTUV, voutput_min);
495 vout2x0123 = vmaxq_f32(vout2x0123, voutput_min);
496 vout2x4567 = vmaxq_f32(vout2x4567, voutput_min);
497 vout2x89AB = vmaxq_f32(vout2x89AB, voutput_min);
498 vout2xCDEF = vmaxq_f32(vout2xCDEF, voutput_min);
499 vout2xGHIJ = vmaxq_f32(vout2xGHIJ, voutput_min);
500 vout2xKLMN = vmaxq_f32(vout2xKLMN, voutput_min);
501 vout2xOPQR = vmaxq_f32(vout2xOPQR, voutput_min);
502 vout2xSTUV = vmaxq_f32(vout2xSTUV, voutput_min);
503 vout3x0123 = vmaxq_f32(vout3x0123, voutput_min);
504 vout3x4567 = vmaxq_f32(vout3x4567, voutput_min);
505 vout3x89AB = vmaxq_f32(vout3x89AB, voutput_min);
506 vout3xCDEF = vmaxq_f32(vout3xCDEF, voutput_min);
507 vout3xGHIJ = vmaxq_f32(vout3xGHIJ, voutput_min);
508 vout3xKLMN = vmaxq_f32(vout3xKLMN, voutput_min);
509 vout3xOPQR = vmaxq_f32(vout3xOPQR, voutput_min);
510 vout3xSTUV = vmaxq_f32(vout3xSTUV, voutput_min);
511
512 const float32x4_t voutput_max = vld1q_dup_f32(&params->scalar.max);
513 vout0x0123 = vminq_f32(vout0x0123, voutput_max);
514 vout0x4567 = vminq_f32(vout0x4567, voutput_max);
515 vout0x89AB = vminq_f32(vout0x89AB, voutput_max);
516 vout0xCDEF = vminq_f32(vout0xCDEF, voutput_max);
517 vout0xGHIJ = vminq_f32(vout0xGHIJ, voutput_max);
518 vout0xKLMN = vminq_f32(vout0xKLMN, voutput_max);
519 vout0xOPQR = vminq_f32(vout0xOPQR, voutput_max);
520 vout0xSTUV = vminq_f32(vout0xSTUV, voutput_max);
521 vout1x0123 = vminq_f32(vout1x0123, voutput_max);
522 vout1x4567 = vminq_f32(vout1x4567, voutput_max);
523 vout1x89AB = vminq_f32(vout1x89AB, voutput_max);
524 vout1xCDEF = vminq_f32(vout1xCDEF, voutput_max);
525 vout1xGHIJ = vminq_f32(vout1xGHIJ, voutput_max);
526 vout1xKLMN = vminq_f32(vout1xKLMN, voutput_max);
527 vout1xOPQR = vminq_f32(vout1xOPQR, voutput_max);
528 vout1xSTUV = vminq_f32(vout1xSTUV, voutput_max);
529 vout2x0123 = vminq_f32(vout2x0123, voutput_max);
530 vout2x4567 = vminq_f32(vout2x4567, voutput_max);
531 vout2x89AB = vminq_f32(vout2x89AB, voutput_max);
532 vout2xCDEF = vminq_f32(vout2xCDEF, voutput_max);
533 vout2xGHIJ = vminq_f32(vout2xGHIJ, voutput_max);
534 vout2xKLMN = vminq_f32(vout2xKLMN, voutput_max);
535 vout2xOPQR = vminq_f32(vout2xOPQR, voutput_max);
536 vout2xSTUV = vminq_f32(vout2xSTUV, voutput_max);
537 vout3x0123 = vminq_f32(vout3x0123, voutput_max);
538 vout3x4567 = vminq_f32(vout3x4567, voutput_max);
539 vout3x89AB = vminq_f32(vout3x89AB, voutput_max);
540 vout3xCDEF = vminq_f32(vout3xCDEF, voutput_max);
541 vout3xGHIJ = vminq_f32(vout3xGHIJ, voutput_max);
542 vout3xKLMN = vminq_f32(vout3xKLMN, voutput_max);
543 vout3xOPQR = vminq_f32(vout3xOPQR, voutput_max);
544 vout3xSTUV = vminq_f32(vout3xSTUV, voutput_max);
545
546 if XNN_LIKELY(nc >= 32) {
547 vst1q_f32(c0, vout0x0123);
548 vst1q_f32(c0 + 4, vout0x4567);
549 vst1q_f32(c0 + 8, vout0x89AB);
550 vst1q_f32(c0 + 12, vout0xCDEF);
551 vst1q_f32(c0 + 16, vout0xGHIJ);
552 vst1q_f32(c0 + 20, vout0xKLMN);
553 vst1q_f32(c0 + 24, vout0xOPQR);
554 vst1q_f32(c0 + 28, vout0xSTUV);
555 vst1q_f32(c1, vout1x0123);
556 vst1q_f32(c1 + 4, vout1x4567);
557 vst1q_f32(c1 + 8, vout1x89AB);
558 vst1q_f32(c1 + 12, vout1xCDEF);
559 vst1q_f32(c1 + 16, vout1xGHIJ);
560 vst1q_f32(c1 + 20, vout1xKLMN);
561 vst1q_f32(c1 + 24, vout1xOPQR);
562 vst1q_f32(c1 + 28, vout1xSTUV);
563 vst1q_f32(c2, vout2x0123);
564 vst1q_f32(c2 + 4, vout2x4567);
565 vst1q_f32(c2 + 8, vout2x89AB);
566 vst1q_f32(c2 + 12, vout2xCDEF);
567 vst1q_f32(c2 + 16, vout2xGHIJ);
568 vst1q_f32(c2 + 20, vout2xKLMN);
569 vst1q_f32(c2 + 24, vout2xOPQR);
570 vst1q_f32(c2 + 28, vout2xSTUV);
571 vst1q_f32(c3, vout3x0123);
572 vst1q_f32(c3 + 4, vout3x4567);
573 vst1q_f32(c3 + 8, vout3x89AB);
574 vst1q_f32(c3 + 12, vout3xCDEF);
575 vst1q_f32(c3 + 16, vout3xGHIJ);
576 vst1q_f32(c3 + 20, vout3xKLMN);
577 vst1q_f32(c3 + 24, vout3xOPQR);
578 vst1q_f32(c3 + 28, vout3xSTUV);
579
580 a0 = (const int8_t*) ((uintptr_t) a0 - kc);
581 a1 = (const int8_t*) ((uintptr_t) a1 - kc);
582 a2 = (const int8_t*) ((uintptr_t) a2 - kc);
583 a3 = (const int8_t*) ((uintptr_t) a3 - kc);
584
585 c0 = (float*) ((uintptr_t) c0 + cn_stride);
586 c1 = (float*) ((uintptr_t) c1 + cn_stride);
587 c2 = (float*) ((uintptr_t) c2 + cn_stride);
588 c3 = (float*) ((uintptr_t) c3 + cn_stride);
589
590 nc -= 32;
591 } else {
592 if (nc & 16) {
593 vst1q_f32(c0, vout0x0123); c0 += 4;
594 vout0x0123 = vout0xGHIJ;
595 vst1q_f32(c1, vout1x0123); c1 += 4;
596 vout1x0123 = vout1xGHIJ;
597 vst1q_f32(c2, vout2x0123); c2 += 4;
598 vout2x0123 = vout2xGHIJ;
599 vst1q_f32(c3, vout3x0123); c3 += 4;
600 vout3x0123 = vout3xGHIJ;
601 vst1q_f32(c0, vout0x4567); c0 += 4;
602 vout0x4567 = vout0xKLMN;
603 vst1q_f32(c1, vout1x4567); c1 += 4;
604 vout1x4567 = vout1xKLMN;
605 vst1q_f32(c2, vout2x4567); c2 += 4;
606 vout2x4567 = vout2xKLMN;
607 vst1q_f32(c3, vout3x4567); c3 += 4;
608 vout3x4567 = vout3xKLMN;
609 vst1q_f32(c0, vout0x89AB); c0 += 4;
610 vout0x89AB = vout0xOPQR;
611 vst1q_f32(c1, vout1x89AB); c1 += 4;
612 vout1x89AB = vout1xOPQR;
613 vst1q_f32(c2, vout2x89AB); c2 += 4;
614 vout2x89AB = vout2xOPQR;
615 vst1q_f32(c3, vout3x89AB); c3 += 4;
616 vout3x89AB = vout3xOPQR;
617 vst1q_f32(c0, vout0xCDEF); c0 += 4;
618 vout0xCDEF = vout0xSTUV;
619 vst1q_f32(c1, vout1xCDEF); c1 += 4;
620 vout1xCDEF = vout1xSTUV;
621 vst1q_f32(c2, vout2xCDEF); c2 += 4;
622 vout2xCDEF = vout2xSTUV;
623 vst1q_f32(c3, vout3xCDEF); c3 += 4;
624 vout3xCDEF = vout3xSTUV;
625 }
626 if (nc & 8) {
627 vst1q_f32(c0, vout0x0123); c0 += 4;
628 vout0x0123 = vout0x89AB;
629 vst1q_f32(c1, vout1x0123); c1 += 4;
630 vout1x0123 = vout1x89AB;
631 vst1q_f32(c2, vout2x0123); c2 += 4;
632 vout2x0123 = vout2x89AB;
633 vst1q_f32(c3, vout3x0123); c3 += 4;
634 vout3x0123 = vout3x89AB;
635 vst1q_f32(c0, vout0x4567); c0 += 4;
636 vout0x4567 = vout0xCDEF;
637 vst1q_f32(c1, vout1x4567); c1 += 4;
638 vout1x4567 = vout1xCDEF;
639 vst1q_f32(c2, vout2x4567); c2 += 4;
640 vout2x4567 = vout2xCDEF;
641 vst1q_f32(c3, vout3x4567); c3 += 4;
642 vout3x4567 = vout3xCDEF;
643 }
644 if (nc & 4) {
645 vst1q_f32(c0, vout0x0123); c0 += 4;
646 vout0x0123 = vout0x4567;
647 vst1q_f32(c1, vout1x0123); c1 += 4;
648 vout1x0123 = vout1x4567;
649 vst1q_f32(c2, vout2x0123); c2 += 4;
650 vout2x0123 = vout2x4567;
651 vst1q_f32(c3, vout3x0123); c3 += 4;
652 vout3x0123 = vout3x4567;
653 }
654 float32x2_t vout0x01 = vget_low_f32(vout0x0123);
655 float32x2_t vout1x01 = vget_low_f32(vout1x0123);
656 float32x2_t vout2x01 = vget_low_f32(vout2x0123);
657 float32x2_t vout3x01 = vget_low_f32(vout3x0123);
658 if (nc & 2) {
659 vst1_f32(c0, vout0x01); c0 += 2;
660 vst1_f32(c1, vout1x01); c1 += 2;
661 vst1_f32(c2, vout2x01); c2 += 2;
662 vst1_f32(c3, vout3x01); c3 += 2;
663 vout0x01 = vget_high_f32(vout0x0123);
664 vout1x01 = vget_high_f32(vout1x0123);
665 vout2x01 = vget_high_f32(vout2x0123);
666 vout3x01 = vget_high_f32(vout3x0123);
667 }
668 if (nc & 1) {
669 vst1_lane_f32(c0, vout0x01, 0);
670 vst1_lane_f32(c1, vout1x01, 0);
671 vst1_lane_f32(c2, vout2x01, 0);
672 vst1_lane_f32(c3, vout3x01, 0);
673 }
674 nc = 0;
675 }
676 } while (nc != 0);
677 }