1 // Auto-generated file. Do not edit! 2 // Template: src/f32-vsigmoid/scalar-rr2-p5-div.c.in 3 // Generator: tools/xngen 4 // 5 // Copyright 2019 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 #include <fp16/bitcasts.h> 17 18 xnn_f32_vsigmoid_ukernel__scalar_rr2_p5_div_x1(size_t n,const float * x,float * y,const union xnn_f32_sigmoid_params params[restrict XNN_MIN_ELEMENTS (1)])19void xnn_f32_vsigmoid_ukernel__scalar_rr2_p5_div_x1( 20 size_t n, 21 const float* x, 22 float* y, 23 const union xnn_f32_sigmoid_params params[restrict XNN_MIN_ELEMENTS(1)]) 24 { 25 assert(n % sizeof(float) == 0); 26 27 const float vmagic_bias = params->scalar_rr2_p5.magic_bias; 28 const float vminus_log2e = params->scalar_rr2_p5.minus_log2e; 29 const float vln2_hi = params->scalar_rr2_p5.ln2_hi; 30 const float vln2_lo = params->scalar_rr2_p5.ln2_lo; 31 const float vc5 = params->scalar_rr2_p5.c5; 32 const float vc4 = params->scalar_rr2_p5.c4; 33 const float vc3 = params->scalar_rr2_p5.c3; 34 const float vc2 = params->scalar_rr2_p5.c2; 35 const float vc1 = params->scalar_rr2_p5.c1; 36 const float vone = params->scalar_rr2_p5.one; 37 const float vdenorm_cutoff = params->scalar_rr2_p5.denorm_cutoff; 38 39 do { 40 const float vx = *x++; 41 42 const float vz = fabsf(vx); 43 44 float vn = vz * vminus_log2e + vmagic_bias; 45 const float vs = fp32_from_bits(fp32_to_bits(vn) << 23); 46 vn -= vmagic_bias; 47 48 float vt = vn * vln2_hi + vz; 49 vt = vn * vln2_lo + vt; 50 51 float vp = vt * vc5 + vc4; 52 vp = vt * vp + vc3; 53 vp = vt * vp + vc2; 54 vp = vt * vp + vc1; 55 56 vt *= vs; 57 const float ve = vt * vp + vs; 58 const float vd = ve + vone; 59 60 float vf = ve / vd; 61 if XNN_UNPREDICTABLE(vz > vdenorm_cutoff) { 62 vf = 0.0f; 63 } 64 if XNN_UNPREDICTABLE(vx > 0.0f) { 65 vf = vone - vf; 66 } 67 68 *y++ = vf; 69 70 n -= sizeof(float); 71 } while (n != 0); 72 } 73