Debian Codegraph @

src/f32-spmm/gen/f32-spmm-32x1-minmax-neon-pipelined.c

raw symbols SCIP
1 // Auto-generated file. Do not edit!
2 // Template: src/f32-spmm/neon-pipelined.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 #include <assert.h>
11
12 #include <arm_neon.h>
13
14 #include "xnnpack/prefetch.h"
15 #include "xnnpack/spmm.h"
16
17
18 void xnn_f32_spmm_minmax_ukernel_32x1__neon_pipelined(
19 size_t mc,
20 size_t nc,
21 const float* input,
22 const float* weights,
23 const int32_t* widx_dmap,
24 const uint32_t* nidx_nnzmap,
25 float* output,
26 size_t output_stride,
27 const union xnn_f32_minmax_params params[restrict XNN_MIN_ELEMENTS(1)])
28 {
29 assert(mc != 0);
30 assert(mc % sizeof(float) == 0);
31 assert(nc != 0);
32
33 #if XNN_ARCH_ARM64
34 const float32x4x2_t vminmax = vld2q_dup_f32(&params->scalar.min);
35 const float32x4_t vmin = vminmax.val[0];
36 const float32x4_t vmax = vminmax.val[1];
37 #else
38 const float32x2x2_t vminmax = vld2_dup_f32(&params->scalar.min);
39 const float32x4_t vmin = vcombine_f32(vminmax.val[0], vminmax.val[0]);
40 const float32x4_t vmax = vcombine_f32(vminmax.val[1], vminmax.val[1]);
41 #endif
42
43 size_t output_decrement = output_stride * nc - 32 * sizeof(float);
44 while XNN_LIKELY(mc >= 32 * sizeof(float)) {
45 const float* w = weights;
46 const int32_t* dmap = widx_dmap;
47 const uint32_t* nnzmap = nidx_nnzmap;
48 float32x4_t vw = vld1q_dup_f32(w); w += 1;
49 intptr_t diff = *dmap++;
50 float32x4_t vi0123 = vld1q_f32(input);
51 float32x4_t vi4567 = vld1q_f32(input + 4);
52 float32x4_t vi89AB = vld1q_f32(input + 8);
53 float32x4_t viCDEF = vld1q_f32(input + 12);
54 float32x4_t viGHIJ = vld1q_f32(input + 16);
55 float32x4_t viKLMN = vld1q_f32(input + 20);
56 float32x4_t viOPQR = vld1q_f32(input + 24);
57 float32x4_t viSTUV = vld1q_f32(input + 28);
58 size_t n = nc;
59 do {
60 uint32_t nnz = *nnzmap++;
61 float32x4_t vacc0123 = vw;
62 float32x4_t vacc4567 = vw;
63 float32x4_t vacc89AB = vw;
64 float32x4_t vaccCDEF = vw;
65 float32x4_t vaccGHIJ = vw;
66 float32x4_t vaccKLMN = vw;
67 float32x4_t vaccOPQR = vw;
68 float32x4_t vaccSTUV = vw;
69 vw = vld1q_dup_f32(w); w += 1;
70 if XNN_LIKELY(nnz != 0) {
71 do {
72 vacc0123 = vmlaq_f32(vacc0123, vi0123, vw);
73 vacc4567 = vmlaq_f32(vacc4567, vi4567, vw);
74 vacc89AB = vmlaq_f32(vacc89AB, vi89AB, vw);
75 vaccCDEF = vmlaq_f32(vaccCDEF, viCDEF, vw);
76 vaccGHIJ = vmlaq_f32(vaccGHIJ, viGHIJ, vw);
77 vaccKLMN = vmlaq_f32(vaccKLMN, viKLMN, vw);
78 vaccOPQR = vmlaq_f32(vaccOPQR, viOPQR, vw);
79 vaccSTUV = vmlaq_f32(vaccSTUV, viSTUV, vw);
80 input = (const float*) ((uintptr_t) input + (uintptr_t) diff);
81 xnn_prefetch_to_l1(input + 16);
82 xnn_prefetch_to_l1(input + 32);
83 diff = *dmap++;
84 vw = vld1q_dup_f32(w); w += 1;
85 xnn_prefetch_to_l1(w + 32);
86 vi0123 = vld1q_f32(input);
87 vi4567 = vld1q_f32(input + 4);
88 vi89AB = vld1q_f32(input + 8);
89 viCDEF = vld1q_f32(input + 12);
90 viGHIJ = vld1q_f32(input + 16);
91 viKLMN = vld1q_f32(input + 20);
92 viOPQR = vld1q_f32(input + 24);
93 viSTUV = vld1q_f32(input + 28);
94 } while (--nnz != 0);
95 }
96 float32x4_t vout0123 = vminq_f32(vacc0123, vmax);
97 float32x4_t vout4567 = vminq_f32(vacc4567, vmax);
98 float32x4_t vout89AB = vminq_f32(vacc89AB, vmax);
99 float32x4_t voutCDEF = vminq_f32(vaccCDEF, vmax);
100 float32x4_t voutGHIJ = vminq_f32(vaccGHIJ, vmax);
101 float32x4_t voutKLMN = vminq_f32(vaccKLMN, vmax);
102 float32x4_t voutOPQR = vminq_f32(vaccOPQR, vmax);
103 float32x4_t voutSTUV = vminq_f32(vaccSTUV, vmax);
104 vout0123 = vmaxq_f32(vout0123, vmin);
105 vout4567 = vmaxq_f32(vout4567, vmin);
106 vout89AB = vmaxq_f32(vout89AB, vmin);
107 voutCDEF = vmaxq_f32(voutCDEF, vmin);
108 voutGHIJ = vmaxq_f32(voutGHIJ, vmin);
109 voutKLMN = vmaxq_f32(voutKLMN, vmin);
110 voutOPQR = vmaxq_f32(voutOPQR, vmin);
111 voutSTUV = vmaxq_f32(voutSTUV, vmin);
112 vst1q_f32(output, vout0123);
113 vst1q_f32(output + 4, vout4567);
114 vst1q_f32(output + 8, vout89AB);
115 vst1q_f32(output + 12, voutCDEF);
116 vst1q_f32(output + 16, voutGHIJ);
117 vst1q_f32(output + 20, voutKLMN);
118 vst1q_f32(output + 24, voutOPQR);
119 vst1q_f32(output + 28, voutSTUV);
120 output = (float*) ((uintptr_t) output + output_stride);
121 } while (--n != 0);
122 output = (float*) ((uintptr_t) output - output_decrement);
123 input += 32;
124 mc -= 32 * sizeof(float);
125 }
126 if XNN_UNLIKELY(mc != 0) {
127 output_decrement += 16 * sizeof(float);
128 if (mc & (16 * sizeof(float))) {
129 const float* w = weights;
130 const int32_t* dmap = widx_dmap;
131 const uint32_t* nnzmap = nidx_nnzmap;
132 size_t n = nc;
133 do {
134 uint32_t nnz = *nnzmap++;
135 float32x4_t vacc0123 = vld1q_dup_f32(w); w += 1;
136 float32x4_t vacc4567 = vacc0123;
137 float32x4_t vacc89AB = vacc0123;
138 float32x4_t vaccCDEF = vacc0123;
139 if XNN_LIKELY(nnz != 0) {
140 do {
141 const intptr_t diff = *dmap++;
142 const float32x4_t vi0123 = vld1q_f32(input);
143 const float32x4_t vi4567 = vld1q_f32(input + 4);
144 const float32x4_t vi89AB = vld1q_f32(input + 8);
145 const float32x4_t viCDEF = vld1q_f32(input + 12);
146 input = (const float*) ((uintptr_t) input + (uintptr_t) diff);
147 xnn_prefetch_to_l1(input + 16);
148 xnn_prefetch_to_l1(input + 32);
149 const float32x4_t vb = vld1q_dup_f32(w); w += 1;
150 xnn_prefetch_to_l1(w + 32);
151 vacc0123 = vmlaq_f32(vacc0123, vi0123, vb);
152 vacc4567 = vmlaq_f32(vacc4567, vi4567, vb);
153 vacc89AB = vmlaq_f32(vacc89AB, vi89AB, vb);
154 vaccCDEF = vmlaq_f32(vaccCDEF, viCDEF, vb);
155 } while (--nnz != 0);
156 }
157 float32x4_t vout0123 = vminq_f32(vacc0123, vmax);
158 float32x4_t vout4567 = vminq_f32(vacc4567, vmax);
159 float32x4_t vout89AB = vminq_f32(vacc89AB, vmax);
160 float32x4_t voutCDEF = vminq_f32(vaccCDEF, vmax);
161 vout0123 = vmaxq_f32(vout0123, vmin);
162 vout4567 = vmaxq_f32(vout4567, vmin);
163 vout89AB = vmaxq_f32(vout89AB, vmin);
164 voutCDEF = vmaxq_f32(voutCDEF, vmin);
165 vst1q_f32(output, vout0123);
166 vst1q_f32(output + 4, vout4567);
167 vst1q_f32(output + 8, vout89AB);
168 vst1q_f32(output + 12, voutCDEF);
169 output = (float*) ((uintptr_t) output + output_stride);
170 } while (--n != 0);
171 output = (float*) ((uintptr_t) output - output_decrement);
172 input += 16;
173 }
174 output_decrement += 8 * sizeof(float);
175 if (mc & (8 * sizeof(float))) {
176 const float* w = weights;
177 const int32_t* dmap = widx_dmap;
178 const uint32_t* nnzmap = nidx_nnzmap;
179 size_t n = nc;
180 do {
181 uint32_t nnz = *nnzmap++;
182 float32x4_t vacc0123 = vld1q_dup_f32(w); w += 1;
183 float32x4_t vacc4567 = vacc0123;
184 if XNN_LIKELY(nnz != 0) {
185 do {
186 const intptr_t diff = *dmap++;
187 const float32x4_t vi0123 = vld1q_f32(input);
188 const float32x4_t vi4567 = vld1q_f32(input + 4);
189 input = (const float*) ((uintptr_t) input + (uintptr_t) diff);
190 xnn_prefetch_to_l1(input + 16);
191 xnn_prefetch_to_l1(input + 32);
192 const float32x4_t vb = vld1q_dup_f32(w); w += 1;
193 xnn_prefetch_to_l1(w + 32);
194 vacc0123 = vmlaq_f32(vacc0123, vi0123, vb);
195 vacc4567 = vmlaq_f32(vacc4567, vi4567, vb);
196 } while (--nnz != 0);
197 }
198 float32x4_t vout0123 = vminq_f32(vacc0123, vmax);
199 float32x4_t vout4567 = vminq_f32(vacc4567, vmax);
200 vout0123 = vmaxq_f32(vout0123, vmin);
201 vout4567 = vmaxq_f32(vout4567, vmin);
202 vst1q_f32(output, vout0123);
203 vst1q_f32(output + 4, vout4567);
204 output = (float*) ((uintptr_t) output + output_stride);
205 } while (--n != 0);
206 output = (float*) ((uintptr_t) output - output_decrement);
207 input += 8;
208 }
209 output_decrement += 4 * sizeof(float);
210 if (mc & (4 * sizeof(float))) {
211 const float* w = weights;
212 const int32_t* dmap = widx_dmap;
213 const uint32_t* nnzmap = nidx_nnzmap;
214 size_t n = nc;
215 do {
216 uint32_t nnz = *nnzmap++;
217 float32x4_t vacc0123 = vld1q_dup_f32(w); w += 1;
218 if XNN_LIKELY(nnz != 0) {
219 do {
220 const intptr_t diff = *dmap++;
221 const float32x4_t vi0123 = vld1q_f32(input);
222 input = (const float*) ((uintptr_t) input + (uintptr_t) diff);
223 xnn_prefetch_to_l1(input + 16);
224 xnn_prefetch_to_l1(input + 32);
225 const float32x4_t vb = vld1q_dup_f32(w); w += 1;
226 xnn_prefetch_to_l1(w + 32);
227 vacc0123 = vmlaq_f32(vacc0123, vi0123, vb);
228 } while (--nnz != 0);
229 }
230 float32x4_t vout0123 = vminq_f32(vacc0123, vmax);
231 vout0123 = vmaxq_f32(vout0123, vmin);
232 vst1q_f32(output, vout0123);
233 output = (float*) ((uintptr_t) output + output_stride);
234 } while (--n != 0);
235 output = (float*) ((uintptr_t) output - output_decrement);
236 input += 4;
237 }
238 output_decrement += 2 * sizeof(float);
239 if (mc & (2 * sizeof(float))) {
240 const float* w = weights;
241 const int32_t* dmap = widx_dmap;
242 const uint32_t* nnzmap = nidx_nnzmap;
243 size_t n = nc;
244 do {
245 uint32_t nnz = *nnzmap++;
246 float32x2_t vacc01 = vld1_dup_f32(w); w += 1;
247 if XNN_LIKELY(nnz != 0) {
248 do {
249 const intptr_t diff = *dmap++;
250 const float32x2_t vi01 = vld1_f32(input);
251 input = (const float*) ((uintptr_t) input + (uintptr_t) diff);
252 xnn_prefetch_to_l1(input + 16);
253 xnn_prefetch_to_l1(input + 32);
254 const float32x2_t vb = vld1_dup_f32(w); w += 1;
255 xnn_prefetch_to_l1(w + 32);
256 vacc01 = vmla_f32(vacc01, vi01, vb);
257 } while (--nnz != 0);
258 }
259 float32x2_t vout01 = vmin_f32(vacc01, vget_low_f32(vmax));
260 vout01 = vmax_f32(vout01, vget_low_f32(vmin));
261 vst1_f32(output, vout01);
262 output = (float*) ((uintptr_t) output + output_stride);
263 } while (--n != 0);
264 output = (float*) ((uintptr_t) output - output_decrement);
265 input += 2;
266 }
267 output_decrement += 1 * sizeof(float);
268 if (mc & (1 * sizeof(float))) {
269 const float* w = weights;
270 const int32_t* dmap = widx_dmap;
271 const uint32_t* nnzmap = nidx_nnzmap;
272 size_t n = nc;
273 do {
274 uint32_t nnz = *nnzmap++;
275 float32x2_t vacc0 = vld1_dup_f32(w); w += 1;
276 if XNN_LIKELY(nnz != 0) {
277 do {
278 const intptr_t diff = *dmap++;
279 const float32x2_t vi0 = vld1_dup_f32(input);
280 input = (const float*) ((uintptr_t) input + (uintptr_t) diff);
281 xnn_prefetch_to_l1(input + 16);
282 xnn_prefetch_to_l1(input + 32);
283 const float32x2_t vb = vld1_dup_f32(w); w += 1;
284 xnn_prefetch_to_l1(w + 32);
285 vacc0 = vmla_f32(vacc0, vi0, vb);
286 } while (--nnz != 0);
287 }
288 float32x2_t vout0 = vmin_f32(vacc0, vget_low_f32(vmax));
289 vout0 = vmax_f32(vout0, vget_low_f32(vmin));
290 vst1_lane_f32(output, vout0, 0);
291 output = (float*) ((uintptr_t) output + output_stride);
292 } while (--n != 0);
293 output = (float*) ((uintptr_t) output - output_decrement);
294 input += 1;
295 }
296 }
297 }