1 // Auto-generated file. Do not edit! 2 // Template: src/f32-hswish/scalar.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 12 #include <xnnpack/common.h> 13 #include <xnnpack/math.h> 14 #include <xnnpack/vbinary.h> 15 16 xnn_f32_hswish_ukernel__wasm_x1(size_t n,const float * x,float * y,const union xnn_f32_hswish_params params[restrict static1])17void xnn_f32_hswish_ukernel__wasm_x1( 18 size_t n, 19 const float* x, 20 float* y, 21 const union xnn_f32_hswish_params params[restrict static 1]) 22 { 23 assert(n != 0); 24 assert(n % sizeof(float) == 0); 25 26 const float vsixth = params->scalar.sixth; 27 const float vhalf = params->scalar.half; 28 const float vone = params->scalar.one; 29 assert(vhalf == 0.5f); 30 assert(vone == 1.0f); 31 32 for (; n >= sizeof(float); n -= sizeof(float)) { 33 const float vx = *x++; 34 float vacc = vx * vsixth + vhalf; 35 vacc = __builtin_wasm_max_f32(vacc, 0.0f); 36 vacc = __builtin_wasm_min_f32(vacc, vone); 37 vacc = vacc * vx; 38 *y++ = vacc; 39 } 40 } 41