Debian Codegraph @

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

raw
1 // Auto-generated file. Do not edit!
2 // Template: src/f32-vcopysign/rcopysignc.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_vrcopysignc_ukernel__scalar_u1(
22 size_t batch,
23 const float* sign,
24 const float* mag,
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(sign != NULL);
31 assert(mag != NULL);
32 assert(output != NULL);
33 assert(xnn_simd_size_f32 == 1);
34
35 XNN_SIMD_CONST_F32(vsign_mask, -0.f);
36 xnn_simd_f32_t vmag = xnn_abs_f32(xnn_set1_f32(*mag));
37
38 for (; batch >= xnn_simd_bytes_f32; batch -= xnn_simd_bytes_f32) {
39 xnn_simd_f32_t vsign = xnn_loadu_f32(sign);
40 sign += xnn_simd_size_f32;
41
42 vsign = xnn_and_f32(vsign, vsign_mask);
43
44 xnn_simd_f32_t vy = xnn_or_f32(vsign, vmag);
45
46 xnn_storeu_f32(output, vy);
47 output += xnn_simd_size_f32;
48 }
49 }
50
51 void xnn_f32_vrcopysignc_ukernel__scalar_u2(
52 size_t batch,
53 const float* sign,
54 const float* mag,
55 float* output,
56 const struct xnn_f32_default_params unused_params[restrict XNN_MIN_ELEMENTS(1)])
57 {
58 assert(batch != 0);
59 assert(batch % sizeof(float) == 0);
60 assert(sign != NULL);
61 assert(mag != NULL);
62 assert(output != NULL);
63 assert(xnn_simd_size_f32 == 1);
64
65 XNN_SIMD_CONST_F32(vsign_mask, -0.f);
66 xnn_simd_f32_t vmag = xnn_abs_f32(xnn_set1_f32(*mag));
67
68 for (; batch >= 2 * sizeof(float); batch -= 2 * sizeof(float)) {
69 xnn_simd_f32_t vsign_0 = xnn_loadu_f32(sign);
70 xnn_simd_f32_t vsign_1 = xnn_loadu_f32(sign + 1 * xnn_simd_size_f32);
71 sign += 2;
72
73 vsign_0 = xnn_and_f32(vsign_0, vsign_mask);
74 vsign_1 = xnn_and_f32(vsign_1, vsign_mask);
75
76 xnn_simd_f32_t vy_0 = xnn_or_f32(vsign_0, vmag);
77 xnn_simd_f32_t vy_1 = xnn_or_f32(vsign_1, vmag);
78
79 xnn_storeu_f32(output, vy_0);
80 xnn_storeu_f32(output + 1 * xnn_simd_size_f32, vy_1);
81 output += 2;
82 }
83 for (; batch >= xnn_simd_bytes_f32; batch -= xnn_simd_bytes_f32) {
84 xnn_simd_f32_t vsign = xnn_loadu_f32(sign);
85 sign += xnn_simd_size_f32;
86
87 vsign = xnn_and_f32(vsign, vsign_mask);
88
89 xnn_simd_f32_t vy = xnn_or_f32(vsign, vmag);
90
91 xnn_storeu_f32(output, vy);
92 output += xnn_simd_size_f32;
93 }
94 }
95
96 void xnn_f32_vrcopysignc_ukernel__scalar_u4(
97 size_t batch,
98 const float* sign,
99 const float* mag,
100 float* output,
101 const struct xnn_f32_default_params unused_params[restrict XNN_MIN_ELEMENTS(1)])
102 {
103 assert(batch != 0);
104 assert(batch % sizeof(float) == 0);
105 assert(sign != NULL);
106 assert(mag != NULL);
107 assert(output != NULL);
108 assert(xnn_simd_size_f32 == 1);
109
110 XNN_SIMD_CONST_F32(vsign_mask, -0.f);
111 xnn_simd_f32_t vmag = xnn_abs_f32(xnn_set1_f32(*mag));
112
113 for (; batch >= 4 * sizeof(float); batch -= 4 * sizeof(float)) {
114 xnn_simd_f32_t vsign_0 = xnn_loadu_f32(sign);
115 xnn_simd_f32_t vsign_1 = xnn_loadu_f32(sign + 1 * xnn_simd_size_f32);
116 xnn_simd_f32_t vsign_2 = xnn_loadu_f32(sign + 2 * xnn_simd_size_f32);
117 xnn_simd_f32_t vsign_3 = xnn_loadu_f32(sign + 3 * xnn_simd_size_f32);
118 sign += 4;
119
120 vsign_0 = xnn_and_f32(vsign_0, vsign_mask);
121 vsign_1 = xnn_and_f32(vsign_1, vsign_mask);
122 vsign_2 = xnn_and_f32(vsign_2, vsign_mask);
123 vsign_3 = xnn_and_f32(vsign_3, vsign_mask);
124
125 xnn_simd_f32_t vy_0 = xnn_or_f32(vsign_0, vmag);
126 xnn_simd_f32_t vy_1 = xnn_or_f32(vsign_1, vmag);
127 xnn_simd_f32_t vy_2 = xnn_or_f32(vsign_2, vmag);
128 xnn_simd_f32_t vy_3 = xnn_or_f32(vsign_3, vmag);
129
130 xnn_storeu_f32(output, vy_0);
131 xnn_storeu_f32(output + 1 * xnn_simd_size_f32, vy_1);
132 xnn_storeu_f32(output + 2 * xnn_simd_size_f32, vy_2);
133 xnn_storeu_f32(output + 3 * xnn_simd_size_f32, vy_3);
134 output += 4;
135 }
136 for (; batch >= xnn_simd_bytes_f32; batch -= xnn_simd_bytes_f32) {
137 xnn_simd_f32_t vsign = xnn_loadu_f32(sign);
138 sign += xnn_simd_size_f32;
139
140 vsign = xnn_and_f32(vsign, vsign_mask);
141
142 xnn_simd_f32_t vy = xnn_or_f32(vsign, vmag);
143
144 xnn_storeu_f32(output, vy);
145 output += xnn_simd_size_f32;
146 }
147 }
148
149 void xnn_f32_vrcopysignc_ukernel__scalar_u8(
150 size_t batch,
151 const float* sign,
152 const float* mag,
153 float* output,
154 const struct xnn_f32_default_params unused_params[restrict XNN_MIN_ELEMENTS(1)])
155 {
156 assert(batch != 0);
157 assert(batch % sizeof(float) == 0);
158 assert(sign != NULL);
159 assert(mag != NULL);
160 assert(output != NULL);
161 assert(xnn_simd_size_f32 == 1);
162
163 XNN_SIMD_CONST_F32(vsign_mask, -0.f);
164 xnn_simd_f32_t vmag = xnn_abs_f32(xnn_set1_f32(*mag));
165
166 for (; batch >= 8 * sizeof(float); batch -= 8 * sizeof(float)) {
167 xnn_simd_f32_t vsign_0 = xnn_loadu_f32(sign);
168 xnn_simd_f32_t vsign_1 = xnn_loadu_f32(sign + 1 * xnn_simd_size_f32);
169 xnn_simd_f32_t vsign_2 = xnn_loadu_f32(sign + 2 * xnn_simd_size_f32);
170 xnn_simd_f32_t vsign_3 = xnn_loadu_f32(sign + 3 * xnn_simd_size_f32);
171 xnn_simd_f32_t vsign_4 = xnn_loadu_f32(sign + 4 * xnn_simd_size_f32);
172 xnn_simd_f32_t vsign_5 = xnn_loadu_f32(sign + 5 * xnn_simd_size_f32);
173 xnn_simd_f32_t vsign_6 = xnn_loadu_f32(sign + 6 * xnn_simd_size_f32);
174 xnn_simd_f32_t vsign_7 = xnn_loadu_f32(sign + 7 * xnn_simd_size_f32);
175 sign += 8;
176
177 vsign_0 = xnn_and_f32(vsign_0, vsign_mask);
178 vsign_1 = xnn_and_f32(vsign_1, vsign_mask);
179 vsign_2 = xnn_and_f32(vsign_2, vsign_mask);
180 vsign_3 = xnn_and_f32(vsign_3, vsign_mask);
181 vsign_4 = xnn_and_f32(vsign_4, vsign_mask);
182 vsign_5 = xnn_and_f32(vsign_5, vsign_mask);
183 vsign_6 = xnn_and_f32(vsign_6, vsign_mask);
184 vsign_7 = xnn_and_f32(vsign_7, vsign_mask);
185
186 xnn_simd_f32_t vy_0 = xnn_or_f32(vsign_0, vmag);
187 xnn_simd_f32_t vy_1 = xnn_or_f32(vsign_1, vmag);
188 xnn_simd_f32_t vy_2 = xnn_or_f32(vsign_2, vmag);
189 xnn_simd_f32_t vy_3 = xnn_or_f32(vsign_3, vmag);
190 xnn_simd_f32_t vy_4 = xnn_or_f32(vsign_4, vmag);
191 xnn_simd_f32_t vy_5 = xnn_or_f32(vsign_5, vmag);
192 xnn_simd_f32_t vy_6 = xnn_or_f32(vsign_6, vmag);
193 xnn_simd_f32_t vy_7 = xnn_or_f32(vsign_7, vmag);
194
195 xnn_storeu_f32(output, vy_0);
196 xnn_storeu_f32(output + 1 * xnn_simd_size_f32, vy_1);
197 xnn_storeu_f32(output + 2 * xnn_simd_size_f32, vy_2);
198 xnn_storeu_f32(output + 3 * xnn_simd_size_f32, vy_3);
199 xnn_storeu_f32(output + 4 * xnn_simd_size_f32, vy_4);
200 xnn_storeu_f32(output + 5 * xnn_simd_size_f32, vy_5);
201 xnn_storeu_f32(output + 6 * xnn_simd_size_f32, vy_6);
202 xnn_storeu_f32(output + 7 * xnn_simd_size_f32, vy_7);
203 output += 8;
204 }
205 for (; batch >= xnn_simd_bytes_f32; batch -= xnn_simd_bytes_f32) {
206 xnn_simd_f32_t vsign = xnn_loadu_f32(sign);
207 sign += xnn_simd_size_f32;
208
209 vsign = xnn_and_f32(vsign, vsign_mask);
210
211 xnn_simd_f32_t vy = xnn_or_f32(vsign, vmag);
212
213 xnn_storeu_f32(output, vy);
214 output += xnn_simd_size_f32;
215 }
216 }