Debian Codegraph @

src/f32-vcopysign/gen/f32-vcopysign-scalar.c

raw
1 // Auto-generated file. Do not edit!
2 // Template: src/f32-vcopysign/copysign.c.in
3 // Generator: tools/xngen
4 //
5 // Copyright 2024 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 #include <stddef.h>
12 #include <stdint.h>
13
14 #include "xnnpack/simd/f32-scalar.h"
15
16 #include "xnnpack/common.h"
17 #include "xnnpack/microparams.h"
18 #include "xnnpack/vunary.h"
19
20
21 void xnn_f32_vcopysign_ukernel__scalar_u1(
22 size_t batch,
23 const float* mag,
24 const float* sign,
25 float* output,
26 const struct xnn_f32_default_params unused_params[restrict XNN_MIN_ELEMENTS(1)])
27 {
28 assert(batch != 0);
29 assert(batch % sizeof(float) == 0);
30 assert(mag != NULL);
31 assert(sign != NULL);
32 assert(output != NULL);
33 assert(xnn_simd_size_f32 == 1);
34
35 XNN_SIMD_CONST_F32(vsign_mask, -0.f);
36
37 for (; batch >= xnn_simd_bytes_f32; batch -= xnn_simd_bytes_f32) {
38 xnn_simd_f32_t vsign = xnn_loadu_f32(sign);
39 sign += xnn_simd_size_f32;
40
41 vsign = xnn_and_f32(vsign, vsign_mask);
42
43 xnn_simd_f32_t vmag = xnn_abs_f32(xnn_loadu_f32(mag));
44 mag += xnn_simd_size_f32;
45
46 xnn_simd_f32_t vy = xnn_or_f32(vsign, vmag);
47
48 xnn_storeu_f32(output, vy);
49 output += xnn_simd_size_f32;
50 }
51 }
52
53 void xnn_f32_vcopysign_ukernel__scalar_u2(
54 size_t batch,
55 const float* mag,
56 const float* sign,
57 float* output,
58 const struct xnn_f32_default_params unused_params[restrict XNN_MIN_ELEMENTS(1)])
59 {
60 assert(batch != 0);
61 assert(batch % sizeof(float) == 0);
62 assert(mag != NULL);
63 assert(sign != NULL);
64 assert(output != NULL);
65 assert(xnn_simd_size_f32 == 1);
66
67 XNN_SIMD_CONST_F32(vsign_mask, -0.f);
68
69 for (; batch >= 2 * sizeof(float); batch -= 2 * sizeof(float)) {
70 xnn_simd_f32_t vsign_0 = xnn_loadu_f32(sign);
71 xnn_simd_f32_t vsign_1 = xnn_loadu_f32(sign + 1 * xnn_simd_size_f32);
72 sign += 2;
73
74 vsign_0 = xnn_and_f32(vsign_0, vsign_mask);
75 vsign_1 = xnn_and_f32(vsign_1, vsign_mask);
76
77 xnn_simd_f32_t vmag_0 = xnn_abs_f32(xnn_loadu_f32(mag));
78 xnn_simd_f32_t vmag_1 = xnn_abs_f32(xnn_loadu_f32(mag + 1 * xnn_simd_size_f32));
79 mag += 2;
80
81 xnn_simd_f32_t vy_0 = xnn_or_f32(vsign_0, vmag_0);
82 xnn_simd_f32_t vy_1 = xnn_or_f32(vsign_1, vmag_1);
83
84 xnn_storeu_f32(output, vy_0);
85 xnn_storeu_f32(output + 1 * xnn_simd_size_f32, vy_1);
86 output += 2;
87 }
88 for (; batch >= xnn_simd_bytes_f32; batch -= xnn_simd_bytes_f32) {
89 xnn_simd_f32_t vsign = xnn_loadu_f32(sign);
90 sign += xnn_simd_size_f32;
91
92 vsign = xnn_and_f32(vsign, vsign_mask);
93
94 xnn_simd_f32_t vmag = xnn_abs_f32(xnn_loadu_f32(mag));
95 mag += xnn_simd_size_f32;
96
97 xnn_simd_f32_t vy = xnn_or_f32(vsign, vmag);
98
99 xnn_storeu_f32(output, vy);
100 output += xnn_simd_size_f32;
101 }
102 }
103
104 void xnn_f32_vcopysign_ukernel__scalar_u4(
105 size_t batch,
106 const float* mag,
107 const float* sign,
108 float* output,
109 const struct xnn_f32_default_params unused_params[restrict XNN_MIN_ELEMENTS(1)])
110 {
111 assert(batch != 0);
112 assert(batch % sizeof(float) == 0);
113 assert(mag != NULL);
114 assert(sign != NULL);
115 assert(output != NULL);
116 assert(xnn_simd_size_f32 == 1);
117
118 XNN_SIMD_CONST_F32(vsign_mask, -0.f);
119
120 for (; batch >= 4 * sizeof(float); batch -= 4 * sizeof(float)) {
121 xnn_simd_f32_t vsign_0 = xnn_loadu_f32(sign);
122 xnn_simd_f32_t vsign_1 = xnn_loadu_f32(sign + 1 * xnn_simd_size_f32);
123 xnn_simd_f32_t vsign_2 = xnn_loadu_f32(sign + 2 * xnn_simd_size_f32);
124 xnn_simd_f32_t vsign_3 = xnn_loadu_f32(sign + 3 * xnn_simd_size_f32);
125 sign += 4;
126
127 vsign_0 = xnn_and_f32(vsign_0, vsign_mask);
128 vsign_1 = xnn_and_f32(vsign_1, vsign_mask);
129 vsign_2 = xnn_and_f32(vsign_2, vsign_mask);
130 vsign_3 = xnn_and_f32(vsign_3, vsign_mask);
131
132 xnn_simd_f32_t vmag_0 = xnn_abs_f32(xnn_loadu_f32(mag));
133 xnn_simd_f32_t vmag_1 = xnn_abs_f32(xnn_loadu_f32(mag + 1 * xnn_simd_size_f32));
134 xnn_simd_f32_t vmag_2 = xnn_abs_f32(xnn_loadu_f32(mag + 2 * xnn_simd_size_f32));
135 xnn_simd_f32_t vmag_3 = xnn_abs_f32(xnn_loadu_f32(mag + 3 * xnn_simd_size_f32));
136 mag += 4;
137
138 xnn_simd_f32_t vy_0 = xnn_or_f32(vsign_0, vmag_0);
139 xnn_simd_f32_t vy_1 = xnn_or_f32(vsign_1, vmag_1);
140 xnn_simd_f32_t vy_2 = xnn_or_f32(vsign_2, vmag_2);
141 xnn_simd_f32_t vy_3 = xnn_or_f32(vsign_3, vmag_3);
142
143 xnn_storeu_f32(output, vy_0);
144 xnn_storeu_f32(output + 1 * xnn_simd_size_f32, vy_1);
145 xnn_storeu_f32(output + 2 * xnn_simd_size_f32, vy_2);
146 xnn_storeu_f32(output + 3 * xnn_simd_size_f32, vy_3);
147 output += 4;
148 }
149 for (; batch >= xnn_simd_bytes_f32; batch -= xnn_simd_bytes_f32) {
150 xnn_simd_f32_t vsign = xnn_loadu_f32(sign);
151 sign += xnn_simd_size_f32;
152
153 vsign = xnn_and_f32(vsign, vsign_mask);
154
155 xnn_simd_f32_t vmag = xnn_abs_f32(xnn_loadu_f32(mag));
156 mag += xnn_simd_size_f32;
157
158 xnn_simd_f32_t vy = xnn_or_f32(vsign, vmag);
159
160 xnn_storeu_f32(output, vy);
161 output += xnn_simd_size_f32;
162 }
163 }
164
165 void xnn_f32_vcopysign_ukernel__scalar_u8(
166 size_t batch,
167 const float* mag,
168 const float* sign,
169 float* output,
170 const struct xnn_f32_default_params unused_params[restrict XNN_MIN_ELEMENTS(1)])
171 {
172 assert(batch != 0);
173 assert(batch % sizeof(float) == 0);
174 assert(mag != NULL);
175 assert(sign != NULL);
176 assert(output != NULL);
177 assert(xnn_simd_size_f32 == 1);
178
179 XNN_SIMD_CONST_F32(vsign_mask, -0.f);
180
181 for (; batch >= 8 * sizeof(float); batch -= 8 * sizeof(float)) {
182 xnn_simd_f32_t vsign_0 = xnn_loadu_f32(sign);
183 xnn_simd_f32_t vsign_1 = xnn_loadu_f32(sign + 1 * xnn_simd_size_f32);
184 xnn_simd_f32_t vsign_2 = xnn_loadu_f32(sign + 2 * xnn_simd_size_f32);
185 xnn_simd_f32_t vsign_3 = xnn_loadu_f32(sign + 3 * xnn_simd_size_f32);
186 xnn_simd_f32_t vsign_4 = xnn_loadu_f32(sign + 4 * xnn_simd_size_f32);
187 xnn_simd_f32_t vsign_5 = xnn_loadu_f32(sign + 5 * xnn_simd_size_f32);
188 xnn_simd_f32_t vsign_6 = xnn_loadu_f32(sign + 6 * xnn_simd_size_f32);
189 xnn_simd_f32_t vsign_7 = xnn_loadu_f32(sign + 7 * xnn_simd_size_f32);
190 sign += 8;
191
192 vsign_0 = xnn_and_f32(vsign_0, vsign_mask);
193 vsign_1 = xnn_and_f32(vsign_1, vsign_mask);
194 vsign_2 = xnn_and_f32(vsign_2, vsign_mask);
195 vsign_3 = xnn_and_f32(vsign_3, vsign_mask);
196 vsign_4 = xnn_and_f32(vsign_4, vsign_mask);
197 vsign_5 = xnn_and_f32(vsign_5, vsign_mask);
198 vsign_6 = xnn_and_f32(vsign_6, vsign_mask);
199 vsign_7 = xnn_and_f32(vsign_7, vsign_mask);
200
201 xnn_simd_f32_t vmag_0 = xnn_abs_f32(xnn_loadu_f32(mag));
202 xnn_simd_f32_t vmag_1 = xnn_abs_f32(xnn_loadu_f32(mag + 1 * xnn_simd_size_f32));
203 xnn_simd_f32_t vmag_2 = xnn_abs_f32(xnn_loadu_f32(mag + 2 * xnn_simd_size_f32));
204 xnn_simd_f32_t vmag_3 = xnn_abs_f32(xnn_loadu_f32(mag + 3 * xnn_simd_size_f32));
205 xnn_simd_f32_t vmag_4 = xnn_abs_f32(xnn_loadu_f32(mag + 4 * xnn_simd_size_f32));
206 xnn_simd_f32_t vmag_5 = xnn_abs_f32(xnn_loadu_f32(mag + 5 * xnn_simd_size_f32));
207 xnn_simd_f32_t vmag_6 = xnn_abs_f32(xnn_loadu_f32(mag + 6 * xnn_simd_size_f32));
208 xnn_simd_f32_t vmag_7 = xnn_abs_f32(xnn_loadu_f32(mag + 7 * xnn_simd_size_f32));
209 mag += 8;
210
211 xnn_simd_f32_t vy_0 = xnn_or_f32(vsign_0, vmag_0);
212 xnn_simd_f32_t vy_1 = xnn_or_f32(vsign_1, vmag_1);
213 xnn_simd_f32_t vy_2 = xnn_or_f32(vsign_2, vmag_2);
214 xnn_simd_f32_t vy_3 = xnn_or_f32(vsign_3, vmag_3);
215 xnn_simd_f32_t vy_4 = xnn_or_f32(vsign_4, vmag_4);
216 xnn_simd_f32_t vy_5 = xnn_or_f32(vsign_5, vmag_5);
217 xnn_simd_f32_t vy_6 = xnn_or_f32(vsign_6, vmag_6);
218 xnn_simd_f32_t vy_7 = xnn_or_f32(vsign_7, vmag_7);
219
220 xnn_storeu_f32(output, vy_0);
221 xnn_storeu_f32(output + 1 * xnn_simd_size_f32, vy_1);
222 xnn_storeu_f32(output + 2 * xnn_simd_size_f32, vy_2);
223 xnn_storeu_f32(output + 3 * xnn_simd_size_f32, vy_3);
224 xnn_storeu_f32(output + 4 * xnn_simd_size_f32, vy_4);
225 xnn_storeu_f32(output + 5 * xnn_simd_size_f32, vy_5);
226 xnn_storeu_f32(output + 6 * xnn_simd_size_f32, vy_6);
227 xnn_storeu_f32(output + 7 * xnn_simd_size_f32, vy_7);
228 output += 8;
229 }
230 for (; batch >= xnn_simd_bytes_f32; batch -= xnn_simd_bytes_f32) {
231 xnn_simd_f32_t vsign = xnn_loadu_f32(sign);
232 sign += xnn_simd_size_f32;
233
234 vsign = xnn_and_f32(vsign, vsign_mask);
235
236 xnn_simd_f32_t vmag = xnn_abs_f32(xnn_loadu_f32(mag));
237 mag += xnn_simd_size_f32;
238
239 xnn_simd_f32_t vy = xnn_or_f32(vsign, vmag);
240
241 xnn_storeu_f32(output, vy);
242 output += xnn_simd_size_f32;
243 }
244 }