Debian Codegraph @

src/f32-vexp/gen/f32-vexp-scalar-exp.c

raw
1 // Auto-generated file. Do not edit!
2 // Template: src/f32-vexp/scalar-exp.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_vexp_ukernel__scalar_exp_u1(
18 size_t batch,
19 const float* input,
20 float* output,
21 const struct xnn_f32_default_params unused_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 >= sizeof(float); batch -= sizeof(float)) {
29 const float vx = *input++;
30 const float vy = expf(vx);
31 *output++ = vy;
32 }
33 }
34
35 void xnn_f32_vexp_ukernel__scalar_exp_u2(
36 size_t batch,
37 const float* input,
38 float* output,
39 const struct xnn_f32_default_params unused_params[restrict XNN_MIN_ELEMENTS(1)])
40 {
41 assert(batch != 0);
42 assert(batch % sizeof(float) == 0);
43 assert(input != NULL);
44 assert(output != NULL);
45
46 for (; batch >= 2 * sizeof(float); batch -= 2 * sizeof(float)) {
47 const float vx0 = input[0];
48 const float vx1 = input[1];
49 input += 2;
50
51 const float vy0 = expf(vx0);
52 const float vy1 = expf(vx1);
53
54 output[0] = vy0;
55 output[1] = vy1;
56 output += 2;
57 }
58 if XNN_UNLIKELY(batch != 0) {
59 const float vx = *input;
60 const float vy = expf(vx);
61 *output = vy;
62 }
63 }
64
65 void xnn_f32_vexp_ukernel__scalar_exp_u4(
66 size_t batch,
67 const float* input,
68 float* output,
69 const struct xnn_f32_default_params unused_params[restrict XNN_MIN_ELEMENTS(1)])
70 {
71 assert(batch != 0);
72 assert(batch % sizeof(float) == 0);
73 assert(input != NULL);
74 assert(output != NULL);
75
76 for (; batch >= 4 * sizeof(float); batch -= 4 * sizeof(float)) {
77 const float vx0 = input[0];
78 const float vx1 = input[1];
79 const float vx2 = input[2];
80 const float vx3 = input[3];
81 input += 4;
82
83 const float vy0 = expf(vx0);
84 const float vy1 = expf(vx1);
85 const float vy2 = expf(vx2);
86 const float vy3 = expf(vx3);
87
88 output[0] = vy0;
89 output[1] = vy1;
90 output[2] = vy2;
91 output[3] = vy3;
92 output += 4;
93 }
94 if XNN_UNLIKELY(batch != 0) {
95 do {
96 const float vx = *input++;
97 const float vy = expf(vx);
98 *output++ = vy;
99 batch -= sizeof(float);
100 } while (batch != 0);
101 }
102 }
103