| 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-avx512f.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__avx512f_u16( |
| 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 == 16); |
| 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 |
if XNN_UNLIKELY(batch != 0) { |
| 52 |
xnn_simd_f32_t vsign = xnn_load_tail_f32(sign, batch >> XNN_LOG2_SIZEOF_FLOAT); |
| 53 |
vsign = xnn_and_f32(vsign, vsign_mask); |
| 54 |
|
| 55 |
xnn_simd_f32_t vmag = xnn_abs_f32(xnn_load_tail_f32(mag, batch >> XNN_LOG2_SIZEOF_FLOAT)); |
| 56 |
|
| 57 |
xnn_simd_f32_t vy = xnn_or_f32(vsign, vmag); |
| 58 |
|
| 59 |
xnn_store_tail_f32(output, vy, batch >> XNN_LOG2_SIZEOF_FLOAT); |
| 60 |
} |
| 61 |
} |
| 62 |
|
| 63 |
void xnn_f32_vcopysign_ukernel__avx512f_u32( |
| 64 |
size_t batch, |
| 65 |
const float* mag, |
| 66 |
const float* sign, |
| 67 |
float* output, |
| 68 |
const struct xnn_f32_default_params unused_params[restrict XNN_MIN_ELEMENTS(1)]) |
| 69 |
{ |
| 70 |
assert(batch != 0); |
| 71 |
assert(batch % sizeof(float) == 0); |
| 72 |
assert(mag != NULL); |
| 73 |
assert(sign != NULL); |
| 74 |
assert(output != NULL); |
| 75 |
assert(xnn_simd_size_f32 == 16); |
| 76 |
|
| 77 |
XNN_SIMD_CONST_F32(vsign_mask, -0.f); |
| 78 |
|
| 79 |
for (; batch >= 32 * sizeof(float); batch -= 32 * sizeof(float)) { |
| 80 |
xnn_simd_f32_t vsign_0 = xnn_loadu_f32(sign); |
| 81 |
xnn_simd_f32_t vsign_1 = xnn_loadu_f32(sign + 1 * xnn_simd_size_f32); |
| 82 |
sign += 32; |
| 83 |
|
| 84 |
vsign_0 = xnn_and_f32(vsign_0, vsign_mask); |
| 85 |
vsign_1 = xnn_and_f32(vsign_1, vsign_mask); |
| 86 |
|
| 87 |
xnn_simd_f32_t vmag_0 = xnn_abs_f32(xnn_loadu_f32(mag)); |
| 88 |
xnn_simd_f32_t vmag_1 = xnn_abs_f32(xnn_loadu_f32(mag + 1 * xnn_simd_size_f32)); |
| 89 |
mag += 32; |
| 90 |
|
| 91 |
xnn_simd_f32_t vy_0 = xnn_or_f32(vsign_0, vmag_0); |
| 92 |
xnn_simd_f32_t vy_1 = xnn_or_f32(vsign_1, vmag_1); |
| 93 |
|
| 94 |
xnn_storeu_f32(output, vy_0); |
| 95 |
xnn_storeu_f32(output + 1 * xnn_simd_size_f32, vy_1); |
| 96 |
output += 32; |
| 97 |
} |
| 98 |
for (; batch >= xnn_simd_bytes_f32; batch -= xnn_simd_bytes_f32) { |
| 99 |
xnn_simd_f32_t vsign = xnn_loadu_f32(sign); |
| 100 |
sign += xnn_simd_size_f32; |
| 101 |
|
| 102 |
vsign = xnn_and_f32(vsign, vsign_mask); |
| 103 |
|
| 104 |
xnn_simd_f32_t vmag = xnn_abs_f32(xnn_loadu_f32(mag)); |
| 105 |
mag += xnn_simd_size_f32; |
| 106 |
|
| 107 |
xnn_simd_f32_t vy = xnn_or_f32(vsign, vmag); |
| 108 |
|
| 109 |
xnn_storeu_f32(output, vy); |
| 110 |
output += xnn_simd_size_f32; |
| 111 |
} |
| 112 |
if XNN_UNLIKELY(batch != 0) { |
| 113 |
xnn_simd_f32_t vsign = xnn_load_tail_f32(sign, batch >> XNN_LOG2_SIZEOF_FLOAT); |
| 114 |
vsign = xnn_and_f32(vsign, vsign_mask); |
| 115 |
|
| 116 |
xnn_simd_f32_t vmag = xnn_abs_f32(xnn_load_tail_f32(mag, batch >> XNN_LOG2_SIZEOF_FLOAT)); |
| 117 |
|
| 118 |
xnn_simd_f32_t vy = xnn_or_f32(vsign, vmag); |
| 119 |
|
| 120 |
xnn_store_tail_f32(output, vy, batch >> XNN_LOG2_SIZEOF_FLOAT); |
| 121 |
} |
| 122 |
} |
| 123 |
|
| 124 |
void xnn_f32_vcopysign_ukernel__avx512f_u48( |
| 125 |
size_t batch, |
| 126 |
const float* mag, |
| 127 |
const float* sign, |
| 128 |
float* output, |
| 129 |
const struct xnn_f32_default_params unused_params[restrict XNN_MIN_ELEMENTS(1)]) |
| 130 |
{ |
| 131 |
assert(batch != 0); |
| 132 |
assert(batch % sizeof(float) == 0); |
| 133 |
assert(mag != NULL); |
| 134 |
assert(sign != NULL); |
| 135 |
assert(output != NULL); |
| 136 |
assert(xnn_simd_size_f32 == 16); |
| 137 |
|
| 138 |
XNN_SIMD_CONST_F32(vsign_mask, -0.f); |
| 139 |
|
| 140 |
for (; batch >= 48 * sizeof(float); batch -= 48 * sizeof(float)) { |
| 141 |
xnn_simd_f32_t vsign_0 = xnn_loadu_f32(sign); |
| 142 |
xnn_simd_f32_t vsign_1 = xnn_loadu_f32(sign + 1 * xnn_simd_size_f32); |
| 143 |
xnn_simd_f32_t vsign_2 = xnn_loadu_f32(sign + 2 * xnn_simd_size_f32); |
| 144 |
sign += 48; |
| 145 |
|
| 146 |
vsign_0 = xnn_and_f32(vsign_0, vsign_mask); |
| 147 |
vsign_1 = xnn_and_f32(vsign_1, vsign_mask); |
| 148 |
vsign_2 = xnn_and_f32(vsign_2, vsign_mask); |
| 149 |
|
| 150 |
xnn_simd_f32_t vmag_0 = xnn_abs_f32(xnn_loadu_f32(mag)); |
| 151 |
xnn_simd_f32_t vmag_1 = xnn_abs_f32(xnn_loadu_f32(mag + 1 * xnn_simd_size_f32)); |
| 152 |
xnn_simd_f32_t vmag_2 = xnn_abs_f32(xnn_loadu_f32(mag + 2 * xnn_simd_size_f32)); |
| 153 |
mag += 48; |
| 154 |
|
| 155 |
xnn_simd_f32_t vy_0 = xnn_or_f32(vsign_0, vmag_0); |
| 156 |
xnn_simd_f32_t vy_1 = xnn_or_f32(vsign_1, vmag_1); |
| 157 |
xnn_simd_f32_t vy_2 = xnn_or_f32(vsign_2, vmag_2); |
| 158 |
|
| 159 |
xnn_storeu_f32(output, vy_0); |
| 160 |
xnn_storeu_f32(output + 1 * xnn_simd_size_f32, vy_1); |
| 161 |
xnn_storeu_f32(output + 2 * xnn_simd_size_f32, vy_2); |
| 162 |
output += 48; |
| 163 |
} |
| 164 |
for (; batch >= xnn_simd_bytes_f32; batch -= xnn_simd_bytes_f32) { |
| 165 |
xnn_simd_f32_t vsign = xnn_loadu_f32(sign); |
| 166 |
sign += xnn_simd_size_f32; |
| 167 |
|
| 168 |
vsign = xnn_and_f32(vsign, vsign_mask); |
| 169 |
|
| 170 |
xnn_simd_f32_t vmag = xnn_abs_f32(xnn_loadu_f32(mag)); |
| 171 |
mag += xnn_simd_size_f32; |
| 172 |
|
| 173 |
xnn_simd_f32_t vy = xnn_or_f32(vsign, vmag); |
| 174 |
|
| 175 |
xnn_storeu_f32(output, vy); |
| 176 |
output += xnn_simd_size_f32; |
| 177 |
} |
| 178 |
if XNN_UNLIKELY(batch != 0) { |
| 179 |
xnn_simd_f32_t vsign = xnn_load_tail_f32(sign, batch >> XNN_LOG2_SIZEOF_FLOAT); |
| 180 |
vsign = xnn_and_f32(vsign, vsign_mask); |
| 181 |
|
| 182 |
xnn_simd_f32_t vmag = xnn_abs_f32(xnn_load_tail_f32(mag, batch >> XNN_LOG2_SIZEOF_FLOAT)); |
| 183 |
|
| 184 |
xnn_simd_f32_t vy = xnn_or_f32(vsign, vmag); |
| 185 |
|
| 186 |
xnn_store_tail_f32(output, vy, batch >> XNN_LOG2_SIZEOF_FLOAT); |
| 187 |
} |
| 188 |
} |
| 189 |
|
| 190 |
void xnn_f32_vcopysign_ukernel__avx512f_u64( |
| 191 |
size_t batch, |
| 192 |
const float* mag, |
| 193 |
const float* sign, |
| 194 |
float* output, |
| 195 |
const struct xnn_f32_default_params unused_params[restrict XNN_MIN_ELEMENTS(1)]) |
| 196 |
{ |
| 197 |
assert(batch != 0); |
| 198 |
assert(batch % sizeof(float) == 0); |
| 199 |
assert(mag != NULL); |
| 200 |
assert(sign != NULL); |
| 201 |
assert(output != NULL); |
| 202 |
assert(xnn_simd_size_f32 == 16); |
| 203 |
|
| 204 |
XNN_SIMD_CONST_F32(vsign_mask, -0.f); |
| 205 |
|
| 206 |
for (; batch >= 64 * sizeof(float); batch -= 64 * sizeof(float)) { |
| 207 |
xnn_simd_f32_t vsign_0 = xnn_loadu_f32(sign); |
| 208 |
xnn_simd_f32_t vsign_1 = xnn_loadu_f32(sign + 1 * xnn_simd_size_f32); |
| 209 |
xnn_simd_f32_t vsign_2 = xnn_loadu_f32(sign + 2 * xnn_simd_size_f32); |
| 210 |
xnn_simd_f32_t vsign_3 = xnn_loadu_f32(sign + 3 * xnn_simd_size_f32); |
| 211 |
sign += 64; |
| 212 |
|
| 213 |
vsign_0 = xnn_and_f32(vsign_0, vsign_mask); |
| 214 |
vsign_1 = xnn_and_f32(vsign_1, vsign_mask); |
| 215 |
vsign_2 = xnn_and_f32(vsign_2, vsign_mask); |
| 216 |
vsign_3 = xnn_and_f32(vsign_3, vsign_mask); |
| 217 |
|
| 218 |
xnn_simd_f32_t vmag_0 = xnn_abs_f32(xnn_loadu_f32(mag)); |
| 219 |
xnn_simd_f32_t vmag_1 = xnn_abs_f32(xnn_loadu_f32(mag + 1 * xnn_simd_size_f32)); |
| 220 |
xnn_simd_f32_t vmag_2 = xnn_abs_f32(xnn_loadu_f32(mag + 2 * xnn_simd_size_f32)); |
| 221 |
xnn_simd_f32_t vmag_3 = xnn_abs_f32(xnn_loadu_f32(mag + 3 * xnn_simd_size_f32)); |
| 222 |
mag += 64; |
| 223 |
|
| 224 |
xnn_simd_f32_t vy_0 = xnn_or_f32(vsign_0, vmag_0); |
| 225 |
xnn_simd_f32_t vy_1 = xnn_or_f32(vsign_1, vmag_1); |
| 226 |
xnn_simd_f32_t vy_2 = xnn_or_f32(vsign_2, vmag_2); |
| 227 |
xnn_simd_f32_t vy_3 = xnn_or_f32(vsign_3, vmag_3); |
| 228 |
|
| 229 |
xnn_storeu_f32(output, vy_0); |
| 230 |
xnn_storeu_f32(output + 1 * xnn_simd_size_f32, vy_1); |
| 231 |
xnn_storeu_f32(output + 2 * xnn_simd_size_f32, vy_2); |
| 232 |
xnn_storeu_f32(output + 3 * xnn_simd_size_f32, vy_3); |
| 233 |
output += 64; |
| 234 |
} |
| 235 |
for (; batch >= xnn_simd_bytes_f32; batch -= xnn_simd_bytes_f32) { |
| 236 |
xnn_simd_f32_t vsign = xnn_loadu_f32(sign); |
| 237 |
sign += xnn_simd_size_f32; |
| 238 |
|
| 239 |
vsign = xnn_and_f32(vsign, vsign_mask); |
| 240 |
|
| 241 |
xnn_simd_f32_t vmag = xnn_abs_f32(xnn_loadu_f32(mag)); |
| 242 |
mag += xnn_simd_size_f32; |
| 243 |
|
| 244 |
xnn_simd_f32_t vy = xnn_or_f32(vsign, vmag); |
| 245 |
|
| 246 |
xnn_storeu_f32(output, vy); |
| 247 |
output += xnn_simd_size_f32; |
| 248 |
} |
| 249 |
if XNN_UNLIKELY(batch != 0) { |
| 250 |
xnn_simd_f32_t vsign = xnn_load_tail_f32(sign, batch >> XNN_LOG2_SIZEOF_FLOAT); |
| 251 |
vsign = xnn_and_f32(vsign, vsign_mask); |
| 252 |
|
| 253 |
xnn_simd_f32_t vmag = xnn_abs_f32(xnn_load_tail_f32(mag, batch >> XNN_LOG2_SIZEOF_FLOAT)); |
| 254 |
|
| 255 |
xnn_simd_f32_t vy = xnn_or_f32(vsign, vmag); |
| 256 |
|
| 257 |
xnn_store_tail_f32(output, vy, batch >> XNN_LOG2_SIZEOF_FLOAT); |
| 258 |
} |
| 259 |
} |