1 // Auto-generated file. Do not edit! 2 // Template: src/f32-vlrelu/scalar.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 12 #include <xnnpack/common.h> 13 #include <xnnpack/vunary.h> 14 15 xnn_f32_vlrelu_ukernel__scalar_x2(size_t n,const float * x,float * y,const union xnn_f32_lrelu_params params[restrict XNN_MIN_ELEMENTS (1)])16void xnn_f32_vlrelu_ukernel__scalar_x2( 17 size_t n, 18 const float* x, 19 float* y, 20 const union xnn_f32_lrelu_params params[restrict XNN_MIN_ELEMENTS(1)]) 21 { 22 assert(n != 0); 23 assert(n % sizeof(float) == 0); 24 25 const float vslope = params->scalar.slope; 26 27 for (; n >= 2 * sizeof(float); n -= 2 * sizeof(float)) { 28 const float vx0 = x[0]; 29 const float vx1 = x[1]; 30 x += 2; 31 32 float vacc0 = vx0 * vslope; 33 float vacc1 = vx1 * vslope; 34 35 vacc0 = XNN_UNPREDICTABLE(vx0 < 0.0f) ? vacc0 : vx0; 36 vacc1 = XNN_UNPREDICTABLE(vx1 < 0.0f) ? vacc1 : vx1; 37 38 y[0] = vacc0; 39 y[1] = vacc1; 40 y += 2; 41 } 42 if XNN_UNLIKELY(n != 0) { 43 const float vx = *x; 44 float vacc = vx * vslope; 45 vacc = XNN_UNPREDICTABLE(vx < 0.0f) ? vacc : vx; 46 *y = vacc; 47 } 48 } 49