1 // Auto-generated file. Do not edit!
2 // Template: src/f32-igemm/neon-ld64.c.in
3 // Generator: tools/xngen
4 //
5 // Copyright 2019 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
13 #include <arm_neon.h>
14
15 #include <xnnpack/igemm.h>
16
17
xnn_f32_igemm_ukernel_6x8__neonfma_dup_ld64(size_t mr,size_t nc,size_t kc,size_t ks,const float ** restrict a,const float * restrict w,float * restrict c,size_t cm_stride,size_t cn_stride,size_t a_offset,const float * zero,const union xnn_f32_output_params params[restrict static1])18 void xnn_f32_igemm_ukernel_6x8__neonfma_dup_ld64(
19 size_t mr,
20 size_t nc,
21 size_t kc,
22 size_t ks,
23 const float**restrict a,
24 const float*restrict w,
25 float*restrict c,
26 size_t cm_stride,
27 size_t cn_stride,
28 size_t a_offset,
29 const float* zero,
30 const union xnn_f32_output_params params[restrict static 1])
31 {
32 assert(mr != 0);
33 assert(mr <= 6);
34 assert(nc != 0);
35 assert(kc != 0);
36 assert(kc % sizeof(float) == 0);
37 assert(ks != 0);
38 assert(ks % (6 * sizeof(void*)) == 0);
39 assert(a_offset % sizeof(float) == 0);
40 assert(a != NULL);
41 assert(w != NULL);
42 assert(c != NULL);
43
44 float* c0 = c;
45 float* c1 = (float*) ((uintptr_t) c0 + cm_stride);
46 if XNN_UNPREDICTABLE(mr < 2) {
47 c1 = c0;
48 }
49 float* c2 = (float*) ((uintptr_t) c1 + cm_stride);
50 if XNN_UNPREDICTABLE(mr <= 2) {
51 c2 = c1;
52 }
53 float* c3 = (float*) ((uintptr_t) c2 + cm_stride);
54 if XNN_UNPREDICTABLE(mr < 4) {
55 c3 = c2;
56 }
57 float* c4 = (float*) ((uintptr_t) c3 + cm_stride);
58 if XNN_UNPREDICTABLE(mr <= 4) {
59 c4 = c3;
60 }
61 float* c5 = (float*) ((uintptr_t) c4 + cm_stride);
62 if XNN_UNPREDICTABLE(mr != 6) {
63 c5 = c4;
64 }
65
66 do {
67 float32x4_t vacc0x0123 = vld1q_f32(w); w += 4;
68 float32x4_t vacc0x4567 = vld1q_f32(w); w += 4;
69 float32x4_t vacc1x0123 = vacc0x0123;
70 float32x4_t vacc1x4567 = vacc0x4567;
71 float32x4_t vacc2x0123 = vacc0x0123;
72 float32x4_t vacc2x4567 = vacc0x4567;
73 float32x4_t vacc3x0123 = vacc0x0123;
74 float32x4_t vacc3x4567 = vacc0x4567;
75 float32x4_t vacc4x0123 = vacc0x0123;
76 float32x4_t vacc4x4567 = vacc0x4567;
77 float32x4_t vacc5x0123 = vacc0x0123;
78 float32x4_t vacc5x4567 = vacc0x4567;
79
80 size_t p = ks;
81 do {
82 const float* restrict a0 = a[0];
83 assert(a0 != NULL);
84 if XNN_UNPREDICTABLE(a0 != zero) {
85 a0 = (const float*) ((uintptr_t) a0 + a_offset);
86 }
87 const float* restrict a1 = a[1];
88 assert(a1 != NULL);
89 if XNN_UNPREDICTABLE(a1 != zero) {
90 a1 = (const float*) ((uintptr_t) a1 + a_offset);
91 }
92 const float* restrict a2 = a[2];
93 assert(a2 != NULL);
94 if XNN_UNPREDICTABLE(a2 != zero) {
95 a2 = (const float*) ((uintptr_t) a2 + a_offset);
96 }
97 const float* restrict a3 = a[3];
98 assert(a3 != NULL);
99 if XNN_UNPREDICTABLE(a3 != zero) {
100 a3 = (const float*) ((uintptr_t) a3 + a_offset);
101 }
102 const float* restrict a4 = a[4];
103 assert(a4 != NULL);
104 if XNN_UNPREDICTABLE(a4 != zero) {
105 a4 = (const float*) ((uintptr_t) a4 + a_offset);
106 }
107 const float* restrict a5 = a[5];
108 assert(a5 != NULL);
109 if XNN_UNPREDICTABLE(a5 != zero) {
110 a5 = (const float*) ((uintptr_t) a5 + a_offset);
111 }
112 a += 6;
113
114 size_t k = kc;
115 for (; k >= 2 * sizeof(float); k -= 2 * sizeof(float)) {
116 const float32x2_t va0 = vld1_f32(a0); a0 += 2;
117 const float32x2_t va1 = vld1_f32(a1); a1 += 2;
118 const float32x2_t va2 = vld1_f32(a2); a2 += 2;
119 const float32x2_t va3 = vld1_f32(a3); a3 += 2;
120 const float32x2_t va4 = vld1_f32(a4); a4 += 2;
121 const float32x2_t va5 = vld1_f32(a5); a5 += 2;
122
123 const float32x4_t vb0123c0 = vld1q_f32(w); w += 4;
124 const float32x4_t vb4567c0 = vld1q_f32(w); w += 4;
125
126 const float32x4_t va0c0 = vdupq_lane_f32(va0, 0);
127 const float32x4_t va1c0 = vdupq_lane_f32(va1, 0);
128 const float32x4_t va2c0 = vdupq_lane_f32(va2, 0);
129 const float32x4_t va3c0 = vdupq_lane_f32(va3, 0);
130 const float32x4_t va4c0 = vdupq_lane_f32(va4, 0);
131 const float32x4_t va5c0 = vdupq_lane_f32(va5, 0);
132 vacc0x0123 = vfmaq_f32(vacc0x0123, va0c0, vb0123c0);
133 vacc1x0123 = vfmaq_f32(vacc1x0123, va1c0, vb0123c0);
134 vacc2x0123 = vfmaq_f32(vacc2x0123, va2c0, vb0123c0);
135 vacc3x0123 = vfmaq_f32(vacc3x0123, va3c0, vb0123c0);
136 vacc4x0123 = vfmaq_f32(vacc4x0123, va4c0, vb0123c0);
137 vacc5x0123 = vfmaq_f32(vacc5x0123, va5c0, vb0123c0);
138 vacc0x4567 = vfmaq_f32(vacc0x4567, va0c0, vb4567c0);
139 vacc1x4567 = vfmaq_f32(vacc1x4567, va1c0, vb4567c0);
140 vacc2x4567 = vfmaq_f32(vacc2x4567, va2c0, vb4567c0);
141 vacc3x4567 = vfmaq_f32(vacc3x4567, va3c0, vb4567c0);
142 vacc4x4567 = vfmaq_f32(vacc4x4567, va4c0, vb4567c0);
143 vacc5x4567 = vfmaq_f32(vacc5x4567, va5c0, vb4567c0);
144 const float32x4_t vb0123c1 = vld1q_f32(w); w += 4;
145 const float32x4_t vb4567c1 = vld1q_f32(w); w += 4;
146
147 const float32x4_t va0c1 = vdupq_lane_f32(va0, 1);
148 const float32x4_t va1c1 = vdupq_lane_f32(va1, 1);
149 const float32x4_t va2c1 = vdupq_lane_f32(va2, 1);
150 const float32x4_t va3c1 = vdupq_lane_f32(va3, 1);
151 const float32x4_t va4c1 = vdupq_lane_f32(va4, 1);
152 const float32x4_t va5c1 = vdupq_lane_f32(va5, 1);
153 vacc0x0123 = vfmaq_f32(vacc0x0123, va0c1, vb0123c1);
154 vacc1x0123 = vfmaq_f32(vacc1x0123, va1c1, vb0123c1);
155 vacc2x0123 = vfmaq_f32(vacc2x0123, va2c1, vb0123c1);
156 vacc3x0123 = vfmaq_f32(vacc3x0123, va3c1, vb0123c1);
157 vacc4x0123 = vfmaq_f32(vacc4x0123, va4c1, vb0123c1);
158 vacc5x0123 = vfmaq_f32(vacc5x0123, va5c1, vb0123c1);
159 vacc0x4567 = vfmaq_f32(vacc0x4567, va0c1, vb4567c1);
160 vacc1x4567 = vfmaq_f32(vacc1x4567, va1c1, vb4567c1);
161 vacc2x4567 = vfmaq_f32(vacc2x4567, va2c1, vb4567c1);
162 vacc3x4567 = vfmaq_f32(vacc3x4567, va3c1, vb4567c1);
163 vacc4x4567 = vfmaq_f32(vacc4x4567, va4c1, vb4567c1);
164 vacc5x4567 = vfmaq_f32(vacc5x4567, va5c1, vb4567c1);
165
166 }
167 if XNN_UNLIKELY(k != 0) {
168 const float32x4_t va0 = vld1q_dup_f32(a0);
169 const float32x4_t va1 = vld1q_dup_f32(a1);
170 const float32x4_t va2 = vld1q_dup_f32(a2);
171 const float32x4_t va3 = vld1q_dup_f32(a3);
172 const float32x4_t va4 = vld1q_dup_f32(a4);
173 const float32x4_t va5 = vld1q_dup_f32(a5);
174
175 const float32x4_t vb0123 = vld1q_f32(w); w += 4;
176 const float32x4_t vb4567 = vld1q_f32(w); w += 4;
177
178 vacc0x0123 = vfmaq_f32(vacc0x0123, va0, vb0123);
179 vacc1x0123 = vfmaq_f32(vacc1x0123, va1, vb0123);
180 vacc2x0123 = vfmaq_f32(vacc2x0123, va2, vb0123);
181 vacc3x0123 = vfmaq_f32(vacc3x0123, va3, vb0123);
182 vacc4x0123 = vfmaq_f32(vacc4x0123, va4, vb0123);
183 vacc5x0123 = vfmaq_f32(vacc5x0123, va5, vb0123);
184 vacc0x4567 = vfmaq_f32(vacc0x4567, va0, vb4567);
185 vacc1x4567 = vfmaq_f32(vacc1x4567, va1, vb4567);
186 vacc2x4567 = vfmaq_f32(vacc2x4567, va2, vb4567);
187 vacc3x4567 = vfmaq_f32(vacc3x4567, va3, vb4567);
188 vacc4x4567 = vfmaq_f32(vacc4x4567, va4, vb4567);
189 vacc5x4567 = vfmaq_f32(vacc5x4567, va5, vb4567);
190 }
191 p -= 6 * sizeof(void*);
192 } while (p != 0);
193
194 const float32x4_t vmax = vld1q_dup_f32(¶ms->scalar.max);
195 vacc0x0123 = vminq_f32(vacc0x0123, vmax);
196 vacc1x0123 = vminq_f32(vacc1x0123, vmax);
197 vacc2x0123 = vminq_f32(vacc2x0123, vmax);
198 vacc3x0123 = vminq_f32(vacc3x0123, vmax);
199 vacc4x0123 = vminq_f32(vacc4x0123, vmax);
200 vacc5x0123 = vminq_f32(vacc5x0123, vmax);
201 vacc0x4567 = vminq_f32(vacc0x4567, vmax);
202 vacc1x4567 = vminq_f32(vacc1x4567, vmax);
203 vacc2x4567 = vminq_f32(vacc2x4567, vmax);
204 vacc3x4567 = vminq_f32(vacc3x4567, vmax);
205 vacc4x4567 = vminq_f32(vacc4x4567, vmax);
206 vacc5x4567 = vminq_f32(vacc5x4567, vmax);
207
208 const float32x4_t vmin = vld1q_dup_f32(¶ms->scalar.min);
209 vacc0x0123 = vmaxq_f32(vacc0x0123, vmin);
210 vacc1x0123 = vmaxq_f32(vacc1x0123, vmin);
211 vacc2x0123 = vmaxq_f32(vacc2x0123, vmin);
212 vacc3x0123 = vmaxq_f32(vacc3x0123, vmin);
213 vacc4x0123 = vmaxq_f32(vacc4x0123, vmin);
214 vacc5x0123 = vmaxq_f32(vacc5x0123, vmin);
215 vacc0x4567 = vmaxq_f32(vacc0x4567, vmin);
216 vacc1x4567 = vmaxq_f32(vacc1x4567, vmin);
217 vacc2x4567 = vmaxq_f32(vacc2x4567, vmin);
218 vacc3x4567 = vmaxq_f32(vacc3x4567, vmin);
219 vacc4x4567 = vmaxq_f32(vacc4x4567, vmin);
220 vacc5x4567 = vmaxq_f32(vacc5x4567, vmin);
221
222 if XNN_LIKELY(nc >= 8) {
223 vst1q_f32(c5, vacc5x0123);
224 vst1q_f32(c5 + 4, vacc5x4567);
225 c5 = (float*) ((uintptr_t) c5 + cn_stride);
226 vst1q_f32(c4, vacc4x0123);
227 vst1q_f32(c4 + 4, vacc4x4567);
228 c4 = (float*) ((uintptr_t) c4 + cn_stride);
229 vst1q_f32(c3, vacc3x0123);
230 vst1q_f32(c3 + 4, vacc3x4567);
231 c3 = (float*) ((uintptr_t) c3 + cn_stride);
232 vst1q_f32(c2, vacc2x0123);
233 vst1q_f32(c2 + 4, vacc2x4567);
234 c2 = (float*) ((uintptr_t) c2 + cn_stride);
235 vst1q_f32(c1, vacc1x0123);
236 vst1q_f32(c1 + 4, vacc1x4567);
237 c1 = (float*) ((uintptr_t) c1 + cn_stride);
238 vst1q_f32(c0, vacc0x0123);
239 vst1q_f32(c0 + 4, vacc0x4567);
240 c0 = (float*) ((uintptr_t) c0 + cn_stride);
241
242 a = (const float**restrict) ((uintptr_t) a - ks);
243 nc -= 8;
244 } else {
245 if (nc & 4) {
246 vst1q_f32(c5, vacc5x0123); c5 += 4;
247 vst1q_f32(c4, vacc4x0123); c4 += 4;
248 vst1q_f32(c3, vacc3x0123); c3 += 4;
249 vst1q_f32(c2, vacc2x0123); c2 += 4;
250 vst1q_f32(c1, vacc1x0123); c1 += 4;
251 vst1q_f32(c0, vacc0x0123); c0 += 4;
252
253 vacc5x0123 = vacc5x4567;
254 vacc4x0123 = vacc4x4567;
255 vacc3x0123 = vacc3x4567;
256 vacc2x0123 = vacc2x4567;
257 vacc1x0123 = vacc1x4567;
258 vacc0x0123 = vacc0x4567;
259 }
260 float32x2_t vacc5x01 = vget_low_f32(vacc5x0123);
261 float32x2_t vacc4x01 = vget_low_f32(vacc4x0123);
262 float32x2_t vacc3x01 = vget_low_f32(vacc3x0123);
263 float32x2_t vacc2x01 = vget_low_f32(vacc2x0123);
264 float32x2_t vacc1x01 = vget_low_f32(vacc1x0123);
265 float32x2_t vacc0x01 = vget_low_f32(vacc0x0123);
266 if (nc & 2) {
267 vst1_f32(c5, vacc5x01); c5 += 2;
268 vst1_f32(c4, vacc4x01); c4 += 2;
269 vst1_f32(c3, vacc3x01); c3 += 2;
270 vst1_f32(c2, vacc2x01); c2 += 2;
271 vst1_f32(c1, vacc1x01); c1 += 2;
272 vst1_f32(c0, vacc0x01); c0 += 2;
273
274 vacc5x01 = vget_high_f32(vacc5x0123);
275 vacc4x01 = vget_high_f32(vacc4x0123);
276 vacc3x01 = vget_high_f32(vacc3x0123);
277 vacc2x01 = vget_high_f32(vacc2x0123);
278 vacc1x01 = vget_high_f32(vacc1x0123);
279 vacc0x01 = vget_high_f32(vacc0x0123);
280 }
281 if (nc & 1) {
282 vst1_lane_f32(c5, vacc5x01, 0);
283 vst1_lane_f32(c4, vacc4x01, 0);
284 vst1_lane_f32(c3, vacc3x01, 0);
285 vst1_lane_f32(c2, vacc2x01, 0);
286 vst1_lane_f32(c1, vacc1x01, 0);
287 vst1_lane_f32(c0, vacc0x01, 0);
288 }
289
290 nc = 0;
291 }
292 } while (nc != 0);
293 }
294