1 // Auto-generated file. Do not edit!
2 // Template: src/f32-gemm/neon-shuffle.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_1x8s4__neon(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_1x8s4__neon(
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 while (k >= 4 * sizeof(float)) {
50 float32x4_t va0 = vld1q_f32(a0); a0 += 4;
51
52
53 const float32x4_t vb0123c0 = vld1q_f32(w); w += 4;
54 const float32x4_t vb4567c0 = vld1q_f32(w); w += 4;
55
56 vacc0x0123 = vmlaq_f32(vacc0x0123, va0, vb0123c0);
57 vacc0x4567 = vmlaq_f32(vacc0x4567, va0, vb4567c0);
58
59 va0 = vextq_f32(va0, va0, 1);
60
61 const float32x4_t vb0123c1 = vld1q_f32(w); w += 4;
62 const float32x4_t vb4567c1 = vld1q_f32(w); w += 4;
63
64 vacc0x0123 = vmlaq_f32(vacc0x0123, va0, vb0123c1);
65 vacc0x4567 = vmlaq_f32(vacc0x4567, va0, vb4567c1);
66
67 va0 = vextq_f32(va0, va0, 1);
68
69 const float32x4_t vb0123c2 = vld1q_f32(w); w += 4;
70 const float32x4_t vb4567c2 = vld1q_f32(w); w += 4;
71
72 vacc0x0123 = vmlaq_f32(vacc0x0123, va0, vb0123c2);
73 vacc0x4567 = vmlaq_f32(vacc0x4567, va0, vb4567c2);
74
75 va0 = vextq_f32(va0, va0, 1);
76
77 const float32x4_t vb0123c3 = vld1q_f32(w); w += 4;
78 const float32x4_t vb4567c3 = vld1q_f32(w); w += 4;
79
80 vacc0x0123 = vmlaq_f32(vacc0x0123, va0, vb0123c3);
81 vacc0x4567 = vmlaq_f32(vacc0x4567, va0, vb4567c3);
82
83
84 k -= 4 * sizeof(float);
85 }
86 if XNN_UNLIKELY(k != 0) {
87 float32x4_t va0 = vld1q_f32(a0); a0 = (const float*) ((uintptr_t) a0 + k);
88
89
90 const float32x4_t vb0123c0 = vld1q_f32(w); w += 4;
91 const float32x4_t vb4567c0 = vld1q_f32(w); w += 4;
92
93 const float32x4_t vmska0x0123c0 = vreinterpretq_f32_u32(vbicq_u32(vreinterpretq_u32_f32(va0), vceqq_f32(vb0123c0, vmovq_n_f32(0.0f))));
94 vacc0x0123 = vmlaq_f32(vacc0x0123, vmska0x0123c0, vb0123c0);
95 const float32x4_t vmska0x4567c0 = vreinterpretq_f32_u32(vbicq_u32(vreinterpretq_u32_f32(va0), vceqq_f32(vb4567c0, vmovq_n_f32(0.0f))));
96 vacc0x4567 = vmlaq_f32(vacc0x4567, vmska0x4567c0, vb4567c0);
97
98 va0 = vextq_f32(va0, va0, 1);
99
100 const float32x4_t vb0123c1 = vld1q_f32(w); w += 4;
101 const float32x4_t vb4567c1 = vld1q_f32(w); w += 4;
102
103 const float32x4_t vmska0x0123c1 = vreinterpretq_f32_u32(vbicq_u32(vreinterpretq_u32_f32(va0), vceqq_f32(vb0123c1, vmovq_n_f32(0.0f))));
104 vacc0x0123 = vmlaq_f32(vacc0x0123, vmska0x0123c1, vb0123c1);
105 const float32x4_t vmska0x4567c1 = vreinterpretq_f32_u32(vbicq_u32(vreinterpretq_u32_f32(va0), vceqq_f32(vb4567c1, vmovq_n_f32(0.0f))));
106 vacc0x4567 = vmlaq_f32(vacc0x4567, vmska0x4567c1, vb4567c1);
107
108 va0 = vextq_f32(va0, va0, 1);
109
110 const float32x4_t vb0123c2 = vld1q_f32(w); w += 4;
111 const float32x4_t vb4567c2 = vld1q_f32(w); w += 4;
112
113 const float32x4_t vmska0x0123c2 = vreinterpretq_f32_u32(vbicq_u32(vreinterpretq_u32_f32(va0), vceqq_f32(vb0123c2, vmovq_n_f32(0.0f))));
114 vacc0x0123 = vmlaq_f32(vacc0x0123, vmska0x0123c2, vb0123c2);
115 const float32x4_t vmska0x4567c2 = vreinterpretq_f32_u32(vbicq_u32(vreinterpretq_u32_f32(va0), vceqq_f32(vb4567c2, vmovq_n_f32(0.0f))));
116 vacc0x4567 = vmlaq_f32(vacc0x4567, vmska0x4567c2, vb4567c2);
117
118 va0 = vextq_f32(va0, va0, 1);
119
120 const float32x4_t vb0123c3 = vld1q_f32(w); w += 4;
121 const float32x4_t vb4567c3 = vld1q_f32(w); w += 4;
122
123 const float32x4_t vmska0x0123c3 = vreinterpretq_f32_u32(vbicq_u32(vreinterpretq_u32_f32(va0), vceqq_f32(vb0123c3, vmovq_n_f32(0.0f))));
124 vacc0x0123 = vmlaq_f32(vacc0x0123, vmska0x0123c3, vb0123c3);
125 const float32x4_t vmska0x4567c3 = vreinterpretq_f32_u32(vbicq_u32(vreinterpretq_u32_f32(va0), vceqq_f32(vb4567c3, vmovq_n_f32(0.0f))));
126 vacc0x4567 = vmlaq_f32(vacc0x4567, vmska0x4567c3, vb4567c3);
127
128 }
129 const float32x4_t vmax = vld1q_dup_f32(¶ms->scalar.max);
130 vacc0x0123 = vminq_f32(vacc0x0123, vmax);
131 vacc0x4567 = vminq_f32(vacc0x4567, vmax);
132
133 const float32x4_t vmin = vld1q_dup_f32(¶ms->scalar.min);
134 vacc0x0123 = vmaxq_f32(vacc0x0123, vmin);
135 vacc0x4567 = vmaxq_f32(vacc0x4567, vmin);
136
137 if XNN_LIKELY(nc >= 8) {
138 vst1q_f32(c0, vacc0x0123);
139 vst1q_f32(c0 + 4, vacc0x4567);
140 c0 = (float*) ((uintptr_t) c0 + cn_stride);
141
142 a0 = (const float*) ((uintptr_t) a0 - kc);
143
144 nc -= 8;
145
146 } else {
147 if (nc & 4) {
148 vst1q_f32(c0, vacc0x0123); c0 += 4;
149
150 vacc0x0123 = vacc0x4567;
151 }
152 float32x2_t vacc0x01 = vget_low_f32(vacc0x0123);
153 if (nc & 2) {
154 vst1_f32(c0, vacc0x01); c0 += 2;
155
156 vacc0x01 = vget_high_f32(vacc0x0123);
157 }
158 if (nc & 1) {
159 vst1_lane_f32(c0, vacc0x01, 0);
160 }
161
162 nc = 0;
163 }
164 } while (nc != 0);
165 }
166