Debian Codegraph @

src/f32-ppmm/gen/f32-ppmm-8x8-minmax-neon.c

raw
1 // Auto-generated file. Do not edit!
2 // Template: src/f32-ppmm/neon.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/common.h"
15 #include "xnnpack/ppmm.h"
16
17
18 void xnn_f32_ppmm_minmax_ukernel_8x8__neon(
19 size_t mr,
20 size_t nc,
21 size_t kc,
22 const float* restrict a,
23 const float* restrict w,
24 float* restrict c,
25 size_t cm_stride,
26 size_t cn_stride,
27 const union xnn_f32_minmax_params params[restrict XNN_MIN_ELEMENTS(1)])
28 {
29 assert(mr != 0);
30 assert(mr <= 8);
31 assert(nc != 0);
32 assert(kc != 0);
33 assert(kc % sizeof(float) == 0);
34
35 #if XNN_ARCH_ARM64
36 const float32x4x2_t vminmax = vld2q_dup_f32(&params->scalar.min);
37 const float32x4_t vmin = vminmax.val[0];
38 const float32x4_t vmax = vminmax.val[1];
39 #else
40 const float32x2x2_t vminmax = vld2_dup_f32(&params->scalar.min);
41 const float32x4_t vmin = vcombine_f32(vminmax.val[0], vminmax.val[0]);
42 const float32x4_t vmax = vcombine_f32(vminmax.val[1], vminmax.val[1]);
43 #endif
44
45 float* c0 = c;
46 float* c1 = (float*) ((uintptr_t) c0 + cm_stride);
47 if XNN_UNPREDICTABLE(mr < 2) {
48 c1 = c0;
49 }
50 float* c2 = (float*) ((uintptr_t) c1 + cm_stride);
51 if XNN_UNPREDICTABLE(mr <= 2) {
52 c2 = c1;
53 }
54 float* c3 = (float*) ((uintptr_t) c2 + cm_stride);
55 if XNN_UNPREDICTABLE(mr < 4) {
56 c3 = c2;
57 }
58 float* c4 = (float*) ((uintptr_t) c3 + cm_stride);
59 if XNN_UNPREDICTABLE(mr <= 4) {
60 c4 = c3;
61 }
62 float* c5 = (float*) ((uintptr_t) c4 + cm_stride);
63 if XNN_UNPREDICTABLE(mr < 6) {
64 c5 = c4;
65 }
66 float* c6 = (float*) ((uintptr_t) c5 + cm_stride);
67 if XNN_UNPREDICTABLE(mr <= 6) {
68 c6 = c5;
69 }
70 float* c7 = (float*) ((uintptr_t) c6 + cm_stride);
71 if XNN_UNPREDICTABLE(mr != 8) {
72 c7 = c6;
73 }
74
75
76 do {
77 float32x4_t vacc0x0123 = vld1q_f32(w); w += 4;
78 float32x4_t vacc0x4567 = vld1q_f32(w); w += 4;
79 float32x4_t vacc1x0123 = vacc0x0123;
80 float32x4_t vacc1x4567 = vacc0x4567;
81 float32x4_t vacc2x0123 = vacc0x0123;
82 float32x4_t vacc2x4567 = vacc0x4567;
83 float32x4_t vacc3x0123 = vacc0x0123;
84 float32x4_t vacc3x4567 = vacc0x4567;
85 float32x4_t vacc4x0123 = vacc0x0123;
86 float32x4_t vacc4x4567 = vacc0x4567;
87 float32x4_t vacc5x0123 = vacc0x0123;
88 float32x4_t vacc5x4567 = vacc0x4567;
89 float32x4_t vacc6x0123 = vacc0x0123;
90 float32x4_t vacc6x4567 = vacc0x4567;
91 float32x4_t vacc7x0123 = vacc0x0123;
92 float32x4_t vacc7x4567 = vacc0x4567;
93
94 size_t k = kc;
95 do {
96 const float32x4_t va0123 = vld1q_f32(a); a += 4;
97 const float32x4_t va4567 = vld1q_f32(a); a += 4;
98
99 const float32x4_t vb0123 = vld1q_f32(w); w += 4;
100 const float32x4_t vb4567 = vld1q_f32(w); w += 4;
101
102 vacc0x0123 = vmlaq_lane_f32(vacc0x0123, vb0123, vget_low_f32(va0123), 0);
103 vacc1x0123 = vmlaq_lane_f32(vacc1x0123, vb0123, vget_low_f32(va0123), 1);
104 vacc2x0123 = vmlaq_lane_f32(vacc2x0123, vb0123, vget_high_f32(va0123), 0);
105 vacc3x0123 = vmlaq_lane_f32(vacc3x0123, vb0123, vget_high_f32(va0123), 1);
106 vacc4x0123 = vmlaq_lane_f32(vacc4x0123, vb0123, vget_low_f32(va4567), 0);
107 vacc5x0123 = vmlaq_lane_f32(vacc5x0123, vb0123, vget_low_f32(va4567), 1);
108 vacc6x0123 = vmlaq_lane_f32(vacc6x0123, vb0123, vget_high_f32(va4567), 0);
109 vacc7x0123 = vmlaq_lane_f32(vacc7x0123, vb0123, vget_high_f32(va4567), 1);
110 vacc0x4567 = vmlaq_lane_f32(vacc0x4567, vb4567, vget_low_f32(va0123), 0);
111 vacc1x4567 = vmlaq_lane_f32(vacc1x4567, vb4567, vget_low_f32(va0123), 1);
112 vacc2x4567 = vmlaq_lane_f32(vacc2x4567, vb4567, vget_high_f32(va0123), 0);
113 vacc3x4567 = vmlaq_lane_f32(vacc3x4567, vb4567, vget_high_f32(va0123), 1);
114 vacc4x4567 = vmlaq_lane_f32(vacc4x4567, vb4567, vget_low_f32(va4567), 0);
115 vacc5x4567 = vmlaq_lane_f32(vacc5x4567, vb4567, vget_low_f32(va4567), 1);
116 vacc6x4567 = vmlaq_lane_f32(vacc6x4567, vb4567, vget_high_f32(va4567), 0);
117 vacc7x4567 = vmlaq_lane_f32(vacc7x4567, vb4567, vget_high_f32(va4567), 1);
118
119 k -= sizeof(float);
120 } while (k != 0);
121
122 vacc0x0123 = vminq_f32(vacc0x0123, vmax);
123 vacc1x0123 = vminq_f32(vacc1x0123, vmax);
124 vacc2x0123 = vminq_f32(vacc2x0123, vmax);
125 vacc3x0123 = vminq_f32(vacc3x0123, vmax);
126 vacc4x0123 = vminq_f32(vacc4x0123, vmax);
127 vacc5x0123 = vminq_f32(vacc5x0123, vmax);
128 vacc6x0123 = vminq_f32(vacc6x0123, vmax);
129 vacc7x0123 = vminq_f32(vacc7x0123, vmax);
130 vacc0x4567 = vminq_f32(vacc0x4567, vmax);
131 vacc1x4567 = vminq_f32(vacc1x4567, vmax);
132 vacc2x4567 = vminq_f32(vacc2x4567, vmax);
133 vacc3x4567 = vminq_f32(vacc3x4567, vmax);
134 vacc4x4567 = vminq_f32(vacc4x4567, vmax);
135 vacc5x4567 = vminq_f32(vacc5x4567, vmax);
136 vacc6x4567 = vminq_f32(vacc6x4567, vmax);
137 vacc7x4567 = vminq_f32(vacc7x4567, vmax);
138
139 vacc0x0123 = vmaxq_f32(vacc0x0123, vmin);
140 vacc1x0123 = vmaxq_f32(vacc1x0123, vmin);
141 vacc2x0123 = vmaxq_f32(vacc2x0123, vmin);
142 vacc3x0123 = vmaxq_f32(vacc3x0123, vmin);
143 vacc4x0123 = vmaxq_f32(vacc4x0123, vmin);
144 vacc5x0123 = vmaxq_f32(vacc5x0123, vmin);
145 vacc6x0123 = vmaxq_f32(vacc6x0123, vmin);
146 vacc7x0123 = vmaxq_f32(vacc7x0123, vmin);
147 vacc0x4567 = vmaxq_f32(vacc0x4567, vmin);
148 vacc1x4567 = vmaxq_f32(vacc1x4567, vmin);
149 vacc2x4567 = vmaxq_f32(vacc2x4567, vmin);
150 vacc3x4567 = vmaxq_f32(vacc3x4567, vmin);
151 vacc4x4567 = vmaxq_f32(vacc4x4567, vmin);
152 vacc5x4567 = vmaxq_f32(vacc5x4567, vmin);
153 vacc6x4567 = vmaxq_f32(vacc6x4567, vmin);
154 vacc7x4567 = vmaxq_f32(vacc7x4567, vmin);
155
156 if XNN_LIKELY(nc >= 8) {
157 vst1q_f32(c7, vacc7x0123);
158 vst1q_f32(c7 + 4, vacc7x4567);
159 c7 = (float*) ((uintptr_t) c7 + cn_stride);
160 vst1q_f32(c6, vacc6x0123);
161 vst1q_f32(c6 + 4, vacc6x4567);
162 c6 = (float*) ((uintptr_t) c6 + cn_stride);
163 vst1q_f32(c5, vacc5x0123);
164 vst1q_f32(c5 + 4, vacc5x4567);
165 c5 = (float*) ((uintptr_t) c5 + cn_stride);
166 vst1q_f32(c4, vacc4x0123);
167 vst1q_f32(c4 + 4, vacc4x4567);
168 c4 = (float*) ((uintptr_t) c4 + cn_stride);
169 vst1q_f32(c3, vacc3x0123);
170 vst1q_f32(c3 + 4, vacc3x4567);
171 c3 = (float*) ((uintptr_t) c3 + cn_stride);
172 vst1q_f32(c2, vacc2x0123);
173 vst1q_f32(c2 + 4, vacc2x4567);
174 c2 = (float*) ((uintptr_t) c2 + cn_stride);
175 vst1q_f32(c1, vacc1x0123);
176 vst1q_f32(c1 + 4, vacc1x4567);
177 c1 = (float*) ((uintptr_t) c1 + cn_stride);
178 vst1q_f32(c0, vacc0x0123);
179 vst1q_f32(c0 + 4, vacc0x4567);
180 c0 = (float*) ((uintptr_t) c0 + cn_stride);
181
182 a = (const float*) ((uintptr_t) a - kc * 8);
183
184 nc -= 8;
185 } else {
186 if (nc & 4) {
187 vst1q_f32(c7, vacc7x0123); c7 += 4;
188 vst1q_f32(c6, vacc6x0123); c6 += 4;
189 vst1q_f32(c5, vacc5x0123); c5 += 4;
190 vst1q_f32(c4, vacc4x0123); c4 += 4;
191 vst1q_f32(c3, vacc3x0123); c3 += 4;
192 vst1q_f32(c2, vacc2x0123); c2 += 4;
193 vst1q_f32(c1, vacc1x0123); c1 += 4;
194 vst1q_f32(c0, vacc0x0123); c0 += 4;
195
196 vacc7x0123 = vacc7x4567;
197 vacc6x0123 = vacc6x4567;
198 vacc5x0123 = vacc5x4567;
199 vacc4x0123 = vacc4x4567;
200 vacc3x0123 = vacc3x4567;
201 vacc2x0123 = vacc2x4567;
202 vacc1x0123 = vacc1x4567;
203 vacc0x0123 = vacc0x4567;
204 }
205 float32x2_t vacc7x01 = vget_low_f32(vacc7x0123);
206 float32x2_t vacc6x01 = vget_low_f32(vacc6x0123);
207 float32x2_t vacc5x01 = vget_low_f32(vacc5x0123);
208 float32x2_t vacc4x01 = vget_low_f32(vacc4x0123);
209 float32x2_t vacc3x01 = vget_low_f32(vacc3x0123);
210 float32x2_t vacc2x01 = vget_low_f32(vacc2x0123);
211 float32x2_t vacc1x01 = vget_low_f32(vacc1x0123);
212 float32x2_t vacc0x01 = vget_low_f32(vacc0x0123);
213 if (nc & 2) {
214 vst1_f32(c7, vacc7x01); c7 += 2;
215 vst1_f32(c6, vacc6x01); c6 += 2;
216 vst1_f32(c5, vacc5x01); c5 += 2;
217 vst1_f32(c4, vacc4x01); c4 += 2;
218 vst1_f32(c3, vacc3x01); c3 += 2;
219 vst1_f32(c2, vacc2x01); c2 += 2;
220 vst1_f32(c1, vacc1x01); c1 += 2;
221 vst1_f32(c0, vacc0x01); c0 += 2;
222
223 vacc7x01 = vget_high_f32(vacc7x0123);
224 vacc6x01 = vget_high_f32(vacc6x0123);
225 vacc5x01 = vget_high_f32(vacc5x0123);
226 vacc4x01 = vget_high_f32(vacc4x0123);
227 vacc3x01 = vget_high_f32(vacc3x0123);
228 vacc2x01 = vget_high_f32(vacc2x0123);
229 vacc1x01 = vget_high_f32(vacc1x0123);
230 vacc0x01 = vget_high_f32(vacc0x0123);
231 }
232 if (nc & 1) {
233 vst1_lane_f32(c7, vacc7x01, 0);
234 vst1_lane_f32(c6, vacc6x01, 0);
235 vst1_lane_f32(c5, vacc5x01, 0);
236 vst1_lane_f32(c4, vacc4x01, 0);
237 vst1_lane_f32(c3, vacc3x01, 0);
238 vst1_lane_f32(c2, vacc2x01, 0);
239 vst1_lane_f32(c1, vacc1x01, 0);
240 vst1_lane_f32(c0, vacc0x01, 0);
241 }
242
243 nc = 0;
244 }
245 } while (nc != 0);
246 }