Debian Codegraph @

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

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