Debian Codegraph @

src/qd8-f32-qc4w-gemm/gen/qd8-f32-qc4w-gemm-8x16c8-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_qc4w_gemm_minmax_ukernel_8x16c8__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 struct xnn_f32_qc4w_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 <= 8);
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 const int8_t* a4 = (const int8_t*) ((uintptr_t) a3 + a_stride);
62 float* c4 = (float*) ((uintptr_t) c3 + cm_stride);
63 if XNN_UNPREDICTABLE(mr <= 4) {
64 a4 = a3;
65 c4 = c3;
66 }
67 const int8_t* a5 = (const int8_t*) ((uintptr_t) a4 + a_stride);
68 float* c5 = (float*) ((uintptr_t) c4 + cm_stride);
69 if XNN_UNPREDICTABLE(mr < 6) {
70 a5 = a4;
71 c5 = c4;
72 }
73 const int8_t* a6 = (const int8_t*) ((uintptr_t) a5 + a_stride);
74 float* c6 = (float*) ((uintptr_t) c5 + cm_stride);
75 if XNN_UNPREDICTABLE(mr <= 6) {
76 a6 = a5;
77 c6 = c5;
78 }
79 const int8_t* a7 = (const int8_t*) ((uintptr_t) a6 + a_stride);
80 float* c7 = (float*) ((uintptr_t) c6 + cm_stride);
81 if XNN_UNPREDICTABLE(mr != 8) {
82 a7 = a6;
83 c7 = c6;
84 }
85 const int8x16_t vmask = vmovq_n_s8(INT8_C(0xF0));
86
87 // Loop over groups of 16 columns.
88 do {
89 // Initialize accumulators with bias. 16 bias values are loaded from the
90 // weight matrix, at the start of the group of 16 columns.
91 const int32x4_t vinput_zero_point01 = vld1q_s32(&quantization_params[0].zero_point);
92 const int32x4_t vksum0123 = vld1q_s32(w); w = (const int32_t*) w + 4;
93 const int32x4_t vksumzp0x0123 = vmulq_lane_s32(vksum0123, vget_low_s32(vinput_zero_point01), 0);
94 const int32x4_t vksumzp1x0123 = vmulq_lane_s32(vksum0123, vget_high_s32(vinput_zero_point01), 0);
95 const int32x4_t vksum4567 = vld1q_s32(w); w = (const int32_t*) w + 4;
96 const int32x4_t vksumzp0x4567 = vmulq_lane_s32(vksum4567, vget_low_s32(vinput_zero_point01), 0);
97 const int32x4_t vksumzp1x4567 = vmulq_lane_s32(vksum4567, vget_high_s32(vinput_zero_point01), 0);
98 const int32x4_t vksum89AB = vld1q_s32(w); w = (const int32_t*) w + 4;
99 const int32x4_t vksumzp0x89AB = vmulq_lane_s32(vksum89AB, vget_low_s32(vinput_zero_point01), 0);
100 const int32x4_t vksumzp1x89AB = vmulq_lane_s32(vksum89AB, vget_high_s32(vinput_zero_point01), 0);
101 const int32x4_t vksumCDEF = vld1q_s32(w); w = (const int32_t*) w + 4;
102 const int32x4_t vksumzp0xCDEF = vmulq_lane_s32(vksumCDEF, vget_low_s32(vinput_zero_point01), 0);
103 const int32x4_t vksumzp1xCDEF = vmulq_lane_s32(vksumCDEF, vget_high_s32(vinput_zero_point01), 0);
104 const int32x4_t vinput_zero_point23 = vld1q_s32(&quantization_params[2].zero_point);
105 const int32x4_t vksumzp2x0123 = vmulq_lane_s32(vksum0123, vget_low_s32(vinput_zero_point23), 0);
106 const int32x4_t vksumzp3x0123 = vmulq_lane_s32(vksum0123, vget_high_s32(vinput_zero_point23), 0);
107 const int32x4_t vksumzp2x4567 = vmulq_lane_s32(vksum4567, vget_low_s32(vinput_zero_point23), 0);
108 const int32x4_t vksumzp3x4567 = vmulq_lane_s32(vksum4567, vget_high_s32(vinput_zero_point23), 0);
109 const int32x4_t vksumzp2x89AB = vmulq_lane_s32(vksum89AB, vget_low_s32(vinput_zero_point23), 0);
110 const int32x4_t vksumzp3x89AB = vmulq_lane_s32(vksum89AB, vget_high_s32(vinput_zero_point23), 0);
111 const int32x4_t vksumzp2xCDEF = vmulq_lane_s32(vksumCDEF, vget_low_s32(vinput_zero_point23), 0);
112 const int32x4_t vksumzp3xCDEF = vmulq_lane_s32(vksumCDEF, vget_high_s32(vinput_zero_point23), 0);
113 const int32x4_t vinput_zero_point45 = vld1q_s32(&quantization_params[4].zero_point);
114 const int32x4_t vksumzp4x0123 = vmulq_lane_s32(vksum0123, vget_low_s32(vinput_zero_point45), 0);
115 const int32x4_t vksumzp5x0123 = vmulq_lane_s32(vksum0123, vget_high_s32(vinput_zero_point45), 0);
116 const int32x4_t vksumzp4x4567 = vmulq_lane_s32(vksum4567, vget_low_s32(vinput_zero_point45), 0);
117 const int32x4_t vksumzp5x4567 = vmulq_lane_s32(vksum4567, vget_high_s32(vinput_zero_point45), 0);
118 const int32x4_t vksumzp4x89AB = vmulq_lane_s32(vksum89AB, vget_low_s32(vinput_zero_point45), 0);
119 const int32x4_t vksumzp5x89AB = vmulq_lane_s32(vksum89AB, vget_high_s32(vinput_zero_point45), 0);
120 const int32x4_t vksumzp4xCDEF = vmulq_lane_s32(vksumCDEF, vget_low_s32(vinput_zero_point45), 0);
121 const int32x4_t vksumzp5xCDEF = vmulq_lane_s32(vksumCDEF, vget_high_s32(vinput_zero_point45), 0);
122 const int32x4_t vinput_zero_point67 = vld1q_s32(&quantization_params[6].zero_point);
123 const int32x4_t vksumzp6x0123 = vmulq_lane_s32(vksum0123, vget_low_s32(vinput_zero_point67), 0);
124 const int32x4_t vksumzp7x0123 = vmulq_lane_s32(vksum0123, vget_high_s32(vinput_zero_point67), 0);
125 const int32x4_t vksumzp6x4567 = vmulq_lane_s32(vksum4567, vget_low_s32(vinput_zero_point67), 0);
126 const int32x4_t vksumzp7x4567 = vmulq_lane_s32(vksum4567, vget_high_s32(vinput_zero_point67), 0);
127 const int32x4_t vksumzp6x89AB = vmulq_lane_s32(vksum89AB, vget_low_s32(vinput_zero_point67), 0);
128 const int32x4_t vksumzp7x89AB = vmulq_lane_s32(vksum89AB, vget_high_s32(vinput_zero_point67), 0);
129 const int32x4_t vksumzp6xCDEF = vmulq_lane_s32(vksumCDEF, vget_low_s32(vinput_zero_point67), 0);
130 const int32x4_t vksumzp7xCDEF = vmulq_lane_s32(vksumCDEF, vget_high_s32(vinput_zero_point67), 0);
131
132 int32x4_t vacc01x01 = vreinterpretq_s32_u64(vtrn1q_u64(vreinterpretq_u64_s32(vksumzp0x0123), vreinterpretq_u64_s32(vksumzp1x0123)));
133 int32x4_t vacc01x23 = vreinterpretq_s32_u64(vtrn2q_u64(vreinterpretq_u64_s32(vksumzp0x0123), vreinterpretq_u64_s32(vksumzp1x0123)));
134 int32x4_t vacc01x45 = vreinterpretq_s32_u64(vtrn1q_u64(vreinterpretq_u64_s32(vksumzp0x4567), vreinterpretq_u64_s32(vksumzp1x4567)));
135 int32x4_t vacc01x67 = vreinterpretq_s32_u64(vtrn2q_u64(vreinterpretq_u64_s32(vksumzp0x4567), vreinterpretq_u64_s32(vksumzp1x4567)));
136 int32x4_t vacc01x89 = vreinterpretq_s32_u64(vtrn1q_u64(vreinterpretq_u64_s32(vksumzp0x89AB), vreinterpretq_u64_s32(vksumzp1x89AB)));
137 int32x4_t vacc01xAB = vreinterpretq_s32_u64(vtrn2q_u64(vreinterpretq_u64_s32(vksumzp0x89AB), vreinterpretq_u64_s32(vksumzp1x89AB)));
138 int32x4_t vacc01xCD = vreinterpretq_s32_u64(vtrn1q_u64(vreinterpretq_u64_s32(vksumzp0xCDEF), vreinterpretq_u64_s32(vksumzp1xCDEF)));
139 int32x4_t vacc01xEF = vreinterpretq_s32_u64(vtrn2q_u64(vreinterpretq_u64_s32(vksumzp0xCDEF), vreinterpretq_u64_s32(vksumzp1xCDEF)));
140 int32x4_t vacc23x01 = vreinterpretq_s32_u64(vtrn1q_u64(vreinterpretq_u64_s32(vksumzp2x0123), vreinterpretq_u64_s32(vksumzp3x0123)));
141 int32x4_t vacc23x23 = vreinterpretq_s32_u64(vtrn2q_u64(vreinterpretq_u64_s32(vksumzp2x0123), vreinterpretq_u64_s32(vksumzp3x0123)));
142 int32x4_t vacc23x45 = vreinterpretq_s32_u64(vtrn1q_u64(vreinterpretq_u64_s32(vksumzp2x4567), vreinterpretq_u64_s32(vksumzp3x4567)));
143 int32x4_t vacc23x67 = vreinterpretq_s32_u64(vtrn2q_u64(vreinterpretq_u64_s32(vksumzp2x4567), vreinterpretq_u64_s32(vksumzp3x4567)));
144 int32x4_t vacc23x89 = vreinterpretq_s32_u64(vtrn1q_u64(vreinterpretq_u64_s32(vksumzp2x89AB), vreinterpretq_u64_s32(vksumzp3x89AB)));
145 int32x4_t vacc23xAB = vreinterpretq_s32_u64(vtrn2q_u64(vreinterpretq_u64_s32(vksumzp2x89AB), vreinterpretq_u64_s32(vksumzp3x89AB)));
146 int32x4_t vacc23xCD = vreinterpretq_s32_u64(vtrn1q_u64(vreinterpretq_u64_s32(vksumzp2xCDEF), vreinterpretq_u64_s32(vksumzp3xCDEF)));
147 int32x4_t vacc23xEF = vreinterpretq_s32_u64(vtrn2q_u64(vreinterpretq_u64_s32(vksumzp2xCDEF), vreinterpretq_u64_s32(vksumzp3xCDEF)));
148 int32x4_t vacc45x01 = vreinterpretq_s32_u64(vtrn1q_u64(vreinterpretq_u64_s32(vksumzp4x0123), vreinterpretq_u64_s32(vksumzp5x0123)));
149 int32x4_t vacc45x23 = vreinterpretq_s32_u64(vtrn2q_u64(vreinterpretq_u64_s32(vksumzp4x0123), vreinterpretq_u64_s32(vksumzp5x0123)));
150 int32x4_t vacc45x45 = vreinterpretq_s32_u64(vtrn1q_u64(vreinterpretq_u64_s32(vksumzp4x4567), vreinterpretq_u64_s32(vksumzp5x4567)));
151 int32x4_t vacc45x67 = vreinterpretq_s32_u64(vtrn2q_u64(vreinterpretq_u64_s32(vksumzp4x4567), vreinterpretq_u64_s32(vksumzp5x4567)));
152 int32x4_t vacc45x89 = vreinterpretq_s32_u64(vtrn1q_u64(vreinterpretq_u64_s32(vksumzp4x89AB), vreinterpretq_u64_s32(vksumzp5x89AB)));
153 int32x4_t vacc45xAB = vreinterpretq_s32_u64(vtrn2q_u64(vreinterpretq_u64_s32(vksumzp4x89AB), vreinterpretq_u64_s32(vksumzp5x89AB)));
154 int32x4_t vacc45xCD = vreinterpretq_s32_u64(vtrn1q_u64(vreinterpretq_u64_s32(vksumzp4xCDEF), vreinterpretq_u64_s32(vksumzp5xCDEF)));
155 int32x4_t vacc45xEF = vreinterpretq_s32_u64(vtrn2q_u64(vreinterpretq_u64_s32(vksumzp4xCDEF), vreinterpretq_u64_s32(vksumzp5xCDEF)));
156 int32x4_t vacc67x01 = vreinterpretq_s32_u64(vtrn1q_u64(vreinterpretq_u64_s32(vksumzp6x0123), vreinterpretq_u64_s32(vksumzp7x0123)));
157 int32x4_t vacc67x23 = vreinterpretq_s32_u64(vtrn2q_u64(vreinterpretq_u64_s32(vksumzp6x0123), vreinterpretq_u64_s32(vksumzp7x0123)));
158 int32x4_t vacc67x45 = vreinterpretq_s32_u64(vtrn1q_u64(vreinterpretq_u64_s32(vksumzp6x4567), vreinterpretq_u64_s32(vksumzp7x4567)));
159 int32x4_t vacc67x67 = vreinterpretq_s32_u64(vtrn2q_u64(vreinterpretq_u64_s32(vksumzp6x4567), vreinterpretq_u64_s32(vksumzp7x4567)));
160 int32x4_t vacc67x89 = vreinterpretq_s32_u64(vtrn1q_u64(vreinterpretq_u64_s32(vksumzp6x89AB), vreinterpretq_u64_s32(vksumzp7x89AB)));
161 int32x4_t vacc67xAB = vreinterpretq_s32_u64(vtrn2q_u64(vreinterpretq_u64_s32(vksumzp6x89AB), vreinterpretq_u64_s32(vksumzp7x89AB)));
162 int32x4_t vacc67xCD = vreinterpretq_s32_u64(vtrn1q_u64(vreinterpretq_u64_s32(vksumzp6xCDEF), vreinterpretq_u64_s32(vksumzp7xCDEF)));
163 int32x4_t vacc67xEF = vreinterpretq_s32_u64(vtrn2q_u64(vreinterpretq_u64_s32(vksumzp6xCDEF), vreinterpretq_u64_s32(vksumzp7xCDEF)));
164
165 // Inner accumulation loop along the 16 columns.
166 size_t k = kc;
167 // 2x partial unrolled loop to load 8 bytes at a time.
168
169 uint64x2x2_t va01x0123456789ABCDEF;
170 va01x0123456789ABCDEF.val[0] = vdupq_n_u64(0);
171 va01x0123456789ABCDEF.val[1] = vdupq_n_u64(0);
172 uint64x2x2_t va23x0123456789ABCDEF;
173 va23x0123456789ABCDEF.val[0] = vdupq_n_u64(0);
174 va23x0123456789ABCDEF.val[1] = vdupq_n_u64(0);
175 uint64x2x2_t va45x0123456789ABCDEF;
176 va45x0123456789ABCDEF.val[0] = vdupq_n_u64(0);
177 va45x0123456789ABCDEF.val[1] = vdupq_n_u64(0);
178 uint64x2x2_t va67x0123456789ABCDEF;
179 va67x0123456789ABCDEF.val[0] = vdupq_n_u64(0);
180 va67x0123456789ABCDEF.val[1] = vdupq_n_u64(0);
181
182 while (k >= 16 * sizeof(int8_t)) {
183 // Load a 8x16 block of activations.
184 va01x0123456789ABCDEF = vld2q_lane_u64((const void*) a0, va01x0123456789ABCDEF, 0); a0 += 16;
185 va23x0123456789ABCDEF = vld2q_lane_u64((const void*) a2, va23x0123456789ABCDEF, 0); a2 += 16;
186 va45x0123456789ABCDEF = vld2q_lane_u64((const void*) a4, va45x0123456789ABCDEF, 0); a4 += 16;
187 va67x0123456789ABCDEF = vld2q_lane_u64((const void*) a6, va67x0123456789ABCDEF, 0); a6 += 16;
188 va01x0123456789ABCDEF = vld2q_lane_u64((const void*) a1, va01x0123456789ABCDEF, 1); a1 += 16;
189 va23x0123456789ABCDEF = vld2q_lane_u64((const void*) a3, va23x0123456789ABCDEF, 1); a3 += 16;
190 va45x0123456789ABCDEF = vld2q_lane_u64((const void*) a5, va45x0123456789ABCDEF, 1); a5 += 16;
191 va67x0123456789ABCDEF = vld2q_lane_u64((const void*) a7, va67x0123456789ABCDEF, 1); a7 += 16;
192
193 const int8x16_t va01x01234567 = vreinterpretq_s8_u64(va01x0123456789ABCDEF.val[0]);
194 const int8x16_t va01x89ABCDEF = vreinterpretq_s8_u64(va01x0123456789ABCDEF.val[1]);
195 const int8x16_t va23x01234567 = vreinterpretq_s8_u64(va23x0123456789ABCDEF.val[0]);
196 const int8x16_t va23x89ABCDEF = vreinterpretq_s8_u64(va23x0123456789ABCDEF.val[1]);
197 const int8x16_t va45x01234567 = vreinterpretq_s8_u64(va45x0123456789ABCDEF.val[0]);
198 const int8x16_t va45x89ABCDEF = vreinterpretq_s8_u64(va45x0123456789ABCDEF.val[1]);
199 const int8x16_t va67x01234567 = vreinterpretq_s8_u64(va67x0123456789ABCDEF.val[0]);
200 const int8x16_t va67x89ABCDEF = vreinterpretq_s8_u64(va67x0123456789ABCDEF.val[1]);
201
202 // Load a 16x16 block of weights.
203 const int8x16_t vb01x0123456789ABCDEF = vld1q_s8(w); w = (const int8_t*) w + 16;
204 const int8x16_t vb23x0123456789ABCDEF = vld1q_s8(w); w = (const int8_t*) w + 16;
205 const int8x16_t vb45x0123456789ABCDEF = vld1q_s8(w); w = (const int8_t*) w + 16;
206 const int8x16_t vb67x0123456789ABCDEF = vld1q_s8(w); w = (const int8_t*) w + 16;
207 const int8x16_t vb89x0123456789ABCDEF = vld1q_s8(w); w = (const int8_t*) w + 16;
208 const int8x16_t vbABx0123456789ABCDEF = vld1q_s8(w); w = (const int8_t*) w + 16;
209 const int8x16_t vbCDx0123456789ABCDEF = vld1q_s8(w); w = (const int8_t*) w + 16;
210 const int8x16_t vbEFx0123456789ABCDEF = vld1q_s8(w); w = (const int8_t*) w + 16;
211 const int8x16_t vb01x01234567 = vshlq_n_s8(vb01x0123456789ABCDEF, 4);
212 const int8x16_t vb23x01234567 = vshlq_n_s8(vb23x0123456789ABCDEF, 4);
213 const int8x16_t vb45x01234567 = vshlq_n_s8(vb45x0123456789ABCDEF, 4);
214 const int8x16_t vb67x01234567 = vshlq_n_s8(vb67x0123456789ABCDEF, 4);
215 const int8x16_t vb89x01234567 = vshlq_n_s8(vb89x0123456789ABCDEF, 4);
216 const int8x16_t vbABx01234567 = vshlq_n_s8(vbABx0123456789ABCDEF, 4);
217 const int8x16_t vbCDx01234567 = vshlq_n_s8(vbCDx0123456789ABCDEF, 4);
218 const int8x16_t vbEFx01234567 = vshlq_n_s8(vbEFx0123456789ABCDEF, 4);
219 const int8x16_t vb01x89ABCDEF = vandq_s8(vb01x0123456789ABCDEF, vmask);
220 const int8x16_t vb23x89ABCDEF = vandq_s8(vb23x0123456789ABCDEF, vmask);
221 const int8x16_t vb45x89ABCDEF = vandq_s8(vb45x0123456789ABCDEF, vmask);
222 const int8x16_t vb67x89ABCDEF = vandq_s8(vb67x0123456789ABCDEF, vmask);
223 const int8x16_t vb89x89ABCDEF = vandq_s8(vb89x0123456789ABCDEF, vmask);
224 const int8x16_t vbABx89ABCDEF = vandq_s8(vbABx0123456789ABCDEF, vmask);
225 const int8x16_t vbCDx89ABCDEF = vandq_s8(vbCDx0123456789ABCDEF, vmask);
226 const int8x16_t vbEFx89ABCDEF = vandq_s8(vbEFx0123456789ABCDEF, vmask);
227
228 // Multiply-accumulate: 8x8 * 8x16 --> 8x16.
229 vacc01x01 = vmmlaq_s32(vacc01x01, va01x01234567, vb01x01234567);
230 vacc01x23 = vmmlaq_s32(vacc01x23, va01x01234567, vb23x01234567);
231 vacc01x45 = vmmlaq_s32(vacc01x45, va01x01234567, vb45x01234567);
232 vacc01x67 = vmmlaq_s32(vacc01x67, va01x01234567, vb67x01234567);
233 vacc01x89 = vmmlaq_s32(vacc01x89, va01x01234567, vb89x01234567);
234 vacc01xAB = vmmlaq_s32(vacc01xAB, va01x01234567, vbABx01234567);
235 vacc01xCD = vmmlaq_s32(vacc01xCD, va01x01234567, vbCDx01234567);
236 vacc01xEF = vmmlaq_s32(vacc01xEF, va01x01234567, vbEFx01234567);
237 vacc23x01 = vmmlaq_s32(vacc23x01, va23x01234567, vb01x01234567);
238 vacc23x23 = vmmlaq_s32(vacc23x23, va23x01234567, vb23x01234567);
239 vacc23x45 = vmmlaq_s32(vacc23x45, va23x01234567, vb45x01234567);
240 vacc23x67 = vmmlaq_s32(vacc23x67, va23x01234567, vb67x01234567);
241 vacc23x89 = vmmlaq_s32(vacc23x89, va23x01234567, vb89x01234567);
242 vacc23xAB = vmmlaq_s32(vacc23xAB, va23x01234567, vbABx01234567);
243 vacc23xCD = vmmlaq_s32(vacc23xCD, va23x01234567, vbCDx01234567);
244 vacc23xEF = vmmlaq_s32(vacc23xEF, va23x01234567, vbEFx01234567);
245 vacc45x01 = vmmlaq_s32(vacc45x01, va45x01234567, vb01x01234567);
246 vacc45x23 = vmmlaq_s32(vacc45x23, va45x01234567, vb23x01234567);
247 vacc45x45 = vmmlaq_s32(vacc45x45, va45x01234567, vb45x01234567);
248 vacc45x67 = vmmlaq_s32(vacc45x67, va45x01234567, vb67x01234567);
249 vacc45x89 = vmmlaq_s32(vacc45x89, va45x01234567, vb89x01234567);
250 vacc45xAB = vmmlaq_s32(vacc45xAB, va45x01234567, vbABx01234567);
251 vacc45xCD = vmmlaq_s32(vacc45xCD, va45x01234567, vbCDx01234567);
252 vacc45xEF = vmmlaq_s32(vacc45xEF, va45x01234567, vbEFx01234567);
253 vacc67x01 = vmmlaq_s32(vacc67x01, va67x01234567, vb01x01234567);
254 vacc67x23 = vmmlaq_s32(vacc67x23, va67x01234567, vb23x01234567);
255 vacc67x45 = vmmlaq_s32(vacc67x45, va67x01234567, vb45x01234567);
256 vacc67x67 = vmmlaq_s32(vacc67x67, va67x01234567, vb67x01234567);
257 vacc67x89 = vmmlaq_s32(vacc67x89, va67x01234567, vb89x01234567);
258 vacc67xAB = vmmlaq_s32(vacc67xAB, va67x01234567, vbABx01234567);
259 vacc67xCD = vmmlaq_s32(vacc67xCD, va67x01234567, vbCDx01234567);
260 vacc67xEF = vmmlaq_s32(vacc67xEF, va67x01234567, vbEFx01234567);
261 vacc01x01 = vmmlaq_s32(vacc01x01, va01x89ABCDEF, vb01x89ABCDEF);
262 vacc01x23 = vmmlaq_s32(vacc01x23, va01x89ABCDEF, vb23x89ABCDEF);
263 vacc01x45 = vmmlaq_s32(vacc01x45, va01x89ABCDEF, vb45x89ABCDEF);
264 vacc01x67 = vmmlaq_s32(vacc01x67, va01x89ABCDEF, vb67x89ABCDEF);
265 vacc01x89 = vmmlaq_s32(vacc01x89, va01x89ABCDEF, vb89x89ABCDEF);
266 vacc01xAB = vmmlaq_s32(vacc01xAB, va01x89ABCDEF, vbABx89ABCDEF);
267 vacc01xCD = vmmlaq_s32(vacc01xCD, va01x89ABCDEF, vbCDx89ABCDEF);
268 vacc01xEF = vmmlaq_s32(vacc01xEF, va01x89ABCDEF, vbEFx89ABCDEF);
269 vacc23x01 = vmmlaq_s32(vacc23x01, va23x89ABCDEF, vb01x89ABCDEF);
270 vacc23x23 = vmmlaq_s32(vacc23x23, va23x89ABCDEF, vb23x89ABCDEF);
271 vacc23x45 = vmmlaq_s32(vacc23x45, va23x89ABCDEF, vb45x89ABCDEF);
272 vacc23x67 = vmmlaq_s32(vacc23x67, va23x89ABCDEF, vb67x89ABCDEF);
273 vacc23x89 = vmmlaq_s32(vacc23x89, va23x89ABCDEF, vb89x89ABCDEF);
274 vacc23xAB = vmmlaq_s32(vacc23xAB, va23x89ABCDEF, vbABx89ABCDEF);
275 vacc23xCD = vmmlaq_s32(vacc23xCD, va23x89ABCDEF, vbCDx89ABCDEF);
276 vacc23xEF = vmmlaq_s32(vacc23xEF, va23x89ABCDEF, vbEFx89ABCDEF);
277 vacc45x01 = vmmlaq_s32(vacc45x01, va45x89ABCDEF, vb01x89ABCDEF);
278 vacc45x23 = vmmlaq_s32(vacc45x23, va45x89ABCDEF, vb23x89ABCDEF);
279 vacc45x45 = vmmlaq_s32(vacc45x45, va45x89ABCDEF, vb45x89ABCDEF);
280 vacc45x67 = vmmlaq_s32(vacc45x67, va45x89ABCDEF, vb67x89ABCDEF);
281 vacc45x89 = vmmlaq_s32(vacc45x89, va45x89ABCDEF, vb89x89ABCDEF);
282 vacc45xAB = vmmlaq_s32(vacc45xAB, va45x89ABCDEF, vbABx89ABCDEF);
283 vacc45xCD = vmmlaq_s32(vacc45xCD, va45x89ABCDEF, vbCDx89ABCDEF);
284 vacc45xEF = vmmlaq_s32(vacc45xEF, va45x89ABCDEF, vbEFx89ABCDEF);
285 vacc67x01 = vmmlaq_s32(vacc67x01, va67x89ABCDEF, vb01x89ABCDEF);
286 vacc67x23 = vmmlaq_s32(vacc67x23, va67x89ABCDEF, vb23x89ABCDEF);
287 vacc67x45 = vmmlaq_s32(vacc67x45, va67x89ABCDEF, vb45x89ABCDEF);
288 vacc67x67 = vmmlaq_s32(vacc67x67, va67x89ABCDEF, vb67x89ABCDEF);
289 vacc67x89 = vmmlaq_s32(vacc67x89, va67x89ABCDEF, vb89x89ABCDEF);
290 vacc67xAB = vmmlaq_s32(vacc67xAB, va67x89ABCDEF, vbABx89ABCDEF);
291 vacc67xCD = vmmlaq_s32(vacc67xCD, va67x89ABCDEF, vbCDx89ABCDEF);
292 vacc67xEF = vmmlaq_s32(vacc67xEF, va67x89ABCDEF, vbEFx89ABCDEF);
293
294 k -= 16 * sizeof(int8_t);
295 }
296 // Handle up to 8 final positions of `k`
297 if XNN_UNLIKELY(k != 0) {
298 // Load a 8x8 block of activations.
299 uint64x2_t va01x01234567 = vld1q_dup_u64((const void*) a0); a0 += 8;
300 uint64x2_t va23x01234567 = vld1q_dup_u64((const void*) a2); a2 += 8;
301 uint64x2_t va45x01234567 = vld1q_dup_u64((const void*) a4); a4 += 8;
302 uint64x2_t va67x01234567 = vld1q_dup_u64((const void*) a6); a6 += 8;
303 va01x01234567 = vld1q_lane_u64((const void*) a1, va01x01234567, 1); a1 += 8;
304 va23x01234567 = vld1q_lane_u64((const void*) a3, va23x01234567, 1); a3 += 8;
305 va45x01234567 = vld1q_lane_u64((const void*) a5, va45x01234567, 1); a5 += 8;
306 va67x01234567 = vld1q_lane_u64((const void*) a7, va67x01234567, 1); a7 += 8;
307
308 // Load a 16x16 block of weights.
309 const int8x16_t vb01x0123456789ABCDEF = vld1q_s8(w); w = (const int8_t*) w + 16;
310 const int8x16_t vb23x0123456789ABCDEF = vld1q_s8(w); w = (const int8_t*) w + 16;
311 const int8x16_t vb45x0123456789ABCDEF = vld1q_s8(w); w = (const int8_t*) w + 16;
312 const int8x16_t vb67x0123456789ABCDEF = vld1q_s8(w); w = (const int8_t*) w + 16;
313 const int8x16_t vb89x0123456789ABCDEF = vld1q_s8(w); w = (const int8_t*) w + 16;
314 const int8x16_t vbABx0123456789ABCDEF = vld1q_s8(w); w = (const int8_t*) w + 16;
315 const int8x16_t vbCDx0123456789ABCDEF = vld1q_s8(w); w = (const int8_t*) w + 16;
316 const int8x16_t vbEFx0123456789ABCDEF = vld1q_s8(w); w = (const int8_t*) w + 16;
317 const int8x16_t vb01x01234567 = vshlq_n_s8(vb01x0123456789ABCDEF, 4);
318 const int8x16_t vb23x01234567 = vshlq_n_s8(vb23x0123456789ABCDEF, 4);
319 const int8x16_t vb45x01234567 = vshlq_n_s8(vb45x0123456789ABCDEF, 4);
320 const int8x16_t vb67x01234567 = vshlq_n_s8(vb67x0123456789ABCDEF, 4);
321 const int8x16_t vb89x01234567 = vshlq_n_s8(vb89x0123456789ABCDEF, 4);
322 const int8x16_t vbABx01234567 = vshlq_n_s8(vbABx0123456789ABCDEF, 4);
323 const int8x16_t vbCDx01234567 = vshlq_n_s8(vbCDx0123456789ABCDEF, 4);
324 const int8x16_t vbEFx01234567 = vshlq_n_s8(vbEFx0123456789ABCDEF, 4);
325
326 // Multiply-accumulate: 8x4 * 4x16 --> 8x16.
327 vacc01x01 = vmmlaq_s32(vacc01x01, vreinterpretq_s8_u64(va01x01234567), vb01x01234567);
328 vacc01x23 = vmmlaq_s32(vacc01x23, vreinterpretq_s8_u64(va01x01234567), vb23x01234567);
329 vacc01x45 = vmmlaq_s32(vacc01x45, vreinterpretq_s8_u64(va01x01234567), vb45x01234567);
330 vacc01x67 = vmmlaq_s32(vacc01x67, vreinterpretq_s8_u64(va01x01234567), vb67x01234567);
331 vacc01x89 = vmmlaq_s32(vacc01x89, vreinterpretq_s8_u64(va01x01234567), vb89x01234567);
332 vacc01xAB = vmmlaq_s32(vacc01xAB, vreinterpretq_s8_u64(va01x01234567), vbABx01234567);
333 vacc01xCD = vmmlaq_s32(vacc01xCD, vreinterpretq_s8_u64(va01x01234567), vbCDx01234567);
334 vacc01xEF = vmmlaq_s32(vacc01xEF, vreinterpretq_s8_u64(va01x01234567), vbEFx01234567);
335 vacc23x01 = vmmlaq_s32(vacc23x01, vreinterpretq_s8_u64(va23x01234567), vb01x01234567);
336 vacc23x23 = vmmlaq_s32(vacc23x23, vreinterpretq_s8_u64(va23x01234567), vb23x01234567);
337 vacc23x45 = vmmlaq_s32(vacc23x45, vreinterpretq_s8_u64(va23x01234567), vb45x01234567);
338 vacc23x67 = vmmlaq_s32(vacc23x67, vreinterpretq_s8_u64(va23x01234567), vb67x01234567);
339 vacc23x89 = vmmlaq_s32(vacc23x89, vreinterpretq_s8_u64(va23x01234567), vb89x01234567);
340 vacc23xAB = vmmlaq_s32(vacc23xAB, vreinterpretq_s8_u64(va23x01234567), vbABx01234567);
341 vacc23xCD = vmmlaq_s32(vacc23xCD, vreinterpretq_s8_u64(va23x01234567), vbCDx01234567);
342 vacc23xEF = vmmlaq_s32(vacc23xEF, vreinterpretq_s8_u64(va23x01234567), vbEFx01234567);
343 vacc45x01 = vmmlaq_s32(vacc45x01, vreinterpretq_s8_u64(va45x01234567), vb01x01234567);
344 vacc45x23 = vmmlaq_s32(vacc45x23, vreinterpretq_s8_u64(va45x01234567), vb23x01234567);
345 vacc45x45 = vmmlaq_s32(vacc45x45, vreinterpretq_s8_u64(va45x01234567), vb45x01234567);
346 vacc45x67 = vmmlaq_s32(vacc45x67, vreinterpretq_s8_u64(va45x01234567), vb67x01234567);
347 vacc45x89 = vmmlaq_s32(vacc45x89, vreinterpretq_s8_u64(va45x01234567), vb89x01234567);
348 vacc45xAB = vmmlaq_s32(vacc45xAB, vreinterpretq_s8_u64(va45x01234567), vbABx01234567);
349 vacc45xCD = vmmlaq_s32(vacc45xCD, vreinterpretq_s8_u64(va45x01234567), vbCDx01234567);
350 vacc45xEF = vmmlaq_s32(vacc45xEF, vreinterpretq_s8_u64(va45x01234567), vbEFx01234567);
351 vacc67x01 = vmmlaq_s32(vacc67x01, vreinterpretq_s8_u64(va67x01234567), vb01x01234567);
352 vacc67x23 = vmmlaq_s32(vacc67x23, vreinterpretq_s8_u64(va67x01234567), vb23x01234567);
353 vacc67x45 = vmmlaq_s32(vacc67x45, vreinterpretq_s8_u64(va67x01234567), vb45x01234567);
354 vacc67x67 = vmmlaq_s32(vacc67x67, vreinterpretq_s8_u64(va67x01234567), vb67x01234567);
355 vacc67x89 = vmmlaq_s32(vacc67x89, vreinterpretq_s8_u64(va67x01234567), vb89x01234567);
356 vacc67xAB = vmmlaq_s32(vacc67xAB, vreinterpretq_s8_u64(va67x01234567), vbABx01234567);
357 vacc67xCD = vmmlaq_s32(vacc67xCD, vreinterpretq_s8_u64(va67x01234567), vbCDx01234567);
358 vacc67xEF = vmmlaq_s32(vacc67xEF, vreinterpretq_s8_u64(va67x01234567), vbEFx01234567);
359 }
360
361 int32x4_t vacc0x0123 = vreinterpretq_s32_u64(vtrn1q_u64(vreinterpretq_u64_s32(vacc01x01), vreinterpretq_u64_s32(vacc01x23)));
362 int32x4_t vacc1x0123 = vreinterpretq_s32_u64(vtrn2q_u64(vreinterpretq_u64_s32(vacc01x01), vreinterpretq_u64_s32(vacc01x23)));
363 int32x4_t vacc0x4567 = vreinterpretq_s32_u64(vtrn1q_u64(vreinterpretq_u64_s32(vacc01x45), vreinterpretq_u64_s32(vacc01x67)));
364 int32x4_t vacc1x4567 = vreinterpretq_s32_u64(vtrn2q_u64(vreinterpretq_u64_s32(vacc01x45), vreinterpretq_u64_s32(vacc01x67)));
365 int32x4_t vacc0x89AB = vreinterpretq_s32_u64(vtrn1q_u64(vreinterpretq_u64_s32(vacc01x89), vreinterpretq_u64_s32(vacc01xAB)));
366 int32x4_t vacc1x89AB = vreinterpretq_s32_u64(vtrn2q_u64(vreinterpretq_u64_s32(vacc01x89), vreinterpretq_u64_s32(vacc01xAB)));
367 int32x4_t vacc0xCDEF = vreinterpretq_s32_u64(vtrn1q_u64(vreinterpretq_u64_s32(vacc01xCD), vreinterpretq_u64_s32(vacc01xEF)));
368 int32x4_t vacc1xCDEF = vreinterpretq_s32_u64(vtrn2q_u64(vreinterpretq_u64_s32(vacc01xCD), vreinterpretq_u64_s32(vacc01xEF)));
369 int32x4_t vacc2x0123 = vreinterpretq_s32_u64(vtrn1q_u64(vreinterpretq_u64_s32(vacc23x01), vreinterpretq_u64_s32(vacc23x23)));
370 int32x4_t vacc3x0123 = vreinterpretq_s32_u64(vtrn2q_u64(vreinterpretq_u64_s32(vacc23x01), vreinterpretq_u64_s32(vacc23x23)));
371 int32x4_t vacc2x4567 = vreinterpretq_s32_u64(vtrn1q_u64(vreinterpretq_u64_s32(vacc23x45), vreinterpretq_u64_s32(vacc23x67)));
372 int32x4_t vacc3x4567 = vreinterpretq_s32_u64(vtrn2q_u64(vreinterpretq_u64_s32(vacc23x45), vreinterpretq_u64_s32(vacc23x67)));
373 int32x4_t vacc2x89AB = vreinterpretq_s32_u64(vtrn1q_u64(vreinterpretq_u64_s32(vacc23x89), vreinterpretq_u64_s32(vacc23xAB)));
374 int32x4_t vacc3x89AB = vreinterpretq_s32_u64(vtrn2q_u64(vreinterpretq_u64_s32(vacc23x89), vreinterpretq_u64_s32(vacc23xAB)));
375 int32x4_t vacc2xCDEF = vreinterpretq_s32_u64(vtrn1q_u64(vreinterpretq_u64_s32(vacc23xCD), vreinterpretq_u64_s32(vacc23xEF)));
376 int32x4_t vacc3xCDEF = vreinterpretq_s32_u64(vtrn2q_u64(vreinterpretq_u64_s32(vacc23xCD), vreinterpretq_u64_s32(vacc23xEF)));
377 int32x4_t vacc4x0123 = vreinterpretq_s32_u64(vtrn1q_u64(vreinterpretq_u64_s32(vacc45x01), vreinterpretq_u64_s32(vacc45x23)));
378 int32x4_t vacc5x0123 = vreinterpretq_s32_u64(vtrn2q_u64(vreinterpretq_u64_s32(vacc45x01), vreinterpretq_u64_s32(vacc45x23)));
379 int32x4_t vacc4x4567 = vreinterpretq_s32_u64(vtrn1q_u64(vreinterpretq_u64_s32(vacc45x45), vreinterpretq_u64_s32(vacc45x67)));
380 int32x4_t vacc5x4567 = vreinterpretq_s32_u64(vtrn2q_u64(vreinterpretq_u64_s32(vacc45x45), vreinterpretq_u64_s32(vacc45x67)));
381 int32x4_t vacc4x89AB = vreinterpretq_s32_u64(vtrn1q_u64(vreinterpretq_u64_s32(vacc45x89), vreinterpretq_u64_s32(vacc45xAB)));
382 int32x4_t vacc5x89AB = vreinterpretq_s32_u64(vtrn2q_u64(vreinterpretq_u64_s32(vacc45x89), vreinterpretq_u64_s32(vacc45xAB)));
383 int32x4_t vacc4xCDEF = vreinterpretq_s32_u64(vtrn1q_u64(vreinterpretq_u64_s32(vacc45xCD), vreinterpretq_u64_s32(vacc45xEF)));
384 int32x4_t vacc5xCDEF = vreinterpretq_s32_u64(vtrn2q_u64(vreinterpretq_u64_s32(vacc45xCD), vreinterpretq_u64_s32(vacc45xEF)));
385 int32x4_t vacc6x0123 = vreinterpretq_s32_u64(vtrn1q_u64(vreinterpretq_u64_s32(vacc67x01), vreinterpretq_u64_s32(vacc67x23)));
386 int32x4_t vacc7x0123 = vreinterpretq_s32_u64(vtrn2q_u64(vreinterpretq_u64_s32(vacc67x01), vreinterpretq_u64_s32(vacc67x23)));
387 int32x4_t vacc6x4567 = vreinterpretq_s32_u64(vtrn1q_u64(vreinterpretq_u64_s32(vacc67x45), vreinterpretq_u64_s32(vacc67x67)));
388 int32x4_t vacc7x4567 = vreinterpretq_s32_u64(vtrn2q_u64(vreinterpretq_u64_s32(vacc67x45), vreinterpretq_u64_s32(vacc67x67)));
389 int32x4_t vacc6x89AB = vreinterpretq_s32_u64(vtrn1q_u64(vreinterpretq_u64_s32(vacc67x89), vreinterpretq_u64_s32(vacc67xAB)));
390 int32x4_t vacc7x89AB = vreinterpretq_s32_u64(vtrn2q_u64(vreinterpretq_u64_s32(vacc67x89), vreinterpretq_u64_s32(vacc67xAB)));
391 int32x4_t vacc6xCDEF = vreinterpretq_s32_u64(vtrn1q_u64(vreinterpretq_u64_s32(vacc67xCD), vreinterpretq_u64_s32(vacc67xEF)));
392 int32x4_t vacc7xCDEF = vreinterpretq_s32_u64(vtrn2q_u64(vreinterpretq_u64_s32(vacc67xCD), vreinterpretq_u64_s32(vacc67xEF)));
393 float32x4_t vout0x0123 = vcvtq_n_f32_s32(vacc0x0123, 4);
394 float32x4_t vout0x4567 = vcvtq_n_f32_s32(vacc0x4567, 4);
395 float32x4_t vout0x89AB = vcvtq_n_f32_s32(vacc0x89AB, 4);
396 float32x4_t vout0xCDEF = vcvtq_n_f32_s32(vacc0xCDEF, 4);
397 float32x4_t vout1x0123 = vcvtq_n_f32_s32(vacc1x0123, 4);
398 float32x4_t vout1x4567 = vcvtq_n_f32_s32(vacc1x4567, 4);
399 float32x4_t vout1x89AB = vcvtq_n_f32_s32(vacc1x89AB, 4);
400 float32x4_t vout1xCDEF = vcvtq_n_f32_s32(vacc1xCDEF, 4);
401 float32x4_t vout2x0123 = vcvtq_n_f32_s32(vacc2x0123, 4);
402 float32x4_t vout2x4567 = vcvtq_n_f32_s32(vacc2x4567, 4);
403 float32x4_t vout2x89AB = vcvtq_n_f32_s32(vacc2x89AB, 4);
404 float32x4_t vout2xCDEF = vcvtq_n_f32_s32(vacc2xCDEF, 4);
405 float32x4_t vout3x0123 = vcvtq_n_f32_s32(vacc3x0123, 4);
406 float32x4_t vout3x4567 = vcvtq_n_f32_s32(vacc3x4567, 4);
407 float32x4_t vout3x89AB = vcvtq_n_f32_s32(vacc3x89AB, 4);
408 float32x4_t vout3xCDEF = vcvtq_n_f32_s32(vacc3xCDEF, 4);
409 float32x4_t vout4x0123 = vcvtq_n_f32_s32(vacc4x0123, 4);
410 float32x4_t vout4x4567 = vcvtq_n_f32_s32(vacc4x4567, 4);
411 float32x4_t vout4x89AB = vcvtq_n_f32_s32(vacc4x89AB, 4);
412 float32x4_t vout4xCDEF = vcvtq_n_f32_s32(vacc4xCDEF, 4);
413 float32x4_t vout5x0123 = vcvtq_n_f32_s32(vacc5x0123, 4);
414 float32x4_t vout5x4567 = vcvtq_n_f32_s32(vacc5x4567, 4);
415 float32x4_t vout5x89AB = vcvtq_n_f32_s32(vacc5x89AB, 4);
416 float32x4_t vout5xCDEF = vcvtq_n_f32_s32(vacc5xCDEF, 4);
417 float32x4_t vout6x0123 = vcvtq_n_f32_s32(vacc6x0123, 4);
418 float32x4_t vout6x4567 = vcvtq_n_f32_s32(vacc6x4567, 4);
419 float32x4_t vout6x89AB = vcvtq_n_f32_s32(vacc6x89AB, 4);
420 float32x4_t vout6xCDEF = vcvtq_n_f32_s32(vacc6xCDEF, 4);
421 float32x4_t vout7x0123 = vcvtq_n_f32_s32(vacc7x0123, 4);
422 float32x4_t vout7x4567 = vcvtq_n_f32_s32(vacc7x4567, 4);
423 float32x4_t vout7x89AB = vcvtq_n_f32_s32(vacc7x89AB, 4);
424 float32x4_t vout7xCDEF = vcvtq_n_f32_s32(vacc7xCDEF, 4);
425
426 const float32x4_t vinput_scale01 = vreinterpretq_f32_s32(vld1q_s32(&quantization_params[0].zero_point));
427 vout0x0123 = vmulq_lane_f32(vout0x0123, vget_low_f32(vinput_scale01), 1);
428 vout1x0123 = vmulq_lane_f32(vout1x0123, vget_high_f32(vinput_scale01), 1);
429 vout0x4567 = vmulq_lane_f32(vout0x4567, vget_low_f32(vinput_scale01), 1);
430 vout1x4567 = vmulq_lane_f32(vout1x4567, vget_high_f32(vinput_scale01), 1);
431 vout0x89AB = vmulq_lane_f32(vout0x89AB, vget_low_f32(vinput_scale01), 1);
432 vout1x89AB = vmulq_lane_f32(vout1x89AB, vget_high_f32(vinput_scale01), 1);
433 vout0xCDEF = vmulq_lane_f32(vout0xCDEF, vget_low_f32(vinput_scale01), 1);
434 vout1xCDEF = vmulq_lane_f32(vout1xCDEF, vget_high_f32(vinput_scale01), 1);
435 const float32x4_t vinput_scale23 = vreinterpretq_f32_s32(vld1q_s32(&quantization_params[2].zero_point));
436 vout2x0123 = vmulq_lane_f32(vout2x0123, vget_low_f32(vinput_scale23), 1);
437 vout3x0123 = vmulq_lane_f32(vout3x0123, vget_high_f32(vinput_scale23), 1);
438 vout2x4567 = vmulq_lane_f32(vout2x4567, vget_low_f32(vinput_scale23), 1);
439 vout3x4567 = vmulq_lane_f32(vout3x4567, vget_high_f32(vinput_scale23), 1);
440 vout2x89AB = vmulq_lane_f32(vout2x89AB, vget_low_f32(vinput_scale23), 1);
441 vout3x89AB = vmulq_lane_f32(vout3x89AB, vget_high_f32(vinput_scale23), 1);
442 vout2xCDEF = vmulq_lane_f32(vout2xCDEF, vget_low_f32(vinput_scale23), 1);
443 vout3xCDEF = vmulq_lane_f32(vout3xCDEF, vget_high_f32(vinput_scale23), 1);
444 const float32x4_t vinput_scale45 = vreinterpretq_f32_s32(vld1q_s32(&quantization_params[4].zero_point));
445 vout4x0123 = vmulq_lane_f32(vout4x0123, vget_low_f32(vinput_scale45), 1);
446 vout5x0123 = vmulq_lane_f32(vout5x0123, vget_high_f32(vinput_scale45), 1);
447 vout4x4567 = vmulq_lane_f32(vout4x4567, vget_low_f32(vinput_scale45), 1);
448 vout5x4567 = vmulq_lane_f32(vout5x4567, vget_high_f32(vinput_scale45), 1);
449 vout4x89AB = vmulq_lane_f32(vout4x89AB, vget_low_f32(vinput_scale45), 1);
450 vout5x89AB = vmulq_lane_f32(vout5x89AB, vget_high_f32(vinput_scale45), 1);
451 vout4xCDEF = vmulq_lane_f32(vout4xCDEF, vget_low_f32(vinput_scale45), 1);
452 vout5xCDEF = vmulq_lane_f32(vout5xCDEF, vget_high_f32(vinput_scale45), 1);
453 const float32x4_t vinput_scale67 = vreinterpretq_f32_s32(vld1q_s32(&quantization_params[6].zero_point));
454 vout6x0123 = vmulq_lane_f32(vout6x0123, vget_low_f32(vinput_scale67), 1);
455 vout7x0123 = vmulq_lane_f32(vout7x0123, vget_high_f32(vinput_scale67), 1);
456 vout6x4567 = vmulq_lane_f32(vout6x4567, vget_low_f32(vinput_scale67), 1);
457 vout7x4567 = vmulq_lane_f32(vout7x4567, vget_high_f32(vinput_scale67), 1);
458 vout6x89AB = vmulq_lane_f32(vout6x89AB, vget_low_f32(vinput_scale67), 1);
459 vout7x89AB = vmulq_lane_f32(vout7x89AB, vget_high_f32(vinput_scale67), 1);
460 vout6xCDEF = vmulq_lane_f32(vout6xCDEF, vget_low_f32(vinput_scale67), 1);
461 vout7xCDEF = vmulq_lane_f32(vout7xCDEF, vget_high_f32(vinput_scale67), 1);
462
463 const float32x4_t vfilter_output_scale0123 = vld1q_f32(w); w = (const float*) w + 4;
464 const float32x4_t vfilter_output_scale4567 = vld1q_f32(w); w = (const float*) w + 4;
465 const float32x4_t vfilter_output_scale89AB = vld1q_f32(w); w = (const float*) w + 4;
466 const float32x4_t vfilter_output_scaleCDEF = vld1q_f32(w); w = (const float*) w + 4;
467
468 const float32x4_t vbias0123 = vld1q_f32(w); w = (const float*) w + 4;
469 vout0x0123 = vfmaq_f32(vbias0123, vout0x0123, vfilter_output_scale0123);
470 vout1x0123 = vfmaq_f32(vbias0123, vout1x0123, vfilter_output_scale0123);
471 vout2x0123 = vfmaq_f32(vbias0123, vout2x0123, vfilter_output_scale0123);
472 vout3x0123 = vfmaq_f32(vbias0123, vout3x0123, vfilter_output_scale0123);
473 vout4x0123 = vfmaq_f32(vbias0123, vout4x0123, vfilter_output_scale0123);
474 vout5x0123 = vfmaq_f32(vbias0123, vout5x0123, vfilter_output_scale0123);
475 vout6x0123 = vfmaq_f32(vbias0123, vout6x0123, vfilter_output_scale0123);
476 vout7x0123 = vfmaq_f32(vbias0123, vout7x0123, vfilter_output_scale0123);
477 const float32x4_t vbias4567 = vld1q_f32(w); w = (const float*) w + 4;
478 vout0x4567 = vfmaq_f32(vbias4567, vout0x4567, vfilter_output_scale4567);
479 vout1x4567 = vfmaq_f32(vbias4567, vout1x4567, vfilter_output_scale4567);
480 vout2x4567 = vfmaq_f32(vbias4567, vout2x4567, vfilter_output_scale4567);
481 vout3x4567 = vfmaq_f32(vbias4567, vout3x4567, vfilter_output_scale4567);
482 vout4x4567 = vfmaq_f32(vbias4567, vout4x4567, vfilter_output_scale4567);
483 vout5x4567 = vfmaq_f32(vbias4567, vout5x4567, vfilter_output_scale4567);
484 vout6x4567 = vfmaq_f32(vbias4567, vout6x4567, vfilter_output_scale4567);
485 vout7x4567 = vfmaq_f32(vbias4567, vout7x4567, vfilter_output_scale4567);
486 const float32x4_t vbias89AB = vld1q_f32(w); w = (const float*) w + 4;
487 vout0x89AB = vfmaq_f32(vbias89AB, vout0x89AB, vfilter_output_scale89AB);
488 vout1x89AB = vfmaq_f32(vbias89AB, vout1x89AB, vfilter_output_scale89AB);
489 vout2x89AB = vfmaq_f32(vbias89AB, vout2x89AB, vfilter_output_scale89AB);
490 vout3x89AB = vfmaq_f32(vbias89AB, vout3x89AB, vfilter_output_scale89AB);
491 vout4x89AB = vfmaq_f32(vbias89AB, vout4x89AB, vfilter_output_scale89AB);
492 vout5x89AB = vfmaq_f32(vbias89AB, vout5x89AB, vfilter_output_scale89AB);
493 vout6x89AB = vfmaq_f32(vbias89AB, vout6x89AB, vfilter_output_scale89AB);
494 vout7x89AB = vfmaq_f32(vbias89AB, vout7x89AB, vfilter_output_scale89AB);
495 const float32x4_t vbiasCDEF = vld1q_f32(w); w = (const float*) w + 4;
496 vout0xCDEF = vfmaq_f32(vbiasCDEF, vout0xCDEF, vfilter_output_scaleCDEF);
497 vout1xCDEF = vfmaq_f32(vbiasCDEF, vout1xCDEF, vfilter_output_scaleCDEF);
498 vout2xCDEF = vfmaq_f32(vbiasCDEF, vout2xCDEF, vfilter_output_scaleCDEF);
499 vout3xCDEF = vfmaq_f32(vbiasCDEF, vout3xCDEF, vfilter_output_scaleCDEF);
500 vout4xCDEF = vfmaq_f32(vbiasCDEF, vout4xCDEF, vfilter_output_scaleCDEF);
501 vout5xCDEF = vfmaq_f32(vbiasCDEF, vout5xCDEF, vfilter_output_scaleCDEF);
502 vout6xCDEF = vfmaq_f32(vbiasCDEF, vout6xCDEF, vfilter_output_scaleCDEF);
503 vout7xCDEF = vfmaq_f32(vbiasCDEF, vout7xCDEF, vfilter_output_scaleCDEF);
504
505 const float32x4_t voutput_min = vld1q_dup_f32(&params->scalar.min);
506 vout0x0123 = vmaxq_f32(vout0x0123, voutput_min);
507 vout0x4567 = vmaxq_f32(vout0x4567, voutput_min);
508 vout0x89AB = vmaxq_f32(vout0x89AB, voutput_min);
509 vout0xCDEF = vmaxq_f32(vout0xCDEF, voutput_min);
510 vout1x0123 = vmaxq_f32(vout1x0123, voutput_min);
511 vout1x4567 = vmaxq_f32(vout1x4567, voutput_min);
512 vout1x89AB = vmaxq_f32(vout1x89AB, voutput_min);
513 vout1xCDEF = vmaxq_f32(vout1xCDEF, voutput_min);
514 vout2x0123 = vmaxq_f32(vout2x0123, voutput_min);
515 vout2x4567 = vmaxq_f32(vout2x4567, voutput_min);
516 vout2x89AB = vmaxq_f32(vout2x89AB, voutput_min);
517 vout2xCDEF = vmaxq_f32(vout2xCDEF, voutput_min);
518 vout3x0123 = vmaxq_f32(vout3x0123, voutput_min);
519 vout3x4567 = vmaxq_f32(vout3x4567, voutput_min);
520 vout3x89AB = vmaxq_f32(vout3x89AB, voutput_min);
521 vout3xCDEF = vmaxq_f32(vout3xCDEF, voutput_min);
522 vout4x0123 = vmaxq_f32(vout4x0123, voutput_min);
523 vout4x4567 = vmaxq_f32(vout4x4567, voutput_min);
524 vout4x89AB = vmaxq_f32(vout4x89AB, voutput_min);
525 vout4xCDEF = vmaxq_f32(vout4xCDEF, voutput_min);
526 vout5x0123 = vmaxq_f32(vout5x0123, voutput_min);
527 vout5x4567 = vmaxq_f32(vout5x4567, voutput_min);
528 vout5x89AB = vmaxq_f32(vout5x89AB, voutput_min);
529 vout5xCDEF = vmaxq_f32(vout5xCDEF, voutput_min);
530 vout6x0123 = vmaxq_f32(vout6x0123, voutput_min);
531 vout6x4567 = vmaxq_f32(vout6x4567, voutput_min);
532 vout6x89AB = vmaxq_f32(vout6x89AB, voutput_min);
533 vout6xCDEF = vmaxq_f32(vout6xCDEF, voutput_min);
534 vout7x0123 = vmaxq_f32(vout7x0123, voutput_min);
535 vout7x4567 = vmaxq_f32(vout7x4567, voutput_min);
536 vout7x89AB = vmaxq_f32(vout7x89AB, voutput_min);
537 vout7xCDEF = vmaxq_f32(vout7xCDEF, voutput_min);
538
539 const float32x4_t voutput_max = vld1q_dup_f32(&params->scalar.max);
540 vout0x0123 = vminq_f32(vout0x0123, voutput_max);
541 vout0x4567 = vminq_f32(vout0x4567, voutput_max);
542 vout0x89AB = vminq_f32(vout0x89AB, voutput_max);
543 vout0xCDEF = vminq_f32(vout0xCDEF, voutput_max);
544 vout1x0123 = vminq_f32(vout1x0123, voutput_max);
545 vout1x4567 = vminq_f32(vout1x4567, voutput_max);
546 vout1x89AB = vminq_f32(vout1x89AB, voutput_max);
547 vout1xCDEF = vminq_f32(vout1xCDEF, voutput_max);
548 vout2x0123 = vminq_f32(vout2x0123, voutput_max);
549 vout2x4567 = vminq_f32(vout2x4567, voutput_max);
550 vout2x89AB = vminq_f32(vout2x89AB, voutput_max);
551 vout2xCDEF = vminq_f32(vout2xCDEF, voutput_max);
552 vout3x0123 = vminq_f32(vout3x0123, voutput_max);
553 vout3x4567 = vminq_f32(vout3x4567, voutput_max);
554 vout3x89AB = vminq_f32(vout3x89AB, voutput_max);
555 vout3xCDEF = vminq_f32(vout3xCDEF, voutput_max);
556 vout4x0123 = vminq_f32(vout4x0123, voutput_max);
557 vout4x4567 = vminq_f32(vout4x4567, voutput_max);
558 vout4x89AB = vminq_f32(vout4x89AB, voutput_max);
559 vout4xCDEF = vminq_f32(vout4xCDEF, voutput_max);
560 vout5x0123 = vminq_f32(vout5x0123, voutput_max);
561 vout5x4567 = vminq_f32(vout5x4567, voutput_max);
562 vout5x89AB = vminq_f32(vout5x89AB, voutput_max);
563 vout5xCDEF = vminq_f32(vout5xCDEF, voutput_max);
564 vout6x0123 = vminq_f32(vout6x0123, voutput_max);
565 vout6x4567 = vminq_f32(vout6x4567, voutput_max);
566 vout6x89AB = vminq_f32(vout6x89AB, voutput_max);
567 vout6xCDEF = vminq_f32(vout6xCDEF, voutput_max);
568 vout7x0123 = vminq_f32(vout7x0123, voutput_max);
569 vout7x4567 = vminq_f32(vout7x4567, voutput_max);
570 vout7x89AB = vminq_f32(vout7x89AB, voutput_max);
571 vout7xCDEF = vminq_f32(vout7xCDEF, voutput_max);
572
573 if XNN_LIKELY(nc >= 16) {
574 vst1q_f32(c0, vout0x0123);
575 vst1q_f32(c0 + 4, vout0x4567);
576 vst1q_f32(c0 + 8, vout0x89AB);
577 vst1q_f32(c0 + 12, vout0xCDEF);
578 vst1q_f32(c1, vout1x0123);
579 vst1q_f32(c1 + 4, vout1x4567);
580 vst1q_f32(c1 + 8, vout1x89AB);
581 vst1q_f32(c1 + 12, vout1xCDEF);
582 vst1q_f32(c2, vout2x0123);
583 vst1q_f32(c2 + 4, vout2x4567);
584 vst1q_f32(c2 + 8, vout2x89AB);
585 vst1q_f32(c2 + 12, vout2xCDEF);
586 vst1q_f32(c3, vout3x0123);
587 vst1q_f32(c3 + 4, vout3x4567);
588 vst1q_f32(c3 + 8, vout3x89AB);
589 vst1q_f32(c3 + 12, vout3xCDEF);
590 vst1q_f32(c4, vout4x0123);
591 vst1q_f32(c4 + 4, vout4x4567);
592 vst1q_f32(c4 + 8, vout4x89AB);
593 vst1q_f32(c4 + 12, vout4xCDEF);
594 vst1q_f32(c5, vout5x0123);
595 vst1q_f32(c5 + 4, vout5x4567);
596 vst1q_f32(c5 + 8, vout5x89AB);
597 vst1q_f32(c5 + 12, vout5xCDEF);
598 vst1q_f32(c6, vout6x0123);
599 vst1q_f32(c6 + 4, vout6x4567);
600 vst1q_f32(c6 + 8, vout6x89AB);
601 vst1q_f32(c6 + 12, vout6xCDEF);
602 vst1q_f32(c7, vout7x0123);
603 vst1q_f32(c7 + 4, vout7x4567);
604 vst1q_f32(c7 + 8, vout7x89AB);
605 vst1q_f32(c7 + 12, vout7xCDEF);
606
607 a0 = (const int8_t*) ((uintptr_t) a0 - kc);
608 a1 = (const int8_t*) ((uintptr_t) a1 - kc);
609 a2 = (const int8_t*) ((uintptr_t) a2 - kc);
610 a3 = (const int8_t*) ((uintptr_t) a3 - kc);
611 a4 = (const int8_t*) ((uintptr_t) a4 - kc);
612 a5 = (const int8_t*) ((uintptr_t) a5 - kc);
613 a6 = (const int8_t*) ((uintptr_t) a6 - kc);
614 a7 = (const int8_t*) ((uintptr_t) a7 - kc);
615
616 c0 = (float*) ((uintptr_t) c0 + cn_stride);
617 c1 = (float*) ((uintptr_t) c1 + cn_stride);
618 c2 = (float*) ((uintptr_t) c2 + cn_stride);
619 c3 = (float*) ((uintptr_t) c3 + cn_stride);
620 c4 = (float*) ((uintptr_t) c4 + cn_stride);
621 c5 = (float*) ((uintptr_t) c5 + cn_stride);
622 c6 = (float*) ((uintptr_t) c6 + cn_stride);
623 c7 = (float*) ((uintptr_t) c7 + cn_stride);
624
625 nc -= 16;
626 } else {
627 if (nc & 8) {
628 vst1q_f32(c0, vout0x0123); c0 += 4;
629 vout0x0123 = vout0x89AB;
630 vst1q_f32(c1, vout1x0123); c1 += 4;
631 vout1x0123 = vout1x89AB;
632 vst1q_f32(c2, vout2x0123); c2 += 4;
633 vout2x0123 = vout2x89AB;
634 vst1q_f32(c3, vout3x0123); c3 += 4;
635 vout3x0123 = vout3x89AB;
636 vst1q_f32(c4, vout4x0123); c4 += 4;
637 vout4x0123 = vout4x89AB;
638 vst1q_f32(c5, vout5x0123); c5 += 4;
639 vout5x0123 = vout5x89AB;
640 vst1q_f32(c6, vout6x0123); c6 += 4;
641 vout6x0123 = vout6x89AB;
642 vst1q_f32(c7, vout7x0123); c7 += 4;
643 vout7x0123 = vout7x89AB;
644 vst1q_f32(c0, vout0x4567); c0 += 4;
645 vout0x4567 = vout0xCDEF;
646 vst1q_f32(c1, vout1x4567); c1 += 4;
647 vout1x4567 = vout1xCDEF;
648 vst1q_f32(c2, vout2x4567); c2 += 4;
649 vout2x4567 = vout2xCDEF;
650 vst1q_f32(c3, vout3x4567); c3 += 4;
651 vout3x4567 = vout3xCDEF;
652 vst1q_f32(c4, vout4x4567); c4 += 4;
653 vout4x4567 = vout4xCDEF;
654 vst1q_f32(c5, vout5x4567); c5 += 4;
655 vout5x4567 = vout5xCDEF;
656 vst1q_f32(c6, vout6x4567); c6 += 4;
657 vout6x4567 = vout6xCDEF;
658 vst1q_f32(c7, vout7x4567); c7 += 4;
659 vout7x4567 = vout7xCDEF;
660 }
661 if (nc & 4) {
662 vst1q_f32(c0, vout0x0123); c0 += 4;
663 vout0x0123 = vout0x4567;
664 vst1q_f32(c1, vout1x0123); c1 += 4;
665 vout1x0123 = vout1x4567;
666 vst1q_f32(c2, vout2x0123); c2 += 4;
667 vout2x0123 = vout2x4567;
668 vst1q_f32(c3, vout3x0123); c3 += 4;
669 vout3x0123 = vout3x4567;
670 vst1q_f32(c4, vout4x0123); c4 += 4;
671 vout4x0123 = vout4x4567;
672 vst1q_f32(c5, vout5x0123); c5 += 4;
673 vout5x0123 = vout5x4567;
674 vst1q_f32(c6, vout6x0123); c6 += 4;
675 vout6x0123 = vout6x4567;
676 vst1q_f32(c7, vout7x0123); c7 += 4;
677 vout7x0123 = vout7x4567;
678 }
679 float32x2_t vout0x01 = vget_low_f32(vout0x0123);
680 float32x2_t vout1x01 = vget_low_f32(vout1x0123);
681 float32x2_t vout2x01 = vget_low_f32(vout2x0123);
682 float32x2_t vout3x01 = vget_low_f32(vout3x0123);
683 float32x2_t vout4x01 = vget_low_f32(vout4x0123);
684 float32x2_t vout5x01 = vget_low_f32(vout5x0123);
685 float32x2_t vout6x01 = vget_low_f32(vout6x0123);
686 float32x2_t vout7x01 = vget_low_f32(vout7x0123);
687 if (nc & 2) {
688 vst1_f32(c0, vout0x01); c0 += 2;
689 vst1_f32(c1, vout1x01); c1 += 2;
690 vst1_f32(c2, vout2x01); c2 += 2;
691 vst1_f32(c3, vout3x01); c3 += 2;
692 vst1_f32(c4, vout4x01); c4 += 2;
693 vst1_f32(c5, vout5x01); c5 += 2;
694 vst1_f32(c6, vout6x01); c6 += 2;
695 vst1_f32(c7, vout7x01); c7 += 2;
696 vout0x01 = vget_high_f32(vout0x0123);
697 vout1x01 = vget_high_f32(vout1x0123);
698 vout2x01 = vget_high_f32(vout2x0123);
699 vout3x01 = vget_high_f32(vout3x0123);
700 vout4x01 = vget_high_f32(vout4x0123);
701 vout5x01 = vget_high_f32(vout5x0123);
702 vout6x01 = vget_high_f32(vout6x0123);
703 vout7x01 = vget_high_f32(vout7x0123);
704 }
705 if (nc & 1) {
706 vst1_lane_f32(c0, vout0x01, 0);
707 vst1_lane_f32(c1, vout1x01, 0);
708 vst1_lane_f32(c2, vout2x01, 0);
709 vst1_lane_f32(c3, vout3x01, 0);
710 vst1_lane_f32(c4, vout4x01, 0);
711 vst1_lane_f32(c5, vout5x01, 0);
712 vst1_lane_f32(c6, vout6x01, 0);
713 vst1_lane_f32(c7, vout7x01, 0);
714 }
715 nc = 0;
716 }
717 } while (nc != 0);
718 }