Debian Codegraph @

src/s32-f32-vcvt/gen/s32-f32-vcvt-avx512f.c

raw symbols SCIP
1 // Auto-generated file. Do not edit!
2 // Template: src/s32-f32-vcvt/simd.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
11 #include <assert.h>
12 #include <stddef.h>
13
14 #include "xnnpack/simd/f32-avx512f.h"
15 #include "xnnpack/simd/s32-avx512f.h"
16
17 #include "xnnpack/common.h"
18 #include "xnnpack/microparams.h"
19
20
21 void xnn_s32_f32_vcvt_ukernel__avx512f_u16(
22 size_t batch,
23 const int32_t* input,
24 float* output,
25 const struct xnn_s32_f32_cvt_params params[restrict XNN_MIN_ELEMENTS(1)])
26 {
27 assert(batch != 0);
28 assert(batch % sizeof(float) == 0);
29 assert(input != NULL);
30 assert(output != NULL);
31 assert(xnn_simd_size_f32 == 16);
32 assert(xnn_simd_size_s32 == 16);
33
34 const xnn_simd_s32_t sub = xnn_set1_s32(params->scalar.zero_point);
35
36
37 for (; batch >= xnn_simd_bytes_s32; batch -= xnn_simd_bytes_s32) {
38 const xnn_simd_s32_t vx = xnn_loadu_s32(input);
39 input += xnn_simd_size_f32;
40
41 const xnn_simd_f32_t vy = xnn_cvt_f32_s32(xnn_sub_s32(vx, sub));
42
43 xnn_storeu_f32(output, vy);
44 output += xnn_simd_size_f32;
45 }
46
47 if (batch != 0) {
48 const xnn_simd_s32_t vx =
49 xnn_load_tail_s32(input, batch >> XNN_LOG2_SIZEOF_INT32_T);
50
51 const xnn_simd_f32_t vy = xnn_cvt_f32_s32(xnn_sub_s32(vx, sub));
52
53 xnn_store_tail_f32(output, vy, batch >> XNN_LOG2_SIZEOF_FLOAT);
54 }
55 }
56
57 void xnn_s32_f32_vcvt_ukernel__avx512f_u32(
58 size_t batch,
59 const int32_t* input,
60 float* output,
61 const struct xnn_s32_f32_cvt_params params[restrict XNN_MIN_ELEMENTS(1)])
62 {
63 assert(batch != 0);
64 assert(batch % sizeof(float) == 0);
65 assert(input != NULL);
66 assert(output != NULL);
67 assert(xnn_simd_size_f32 == 16);
68 assert(xnn_simd_size_s32 == 16);
69
70 const xnn_simd_s32_t sub = xnn_set1_s32(params->scalar.zero_point);
71
72 for (; batch >= 32 * sizeof(int32_t); batch -= 32 * sizeof(int32_t)) {
73 const xnn_simd_s32_t vx0 = xnn_loadu_s32(input);
74 const xnn_simd_s32_t vx1 = xnn_loadu_s32(input + 1 * xnn_simd_size_s32);
75 input += 2 * xnn_simd_size_s32;
76
77 const xnn_simd_f32_t vy0 = xnn_cvt_f32_s32(xnn_sub_s32(vx0, sub));
78 const xnn_simd_f32_t vy1 = xnn_cvt_f32_s32(xnn_sub_s32(vx1, sub));
79
80 xnn_storeu_f32(output, vy0);
81 xnn_storeu_f32(output + 1 * xnn_simd_size_f32, vy1);
82 output += 2 * xnn_simd_size_f32;
83 }
84
85 for (; batch >= xnn_simd_bytes_s32; batch -= xnn_simd_bytes_s32) {
86 const xnn_simd_s32_t vx = xnn_loadu_s32(input);
87 input += xnn_simd_size_f32;
88
89 const xnn_simd_f32_t vy = xnn_cvt_f32_s32(xnn_sub_s32(vx, sub));
90
91 xnn_storeu_f32(output, vy);
92 output += xnn_simd_size_f32;
93 }
94
95 if (batch != 0) {
96 const xnn_simd_s32_t vx =
97 xnn_load_tail_s32(input, batch >> XNN_LOG2_SIZEOF_INT32_T);
98
99 const xnn_simd_f32_t vy = xnn_cvt_f32_s32(xnn_sub_s32(vx, sub));
100
101 xnn_store_tail_f32(output, vy, batch >> XNN_LOG2_SIZEOF_FLOAT);
102 }
103 }
104
105 void xnn_s32_f32_vcvt_ukernel__avx512f_u48(
106 size_t batch,
107 const int32_t* input,
108 float* output,
109 const struct xnn_s32_f32_cvt_params params[restrict XNN_MIN_ELEMENTS(1)])
110 {
111 assert(batch != 0);
112 assert(batch % sizeof(float) == 0);
113 assert(input != NULL);
114 assert(output != NULL);
115 assert(xnn_simd_size_f32 == 16);
116 assert(xnn_simd_size_s32 == 16);
117
118 const xnn_simd_s32_t sub = xnn_set1_s32(params->scalar.zero_point);
119
120 for (; batch >= 48 * sizeof(int32_t); batch -= 48 * sizeof(int32_t)) {
121 const xnn_simd_s32_t vx0 = xnn_loadu_s32(input);
122 const xnn_simd_s32_t vx1 = xnn_loadu_s32(input + 1 * xnn_simd_size_s32);
123 const xnn_simd_s32_t vx2 = xnn_loadu_s32(input + 2 * xnn_simd_size_s32);
124 input += 3 * xnn_simd_size_s32;
125
126 const xnn_simd_f32_t vy0 = xnn_cvt_f32_s32(xnn_sub_s32(vx0, sub));
127 const xnn_simd_f32_t vy1 = xnn_cvt_f32_s32(xnn_sub_s32(vx1, sub));
128 const xnn_simd_f32_t vy2 = xnn_cvt_f32_s32(xnn_sub_s32(vx2, sub));
129
130 xnn_storeu_f32(output, vy0);
131 xnn_storeu_f32(output + 1 * xnn_simd_size_f32, vy1);
132 xnn_storeu_f32(output + 2 * xnn_simd_size_f32, vy2);
133 output += 3 * xnn_simd_size_f32;
134 }
135
136 for (; batch >= xnn_simd_bytes_s32; batch -= xnn_simd_bytes_s32) {
137 const xnn_simd_s32_t vx = xnn_loadu_s32(input);
138 input += xnn_simd_size_f32;
139
140 const xnn_simd_f32_t vy = xnn_cvt_f32_s32(xnn_sub_s32(vx, sub));
141
142 xnn_storeu_f32(output, vy);
143 output += xnn_simd_size_f32;
144 }
145
146 if (batch != 0) {
147 const xnn_simd_s32_t vx =
148 xnn_load_tail_s32(input, batch >> XNN_LOG2_SIZEOF_INT32_T);
149
150 const xnn_simd_f32_t vy = xnn_cvt_f32_s32(xnn_sub_s32(vx, sub));
151
152 xnn_store_tail_f32(output, vy, batch >> XNN_LOG2_SIZEOF_FLOAT);
153 }
154 }
155
156 void xnn_s32_f32_vcvt_ukernel__avx512f_u64(
157 size_t batch,
158 const int32_t* input,
159 float* output,
160 const struct xnn_s32_f32_cvt_params params[restrict XNN_MIN_ELEMENTS(1)])
161 {
162 assert(batch != 0);
163 assert(batch % sizeof(float) == 0);
164 assert(input != NULL);
165 assert(output != NULL);
166 assert(xnn_simd_size_f32 == 16);
167 assert(xnn_simd_size_s32 == 16);
168
169 const xnn_simd_s32_t sub = xnn_set1_s32(params->scalar.zero_point);
170
171 for (; batch >= 64 * sizeof(int32_t); batch -= 64 * sizeof(int32_t)) {
172 const xnn_simd_s32_t vx0 = xnn_loadu_s32(input);
173 const xnn_simd_s32_t vx1 = xnn_loadu_s32(input + 1 * xnn_simd_size_s32);
174 const xnn_simd_s32_t vx2 = xnn_loadu_s32(input + 2 * xnn_simd_size_s32);
175 const xnn_simd_s32_t vx3 = xnn_loadu_s32(input + 3 * xnn_simd_size_s32);
176 input += 4 * xnn_simd_size_s32;
177
178 const xnn_simd_f32_t vy0 = xnn_cvt_f32_s32(xnn_sub_s32(vx0, sub));
179 const xnn_simd_f32_t vy1 = xnn_cvt_f32_s32(xnn_sub_s32(vx1, sub));
180 const xnn_simd_f32_t vy2 = xnn_cvt_f32_s32(xnn_sub_s32(vx2, sub));
181 const xnn_simd_f32_t vy3 = xnn_cvt_f32_s32(xnn_sub_s32(vx3, sub));
182
183 xnn_storeu_f32(output, vy0);
184 xnn_storeu_f32(output + 1 * xnn_simd_size_f32, vy1);
185 xnn_storeu_f32(output + 2 * xnn_simd_size_f32, vy2);
186 xnn_storeu_f32(output + 3 * xnn_simd_size_f32, vy3);
187 output += 4 * xnn_simd_size_f32;
188 }
189
190 for (; batch >= xnn_simd_bytes_s32; batch -= xnn_simd_bytes_s32) {
191 const xnn_simd_s32_t vx = xnn_loadu_s32(input);
192 input += xnn_simd_size_f32;
193
194 const xnn_simd_f32_t vy = xnn_cvt_f32_s32(xnn_sub_s32(vx, sub));
195
196 xnn_storeu_f32(output, vy);
197 output += xnn_simd_size_f32;
198 }
199
200 if (batch != 0) {
201 const xnn_simd_s32_t vx =
202 xnn_load_tail_s32(input, batch >> XNN_LOG2_SIZEOF_INT32_T);
203
204 const xnn_simd_f32_t vy = xnn_cvt_f32_s32(xnn_sub_s32(vx, sub));
205
206 xnn_store_tail_f32(output, vy, batch >> XNN_LOG2_SIZEOF_FLOAT);
207 }
208 }