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_gemm_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 union xnn_f32_minmax_params params[restrict XNN_MIN_ELEMENTS (1)])18 void xnn_f32_gemm_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 union xnn_f32_minmax_params params[restrict XNN_MIN_ELEMENTS(1)])
29 {
30 assert(mr != 0);
31 assert(mr <= 1);
32 assert(nc != 0);
33 assert(kc != 0);
34 assert(kc % sizeof(float) == 0);
35 assert(a != NULL);
36 assert(w != NULL);
37 assert(c != NULL);
38
39 const float* a0 = a;
40 float* c0 = c;
41
42 do {
43 float32x4_t vacc0x0123 = vld1q_f32(w); w += 4;
44 float32x4_t vacc0x4567 = vld1q_f32(w); w += 4;
45
46 size_t k = kc;
47 while (k >= 4 * sizeof(float)) {
48 float32x4_t va0 = vld1q_f32(a0); a0 += 4;
49
50
51 const float32x4_t vb0123c0 = vld1q_f32(w); w += 4;
52 const float32x4_t vb4567c0 = vld1q_f32(w); w += 4;
53
54 vacc0x0123 = vmlaq_f32(vacc0x0123, va0, vb0123c0);
55 vacc0x4567 = vmlaq_f32(vacc0x4567, va0, vb4567c0);
56
57 va0 = vextq_f32(va0, va0, 1);
58
59 const float32x4_t vb0123c1 = vld1q_f32(w); w += 4;
60 const float32x4_t vb4567c1 = vld1q_f32(w); w += 4;
61
62 vacc0x0123 = vmlaq_f32(vacc0x0123, va0, vb0123c1);
63 vacc0x4567 = vmlaq_f32(vacc0x4567, va0, vb4567c1);
64
65 va0 = vextq_f32(va0, va0, 1);
66
67 const float32x4_t vb0123c2 = vld1q_f32(w); w += 4;
68 const float32x4_t vb4567c2 = vld1q_f32(w); w += 4;
69
70 vacc0x0123 = vmlaq_f32(vacc0x0123, va0, vb0123c2);
71 vacc0x4567 = vmlaq_f32(vacc0x4567, va0, vb4567c2);
72
73 va0 = vextq_f32(va0, va0, 1);
74
75 const float32x4_t vb0123c3 = vld1q_f32(w); w += 4;
76 const float32x4_t vb4567c3 = vld1q_f32(w); w += 4;
77
78 vacc0x0123 = vmlaq_f32(vacc0x0123, va0, vb0123c3);
79 vacc0x4567 = vmlaq_f32(vacc0x4567, va0, vb4567c3);
80
81
82 k -= 4 * sizeof(float);
83 }
84 if XNN_UNLIKELY(k != 0) {
85 float32x4_t va0 = vld1q_f32(a0); a0 = (const float*) ((uintptr_t) a0 + k);
86
87
88 const float32x4_t vb0123c0 = vld1q_f32(w); w += 4;
89 const float32x4_t vb4567c0 = vld1q_f32(w); w += 4;
90
91 const float32x4_t vmska0x0123c0 = vreinterpretq_f32_u32(vbicq_u32(vreinterpretq_u32_f32(va0), vceqq_f32(vb0123c0, vmovq_n_f32(0.0f))));
92 vacc0x0123 = vmlaq_f32(vacc0x0123, vmska0x0123c0, vb0123c0);
93 const float32x4_t vmska0x4567c0 = vreinterpretq_f32_u32(vbicq_u32(vreinterpretq_u32_f32(va0), vceqq_f32(vb4567c0, vmovq_n_f32(0.0f))));
94 vacc0x4567 = vmlaq_f32(vacc0x4567, vmska0x4567c0, vb4567c0);
95
96 va0 = vextq_f32(va0, va0, 1);
97
98 const float32x4_t vb0123c1 = vld1q_f32(w); w += 4;
99 const float32x4_t vb4567c1 = vld1q_f32(w); w += 4;
100
101 const float32x4_t vmska0x0123c1 = vreinterpretq_f32_u32(vbicq_u32(vreinterpretq_u32_f32(va0), vceqq_f32(vb0123c1, vmovq_n_f32(0.0f))));
102 vacc0x0123 = vmlaq_f32(vacc0x0123, vmska0x0123c1, vb0123c1);
103 const float32x4_t vmska0x4567c1 = vreinterpretq_f32_u32(vbicq_u32(vreinterpretq_u32_f32(va0), vceqq_f32(vb4567c1, vmovq_n_f32(0.0f))));
104 vacc0x4567 = vmlaq_f32(vacc0x4567, vmska0x4567c1, vb4567c1);
105
106 va0 = vextq_f32(va0, va0, 1);
107
108 const float32x4_t vb0123c2 = vld1q_f32(w); w += 4;
109 const float32x4_t vb4567c2 = vld1q_f32(w); w += 4;
110
111 const float32x4_t vmska0x0123c2 = vreinterpretq_f32_u32(vbicq_u32(vreinterpretq_u32_f32(va0), vceqq_f32(vb0123c2, vmovq_n_f32(0.0f))));
112 vacc0x0123 = vmlaq_f32(vacc0x0123, vmska0x0123c2, vb0123c2);
113 const float32x4_t vmska0x4567c2 = vreinterpretq_f32_u32(vbicq_u32(vreinterpretq_u32_f32(va0), vceqq_f32(vb4567c2, vmovq_n_f32(0.0f))));
114 vacc0x4567 = vmlaq_f32(vacc0x4567, vmska0x4567c2, vb4567c2);
115
116 va0 = vextq_f32(va0, va0, 1);
117
118 const float32x4_t vb0123c3 = vld1q_f32(w); w += 4;
119 const float32x4_t vb4567c3 = vld1q_f32(w); w += 4;
120
121 const float32x4_t vmska0x0123c3 = vreinterpretq_f32_u32(vbicq_u32(vreinterpretq_u32_f32(va0), vceqq_f32(vb0123c3, vmovq_n_f32(0.0f))));
122 vacc0x0123 = vmlaq_f32(vacc0x0123, vmska0x0123c3, vb0123c3);
123 const float32x4_t vmska0x4567c3 = vreinterpretq_f32_u32(vbicq_u32(vreinterpretq_u32_f32(va0), vceqq_f32(vb4567c3, vmovq_n_f32(0.0f))));
124 vacc0x4567 = vmlaq_f32(vacc0x4567, vmska0x4567c3, vb4567c3);
125
126 }
127 const float32x4_t vmax = vld1q_dup_f32(¶ms->scalar.max);
128 vacc0x0123 = vminq_f32(vacc0x0123, vmax);
129 vacc0x4567 = vminq_f32(vacc0x4567, vmax);
130
131 const float32x4_t vmin = vld1q_dup_f32(¶ms->scalar.min);
132 vacc0x0123 = vmaxq_f32(vacc0x0123, vmin);
133 vacc0x4567 = vmaxq_f32(vacc0x4567, vmin);
134
135 if XNN_LIKELY(nc >= 8) {
136 vst1q_f32(c0, vacc0x0123);
137 vst1q_f32(c0 + 4, vacc0x4567);
138 c0 = (float*) ((uintptr_t) c0 + cn_stride);
139
140 a0 = (const float*) ((uintptr_t) a0 - kc);
141
142 nc -= 8;
143
144 } else {
145 if (nc & 4) {
146 vst1q_f32(c0, vacc0x0123); c0 += 4;
147
148 vacc0x0123 = vacc0x4567;
149 }
150 float32x2_t vacc0x01 = vget_low_f32(vacc0x0123);
151 if (nc & 2) {
152 vst1_f32(c0, vacc0x01); c0 += 2;
153
154 vacc0x01 = vget_high_f32(vacc0x0123);
155 }
156 if (nc & 1) {
157 vst1_lane_f32(c0, vacc0x01, 0);
158 }
159
160 nc = 0;
161 }
162 } while (nc != 0);
163 }
164