• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Auto-generated file. Do not edit!
2 //   Template: src/f32-igemm/neon-ld128.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__neon_dup_ld128(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__neon_dup_ld128(
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 >= 4 * sizeof(float); k -= 4 * sizeof(float)) {
116         const float32x4_t va0 = vld1q_f32(a0); a0 += 4;
117         const float32x4_t va1 = vld1q_f32(a1); a1 += 4;
118         const float32x4_t va2 = vld1q_f32(a2); a2 += 4;
119         const float32x4_t va3 = vld1q_f32(a3); a3 += 4;
120         const float32x4_t va4 = vld1q_f32(a4); a4 += 4;
121         const float32x4_t va5 = vld1q_f32(a5); a5 += 4;
122 
123 
124         const float32x4_t vb0123c0 = vld1q_f32(w); w += 4;
125         const float32x4_t vb4567c0 = vld1q_f32(w); w += 4;
126 
127         const float32x4_t va0c0 = vdupq_lane_f32(vget_low_f32(va0), 0);
128         const float32x4_t va1c0 = vdupq_lane_f32(vget_low_f32(va1), 0);
129         const float32x4_t va2c0 = vdupq_lane_f32(vget_low_f32(va2), 0);
130         const float32x4_t va3c0 = vdupq_lane_f32(vget_low_f32(va3), 0);
131         const float32x4_t va4c0 = vdupq_lane_f32(vget_low_f32(va4), 0);
132         const float32x4_t va5c0 = vdupq_lane_f32(vget_low_f32(va5), 0);
133         vacc0x0123 = vmlaq_f32(vacc0x0123, va0c0, vb0123c0);
134         vacc1x0123 = vmlaq_f32(vacc1x0123, va1c0, vb0123c0);
135         vacc2x0123 = vmlaq_f32(vacc2x0123, va2c0, vb0123c0);
136         vacc3x0123 = vmlaq_f32(vacc3x0123, va3c0, vb0123c0);
137         vacc4x0123 = vmlaq_f32(vacc4x0123, va4c0, vb0123c0);
138         vacc5x0123 = vmlaq_f32(vacc5x0123, va5c0, vb0123c0);
139         vacc0x4567 = vmlaq_f32(vacc0x4567, va0c0, vb4567c0);
140         vacc1x4567 = vmlaq_f32(vacc1x4567, va1c0, vb4567c0);
141         vacc2x4567 = vmlaq_f32(vacc2x4567, va2c0, vb4567c0);
142         vacc3x4567 = vmlaq_f32(vacc3x4567, va3c0, vb4567c0);
143         vacc4x4567 = vmlaq_f32(vacc4x4567, va4c0, vb4567c0);
144         vacc5x4567 = vmlaq_f32(vacc5x4567, va5c0, vb4567c0);
145 
146         const float32x4_t vb0123c1 = vld1q_f32(w); w += 4;
147         const float32x4_t vb4567c1 = vld1q_f32(w); w += 4;
148 
149         const float32x4_t va0c1 = vdupq_lane_f32(vget_low_f32(va0), 1);
150         const float32x4_t va1c1 = vdupq_lane_f32(vget_low_f32(va1), 1);
151         const float32x4_t va2c1 = vdupq_lane_f32(vget_low_f32(va2), 1);
152         const float32x4_t va3c1 = vdupq_lane_f32(vget_low_f32(va3), 1);
153         const float32x4_t va4c1 = vdupq_lane_f32(vget_low_f32(va4), 1);
154         const float32x4_t va5c1 = vdupq_lane_f32(vget_low_f32(va5), 1);
155         vacc0x0123 = vmlaq_f32(vacc0x0123, va0c1, vb0123c1);
156         vacc1x0123 = vmlaq_f32(vacc1x0123, va1c1, vb0123c1);
157         vacc2x0123 = vmlaq_f32(vacc2x0123, va2c1, vb0123c1);
158         vacc3x0123 = vmlaq_f32(vacc3x0123, va3c1, vb0123c1);
159         vacc4x0123 = vmlaq_f32(vacc4x0123, va4c1, vb0123c1);
160         vacc5x0123 = vmlaq_f32(vacc5x0123, va5c1, vb0123c1);
161         vacc0x4567 = vmlaq_f32(vacc0x4567, va0c1, vb4567c1);
162         vacc1x4567 = vmlaq_f32(vacc1x4567, va1c1, vb4567c1);
163         vacc2x4567 = vmlaq_f32(vacc2x4567, va2c1, vb4567c1);
164         vacc3x4567 = vmlaq_f32(vacc3x4567, va3c1, vb4567c1);
165         vacc4x4567 = vmlaq_f32(vacc4x4567, va4c1, vb4567c1);
166         vacc5x4567 = vmlaq_f32(vacc5x4567, va5c1, vb4567c1);
167 
168         const float32x4_t vb0123c2 = vld1q_f32(w); w += 4;
169         const float32x4_t vb4567c2 = vld1q_f32(w); w += 4;
170 
171         const float32x4_t va0c2 = vdupq_lane_f32(vget_high_f32(va0), 0);
172         const float32x4_t va1c2 = vdupq_lane_f32(vget_high_f32(va1), 0);
173         const float32x4_t va2c2 = vdupq_lane_f32(vget_high_f32(va2), 0);
174         const float32x4_t va3c2 = vdupq_lane_f32(vget_high_f32(va3), 0);
175         const float32x4_t va4c2 = vdupq_lane_f32(vget_high_f32(va4), 0);
176         const float32x4_t va5c2 = vdupq_lane_f32(vget_high_f32(va5), 0);
177         vacc0x0123 = vmlaq_f32(vacc0x0123, va0c2, vb0123c2);
178         vacc1x0123 = vmlaq_f32(vacc1x0123, va1c2, vb0123c2);
179         vacc2x0123 = vmlaq_f32(vacc2x0123, va2c2, vb0123c2);
180         vacc3x0123 = vmlaq_f32(vacc3x0123, va3c2, vb0123c2);
181         vacc4x0123 = vmlaq_f32(vacc4x0123, va4c2, vb0123c2);
182         vacc5x0123 = vmlaq_f32(vacc5x0123, va5c2, vb0123c2);
183         vacc0x4567 = vmlaq_f32(vacc0x4567, va0c2, vb4567c2);
184         vacc1x4567 = vmlaq_f32(vacc1x4567, va1c2, vb4567c2);
185         vacc2x4567 = vmlaq_f32(vacc2x4567, va2c2, vb4567c2);
186         vacc3x4567 = vmlaq_f32(vacc3x4567, va3c2, vb4567c2);
187         vacc4x4567 = vmlaq_f32(vacc4x4567, va4c2, vb4567c2);
188         vacc5x4567 = vmlaq_f32(vacc5x4567, va5c2, vb4567c2);
189 
190         const float32x4_t vb0123c3 = vld1q_f32(w); w += 4;
191         const float32x4_t vb4567c3 = vld1q_f32(w); w += 4;
192 
193         const float32x4_t va0c3 = vdupq_lane_f32(vget_high_f32(va0), 1);
194         const float32x4_t va1c3 = vdupq_lane_f32(vget_high_f32(va1), 1);
195         const float32x4_t va2c3 = vdupq_lane_f32(vget_high_f32(va2), 1);
196         const float32x4_t va3c3 = vdupq_lane_f32(vget_high_f32(va3), 1);
197         const float32x4_t va4c3 = vdupq_lane_f32(vget_high_f32(va4), 1);
198         const float32x4_t va5c3 = vdupq_lane_f32(vget_high_f32(va5), 1);
199         vacc0x0123 = vmlaq_f32(vacc0x0123, va0c3, vb0123c3);
200         vacc1x0123 = vmlaq_f32(vacc1x0123, va1c3, vb0123c3);
201         vacc2x0123 = vmlaq_f32(vacc2x0123, va2c3, vb0123c3);
202         vacc3x0123 = vmlaq_f32(vacc3x0123, va3c3, vb0123c3);
203         vacc4x0123 = vmlaq_f32(vacc4x0123, va4c3, vb0123c3);
204         vacc5x0123 = vmlaq_f32(vacc5x0123, va5c3, vb0123c3);
205         vacc0x4567 = vmlaq_f32(vacc0x4567, va0c3, vb4567c3);
206         vacc1x4567 = vmlaq_f32(vacc1x4567, va1c3, vb4567c3);
207         vacc2x4567 = vmlaq_f32(vacc2x4567, va2c3, vb4567c3);
208         vacc3x4567 = vmlaq_f32(vacc3x4567, va3c3, vb4567c3);
209         vacc4x4567 = vmlaq_f32(vacc4x4567, va4c3, vb4567c3);
210         vacc5x4567 = vmlaq_f32(vacc5x4567, va5c3, vb4567c3);
211       }
212       if XNN_UNLIKELY(k != 0) {
213         do {
214           const float32x4_t va0 = vld1q_dup_f32(a0); a0 += 1;
215           const float32x4_t va1 = vld1q_dup_f32(a1); a1 += 1;
216           const float32x4_t va2 = vld1q_dup_f32(a2); a2 += 1;
217           const float32x4_t va3 = vld1q_dup_f32(a3); a3 += 1;
218           const float32x4_t va4 = vld1q_dup_f32(a4); a4 += 1;
219           const float32x4_t va5 = vld1q_dup_f32(a5); a5 += 1;
220 
221           const float32x4_t vb0123 = vld1q_f32(w); w += 4;
222           const float32x4_t vb4567 = vld1q_f32(w); w += 4;
223 
224           vacc0x0123 = vmlaq_f32(vacc0x0123, va0, vb0123);
225           vacc1x0123 = vmlaq_f32(vacc1x0123, va1, vb0123);
226           vacc2x0123 = vmlaq_f32(vacc2x0123, va2, vb0123);
227           vacc3x0123 = vmlaq_f32(vacc3x0123, va3, vb0123);
228           vacc4x0123 = vmlaq_f32(vacc4x0123, va4, vb0123);
229           vacc5x0123 = vmlaq_f32(vacc5x0123, va5, vb0123);
230           vacc0x4567 = vmlaq_f32(vacc0x4567, va0, vb4567);
231           vacc1x4567 = vmlaq_f32(vacc1x4567, va1, vb4567);
232           vacc2x4567 = vmlaq_f32(vacc2x4567, va2, vb4567);
233           vacc3x4567 = vmlaq_f32(vacc3x4567, va3, vb4567);
234           vacc4x4567 = vmlaq_f32(vacc4x4567, va4, vb4567);
235           vacc5x4567 = vmlaq_f32(vacc5x4567, va5, vb4567);
236 
237           k -= sizeof(float);
238         } while (k != 0);
239       }
240 
241       p -= 6 * sizeof(void*);
242     } while (p != 0);
243 
244     const float32x4_t vmax = vld1q_dup_f32(&params->scalar.max);
245     vacc0x0123 = vminq_f32(vacc0x0123, vmax);
246     vacc1x0123 = vminq_f32(vacc1x0123, vmax);
247     vacc2x0123 = vminq_f32(vacc2x0123, vmax);
248     vacc3x0123 = vminq_f32(vacc3x0123, vmax);
249     vacc4x0123 = vminq_f32(vacc4x0123, vmax);
250     vacc5x0123 = vminq_f32(vacc5x0123, vmax);
251     vacc0x4567 = vminq_f32(vacc0x4567, vmax);
252     vacc1x4567 = vminq_f32(vacc1x4567, vmax);
253     vacc2x4567 = vminq_f32(vacc2x4567, vmax);
254     vacc3x4567 = vminq_f32(vacc3x4567, vmax);
255     vacc4x4567 = vminq_f32(vacc4x4567, vmax);
256     vacc5x4567 = vminq_f32(vacc5x4567, vmax);
257 
258     const float32x4_t vmin = vld1q_dup_f32(&params->scalar.min);
259     vacc0x0123 = vmaxq_f32(vacc0x0123, vmin);
260     vacc1x0123 = vmaxq_f32(vacc1x0123, vmin);
261     vacc2x0123 = vmaxq_f32(vacc2x0123, vmin);
262     vacc3x0123 = vmaxq_f32(vacc3x0123, vmin);
263     vacc4x0123 = vmaxq_f32(vacc4x0123, vmin);
264     vacc5x0123 = vmaxq_f32(vacc5x0123, vmin);
265     vacc0x4567 = vmaxq_f32(vacc0x4567, vmin);
266     vacc1x4567 = vmaxq_f32(vacc1x4567, vmin);
267     vacc2x4567 = vmaxq_f32(vacc2x4567, vmin);
268     vacc3x4567 = vmaxq_f32(vacc3x4567, vmin);
269     vacc4x4567 = vmaxq_f32(vacc4x4567, vmin);
270     vacc5x4567 = vmaxq_f32(vacc5x4567, vmin);
271 
272     if XNN_LIKELY(nc >= 8) {
273       vst1q_f32(c5, vacc5x0123);
274       vst1q_f32(c5 + 4, vacc5x4567);
275       c5 = (float*) ((uintptr_t) c5 + cn_stride);
276       vst1q_f32(c4, vacc4x0123);
277       vst1q_f32(c4 + 4, vacc4x4567);
278       c4 = (float*) ((uintptr_t) c4 + cn_stride);
279       vst1q_f32(c3, vacc3x0123);
280       vst1q_f32(c3 + 4, vacc3x4567);
281       c3 = (float*) ((uintptr_t) c3 + cn_stride);
282       vst1q_f32(c2, vacc2x0123);
283       vst1q_f32(c2 + 4, vacc2x4567);
284       c2 = (float*) ((uintptr_t) c2 + cn_stride);
285       vst1q_f32(c1, vacc1x0123);
286       vst1q_f32(c1 + 4, vacc1x4567);
287       c1 = (float*) ((uintptr_t) c1 + cn_stride);
288       vst1q_f32(c0, vacc0x0123);
289       vst1q_f32(c0 + 4, vacc0x4567);
290       c0 = (float*) ((uintptr_t) c0 + cn_stride);
291 
292       a = (const float**restrict) ((uintptr_t) a - ks);
293       nc -= 8;
294     } else {
295       if (nc & 4) {
296         vst1q_f32(c5, vacc5x0123); c5 += 4;
297         vst1q_f32(c4, vacc4x0123); c4 += 4;
298         vst1q_f32(c3, vacc3x0123); c3 += 4;
299         vst1q_f32(c2, vacc2x0123); c2 += 4;
300         vst1q_f32(c1, vacc1x0123); c1 += 4;
301         vst1q_f32(c0, vacc0x0123); c0 += 4;
302 
303         vacc5x0123 = vacc5x4567;
304         vacc4x0123 = vacc4x4567;
305         vacc3x0123 = vacc3x4567;
306         vacc2x0123 = vacc2x4567;
307         vacc1x0123 = vacc1x4567;
308         vacc0x0123 = vacc0x4567;
309       }
310       float32x2_t vacc5x01 = vget_low_f32(vacc5x0123);
311       float32x2_t vacc4x01 = vget_low_f32(vacc4x0123);
312       float32x2_t vacc3x01 = vget_low_f32(vacc3x0123);
313       float32x2_t vacc2x01 = vget_low_f32(vacc2x0123);
314       float32x2_t vacc1x01 = vget_low_f32(vacc1x0123);
315       float32x2_t vacc0x01 = vget_low_f32(vacc0x0123);
316       if (nc & 2) {
317         vst1_f32(c5, vacc5x01); c5 += 2;
318         vst1_f32(c4, vacc4x01); c4 += 2;
319         vst1_f32(c3, vacc3x01); c3 += 2;
320         vst1_f32(c2, vacc2x01); c2 += 2;
321         vst1_f32(c1, vacc1x01); c1 += 2;
322         vst1_f32(c0, vacc0x01); c0 += 2;
323 
324         vacc5x01 = vget_high_f32(vacc5x0123);
325         vacc4x01 = vget_high_f32(vacc4x0123);
326         vacc3x01 = vget_high_f32(vacc3x0123);
327         vacc2x01 = vget_high_f32(vacc2x0123);
328         vacc1x01 = vget_high_f32(vacc1x0123);
329         vacc0x01 = vget_high_f32(vacc0x0123);
330       }
331       if (nc & 1) {
332         vst1_lane_f32(c5, vacc5x01, 0);
333         vst1_lane_f32(c4, vacc4x01, 0);
334         vst1_lane_f32(c3, vacc3x01, 0);
335         vst1_lane_f32(c2, vacc2x01, 0);
336         vst1_lane_f32(c1, vacc1x01, 0);
337         vst1_lane_f32(c0, vacc0x01, 0);
338       }
339 
340       nc = 0;
341     }
342   } while (nc != 0);
343 }
344