1 // Auto-generated file. Do not edit!
2 //   Template: src/f32-gemm/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/gemm.h>
16 
17 
xnn_f32_gemminc_minmax_ukernel_1x8__neonfma_lane_ld64(size_t mr,size_t nc,size_t kc,const float * restrict a,size_t a_stride,const float * restrict w,float * restrict c,size_t cm_stride,size_t cn_stride,const float * restrict acc,const union xnn_f32_minmax_params params[restrict XNN_MIN_ELEMENTS (1)])18 void xnn_f32_gemminc_minmax_ukernel_1x8__neonfma_lane_ld64(
19     size_t mr,
20     size_t nc,
21     size_t kc,
22     const float* restrict a,
23     size_t a_stride,
24     const float* restrict w,
25     float* restrict c,
26     size_t cm_stride,
27     size_t cn_stride,
28     const float*restrict acc,
29     const union xnn_f32_minmax_params params[restrict XNN_MIN_ELEMENTS(1)])
30 {
31   assert(mr != 0);
32   assert(mr <= 1);
33   assert(nc != 0);
34   assert(kc != 0);
35   assert(kc % sizeof(float) == 0);
36   assert(a != NULL);
37   assert(w != NULL);
38   assert(c != NULL);
39   assert(acc != NULL);
40 
41   const float* a0 = a;
42   float* c0 = c;
43 
44   do {
45     float32x4_t vacc0x0123 = vld1q_f32(acc); acc += 4;
46     float32x4_t vacc0x4567 = vld1q_f32(acc); acc += 4;
47 
48     size_t k = kc;
49     for (; k >= 2 * sizeof(float); k -= 2 * sizeof(float)) {
50       const float32x2_t va0 = vld1_f32(a0); a0 += 2;
51 
52       const float32x4_t vb0123c0 = vld1q_f32(w); w += 4;
53       const float32x4_t vb4567c0 = vld1q_f32(w); w += 4;
54 
55       vacc0x0123 = vfmaq_lane_f32(vacc0x0123, vb0123c0, va0, 0);
56       vacc0x4567 = vfmaq_lane_f32(vacc0x4567, vb4567c0, va0, 0);
57       const float32x4_t vb0123c1 = vld1q_f32(w); w += 4;
58       const float32x4_t vb4567c1 = vld1q_f32(w); w += 4;
59 
60       vacc0x0123 = vfmaq_lane_f32(vacc0x0123, vb0123c1, va0, 1);
61       vacc0x4567 = vfmaq_lane_f32(vacc0x4567, vb4567c1, va0, 1);
62     }
63     if XNN_UNLIKELY(k != 0) {
64       const float32x4_t va0 = vld1q_dup_f32(a0); a0 += 1;
65 
66       const float32x4_t vb0123 = vld1q_f32(w); w += 4;
67       const float32x4_t vb4567 = vld1q_f32(w); w += 4;
68 
69       vacc0x0123 = vfmaq_f32(vacc0x0123, va0, vb0123);
70       vacc0x4567 = vfmaq_f32(vacc0x4567, va0, vb4567);
71     }
72     const float32x4_t vmax = vld1q_dup_f32(&params->scalar.max);
73     vacc0x0123 = vminq_f32(vacc0x0123, vmax);
74     vacc0x4567 = vminq_f32(vacc0x4567, vmax);
75 
76     const float32x4_t vmin = vld1q_dup_f32(&params->scalar.min);
77     vacc0x0123 = vmaxq_f32(vacc0x0123, vmin);
78     vacc0x4567 = vmaxq_f32(vacc0x4567, vmin);
79 
80     if XNN_LIKELY(nc >= 8) {
81       vst1q_f32(c0, vacc0x0123);
82       vst1q_f32(c0 + 4, vacc0x4567);
83       c0 = (float*) ((uintptr_t) c0 + cn_stride);
84 
85       a0 = (const float*) ((uintptr_t) a0 - kc);
86 
87       nc -= 8;
88 
89     } else {
90       if (nc & 4) {
91         vst1q_f32(c0, vacc0x0123); c0 += 4;
92 
93         vacc0x0123 = vacc0x4567;
94       }
95       float32x2_t vacc0x01 = vget_low_f32(vacc0x0123);
96       if (nc & 2) {
97         vst1_f32(c0, vacc0x01); c0 += 2;
98 
99         vacc0x01 = vget_high_f32(vacc0x0123);
100       }
101       if (nc & 1) {
102         vst1_lane_f32(c0, vacc0x01, 0);
103       }
104 
105       nc = 0;
106     }
107   } while (nc != 0);
108 }
109