Debian Codegraph @

src/x16-packw/gen/x16-packw-x8-gemm-goi-neon-ld4lane-u16-prfm.c

raw
1 // Auto-generated file. Do not edit!
2 // Template: src/x16-packw/neon.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
11 #include <assert.h>
12 #include <stddef.h>
13 #include <stdint.h>
14
15 #include <arm_neon.h>
16
17 #include "xnnpack/packw.h"
18 #include "xnnpack/prefetch.h"
19
20
21 void xnn_x16_packw_gemm_goi_ukernel_x8__neon_ld4lane_u16_prfm(
22 size_t g,
23 size_t nc,
24 size_t kc,
25 size_t nr,
26 size_t kr,
27 size_t sr,
28 const uint16_t* weights,
29 const uint16_t* bias,
30 const void* scale,
31 uint16_t* packed_weights,
32 size_t extra_bytes,
33 const void* params)
34 {
35 assert(g != 0);
36 assert(nc != 0);
37 assert(kc != 0);
38 assert(nr == 8);
39 assert(kr == 1);
40 assert(sr == 1);
41 assert(weights != NULL);
42 assert(packed_weights != NULL);
43
44 uint16x8x4_t vtmp0123x01234567;
45 vtmp0123x01234567.val[0] = vdupq_n_u16(0);
46 vtmp0123x01234567.val[1] = vdupq_n_u16(0);
47 vtmp0123x01234567.val[2] = vdupq_n_u16(0);
48 vtmp0123x01234567.val[3] = vdupq_n_u16(0);
49 uint16x8x4_t vtmp4567x01234567;
50 vtmp4567x01234567.val[0] = vdupq_n_u16(0);
51 vtmp4567x01234567.val[1] = vdupq_n_u16(0);
52 vtmp4567x01234567.val[2] = vdupq_n_u16(0);
53 vtmp4567x01234567.val[3] = vdupq_n_u16(0);
54 uint16x8x4_t vtmp89ABx01234567;
55 vtmp89ABx01234567.val[0] = vdupq_n_u16(0);
56 vtmp89ABx01234567.val[1] = vdupq_n_u16(0);
57 vtmp89ABx01234567.val[2] = vdupq_n_u16(0);
58 vtmp89ABx01234567.val[3] = vdupq_n_u16(0);
59 uint16x8x4_t vtmpCDEFx01234567;
60 vtmpCDEFx01234567.val[0] = vdupq_n_u16(0);
61 vtmpCDEFx01234567.val[1] = vdupq_n_u16(0);
62 vtmpCDEFx01234567.val[2] = vdupq_n_u16(0);
63 vtmpCDEFx01234567.val[3] = vdupq_n_u16(0);
64
65 do {
66 // NC main loop multiple of 8
67 const uint16_t* w0 = weights;
68 size_t n = nc;
69
70 for (; n >= 8; n -= 8) {
71 if XNN_LIKELY(bias != NULL) {
72 uint16x8_t vb0 = vld1q_u16(bias); bias += 8;
73 vst1q_u16(packed_weights, vb0); packed_weights += 8;
74 } else {
75 const uint16x8_t vzero = vmovq_n_u16(0);
76 vst1q_u16(packed_weights, vzero); packed_weights += 8;
77 }
78
79 const uint16_t* w1 = w0 + kc;
80 const uint16_t* w2 = w1 + kc;
81 const uint16_t* w3 = w2 + kc;
82 const uint16_t* w4 = w3 + kc;
83 const uint16_t* w5 = w4 + kc;
84 const uint16_t* w6 = w5 + kc;
85 const uint16_t* w7 = w6 + kc;
86 xnn_prefetch_to_l1((const int8_t*) w0);
87 xnn_prefetch_to_l1((const int8_t*) w0 + 64);
88 xnn_prefetch_to_l1((const int8_t*) w1);
89 xnn_prefetch_to_l1((const int8_t*) w1 + 64);
90 xnn_prefetch_to_l1((const int8_t*) w2);
91 xnn_prefetch_to_l1((const int8_t*) w2 + 64);
92 xnn_prefetch_to_l1((const int8_t*) w3);
93 xnn_prefetch_to_l1((const int8_t*) w3 + 64);
94 xnn_prefetch_to_l1((const int8_t*) w4);
95 xnn_prefetch_to_l1((const int8_t*) w4 + 64);
96 xnn_prefetch_to_l1((const int8_t*) w5);
97 xnn_prefetch_to_l1((const int8_t*) w5 + 64);
98 xnn_prefetch_to_l1((const int8_t*) w6);
99 xnn_prefetch_to_l1((const int8_t*) w6 + 64);
100 xnn_prefetch_to_l1((const int8_t*) w7);
101 xnn_prefetch_to_l1((const int8_t*) w7 + 64);
102
103 // KC main loop multiple of 16
104 size_t k = kc;
105 for (; k >= 16; k -= 16) {
106 vtmp0123x01234567 = vld4q_lane_u16(w0, vtmp0123x01234567, 0); w0 += 4;
107 vtmp0123x01234567 = vld4q_lane_u16(w1, vtmp0123x01234567, 1); w1 += 4;
108 vtmp0123x01234567 = vld4q_lane_u16(w2, vtmp0123x01234567, 2); w2 += 4;
109 vtmp0123x01234567 = vld4q_lane_u16(w3, vtmp0123x01234567, 3); w3 += 4;
110 vtmp0123x01234567 = vld4q_lane_u16(w4, vtmp0123x01234567, 4); w4 += 4;
111 vtmp0123x01234567 = vld4q_lane_u16(w5, vtmp0123x01234567, 5); w5 += 4;
112 vtmp0123x01234567 = vld4q_lane_u16(w6, vtmp0123x01234567, 6); w6 += 4;
113 vtmp0123x01234567 = vld4q_lane_u16(w7, vtmp0123x01234567, 7); w7 += 4;
114 vtmp4567x01234567 = vld4q_lane_u16(w0, vtmp4567x01234567, 0); w0 += 4;
115 vtmp4567x01234567 = vld4q_lane_u16(w1, vtmp4567x01234567, 1); w1 += 4;
116 vtmp4567x01234567 = vld4q_lane_u16(w2, vtmp4567x01234567, 2); w2 += 4;
117 vtmp4567x01234567 = vld4q_lane_u16(w3, vtmp4567x01234567, 3); w3 += 4;
118 vtmp4567x01234567 = vld4q_lane_u16(w4, vtmp4567x01234567, 4); w4 += 4;
119 vtmp4567x01234567 = vld4q_lane_u16(w5, vtmp4567x01234567, 5); w5 += 4;
120 vtmp4567x01234567 = vld4q_lane_u16(w6, vtmp4567x01234567, 6); w6 += 4;
121 vtmp4567x01234567 = vld4q_lane_u16(w7, vtmp4567x01234567, 7); w7 += 4;
122 vtmp89ABx01234567 = vld4q_lane_u16(w0, vtmp89ABx01234567, 0); w0 += 4;
123 vtmp89ABx01234567 = vld4q_lane_u16(w1, vtmp89ABx01234567, 1); w1 += 4;
124 vtmp89ABx01234567 = vld4q_lane_u16(w2, vtmp89ABx01234567, 2); w2 += 4;
125 vtmp89ABx01234567 = vld4q_lane_u16(w3, vtmp89ABx01234567, 3); w3 += 4;
126 vtmp89ABx01234567 = vld4q_lane_u16(w4, vtmp89ABx01234567, 4); w4 += 4;
127 vtmp89ABx01234567 = vld4q_lane_u16(w5, vtmp89ABx01234567, 5); w5 += 4;
128 vtmp89ABx01234567 = vld4q_lane_u16(w6, vtmp89ABx01234567, 6); w6 += 4;
129 vtmp89ABx01234567 = vld4q_lane_u16(w7, vtmp89ABx01234567, 7); w7 += 4;
130 vtmpCDEFx01234567 = vld4q_lane_u16(w0, vtmpCDEFx01234567, 0); w0 += 4;
131 vtmpCDEFx01234567 = vld4q_lane_u16(w1, vtmpCDEFx01234567, 1); w1 += 4;
132 vtmpCDEFx01234567 = vld4q_lane_u16(w2, vtmpCDEFx01234567, 2); w2 += 4;
133 vtmpCDEFx01234567 = vld4q_lane_u16(w3, vtmpCDEFx01234567, 3); w3 += 4;
134 vtmpCDEFx01234567 = vld4q_lane_u16(w4, vtmpCDEFx01234567, 4); w4 += 4;
135 vtmpCDEFx01234567 = vld4q_lane_u16(w5, vtmpCDEFx01234567, 5); w5 += 4;
136 vtmpCDEFx01234567 = vld4q_lane_u16(w6, vtmpCDEFx01234567, 6); w6 += 4;
137 vtmpCDEFx01234567 = vld4q_lane_u16(w7, vtmpCDEFx01234567, 7); w7 += 4;
138 xnn_prefetch_to_l1((const int8_t*) w0 + 128);
139 xnn_prefetch_to_l1((const int8_t*) w1 + 128);
140 xnn_prefetch_to_l1((const int8_t*) w2 + 128);
141 xnn_prefetch_to_l1((const int8_t*) w3 + 128);
142 xnn_prefetch_to_l1((const int8_t*) w4 + 128);
143 xnn_prefetch_to_l1((const int8_t*) w5 + 128);
144 xnn_prefetch_to_l1((const int8_t*) w6 + 128);
145 xnn_prefetch_to_l1((const int8_t*) w7 + 128);
146 vst1q_u16(packed_weights, vtmp0123x01234567.val[0]); packed_weights += 8;
147 vst1q_u16(packed_weights, vtmp0123x01234567.val[1]); packed_weights += 8;
148 vst1q_u16(packed_weights, vtmp0123x01234567.val[2]); packed_weights += 8;
149 vst1q_u16(packed_weights, vtmp0123x01234567.val[3]); packed_weights += 8;
150 vst1q_u16(packed_weights, vtmp4567x01234567.val[0]); packed_weights += 8;
151 vst1q_u16(packed_weights, vtmp4567x01234567.val[1]); packed_weights += 8;
152 vst1q_u16(packed_weights, vtmp4567x01234567.val[2]); packed_weights += 8;
153 vst1q_u16(packed_weights, vtmp4567x01234567.val[3]); packed_weights += 8;
154 vst1q_u16(packed_weights, vtmp89ABx01234567.val[0]); packed_weights += 8;
155 vst1q_u16(packed_weights, vtmp89ABx01234567.val[1]); packed_weights += 8;
156 vst1q_u16(packed_weights, vtmp89ABx01234567.val[2]); packed_weights += 8;
157 vst1q_u16(packed_weights, vtmp89ABx01234567.val[3]); packed_weights += 8;
158 vst1q_u16(packed_weights, vtmpCDEFx01234567.val[0]); packed_weights += 8;
159 vst1q_u16(packed_weights, vtmpCDEFx01234567.val[1]); packed_weights += 8;
160 vst1q_u16(packed_weights, vtmpCDEFx01234567.val[2]); packed_weights += 8;
161 vst1q_u16(packed_weights, vtmpCDEFx01234567.val[3]); packed_weights += 8;
162 }
163 // KC remainder multiple of 4
164 while (k >= 4) {
165 vtmp0123x01234567 = vld4q_lane_u16(w0, vtmp0123x01234567, 0); w0 += 4;
166 vtmp0123x01234567 = vld4q_lane_u16(w1, vtmp0123x01234567, 1); w1 += 4;
167 vtmp0123x01234567 = vld4q_lane_u16(w2, vtmp0123x01234567, 2); w2 += 4;
168 vtmp0123x01234567 = vld4q_lane_u16(w3, vtmp0123x01234567, 3); w3 += 4;
169 vtmp0123x01234567 = vld4q_lane_u16(w4, vtmp0123x01234567, 4); w4 += 4;
170 vtmp0123x01234567 = vld4q_lane_u16(w5, vtmp0123x01234567, 5); w5 += 4;
171 vtmp0123x01234567 = vld4q_lane_u16(w6, vtmp0123x01234567, 6); w6 += 4;
172 vtmp0123x01234567 = vld4q_lane_u16(w7, vtmp0123x01234567, 7); w7 += 4;
173 vst1q_u16(packed_weights, vtmp0123x01234567.val[0]); packed_weights += 8;
174 vst1q_u16(packed_weights, vtmp0123x01234567.val[1]); packed_weights += 8;
175 vst1q_u16(packed_weights, vtmp0123x01234567.val[2]); packed_weights += 8;
176 vst1q_u16(packed_weights, vtmp0123x01234567.val[3]); packed_weights += 8;
177 k -= 4;
178 }
179
180 // KC remainder of 1..3
181 // Same as main loop but ld1, ld2 or ld3
182 if XNN_UNLIKELY(k != 0) {
183 assert(k >= 1);
184 assert(k <= 3);
185 switch (k) {
186 // KC remainder of 8x1
187 case 1:
188 {
189 uint16x8_t vtmp0x01234567 = vdupq_n_u16(0);
190
191 vtmp0x01234567 = vld1q_lane_u16(w0, vtmp0x01234567, 0); w0 += 1;
192 vtmp0x01234567 = vld1q_lane_u16(w1, vtmp0x01234567, 1); w1 += 1;
193 vtmp0x01234567 = vld1q_lane_u16(w2, vtmp0x01234567, 2); w2 += 1;
194 vtmp0x01234567 = vld1q_lane_u16(w3, vtmp0x01234567, 3); w3 += 1;
195 vtmp0x01234567 = vld1q_lane_u16(w4, vtmp0x01234567, 4); w4 += 1;
196 vtmp0x01234567 = vld1q_lane_u16(w5, vtmp0x01234567, 5); w5 += 1;
197 vtmp0x01234567 = vld1q_lane_u16(w6, vtmp0x01234567, 6); w6 += 1;
198 vtmp0x01234567 = vld1q_lane_u16(w7, vtmp0x01234567, 7); w7 += 1;
199
200 vst1q_u16(packed_weights, vtmp0x01234567); packed_weights += 8;
201 break;
202 }
203 // KC remainder of 8x2
204 case 2:
205 {
206 uint16x8x2_t vtmp01x01234567;
207 vtmp01x01234567.val[0] = vdupq_n_u16(0);
208 vtmp01x01234567.val[1] = vdupq_n_u16(0);
209
210 vtmp01x01234567 = vld2q_lane_u16(w0, vtmp01x01234567, 0); w0 += 2;
211 vtmp01x01234567 = vld2q_lane_u16(w1, vtmp01x01234567, 1); w1 += 2;
212 vtmp01x01234567 = vld2q_lane_u16(w2, vtmp01x01234567, 2); w2 += 2;
213 vtmp01x01234567 = vld2q_lane_u16(w3, vtmp01x01234567, 3); w3 += 2;
214 vtmp01x01234567 = vld2q_lane_u16(w4, vtmp01x01234567, 4); w4 += 2;
215 vtmp01x01234567 = vld2q_lane_u16(w5, vtmp01x01234567, 5); w5 += 2;
216 vtmp01x01234567 = vld2q_lane_u16(w6, vtmp01x01234567, 6); w6 += 2;
217 vtmp01x01234567 = vld2q_lane_u16(w7, vtmp01x01234567, 7); w7 += 2;
218
219 vst1q_u16(packed_weights, vtmp01x01234567.val[0]); packed_weights += 8;
220 vst1q_u16(packed_weights, vtmp01x01234567.val[1]); packed_weights += 8;
221 break;
222 }
223 // KC remainder of 8x3
224 case 3:
225 {
226 uint16x8x3_t vtmp012x01234567;
227 vtmp012x01234567.val[0] = vdupq_n_u16(0);
228 vtmp012x01234567.val[1] = vdupq_n_u16(0);
229 vtmp012x01234567.val[2] = vdupq_n_u16(0);
230
231 vtmp012x01234567 = vld3q_lane_u16(w0, vtmp012x01234567, 0); w0 += 3;
232 vtmp012x01234567 = vld3q_lane_u16(w1, vtmp012x01234567, 1); w1 += 3;
233 vtmp012x01234567 = vld3q_lane_u16(w2, vtmp012x01234567, 2); w2 += 3;
234 vtmp012x01234567 = vld3q_lane_u16(w3, vtmp012x01234567, 3); w3 += 3;
235 vtmp012x01234567 = vld3q_lane_u16(w4, vtmp012x01234567, 4); w4 += 3;
236 vtmp012x01234567 = vld3q_lane_u16(w5, vtmp012x01234567, 5); w5 += 3;
237 vtmp012x01234567 = vld3q_lane_u16(w6, vtmp012x01234567, 6); w6 += 3;
238 vtmp012x01234567 = vld3q_lane_u16(w7, vtmp012x01234567, 7); w7 += 3;
239
240 vst1q_u16(packed_weights, vtmp012x01234567.val[0]); packed_weights += 8;
241 vst1q_u16(packed_weights, vtmp012x01234567.val[1]); packed_weights += 8;
242 vst1q_u16(packed_weights, vtmp012x01234567.val[2]); packed_weights += 8;
243 break;
244 }
245 default:
246 XNN_UNREACHABLE;
247 }
248 }
249 packed_weights = (uint16_t*) ((uintptr_t) packed_weights + extra_bytes);
250 w0 = w7;
251 }
252
253 // NC remainder (1..7)
254 if XNN_UNLIKELY(n != 0) {
255 assert(n >= 1);
256 assert(n <= 7);
257 if XNN_LIKELY(bias != NULL) {
258 size_t nb = n;
259 do {
260 *packed_weights++ = *bias++;
261 } while (--nb != 0);
262 packed_weights += (8 - n);
263 } else {
264 const uint16x8_t vzero = vmovq_n_u16(0);
265 vst1q_u16(packed_weights, vzero); packed_weights += 8;
266 }
267
268 // NR remainder has less than 8 rows so last row is not loaded
269 const uint16_t* w1 = w0 + kc;
270 if XNN_UNPREDICTABLE(n < 2) {
271 w1 = w0;
272 }
273 const uint16_t* w2 = w1 + kc;
274 if XNN_UNPREDICTABLE(n <= 2) {
275 w2 = w1;
276 }
277 const uint16_t* w3 = w2 + kc;
278 if XNN_UNPREDICTABLE(n < 4) {
279 w3 = w2;
280 }
281 const uint16_t* w4 = w3 + kc;
282 if XNN_UNPREDICTABLE(n <= 4) {
283 w4 = w3;
284 }
285 const uint16_t* w5 = w4 + kc;
286 if XNN_UNPREDICTABLE(n < 6) {
287 w5 = w4;
288 }
289 const uint16_t* w6 = w5 + kc;
290 if XNN_UNPREDICTABLE(n <= 6) {
291 w6 = w5;
292 }
293
294 // KC main loop multiple of 16
295 size_t k = kc;
296 for (; k >= 16; k -= 16) {
297 vtmp0123x01234567 = vld4q_lane_u16(w0, vtmp0123x01234567, 0); w0 += 4;
298 vtmp0123x01234567 = vld4q_lane_u16(w1, vtmp0123x01234567, 1); w1 += 4;
299 vtmp0123x01234567 = vld4q_lane_u16(w2, vtmp0123x01234567, 2); w2 += 4;
300 vtmp0123x01234567 = vld4q_lane_u16(w3, vtmp0123x01234567, 3); w3 += 4;
301 vtmp0123x01234567 = vld4q_lane_u16(w4, vtmp0123x01234567, 4); w4 += 4;
302 vtmp0123x01234567 = vld4q_lane_u16(w5, vtmp0123x01234567, 5); w5 += 4;
303 vtmp0123x01234567 = vld4q_lane_u16(w6, vtmp0123x01234567, 6); w6 += 4;
304 vtmp4567x01234567 = vld4q_lane_u16(w0, vtmp4567x01234567, 0); w0 += 4;
305 vtmp4567x01234567 = vld4q_lane_u16(w1, vtmp4567x01234567, 1); w1 += 4;
306 vtmp4567x01234567 = vld4q_lane_u16(w2, vtmp4567x01234567, 2); w2 += 4;
307 vtmp4567x01234567 = vld4q_lane_u16(w3, vtmp4567x01234567, 3); w3 += 4;
308 vtmp4567x01234567 = vld4q_lane_u16(w4, vtmp4567x01234567, 4); w4 += 4;
309 vtmp4567x01234567 = vld4q_lane_u16(w5, vtmp4567x01234567, 5); w5 += 4;
310 vtmp4567x01234567 = vld4q_lane_u16(w6, vtmp4567x01234567, 6); w6 += 4;
311 vtmp89ABx01234567 = vld4q_lane_u16(w0, vtmp89ABx01234567, 0); w0 += 4;
312 vtmp89ABx01234567 = vld4q_lane_u16(w1, vtmp89ABx01234567, 1); w1 += 4;
313 vtmp89ABx01234567 = vld4q_lane_u16(w2, vtmp89ABx01234567, 2); w2 += 4;
314 vtmp89ABx01234567 = vld4q_lane_u16(w3, vtmp89ABx01234567, 3); w3 += 4;
315 vtmp89ABx01234567 = vld4q_lane_u16(w4, vtmp89ABx01234567, 4); w4 += 4;
316 vtmp89ABx01234567 = vld4q_lane_u16(w5, vtmp89ABx01234567, 5); w5 += 4;
317 vtmp89ABx01234567 = vld4q_lane_u16(w6, vtmp89ABx01234567, 6); w6 += 4;
318 vtmpCDEFx01234567 = vld4q_lane_u16(w0, vtmpCDEFx01234567, 0); w0 += 4;
319 vtmpCDEFx01234567 = vld4q_lane_u16(w1, vtmpCDEFx01234567, 1); w1 += 4;
320 vtmpCDEFx01234567 = vld4q_lane_u16(w2, vtmpCDEFx01234567, 2); w2 += 4;
321 vtmpCDEFx01234567 = vld4q_lane_u16(w3, vtmpCDEFx01234567, 3); w3 += 4;
322 vtmpCDEFx01234567 = vld4q_lane_u16(w4, vtmpCDEFx01234567, 4); w4 += 4;
323 vtmpCDEFx01234567 = vld4q_lane_u16(w5, vtmpCDEFx01234567, 5); w5 += 4;
324 vtmpCDEFx01234567 = vld4q_lane_u16(w6, vtmpCDEFx01234567, 6); w6 += 4;
325 xnn_prefetch_to_l1((const int8_t*) w0 + 128);
326 xnn_prefetch_to_l1((const int8_t*) w1 + 128);
327 xnn_prefetch_to_l1((const int8_t*) w2 + 128);
328 xnn_prefetch_to_l1((const int8_t*) w3 + 128);
329 xnn_prefetch_to_l1((const int8_t*) w4 + 128);
330 xnn_prefetch_to_l1((const int8_t*) w5 + 128);
331 xnn_prefetch_to_l1((const int8_t*) w6 + 128);
332 vst1q_u16(packed_weights, vtmp0123x01234567.val[0]); packed_weights += 8;
333 vst1q_u16(packed_weights, vtmp0123x01234567.val[1]); packed_weights += 8;
334 vst1q_u16(packed_weights, vtmp0123x01234567.val[2]); packed_weights += 8;
335 vst1q_u16(packed_weights, vtmp0123x01234567.val[3]); packed_weights += 8;
336 vst1q_u16(packed_weights, vtmp4567x01234567.val[0]); packed_weights += 8;
337 vst1q_u16(packed_weights, vtmp4567x01234567.val[1]); packed_weights += 8;
338 vst1q_u16(packed_weights, vtmp4567x01234567.val[2]); packed_weights += 8;
339 vst1q_u16(packed_weights, vtmp4567x01234567.val[3]); packed_weights += 8;
340 vst1q_u16(packed_weights, vtmp89ABx01234567.val[0]); packed_weights += 8;
341 vst1q_u16(packed_weights, vtmp89ABx01234567.val[1]); packed_weights += 8;
342 vst1q_u16(packed_weights, vtmp89ABx01234567.val[2]); packed_weights += 8;
343 vst1q_u16(packed_weights, vtmp89ABx01234567.val[3]); packed_weights += 8;
344 vst1q_u16(packed_weights, vtmpCDEFx01234567.val[0]); packed_weights += 8;
345 vst1q_u16(packed_weights, vtmpCDEFx01234567.val[1]); packed_weights += 8;
346 vst1q_u16(packed_weights, vtmpCDEFx01234567.val[2]); packed_weights += 8;
347 vst1q_u16(packed_weights, vtmpCDEFx01234567.val[3]); packed_weights += 8;
348 }
349
350 // KC remainder multiple of 4
351 while (k >= 4) {
352 vtmp0123x01234567 = vld4q_lane_u16(w0, vtmp0123x01234567, 0); w0 += 4;
353 vtmp0123x01234567 = vld4q_lane_u16(w1, vtmp0123x01234567, 1); w1 += 4;
354 vtmp0123x01234567 = vld4q_lane_u16(w2, vtmp0123x01234567, 2); w2 += 4;
355 vtmp0123x01234567 = vld4q_lane_u16(w3, vtmp0123x01234567, 3); w3 += 4;
356 vtmp0123x01234567 = vld4q_lane_u16(w4, vtmp0123x01234567, 4); w4 += 4;
357 vtmp0123x01234567 = vld4q_lane_u16(w5, vtmp0123x01234567, 5); w5 += 4;
358 vtmp0123x01234567 = vld4q_lane_u16(w6, vtmp0123x01234567, 6); w6 += 4;
359 vst1q_u16(packed_weights, vtmp0123x01234567.val[0]); packed_weights += 8;
360 vst1q_u16(packed_weights, vtmp0123x01234567.val[1]); packed_weights += 8;
361 vst1q_u16(packed_weights, vtmp0123x01234567.val[2]); packed_weights += 8;
362 vst1q_u16(packed_weights, vtmp0123x01234567.val[3]); packed_weights += 8;
363 k -= 4;
364 }
365
366 // KC remainder of 1..3
367 // Same as main loop but ld1, ld2 or ld3
368 if XNN_UNLIKELY(k != 0) {
369 assert(k >= 1);
370 assert(k <= 3);
371 switch (k) {
372 // KC remainder of 8x1
373 case 1:
374 {
375 uint16x8_t vtmp0x01234567 = vdupq_n_u16(0);
376
377 vtmp0x01234567 = vld1q_lane_u16(w0, vtmp0x01234567, 0); w0 += 1;
378 vtmp0x01234567 = vld1q_lane_u16(w1, vtmp0x01234567, 1); w1 += 1;
379 vtmp0x01234567 = vld1q_lane_u16(w2, vtmp0x01234567, 2); w2 += 1;
380 vtmp0x01234567 = vld1q_lane_u16(w3, vtmp0x01234567, 3); w3 += 1;
381 vtmp0x01234567 = vld1q_lane_u16(w4, vtmp0x01234567, 4); w4 += 1;
382 vtmp0x01234567 = vld1q_lane_u16(w5, vtmp0x01234567, 5); w5 += 1;
383 vtmp0x01234567 = vld1q_lane_u16(w6, vtmp0x01234567, 6); w6 += 1;
384
385 vst1q_u16(packed_weights, vtmp0x01234567); packed_weights += 8;
386 break;
387 }
388 // KC remainder of 8x2
389 case 2:
390 {
391 uint16x8x2_t vtmp01x01234567;
392 vtmp01x01234567.val[0] = vdupq_n_u16(0);
393 vtmp01x01234567.val[1] = vdupq_n_u16(0);
394
395 vtmp01x01234567 = vld2q_lane_u16(w0, vtmp01x01234567, 0); w0 += 2;
396 vtmp01x01234567 = vld2q_lane_u16(w1, vtmp01x01234567, 1); w1 += 2;
397 vtmp01x01234567 = vld2q_lane_u16(w2, vtmp01x01234567, 2); w2 += 2;
398 vtmp01x01234567 = vld2q_lane_u16(w3, vtmp01x01234567, 3); w3 += 2;
399 vtmp01x01234567 = vld2q_lane_u16(w4, vtmp01x01234567, 4); w4 += 2;
400 vtmp01x01234567 = vld2q_lane_u16(w5, vtmp01x01234567, 5); w5 += 2;
401 vtmp01x01234567 = vld2q_lane_u16(w6, vtmp01x01234567, 6); w6 += 2;
402
403 vst1q_u16(packed_weights, vtmp01x01234567.val[0]); packed_weights += 8;
404 vst1q_u16(packed_weights, vtmp01x01234567.val[1]); packed_weights += 8;
405 break;
406 }
407 // KC remainder of 8x3
408 case 3:
409 {
410 uint16x8x3_t vtmp012x01234567;
411 vtmp012x01234567.val[0] = vdupq_n_u16(0);
412 vtmp012x01234567.val[1] = vdupq_n_u16(0);
413 vtmp012x01234567.val[2] = vdupq_n_u16(0);
414
415 vtmp012x01234567 = vld3q_lane_u16(w0, vtmp012x01234567, 0); w0 += 3;
416 vtmp012x01234567 = vld3q_lane_u16(w1, vtmp012x01234567, 1); w1 += 3;
417 vtmp012x01234567 = vld3q_lane_u16(w2, vtmp012x01234567, 2); w2 += 3;
418 vtmp012x01234567 = vld3q_lane_u16(w3, vtmp012x01234567, 3); w3 += 3;
419 vtmp012x01234567 = vld3q_lane_u16(w4, vtmp012x01234567, 4); w4 += 3;
420 vtmp012x01234567 = vld3q_lane_u16(w5, vtmp012x01234567, 5); w5 += 3;
421 vtmp012x01234567 = vld3q_lane_u16(w6, vtmp012x01234567, 6); w6 += 3;
422
423 vst1q_u16(packed_weights, vtmp012x01234567.val[0]); packed_weights += 8;
424 vst1q_u16(packed_weights, vtmp012x01234567.val[1]); packed_weights += 8;
425 vst1q_u16(packed_weights, vtmp012x01234567.val[2]); packed_weights += 8;
426 break;
427 }
428 default:
429 XNN_UNREACHABLE;
430 }
431 }
432 packed_weights = (uint16_t*) ((uintptr_t) packed_weights + extra_bytes);
433 }
434
435 weights += nc * kc;
436 } while (--g != 0);
437 }