Debian Codegraph @

src/f32-velu/gen/f32-velu-scalar-rr2-p6-u1.c

raw symbols SCIP
1 // Auto-generated file. Do not edit!
2 // Template: src/f32-velu/scalar-rr2-p6.c.in
3 // Generator: tools/xngen
4 //
5 // Copyright 2020 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/math.h"
15 #include "xnnpack/vunary.h"
16
17
18 void xnn_f32_velu_ukernel__scalar_rr2_p6_u1(
19 size_t batch,
20 const float* input,
21 float* output,
22 const struct xnn_f32_elu_params params[restrict XNN_MIN_ELEMENTS(1)])
23 {
24 assert(batch != 0);
25 assert(batch % sizeof(float) == 0);
26 assert(input != NULL);
27 assert(output != NULL);
28
29 const float vsat_cutoff = -0x1.154246p+4f;
30 const float vmagic_bias = 0x1.8000FEp23f;
31 const float vlog2e = 0x1.715476p+0f;
32 const float vminus_ln2_hi = -0x1.62E440p-1f;
33 const float vminus_ln2_lo = 0x1.0105C6p-21f;
34 const float vc6 = 0x1.6b7338p-10f;
35 const float vc5 = 0x1.12278Ep-7f;
36 const float vc4 = 0x1.555716p-5f;
37 const float vc3 = 0x1.5554B0p-3f;
38 const float vc2 = 0x1.FFFFFEp-2f;
39 const float vone = 1.0f;
40
41 const float vprescale = params->scalar.prescale;
42 const float valpha = params->scalar.alpha;
43 const float vbeta = params->scalar.beta;
44
45 do {
46 float vx = *input++;
47
48 const float vz = vx * vprescale;
49
50 float vn = vz * vlog2e + vmagic_bias;
51 float vs = uint32_as_float(float_as_uint32(vn) << 23);
52 vn -= vmagic_bias;
53
54 float vt = vn * vminus_ln2_hi + vz;
55 vt = vn * vminus_ln2_lo + vt;
56
57 if XNN_UNPREDICTABLE(vz <= vsat_cutoff) {
58 vs = 0.0f;
59 vt = 0.0f;
60 }
61
62 float vp = vc6 * vt + vc5;
63 vp = vp * vt + vc4;
64 vp = vp * vt + vc3;
65 vp = vp * vt + vc2;
66 vp *= vt;
67
68 vt *= vs;
69 vs -= vone;
70 vp = vp * vt + vt;
71 const float ve = (vp + vs) * valpha;
72
73 float vy = vx * vbeta;
74 if XNN_UNPREDICTABLE(vx < 0.0f) {
75 vy = ve;
76 }
77
78 *output++ = vy;
79
80 batch -= sizeof(float);
81 } while (batch != 0);
82 }