Debian Codegraph @

src/x16-packw/gen/x16-packw-x16-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_x16__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 == 16);
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 uint16x8x4_t vtmp0123x89ABCDEF;
65 vtmp0123x89ABCDEF.val[0] = vdupq_n_u16(0);
66 vtmp0123x89ABCDEF.val[1] = vdupq_n_u16(0);
67 vtmp0123x89ABCDEF.val[2] = vdupq_n_u16(0);
68 vtmp0123x89ABCDEF.val[3] = vdupq_n_u16(0);
69 uint16x8x4_t vtmp4567x89ABCDEF;
70 vtmp4567x89ABCDEF.val[0] = vdupq_n_u16(0);
71 vtmp4567x89ABCDEF.val[1] = vdupq_n_u16(0);
72 vtmp4567x89ABCDEF.val[2] = vdupq_n_u16(0);
73 vtmp4567x89ABCDEF.val[3] = vdupq_n_u16(0);
74 uint16x8x4_t vtmp89ABx89ABCDEF;
75 vtmp89ABx89ABCDEF.val[0] = vdupq_n_u16(0);
76 vtmp89ABx89ABCDEF.val[1] = vdupq_n_u16(0);
77 vtmp89ABx89ABCDEF.val[2] = vdupq_n_u16(0);
78 vtmp89ABx89ABCDEF.val[3] = vdupq_n_u16(0);
79 uint16x8x4_t vtmpCDEFx89ABCDEF;
80 vtmpCDEFx89ABCDEF.val[0] = vdupq_n_u16(0);
81 vtmpCDEFx89ABCDEF.val[1] = vdupq_n_u16(0);
82 vtmpCDEFx89ABCDEF.val[2] = vdupq_n_u16(0);
83 vtmpCDEFx89ABCDEF.val[3] = vdupq_n_u16(0);
84
85 do {
86 // NC main loop multiple of 16
87 const uint16_t* w0 = weights;
88 size_t n = nc;
89
90 for (; n >= 16; n -= 16) {
91 if XNN_LIKELY(bias != NULL) {
92 uint16x8_t vb0 = vld1q_u16(bias); bias += 8;
93 uint16x8_t vb8 = vld1q_u16(bias); bias += 8;
94 vst1q_u16(packed_weights, vb0); packed_weights += 8;
95 vst1q_u16(packed_weights, vb8); packed_weights += 8;
96 } else {
97 const uint16x8_t vzero = vmovq_n_u16(0);
98 vst1q_u16(packed_weights, vzero); packed_weights += 8;
99 vst1q_u16(packed_weights, vzero); packed_weights += 8;
100 }
101
102 const uint16_t* w1 = w0 + kc;
103 const uint16_t* w2 = w1 + kc;
104 const uint16_t* w3 = w2 + kc;
105 const uint16_t* w4 = w3 + kc;
106 const uint16_t* w5 = w4 + kc;
107 const uint16_t* w6 = w5 + kc;
108 const uint16_t* w7 = w6 + kc;
109 const uint16_t* w8 = w7 + kc;
110 const uint16_t* w9 = w8 + kc;
111 const uint16_t* w10 = w9 + kc;
112 const uint16_t* w11 = w10 + kc;
113 const uint16_t* w12 = w11 + kc;
114 const uint16_t* w13 = w12 + kc;
115 const uint16_t* w14 = w13 + kc;
116 const uint16_t* w15 = w14 + kc;
117 xnn_prefetch_to_l1((const int8_t*) w0);
118 xnn_prefetch_to_l1((const int8_t*) w0 + 64);
119 xnn_prefetch_to_l1((const int8_t*) w1);
120 xnn_prefetch_to_l1((const int8_t*) w1 + 64);
121 xnn_prefetch_to_l1((const int8_t*) w2);
122 xnn_prefetch_to_l1((const int8_t*) w2 + 64);
123 xnn_prefetch_to_l1((const int8_t*) w3);
124 xnn_prefetch_to_l1((const int8_t*) w3 + 64);
125 xnn_prefetch_to_l1((const int8_t*) w4);
126 xnn_prefetch_to_l1((const int8_t*) w4 + 64);
127 xnn_prefetch_to_l1((const int8_t*) w5);
128 xnn_prefetch_to_l1((const int8_t*) w5 + 64);
129 xnn_prefetch_to_l1((const int8_t*) w6);
130 xnn_prefetch_to_l1((const int8_t*) w6 + 64);
131 xnn_prefetch_to_l1((const int8_t*) w7);
132 xnn_prefetch_to_l1((const int8_t*) w7 + 64);
133 xnn_prefetch_to_l1((const int8_t*) w8);
134 xnn_prefetch_to_l1((const int8_t*) w8 + 64);
135 xnn_prefetch_to_l1((const int8_t*) w9);
136 xnn_prefetch_to_l1((const int8_t*) w9 + 64);
137 xnn_prefetch_to_l1((const int8_t*) w10);
138 xnn_prefetch_to_l1((const int8_t*) w10 + 64);
139 xnn_prefetch_to_l1((const int8_t*) w11);
140 xnn_prefetch_to_l1((const int8_t*) w11 + 64);
141 xnn_prefetch_to_l1((const int8_t*) w12);
142 xnn_prefetch_to_l1((const int8_t*) w12 + 64);
143 xnn_prefetch_to_l1((const int8_t*) w13);
144 xnn_prefetch_to_l1((const int8_t*) w13 + 64);
145 xnn_prefetch_to_l1((const int8_t*) w14);
146 xnn_prefetch_to_l1((const int8_t*) w14 + 64);
147 xnn_prefetch_to_l1((const int8_t*) w15);
148 xnn_prefetch_to_l1((const int8_t*) w15 + 64);
149
150 // KC main loop multiple of 16
151 size_t k = kc;
152 for (; k >= 16; k -= 16) {
153 vtmp0123x01234567 = vld4q_lane_u16(w0, vtmp0123x01234567, 0); w0 += 4;
154 vtmp0123x01234567 = vld4q_lane_u16(w1, vtmp0123x01234567, 1); w1 += 4;
155 vtmp0123x01234567 = vld4q_lane_u16(w2, vtmp0123x01234567, 2); w2 += 4;
156 vtmp0123x01234567 = vld4q_lane_u16(w3, vtmp0123x01234567, 3); w3 += 4;
157 vtmp0123x01234567 = vld4q_lane_u16(w4, vtmp0123x01234567, 4); w4 += 4;
158 vtmp0123x01234567 = vld4q_lane_u16(w5, vtmp0123x01234567, 5); w5 += 4;
159 vtmp0123x01234567 = vld4q_lane_u16(w6, vtmp0123x01234567, 6); w6 += 4;
160 vtmp0123x01234567 = vld4q_lane_u16(w7, vtmp0123x01234567, 7); w7 += 4;
161 vtmp0123x89ABCDEF = vld4q_lane_u16(w8, vtmp0123x89ABCDEF, 0); w8 += 4;
162 vtmp0123x89ABCDEF = vld4q_lane_u16(w9, vtmp0123x89ABCDEF, 1); w9 += 4;
163 vtmp0123x89ABCDEF = vld4q_lane_u16(w10, vtmp0123x89ABCDEF, 2); w10 += 4;
164 vtmp0123x89ABCDEF = vld4q_lane_u16(w11, vtmp0123x89ABCDEF, 3); w11 += 4;
165 vtmp0123x89ABCDEF = vld4q_lane_u16(w12, vtmp0123x89ABCDEF, 4); w12 += 4;
166 vtmp0123x89ABCDEF = vld4q_lane_u16(w13, vtmp0123x89ABCDEF, 5); w13 += 4;
167 vtmp0123x89ABCDEF = vld4q_lane_u16(w14, vtmp0123x89ABCDEF, 6); w14 += 4;
168 vtmp0123x89ABCDEF = vld4q_lane_u16(w15, vtmp0123x89ABCDEF, 7); w15 += 4;
169 vtmp4567x01234567 = vld4q_lane_u16(w0, vtmp4567x01234567, 0); w0 += 4;
170 vtmp4567x01234567 = vld4q_lane_u16(w1, vtmp4567x01234567, 1); w1 += 4;
171 vtmp4567x01234567 = vld4q_lane_u16(w2, vtmp4567x01234567, 2); w2 += 4;
172 vtmp4567x01234567 = vld4q_lane_u16(w3, vtmp4567x01234567, 3); w3 += 4;
173 vtmp4567x01234567 = vld4q_lane_u16(w4, vtmp4567x01234567, 4); w4 += 4;
174 vtmp4567x01234567 = vld4q_lane_u16(w5, vtmp4567x01234567, 5); w5 += 4;
175 vtmp4567x01234567 = vld4q_lane_u16(w6, vtmp4567x01234567, 6); w6 += 4;
176 vtmp4567x01234567 = vld4q_lane_u16(w7, vtmp4567x01234567, 7); w7 += 4;
177 vtmp4567x89ABCDEF = vld4q_lane_u16(w8, vtmp4567x89ABCDEF, 0); w8 += 4;
178 vtmp4567x89ABCDEF = vld4q_lane_u16(w9, vtmp4567x89ABCDEF, 1); w9 += 4;
179 vtmp4567x89ABCDEF = vld4q_lane_u16(w10, vtmp4567x89ABCDEF, 2); w10 += 4;
180 vtmp4567x89ABCDEF = vld4q_lane_u16(w11, vtmp4567x89ABCDEF, 3); w11 += 4;
181 vtmp4567x89ABCDEF = vld4q_lane_u16(w12, vtmp4567x89ABCDEF, 4); w12 += 4;
182 vtmp4567x89ABCDEF = vld4q_lane_u16(w13, vtmp4567x89ABCDEF, 5); w13 += 4;
183 vtmp4567x89ABCDEF = vld4q_lane_u16(w14, vtmp4567x89ABCDEF, 6); w14 += 4;
184 vtmp4567x89ABCDEF = vld4q_lane_u16(w15, vtmp4567x89ABCDEF, 7); w15 += 4;
185 vtmp89ABx01234567 = vld4q_lane_u16(w0, vtmp89ABx01234567, 0); w0 += 4;
186 vtmp89ABx01234567 = vld4q_lane_u16(w1, vtmp89ABx01234567, 1); w1 += 4;
187 vtmp89ABx01234567 = vld4q_lane_u16(w2, vtmp89ABx01234567, 2); w2 += 4;
188 vtmp89ABx01234567 = vld4q_lane_u16(w3, vtmp89ABx01234567, 3); w3 += 4;
189 vtmp89ABx01234567 = vld4q_lane_u16(w4, vtmp89ABx01234567, 4); w4 += 4;
190 vtmp89ABx01234567 = vld4q_lane_u16(w5, vtmp89ABx01234567, 5); w5 += 4;
191 vtmp89ABx01234567 = vld4q_lane_u16(w6, vtmp89ABx01234567, 6); w6 += 4;
192 vtmp89ABx01234567 = vld4q_lane_u16(w7, vtmp89ABx01234567, 7); w7 += 4;
193 vtmp89ABx89ABCDEF = vld4q_lane_u16(w8, vtmp89ABx89ABCDEF, 0); w8 += 4;
194 vtmp89ABx89ABCDEF = vld4q_lane_u16(w9, vtmp89ABx89ABCDEF, 1); w9 += 4;
195 vtmp89ABx89ABCDEF = vld4q_lane_u16(w10, vtmp89ABx89ABCDEF, 2); w10 += 4;
196 vtmp89ABx89ABCDEF = vld4q_lane_u16(w11, vtmp89ABx89ABCDEF, 3); w11 += 4;
197 vtmp89ABx89ABCDEF = vld4q_lane_u16(w12, vtmp89ABx89ABCDEF, 4); w12 += 4;
198 vtmp89ABx89ABCDEF = vld4q_lane_u16(w13, vtmp89ABx89ABCDEF, 5); w13 += 4;
199 vtmp89ABx89ABCDEF = vld4q_lane_u16(w14, vtmp89ABx89ABCDEF, 6); w14 += 4;
200 vtmp89ABx89ABCDEF = vld4q_lane_u16(w15, vtmp89ABx89ABCDEF, 7); w15 += 4;
201 vtmpCDEFx01234567 = vld4q_lane_u16(w0, vtmpCDEFx01234567, 0); w0 += 4;
202 vtmpCDEFx01234567 = vld4q_lane_u16(w1, vtmpCDEFx01234567, 1); w1 += 4;
203 vtmpCDEFx01234567 = vld4q_lane_u16(w2, vtmpCDEFx01234567, 2); w2 += 4;
204 vtmpCDEFx01234567 = vld4q_lane_u16(w3, vtmpCDEFx01234567, 3); w3 += 4;
205 vtmpCDEFx01234567 = vld4q_lane_u16(w4, vtmpCDEFx01234567, 4); w4 += 4;
206 vtmpCDEFx01234567 = vld4q_lane_u16(w5, vtmpCDEFx01234567, 5); w5 += 4;
207 vtmpCDEFx01234567 = vld4q_lane_u16(w6, vtmpCDEFx01234567, 6); w6 += 4;
208 vtmpCDEFx01234567 = vld4q_lane_u16(w7, vtmpCDEFx01234567, 7); w7 += 4;
209 vtmpCDEFx89ABCDEF = vld4q_lane_u16(w8, vtmpCDEFx89ABCDEF, 0); w8 += 4;
210 vtmpCDEFx89ABCDEF = vld4q_lane_u16(w9, vtmpCDEFx89ABCDEF, 1); w9 += 4;
211 vtmpCDEFx89ABCDEF = vld4q_lane_u16(w10, vtmpCDEFx89ABCDEF, 2); w10 += 4;
212 vtmpCDEFx89ABCDEF = vld4q_lane_u16(w11, vtmpCDEFx89ABCDEF, 3); w11 += 4;
213 vtmpCDEFx89ABCDEF = vld4q_lane_u16(w12, vtmpCDEFx89ABCDEF, 4); w12 += 4;
214 vtmpCDEFx89ABCDEF = vld4q_lane_u16(w13, vtmpCDEFx89ABCDEF, 5); w13 += 4;
215 vtmpCDEFx89ABCDEF = vld4q_lane_u16(w14, vtmpCDEFx89ABCDEF, 6); w14 += 4;
216 vtmpCDEFx89ABCDEF = vld4q_lane_u16(w15, vtmpCDEFx89ABCDEF, 7); w15 += 4;
217 xnn_prefetch_to_l1((const int8_t*) w0 + 128);
218 xnn_prefetch_to_l1((const int8_t*) w1 + 128);
219 xnn_prefetch_to_l1((const int8_t*) w2 + 128);
220 xnn_prefetch_to_l1((const int8_t*) w3 + 128);
221 xnn_prefetch_to_l1((const int8_t*) w4 + 128);
222 xnn_prefetch_to_l1((const int8_t*) w5 + 128);
223 xnn_prefetch_to_l1((const int8_t*) w6 + 128);
224 xnn_prefetch_to_l1((const int8_t*) w7 + 128);
225 xnn_prefetch_to_l1((const int8_t*) w8 + 128);
226 xnn_prefetch_to_l1((const int8_t*) w9 + 128);
227 xnn_prefetch_to_l1((const int8_t*) w10 + 128);
228 xnn_prefetch_to_l1((const int8_t*) w11 + 128);
229 xnn_prefetch_to_l1((const int8_t*) w12 + 128);
230 xnn_prefetch_to_l1((const int8_t*) w13 + 128);
231 xnn_prefetch_to_l1((const int8_t*) w14 + 128);
232 xnn_prefetch_to_l1((const int8_t*) w15 + 128);
233 vst1q_u16(packed_weights, vtmp0123x01234567.val[0]); packed_weights += 8;
234 vst1q_u16(packed_weights, vtmp0123x89ABCDEF.val[0]); packed_weights += 8;
235 vst1q_u16(packed_weights, vtmp0123x01234567.val[1]); packed_weights += 8;
236 vst1q_u16(packed_weights, vtmp0123x89ABCDEF.val[1]); packed_weights += 8;
237 vst1q_u16(packed_weights, vtmp0123x01234567.val[2]); packed_weights += 8;
238 vst1q_u16(packed_weights, vtmp0123x89ABCDEF.val[2]); packed_weights += 8;
239 vst1q_u16(packed_weights, vtmp0123x01234567.val[3]); packed_weights += 8;
240 vst1q_u16(packed_weights, vtmp0123x89ABCDEF.val[3]); packed_weights += 8;
241 vst1q_u16(packed_weights, vtmp4567x01234567.val[0]); packed_weights += 8;
242 vst1q_u16(packed_weights, vtmp4567x89ABCDEF.val[0]); packed_weights += 8;
243 vst1q_u16(packed_weights, vtmp4567x01234567.val[1]); packed_weights += 8;
244 vst1q_u16(packed_weights, vtmp4567x89ABCDEF.val[1]); packed_weights += 8;
245 vst1q_u16(packed_weights, vtmp4567x01234567.val[2]); packed_weights += 8;
246 vst1q_u16(packed_weights, vtmp4567x89ABCDEF.val[2]); packed_weights += 8;
247 vst1q_u16(packed_weights, vtmp4567x01234567.val[3]); packed_weights += 8;
248 vst1q_u16(packed_weights, vtmp4567x89ABCDEF.val[3]); packed_weights += 8;
249 vst1q_u16(packed_weights, vtmp89ABx01234567.val[0]); packed_weights += 8;
250 vst1q_u16(packed_weights, vtmp89ABx89ABCDEF.val[0]); packed_weights += 8;
251 vst1q_u16(packed_weights, vtmp89ABx01234567.val[1]); packed_weights += 8;
252 vst1q_u16(packed_weights, vtmp89ABx89ABCDEF.val[1]); packed_weights += 8;
253 vst1q_u16(packed_weights, vtmp89ABx01234567.val[2]); packed_weights += 8;
254 vst1q_u16(packed_weights, vtmp89ABx89ABCDEF.val[2]); packed_weights += 8;
255 vst1q_u16(packed_weights, vtmp89ABx01234567.val[3]); packed_weights += 8;
256 vst1q_u16(packed_weights, vtmp89ABx89ABCDEF.val[3]); packed_weights += 8;
257 vst1q_u16(packed_weights, vtmpCDEFx01234567.val[0]); packed_weights += 8;
258 vst1q_u16(packed_weights, vtmpCDEFx89ABCDEF.val[0]); packed_weights += 8;
259 vst1q_u16(packed_weights, vtmpCDEFx01234567.val[1]); packed_weights += 8;
260 vst1q_u16(packed_weights, vtmpCDEFx89ABCDEF.val[1]); packed_weights += 8;
261 vst1q_u16(packed_weights, vtmpCDEFx01234567.val[2]); packed_weights += 8;
262 vst1q_u16(packed_weights, vtmpCDEFx89ABCDEF.val[2]); packed_weights += 8;
263 vst1q_u16(packed_weights, vtmpCDEFx01234567.val[3]); packed_weights += 8;
264 vst1q_u16(packed_weights, vtmpCDEFx89ABCDEF.val[3]); packed_weights += 8;
265 }
266 // KC remainder multiple of 4
267 while (k >= 4) {
268 vtmp0123x01234567 = vld4q_lane_u16(w0, vtmp0123x01234567, 0); w0 += 4;
269 vtmp0123x01234567 = vld4q_lane_u16(w1, vtmp0123x01234567, 1); w1 += 4;
270 vtmp0123x01234567 = vld4q_lane_u16(w2, vtmp0123x01234567, 2); w2 += 4;
271 vtmp0123x01234567 = vld4q_lane_u16(w3, vtmp0123x01234567, 3); w3 += 4;
272 vtmp0123x01234567 = vld4q_lane_u16(w4, vtmp0123x01234567, 4); w4 += 4;
273 vtmp0123x01234567 = vld4q_lane_u16(w5, vtmp0123x01234567, 5); w5 += 4;
274 vtmp0123x01234567 = vld4q_lane_u16(w6, vtmp0123x01234567, 6); w6 += 4;
275 vtmp0123x01234567 = vld4q_lane_u16(w7, vtmp0123x01234567, 7); w7 += 4;
276 vtmp0123x89ABCDEF = vld4q_lane_u16(w8, vtmp0123x89ABCDEF, 0); w8 += 4;
277 vtmp0123x89ABCDEF = vld4q_lane_u16(w9, vtmp0123x89ABCDEF, 1); w9 += 4;
278 vtmp0123x89ABCDEF = vld4q_lane_u16(w10, vtmp0123x89ABCDEF, 2); w10 += 4;
279 vtmp0123x89ABCDEF = vld4q_lane_u16(w11, vtmp0123x89ABCDEF, 3); w11 += 4;
280 vtmp0123x89ABCDEF = vld4q_lane_u16(w12, vtmp0123x89ABCDEF, 4); w12 += 4;
281 vtmp0123x89ABCDEF = vld4q_lane_u16(w13, vtmp0123x89ABCDEF, 5); w13 += 4;
282 vtmp0123x89ABCDEF = vld4q_lane_u16(w14, vtmp0123x89ABCDEF, 6); w14 += 4;
283 vtmp0123x89ABCDEF = vld4q_lane_u16(w15, vtmp0123x89ABCDEF, 7); w15 += 4;
284 vst1q_u16(packed_weights, vtmp0123x01234567.val[0]); packed_weights += 8;
285 vst1q_u16(packed_weights, vtmp0123x89ABCDEF.val[0]); packed_weights += 8;
286 vst1q_u16(packed_weights, vtmp0123x01234567.val[1]); packed_weights += 8;
287 vst1q_u16(packed_weights, vtmp0123x89ABCDEF.val[1]); packed_weights += 8;
288 vst1q_u16(packed_weights, vtmp0123x01234567.val[2]); packed_weights += 8;
289 vst1q_u16(packed_weights, vtmp0123x89ABCDEF.val[2]); packed_weights += 8;
290 vst1q_u16(packed_weights, vtmp0123x01234567.val[3]); packed_weights += 8;
291 vst1q_u16(packed_weights, vtmp0123x89ABCDEF.val[3]); packed_weights += 8;
292 k -= 4;
293 }
294
295 // KC remainder of 1..3
296 // Same as main loop but ld1, ld2 or ld3
297 if XNN_UNLIKELY(k != 0) {
298 assert(k >= 1);
299 assert(k <= 3);
300 switch (k) {
301 // KC remainder of 16x1
302 case 1:
303 {
304 uint16x8_t vtmp0x01234567 = vdupq_n_u16(0);
305 uint16x8_t vtmp0x89ABCDEF = vdupq_n_u16(0);
306
307 vtmp0x01234567 = vld1q_lane_u16(w0, vtmp0x01234567, 0); w0 += 1;
308 vtmp0x01234567 = vld1q_lane_u16(w1, vtmp0x01234567, 1); w1 += 1;
309 vtmp0x01234567 = vld1q_lane_u16(w2, vtmp0x01234567, 2); w2 += 1;
310 vtmp0x01234567 = vld1q_lane_u16(w3, vtmp0x01234567, 3); w3 += 1;
311 vtmp0x01234567 = vld1q_lane_u16(w4, vtmp0x01234567, 4); w4 += 1;
312 vtmp0x01234567 = vld1q_lane_u16(w5, vtmp0x01234567, 5); w5 += 1;
313 vtmp0x01234567 = vld1q_lane_u16(w6, vtmp0x01234567, 6); w6 += 1;
314 vtmp0x01234567 = vld1q_lane_u16(w7, vtmp0x01234567, 7); w7 += 1;
315 vtmp0x89ABCDEF = vld1q_lane_u16(w8, vtmp0x89ABCDEF, 0); w8 += 1;
316 vtmp0x89ABCDEF = vld1q_lane_u16(w9, vtmp0x89ABCDEF, 1); w9 += 1;
317 vtmp0x89ABCDEF = vld1q_lane_u16(w10, vtmp0x89ABCDEF, 2); w10 += 1;
318 vtmp0x89ABCDEF = vld1q_lane_u16(w11, vtmp0x89ABCDEF, 3); w11 += 1;
319 vtmp0x89ABCDEF = vld1q_lane_u16(w12, vtmp0x89ABCDEF, 4); w12 += 1;
320 vtmp0x89ABCDEF = vld1q_lane_u16(w13, vtmp0x89ABCDEF, 5); w13 += 1;
321 vtmp0x89ABCDEF = vld1q_lane_u16(w14, vtmp0x89ABCDEF, 6); w14 += 1;
322 vtmp0x89ABCDEF = vld1q_lane_u16(w15, vtmp0x89ABCDEF, 7); w15 += 1;
323
324 vst1q_u16(packed_weights, vtmp0x01234567); packed_weights += 8;
325 vst1q_u16(packed_weights, vtmp0x89ABCDEF); packed_weights += 8;
326 break;
327 }
328 // KC remainder of 16x2
329 case 2:
330 {
331 uint16x8x2_t vtmp01x01234567;
332 vtmp01x01234567.val[0] = vdupq_n_u16(0);
333 vtmp01x01234567.val[1] = vdupq_n_u16(0);
334 uint16x8x2_t vtmp01x89ABCDEF;
335 vtmp01x89ABCDEF.val[0] = vdupq_n_u16(0);
336 vtmp01x89ABCDEF.val[1] = vdupq_n_u16(0);
337
338 vtmp01x01234567 = vld2q_lane_u16(w0, vtmp01x01234567, 0); w0 += 2;
339 vtmp01x01234567 = vld2q_lane_u16(w1, vtmp01x01234567, 1); w1 += 2;
340 vtmp01x01234567 = vld2q_lane_u16(w2, vtmp01x01234567, 2); w2 += 2;
341 vtmp01x01234567 = vld2q_lane_u16(w3, vtmp01x01234567, 3); w3 += 2;
342 vtmp01x01234567 = vld2q_lane_u16(w4, vtmp01x01234567, 4); w4 += 2;
343 vtmp01x01234567 = vld2q_lane_u16(w5, vtmp01x01234567, 5); w5 += 2;
344 vtmp01x01234567 = vld2q_lane_u16(w6, vtmp01x01234567, 6); w6 += 2;
345 vtmp01x01234567 = vld2q_lane_u16(w7, vtmp01x01234567, 7); w7 += 2;
346 vtmp01x89ABCDEF = vld2q_lane_u16(w8, vtmp01x89ABCDEF, 0); w8 += 2;
347 vtmp01x89ABCDEF = vld2q_lane_u16(w9, vtmp01x89ABCDEF, 1); w9 += 2;
348 vtmp01x89ABCDEF = vld2q_lane_u16(w10, vtmp01x89ABCDEF, 2); w10 += 2;
349 vtmp01x89ABCDEF = vld2q_lane_u16(w11, vtmp01x89ABCDEF, 3); w11 += 2;
350 vtmp01x89ABCDEF = vld2q_lane_u16(w12, vtmp01x89ABCDEF, 4); w12 += 2;
351 vtmp01x89ABCDEF = vld2q_lane_u16(w13, vtmp01x89ABCDEF, 5); w13 += 2;
352 vtmp01x89ABCDEF = vld2q_lane_u16(w14, vtmp01x89ABCDEF, 6); w14 += 2;
353 vtmp01x89ABCDEF = vld2q_lane_u16(w15, vtmp01x89ABCDEF, 7); w15 += 2;
354
355 vst1q_u16(packed_weights, vtmp01x01234567.val[0]); packed_weights += 8;
356 vst1q_u16(packed_weights, vtmp01x89ABCDEF.val[0]); packed_weights += 8;
357 vst1q_u16(packed_weights, vtmp01x01234567.val[1]); packed_weights += 8;
358 vst1q_u16(packed_weights, vtmp01x89ABCDEF.val[1]); packed_weights += 8;
359 break;
360 }
361 // KC remainder of 16x3
362 case 3:
363 {
364 uint16x8x3_t vtmp012x01234567;
365 vtmp012x01234567.val[0] = vdupq_n_u16(0);
366 vtmp012x01234567.val[1] = vdupq_n_u16(0);
367 vtmp012x01234567.val[2] = vdupq_n_u16(0);
368 uint16x8x3_t vtmp012x89ABCDEF;
369 vtmp012x89ABCDEF.val[0] = vdupq_n_u16(0);
370 vtmp012x89ABCDEF.val[1] = vdupq_n_u16(0);
371 vtmp012x89ABCDEF.val[2] = vdupq_n_u16(0);
372
373 vtmp012x01234567 = vld3q_lane_u16(w0, vtmp012x01234567, 0); w0 += 3;
374 vtmp012x01234567 = vld3q_lane_u16(w1, vtmp012x01234567, 1); w1 += 3;
375 vtmp012x01234567 = vld3q_lane_u16(w2, vtmp012x01234567, 2); w2 += 3;
376 vtmp012x01234567 = vld3q_lane_u16(w3, vtmp012x01234567, 3); w3 += 3;
377 vtmp012x01234567 = vld3q_lane_u16(w4, vtmp012x01234567, 4); w4 += 3;
378 vtmp012x01234567 = vld3q_lane_u16(w5, vtmp012x01234567, 5); w5 += 3;
379 vtmp012x01234567 = vld3q_lane_u16(w6, vtmp012x01234567, 6); w6 += 3;
380 vtmp012x01234567 = vld3q_lane_u16(w7, vtmp012x01234567, 7); w7 += 3;
381 vtmp012x89ABCDEF = vld3q_lane_u16(w8, vtmp012x89ABCDEF, 0); w8 += 3;
382 vtmp012x89ABCDEF = vld3q_lane_u16(w9, vtmp012x89ABCDEF, 1); w9 += 3;
383 vtmp012x89ABCDEF = vld3q_lane_u16(w10, vtmp012x89ABCDEF, 2); w10 += 3;
384 vtmp012x89ABCDEF = vld3q_lane_u16(w11, vtmp012x89ABCDEF, 3); w11 += 3;
385 vtmp012x89ABCDEF = vld3q_lane_u16(w12, vtmp012x89ABCDEF, 4); w12 += 3;
386 vtmp012x89ABCDEF = vld3q_lane_u16(w13, vtmp012x89ABCDEF, 5); w13 += 3;
387 vtmp012x89ABCDEF = vld3q_lane_u16(w14, vtmp012x89ABCDEF, 6); w14 += 3;
388 vtmp012x89ABCDEF = vld3q_lane_u16(w15, vtmp012x89ABCDEF, 7); w15 += 3;
389
390 vst1q_u16(packed_weights, vtmp012x01234567.val[0]); packed_weights += 8;
391 vst1q_u16(packed_weights, vtmp012x89ABCDEF.val[0]); packed_weights += 8;
392 vst1q_u16(packed_weights, vtmp012x01234567.val[1]); packed_weights += 8;
393 vst1q_u16(packed_weights, vtmp012x89ABCDEF.val[1]); packed_weights += 8;
394 vst1q_u16(packed_weights, vtmp012x01234567.val[2]); packed_weights += 8;
395 vst1q_u16(packed_weights, vtmp012x89ABCDEF.val[2]); packed_weights += 8;
396 break;
397 }
398 default:
399 XNN_UNREACHABLE;
400 }
401 }
402 packed_weights = (uint16_t*) ((uintptr_t) packed_weights + extra_bytes);
403 w0 = w15;
404 }
405
406 // NC remainder (1..15)
407 if XNN_UNLIKELY(n != 0) {
408 assert(n >= 1);
409 assert(n <= 15);
410 if XNN_LIKELY(bias != NULL) {
411 size_t nb = n;
412 do {
413 *packed_weights++ = *bias++;
414 } while (--nb != 0);
415 packed_weights += (16 - n);
416 } else {
417 const uint16x8_t vzero = vmovq_n_u16(0);
418 vst1q_u16(packed_weights, vzero); packed_weights += 8;
419 vst1q_u16(packed_weights, vzero); packed_weights += 8;
420 }
421
422 // NR remainder has less than 16 rows so last row is not loaded
423 const uint16_t* w1 = w0 + kc;
424 if XNN_UNPREDICTABLE(n < 2) {
425 w1 = w0;
426 }
427 const uint16_t* w2 = w1 + kc;
428 if XNN_UNPREDICTABLE(n <= 2) {
429 w2 = w1;
430 }
431 const uint16_t* w3 = w2 + kc;
432 if XNN_UNPREDICTABLE(n < 4) {
433 w3 = w2;
434 }
435 const uint16_t* w4 = w3 + kc;
436 if XNN_UNPREDICTABLE(n <= 4) {
437 w4 = w3;
438 }
439 const uint16_t* w5 = w4 + kc;
440 if XNN_UNPREDICTABLE(n < 6) {
441 w5 = w4;
442 }
443 const uint16_t* w6 = w5 + kc;
444 if XNN_UNPREDICTABLE(n <= 6) {
445 w6 = w5;
446 }
447 const uint16_t* w7 = w6 + kc;
448 if XNN_UNPREDICTABLE(n < 8) {
449 w7 = w6;
450 }
451 const uint16_t* w8 = w7 + kc;
452 if XNN_UNPREDICTABLE(n <= 8) {
453 w8 = w7;
454 }
455 const uint16_t* w9 = w8 + kc;
456 if XNN_UNPREDICTABLE(n < 10) {
457 w9 = w8;
458 }
459 const uint16_t* w10 = w9 + kc;
460 if XNN_UNPREDICTABLE(n <= 10) {
461 w10 = w9;
462 }
463 const uint16_t* w11 = w10 + kc;
464 if XNN_UNPREDICTABLE(n < 12) {
465 w11 = w10;
466 }
467 const uint16_t* w12 = w11 + kc;
468 if XNN_UNPREDICTABLE(n <= 12) {
469 w12 = w11;
470 }
471 const uint16_t* w13 = w12 + kc;
472 if XNN_UNPREDICTABLE(n < 14) {
473 w13 = w12;
474 }
475 const uint16_t* w14 = w13 + kc;
476 if XNN_UNPREDICTABLE(n <= 14) {
477 w14 = w13;
478 }
479
480 // KC main loop multiple of 16
481 size_t k = kc;
482 for (; k >= 16; k -= 16) {
483 vtmp0123x01234567 = vld4q_lane_u16(w0, vtmp0123x01234567, 0); w0 += 4;
484 vtmp0123x01234567 = vld4q_lane_u16(w1, vtmp0123x01234567, 1); w1 += 4;
485 vtmp0123x01234567 = vld4q_lane_u16(w2, vtmp0123x01234567, 2); w2 += 4;
486 vtmp0123x01234567 = vld4q_lane_u16(w3, vtmp0123x01234567, 3); w3 += 4;
487 vtmp0123x01234567 = vld4q_lane_u16(w4, vtmp0123x01234567, 4); w4 += 4;
488 vtmp0123x01234567 = vld4q_lane_u16(w5, vtmp0123x01234567, 5); w5 += 4;
489 vtmp0123x01234567 = vld4q_lane_u16(w6, vtmp0123x01234567, 6); w6 += 4;
490 vtmp0123x01234567 = vld4q_lane_u16(w7, vtmp0123x01234567, 7); w7 += 4;
491 vtmp0123x89ABCDEF = vld4q_lane_u16(w8, vtmp0123x89ABCDEF, 0); w8 += 4;
492 vtmp0123x89ABCDEF = vld4q_lane_u16(w9, vtmp0123x89ABCDEF, 1); w9 += 4;
493 vtmp0123x89ABCDEF = vld4q_lane_u16(w10, vtmp0123x89ABCDEF, 2); w10 += 4;
494 vtmp0123x89ABCDEF = vld4q_lane_u16(w11, vtmp0123x89ABCDEF, 3); w11 += 4;
495 vtmp0123x89ABCDEF = vld4q_lane_u16(w12, vtmp0123x89ABCDEF, 4); w12 += 4;
496 vtmp0123x89ABCDEF = vld4q_lane_u16(w13, vtmp0123x89ABCDEF, 5); w13 += 4;
497 vtmp0123x89ABCDEF = vld4q_lane_u16(w14, vtmp0123x89ABCDEF, 6); w14 += 4;
498 vtmp4567x01234567 = vld4q_lane_u16(w0, vtmp4567x01234567, 0); w0 += 4;
499 vtmp4567x01234567 = vld4q_lane_u16(w1, vtmp4567x01234567, 1); w1 += 4;
500 vtmp4567x01234567 = vld4q_lane_u16(w2, vtmp4567x01234567, 2); w2 += 4;
501 vtmp4567x01234567 = vld4q_lane_u16(w3, vtmp4567x01234567, 3); w3 += 4;
502 vtmp4567x01234567 = vld4q_lane_u16(w4, vtmp4567x01234567, 4); w4 += 4;
503 vtmp4567x01234567 = vld4q_lane_u16(w5, vtmp4567x01234567, 5); w5 += 4;
504 vtmp4567x01234567 = vld4q_lane_u16(w6, vtmp4567x01234567, 6); w6 += 4;
505 vtmp4567x01234567 = vld4q_lane_u16(w7, vtmp4567x01234567, 7); w7 += 4;
506 vtmp4567x89ABCDEF = vld4q_lane_u16(w8, vtmp4567x89ABCDEF, 0); w8 += 4;
507 vtmp4567x89ABCDEF = vld4q_lane_u16(w9, vtmp4567x89ABCDEF, 1); w9 += 4;
508 vtmp4567x89ABCDEF = vld4q_lane_u16(w10, vtmp4567x89ABCDEF, 2); w10 += 4;
509 vtmp4567x89ABCDEF = vld4q_lane_u16(w11, vtmp4567x89ABCDEF, 3); w11 += 4;
510 vtmp4567x89ABCDEF = vld4q_lane_u16(w12, vtmp4567x89ABCDEF, 4); w12 += 4;
511 vtmp4567x89ABCDEF = vld4q_lane_u16(w13, vtmp4567x89ABCDEF, 5); w13 += 4;
512 vtmp4567x89ABCDEF = vld4q_lane_u16(w14, vtmp4567x89ABCDEF, 6); w14 += 4;
513 vtmp89ABx01234567 = vld4q_lane_u16(w0, vtmp89ABx01234567, 0); w0 += 4;
514 vtmp89ABx01234567 = vld4q_lane_u16(w1, vtmp89ABx01234567, 1); w1 += 4;
515 vtmp89ABx01234567 = vld4q_lane_u16(w2, vtmp89ABx01234567, 2); w2 += 4;
516 vtmp89ABx01234567 = vld4q_lane_u16(w3, vtmp89ABx01234567, 3); w3 += 4;
517 vtmp89ABx01234567 = vld4q_lane_u16(w4, vtmp89ABx01234567, 4); w4 += 4;
518 vtmp89ABx01234567 = vld4q_lane_u16(w5, vtmp89ABx01234567, 5); w5 += 4;
519 vtmp89ABx01234567 = vld4q_lane_u16(w6, vtmp89ABx01234567, 6); w6 += 4;
520 vtmp89ABx01234567 = vld4q_lane_u16(w7, vtmp89ABx01234567, 7); w7 += 4;
521 vtmp89ABx89ABCDEF = vld4q_lane_u16(w8, vtmp89ABx89ABCDEF, 0); w8 += 4;
522 vtmp89ABx89ABCDEF = vld4q_lane_u16(w9, vtmp89ABx89ABCDEF, 1); w9 += 4;
523 vtmp89ABx89ABCDEF = vld4q_lane_u16(w10, vtmp89ABx89ABCDEF, 2); w10 += 4;
524 vtmp89ABx89ABCDEF = vld4q_lane_u16(w11, vtmp89ABx89ABCDEF, 3); w11 += 4;
525 vtmp89ABx89ABCDEF = vld4q_lane_u16(w12, vtmp89ABx89ABCDEF, 4); w12 += 4;
526 vtmp89ABx89ABCDEF = vld4q_lane_u16(w13, vtmp89ABx89ABCDEF, 5); w13 += 4;
527 vtmp89ABx89ABCDEF = vld4q_lane_u16(w14, vtmp89ABx89ABCDEF, 6); w14 += 4;
528 vtmpCDEFx01234567 = vld4q_lane_u16(w0, vtmpCDEFx01234567, 0); w0 += 4;
529 vtmpCDEFx01234567 = vld4q_lane_u16(w1, vtmpCDEFx01234567, 1); w1 += 4;
530 vtmpCDEFx01234567 = vld4q_lane_u16(w2, vtmpCDEFx01234567, 2); w2 += 4;
531 vtmpCDEFx01234567 = vld4q_lane_u16(w3, vtmpCDEFx01234567, 3); w3 += 4;
532 vtmpCDEFx01234567 = vld4q_lane_u16(w4, vtmpCDEFx01234567, 4); w4 += 4;
533 vtmpCDEFx01234567 = vld4q_lane_u16(w5, vtmpCDEFx01234567, 5); w5 += 4;
534 vtmpCDEFx01234567 = vld4q_lane_u16(w6, vtmpCDEFx01234567, 6); w6 += 4;
535 vtmpCDEFx01234567 = vld4q_lane_u16(w7, vtmpCDEFx01234567, 7); w7 += 4;
536 vtmpCDEFx89ABCDEF = vld4q_lane_u16(w8, vtmpCDEFx89ABCDEF, 0); w8 += 4;
537 vtmpCDEFx89ABCDEF = vld4q_lane_u16(w9, vtmpCDEFx89ABCDEF, 1); w9 += 4;
538 vtmpCDEFx89ABCDEF = vld4q_lane_u16(w10, vtmpCDEFx89ABCDEF, 2); w10 += 4;
539 vtmpCDEFx89ABCDEF = vld4q_lane_u16(w11, vtmpCDEFx89ABCDEF, 3); w11 += 4;
540 vtmpCDEFx89ABCDEF = vld4q_lane_u16(w12, vtmpCDEFx89ABCDEF, 4); w12 += 4;
541 vtmpCDEFx89ABCDEF = vld4q_lane_u16(w13, vtmpCDEFx89ABCDEF, 5); w13 += 4;
542 vtmpCDEFx89ABCDEF = vld4q_lane_u16(w14, vtmpCDEFx89ABCDEF, 6); w14 += 4;
543 xnn_prefetch_to_l1((const int8_t*) w0 + 128);
544 xnn_prefetch_to_l1((const int8_t*) w1 + 128);
545 xnn_prefetch_to_l1((const int8_t*) w2 + 128);
546 xnn_prefetch_to_l1((const int8_t*) w3 + 128);
547 xnn_prefetch_to_l1((const int8_t*) w4 + 128);
548 xnn_prefetch_to_l1((const int8_t*) w5 + 128);
549 xnn_prefetch_to_l1((const int8_t*) w6 + 128);
550 xnn_prefetch_to_l1((const int8_t*) w7 + 128);
551 xnn_prefetch_to_l1((const int8_t*) w8 + 128);
552 xnn_prefetch_to_l1((const int8_t*) w9 + 128);
553 xnn_prefetch_to_l1((const int8_t*) w10 + 128);
554 xnn_prefetch_to_l1((const int8_t*) w11 + 128);
555 xnn_prefetch_to_l1((const int8_t*) w12 + 128);
556 xnn_prefetch_to_l1((const int8_t*) w13 + 128);
557 xnn_prefetch_to_l1((const int8_t*) w14 + 128);
558 vst1q_u16(packed_weights, vtmp0123x01234567.val[0]); packed_weights += 8;
559 vst1q_u16(packed_weights, vtmp0123x89ABCDEF.val[0]); packed_weights += 8;
560 vst1q_u16(packed_weights, vtmp0123x01234567.val[1]); packed_weights += 8;
561 vst1q_u16(packed_weights, vtmp0123x89ABCDEF.val[1]); packed_weights += 8;
562 vst1q_u16(packed_weights, vtmp0123x01234567.val[2]); packed_weights += 8;
563 vst1q_u16(packed_weights, vtmp0123x89ABCDEF.val[2]); packed_weights += 8;
564 vst1q_u16(packed_weights, vtmp0123x01234567.val[3]); packed_weights += 8;
565 vst1q_u16(packed_weights, vtmp0123x89ABCDEF.val[3]); packed_weights += 8;
566 vst1q_u16(packed_weights, vtmp4567x01234567.val[0]); packed_weights += 8;
567 vst1q_u16(packed_weights, vtmp4567x89ABCDEF.val[0]); packed_weights += 8;
568 vst1q_u16(packed_weights, vtmp4567x01234567.val[1]); packed_weights += 8;
569 vst1q_u16(packed_weights, vtmp4567x89ABCDEF.val[1]); packed_weights += 8;
570 vst1q_u16(packed_weights, vtmp4567x01234567.val[2]); packed_weights += 8;
571 vst1q_u16(packed_weights, vtmp4567x89ABCDEF.val[2]); packed_weights += 8;
572 vst1q_u16(packed_weights, vtmp4567x01234567.val[3]); packed_weights += 8;
573 vst1q_u16(packed_weights, vtmp4567x89ABCDEF.val[3]); packed_weights += 8;
574 vst1q_u16(packed_weights, vtmp89ABx01234567.val[0]); packed_weights += 8;
575 vst1q_u16(packed_weights, vtmp89ABx89ABCDEF.val[0]); packed_weights += 8;
576 vst1q_u16(packed_weights, vtmp89ABx01234567.val[1]); packed_weights += 8;
577 vst1q_u16(packed_weights, vtmp89ABx89ABCDEF.val[1]); packed_weights += 8;
578 vst1q_u16(packed_weights, vtmp89ABx01234567.val[2]); packed_weights += 8;
579 vst1q_u16(packed_weights, vtmp89ABx89ABCDEF.val[2]); packed_weights += 8;
580 vst1q_u16(packed_weights, vtmp89ABx01234567.val[3]); packed_weights += 8;
581 vst1q_u16(packed_weights, vtmp89ABx89ABCDEF.val[3]); packed_weights += 8;
582 vst1q_u16(packed_weights, vtmpCDEFx01234567.val[0]); packed_weights += 8;
583 vst1q_u16(packed_weights, vtmpCDEFx89ABCDEF.val[0]); packed_weights += 8;
584 vst1q_u16(packed_weights, vtmpCDEFx01234567.val[1]); packed_weights += 8;
585 vst1q_u16(packed_weights, vtmpCDEFx89ABCDEF.val[1]); packed_weights += 8;
586 vst1q_u16(packed_weights, vtmpCDEFx01234567.val[2]); packed_weights += 8;
587 vst1q_u16(packed_weights, vtmpCDEFx89ABCDEF.val[2]); packed_weights += 8;
588 vst1q_u16(packed_weights, vtmpCDEFx01234567.val[3]); packed_weights += 8;
589 vst1q_u16(packed_weights, vtmpCDEFx89ABCDEF.val[3]); packed_weights += 8;
590 }
591
592 // KC remainder multiple of 4
593 while (k >= 4) {
594 vtmp0123x01234567 = vld4q_lane_u16(w0, vtmp0123x01234567, 0); w0 += 4;
595 vtmp0123x01234567 = vld4q_lane_u16(w1, vtmp0123x01234567, 1); w1 += 4;
596 vtmp0123x01234567 = vld4q_lane_u16(w2, vtmp0123x01234567, 2); w2 += 4;
597 vtmp0123x01234567 = vld4q_lane_u16(w3, vtmp0123x01234567, 3); w3 += 4;
598 vtmp0123x01234567 = vld4q_lane_u16(w4, vtmp0123x01234567, 4); w4 += 4;
599 vtmp0123x01234567 = vld4q_lane_u16(w5, vtmp0123x01234567, 5); w5 += 4;
600 vtmp0123x01234567 = vld4q_lane_u16(w6, vtmp0123x01234567, 6); w6 += 4;
601 vtmp0123x01234567 = vld4q_lane_u16(w7, vtmp0123x01234567, 7); w7 += 4;
602 vtmp0123x89ABCDEF = vld4q_lane_u16(w8, vtmp0123x89ABCDEF, 0); w8 += 4;
603 vtmp0123x89ABCDEF = vld4q_lane_u16(w9, vtmp0123x89ABCDEF, 1); w9 += 4;
604 vtmp0123x89ABCDEF = vld4q_lane_u16(w10, vtmp0123x89ABCDEF, 2); w10 += 4;
605 vtmp0123x89ABCDEF = vld4q_lane_u16(w11, vtmp0123x89ABCDEF, 3); w11 += 4;
606 vtmp0123x89ABCDEF = vld4q_lane_u16(w12, vtmp0123x89ABCDEF, 4); w12 += 4;
607 vtmp0123x89ABCDEF = vld4q_lane_u16(w13, vtmp0123x89ABCDEF, 5); w13 += 4;
608 vtmp0123x89ABCDEF = vld4q_lane_u16(w14, vtmp0123x89ABCDEF, 6); w14 += 4;
609 vst1q_u16(packed_weights, vtmp0123x01234567.val[0]); packed_weights += 8;
610 vst1q_u16(packed_weights, vtmp0123x89ABCDEF.val[0]); packed_weights += 8;
611 vst1q_u16(packed_weights, vtmp0123x01234567.val[1]); packed_weights += 8;
612 vst1q_u16(packed_weights, vtmp0123x89ABCDEF.val[1]); packed_weights += 8;
613 vst1q_u16(packed_weights, vtmp0123x01234567.val[2]); packed_weights += 8;
614 vst1q_u16(packed_weights, vtmp0123x89ABCDEF.val[2]); packed_weights += 8;
615 vst1q_u16(packed_weights, vtmp0123x01234567.val[3]); packed_weights += 8;
616 vst1q_u16(packed_weights, vtmp0123x89ABCDEF.val[3]); packed_weights += 8;
617 k -= 4;
618 }
619
620 // KC remainder of 1..3
621 // Same as main loop but ld1, ld2 or ld3
622 if XNN_UNLIKELY(k != 0) {
623 assert(k >= 1);
624 assert(k <= 3);
625 switch (k) {
626 // KC remainder of 16x1
627 case 1:
628 {
629 uint16x8_t vtmp0x01234567 = vdupq_n_u16(0);
630 uint16x8_t vtmp0x89ABCDEF = vdupq_n_u16(0);
631
632 vtmp0x01234567 = vld1q_lane_u16(w0, vtmp0x01234567, 0); w0 += 1;
633 vtmp0x01234567 = vld1q_lane_u16(w1, vtmp0x01234567, 1); w1 += 1;
634 vtmp0x01234567 = vld1q_lane_u16(w2, vtmp0x01234567, 2); w2 += 1;
635 vtmp0x01234567 = vld1q_lane_u16(w3, vtmp0x01234567, 3); w3 += 1;
636 vtmp0x01234567 = vld1q_lane_u16(w4, vtmp0x01234567, 4); w4 += 1;
637 vtmp0x01234567 = vld1q_lane_u16(w5, vtmp0x01234567, 5); w5 += 1;
638 vtmp0x01234567 = vld1q_lane_u16(w6, vtmp0x01234567, 6); w6 += 1;
639 vtmp0x01234567 = vld1q_lane_u16(w7, vtmp0x01234567, 7); w7 += 1;
640 vtmp0x89ABCDEF = vld1q_lane_u16(w8, vtmp0x89ABCDEF, 0); w8 += 1;
641 vtmp0x89ABCDEF = vld1q_lane_u16(w9, vtmp0x89ABCDEF, 1); w9 += 1;
642 vtmp0x89ABCDEF = vld1q_lane_u16(w10, vtmp0x89ABCDEF, 2); w10 += 1;
643 vtmp0x89ABCDEF = vld1q_lane_u16(w11, vtmp0x89ABCDEF, 3); w11 += 1;
644 vtmp0x89ABCDEF = vld1q_lane_u16(w12, vtmp0x89ABCDEF, 4); w12 += 1;
645 vtmp0x89ABCDEF = vld1q_lane_u16(w13, vtmp0x89ABCDEF, 5); w13 += 1;
646 vtmp0x89ABCDEF = vld1q_lane_u16(w14, vtmp0x89ABCDEF, 6); w14 += 1;
647
648 vst1q_u16(packed_weights, vtmp0x01234567); packed_weights += 8;
649 vst1q_u16(packed_weights, vtmp0x89ABCDEF); packed_weights += 8;
650 break;
651 }
652 // KC remainder of 16x2
653 case 2:
654 {
655 uint16x8x2_t vtmp01x01234567;
656 vtmp01x01234567.val[0] = vdupq_n_u16(0);
657 vtmp01x01234567.val[1] = vdupq_n_u16(0);
658 uint16x8x2_t vtmp01x89ABCDEF;
659 vtmp01x89ABCDEF.val[0] = vdupq_n_u16(0);
660 vtmp01x89ABCDEF.val[1] = vdupq_n_u16(0);
661
662 vtmp01x01234567 = vld2q_lane_u16(w0, vtmp01x01234567, 0); w0 += 2;
663 vtmp01x01234567 = vld2q_lane_u16(w1, vtmp01x01234567, 1); w1 += 2;
664 vtmp01x01234567 = vld2q_lane_u16(w2, vtmp01x01234567, 2); w2 += 2;
665 vtmp01x01234567 = vld2q_lane_u16(w3, vtmp01x01234567, 3); w3 += 2;
666 vtmp01x01234567 = vld2q_lane_u16(w4, vtmp01x01234567, 4); w4 += 2;
667 vtmp01x01234567 = vld2q_lane_u16(w5, vtmp01x01234567, 5); w5 += 2;
668 vtmp01x01234567 = vld2q_lane_u16(w6, vtmp01x01234567, 6); w6 += 2;
669 vtmp01x01234567 = vld2q_lane_u16(w7, vtmp01x01234567, 7); w7 += 2;
670 vtmp01x89ABCDEF = vld2q_lane_u16(w8, vtmp01x89ABCDEF, 0); w8 += 2;
671 vtmp01x89ABCDEF = vld2q_lane_u16(w9, vtmp01x89ABCDEF, 1); w9 += 2;
672 vtmp01x89ABCDEF = vld2q_lane_u16(w10, vtmp01x89ABCDEF, 2); w10 += 2;
673 vtmp01x89ABCDEF = vld2q_lane_u16(w11, vtmp01x89ABCDEF, 3); w11 += 2;
674 vtmp01x89ABCDEF = vld2q_lane_u16(w12, vtmp01x89ABCDEF, 4); w12 += 2;
675 vtmp01x89ABCDEF = vld2q_lane_u16(w13, vtmp01x89ABCDEF, 5); w13 += 2;
676 vtmp01x89ABCDEF = vld2q_lane_u16(w14, vtmp01x89ABCDEF, 6); w14 += 2;
677
678 vst1q_u16(packed_weights, vtmp01x01234567.val[0]); packed_weights += 8;
679 vst1q_u16(packed_weights, vtmp01x89ABCDEF.val[0]); packed_weights += 8;
680 vst1q_u16(packed_weights, vtmp01x01234567.val[1]); packed_weights += 8;
681 vst1q_u16(packed_weights, vtmp01x89ABCDEF.val[1]); packed_weights += 8;
682 break;
683 }
684 // KC remainder of 16x3
685 case 3:
686 {
687 uint16x8x3_t vtmp012x01234567;
688 vtmp012x01234567.val[0] = vdupq_n_u16(0);
689 vtmp012x01234567.val[1] = vdupq_n_u16(0);
690 vtmp012x01234567.val[2] = vdupq_n_u16(0);
691 uint16x8x3_t vtmp012x89ABCDEF;
692 vtmp012x89ABCDEF.val[0] = vdupq_n_u16(0);
693 vtmp012x89ABCDEF.val[1] = vdupq_n_u16(0);
694 vtmp012x89ABCDEF.val[2] = vdupq_n_u16(0);
695
696 vtmp012x01234567 = vld3q_lane_u16(w0, vtmp012x01234567, 0); w0 += 3;
697 vtmp012x01234567 = vld3q_lane_u16(w1, vtmp012x01234567, 1); w1 += 3;
698 vtmp012x01234567 = vld3q_lane_u16(w2, vtmp012x01234567, 2); w2 += 3;
699 vtmp012x01234567 = vld3q_lane_u16(w3, vtmp012x01234567, 3); w3 += 3;
700 vtmp012x01234567 = vld3q_lane_u16(w4, vtmp012x01234567, 4); w4 += 3;
701 vtmp012x01234567 = vld3q_lane_u16(w5, vtmp012x01234567, 5); w5 += 3;
702 vtmp012x01234567 = vld3q_lane_u16(w6, vtmp012x01234567, 6); w6 += 3;
703 vtmp012x01234567 = vld3q_lane_u16(w7, vtmp012x01234567, 7); w7 += 3;
704 vtmp012x89ABCDEF = vld3q_lane_u16(w8, vtmp012x89ABCDEF, 0); w8 += 3;
705 vtmp012x89ABCDEF = vld3q_lane_u16(w9, vtmp012x89ABCDEF, 1); w9 += 3;
706 vtmp012x89ABCDEF = vld3q_lane_u16(w10, vtmp012x89ABCDEF, 2); w10 += 3;
707 vtmp012x89ABCDEF = vld3q_lane_u16(w11, vtmp012x89ABCDEF, 3); w11 += 3;
708 vtmp012x89ABCDEF = vld3q_lane_u16(w12, vtmp012x89ABCDEF, 4); w12 += 3;
709 vtmp012x89ABCDEF = vld3q_lane_u16(w13, vtmp012x89ABCDEF, 5); w13 += 3;
710 vtmp012x89ABCDEF = vld3q_lane_u16(w14, vtmp012x89ABCDEF, 6); w14 += 3;
711
712 vst1q_u16(packed_weights, vtmp012x01234567.val[0]); packed_weights += 8;
713 vst1q_u16(packed_weights, vtmp012x89ABCDEF.val[0]); packed_weights += 8;
714 vst1q_u16(packed_weights, vtmp012x01234567.val[1]); packed_weights += 8;
715 vst1q_u16(packed_weights, vtmp012x89ABCDEF.val[1]); packed_weights += 8;
716 vst1q_u16(packed_weights, vtmp012x01234567.val[2]); packed_weights += 8;
717 vst1q_u16(packed_weights, vtmp012x89ABCDEF.val[2]); packed_weights += 8;
718 break;
719 }
720 default:
721 XNN_UNREACHABLE;
722 }
723 }
724 packed_weights = (uint16_t*) ((uintptr_t) packed_weights + extra_bytes);
725 }
726
727 weights += nc * kc;
728 } while (--g != 0);
729 }