Debian Codegraph @

src/f32-vrsqrt/gen/f32-vrsqrt-scalar-rsqrt-u4.c

raw
1 // Auto-generated file. Do not edit!
2 // Template: src/f32-vrsqrt/scalar-rsqrt.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 <math.h>
12
13 #include "xnnpack/common.h"
14 #include "xnnpack/vunary.h"
15
16
17 void xnn_f32_vrsqrt_ukernel__scalar_rsqrt_u4(
18 size_t batch,
19 const float* input,
20 float* output,
21 const struct xnn_f32_default_params params[restrict XNN_MIN_ELEMENTS(1)])
22 {
23 assert(batch != 0);
24 assert(batch % sizeof(float) == 0);
25 assert(input != NULL);
26 assert(output != NULL);
27
28 for (; batch >= 4 * sizeof(float); batch -= 4 * sizeof(float)) {
29 const float vx0 = input[0];
30 const float vx1 = input[1];
31 const float vx2 = input[2];
32 const float vx3 = input[3];
33 input += 4;
34
35 const float vt0 = sqrtf(vx0);
36 const float vt1 = sqrtf(vx1);
37 const float vt2 = sqrtf(vx2);
38 const float vt3 = sqrtf(vx3);
39 const float vy0 = 1.0f / vt0;
40 const float vy1 = 1.0f / vt1;
41 const float vy2 = 1.0f / vt2;
42 const float vy3 = 1.0f / vt3;
43
44 output[0] = vy0;
45 output[1] = vy1;
46 output[2] = vy2;
47 output[3] = vy3;
48 output += 4;
49 }
50 if XNN_UNLIKELY(batch != 0) {
51 do {
52 const float vx = *input++;
53 const float vy = 1.0f / sqrtf(vx);
54 *output++ = vy;
55 batch -= sizeof(float);
56 } while (batch != 0);
57 }
58 }