• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Auto-generated file. Do not edit!
2 //   Template: src/f32-vunary/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/math.h>
14 #include <xnnpack/vunary.h>
15 
16 
xnn_f32_vsqr_ukernel__scalar_x2(size_t n,const float * x,float * y,const void * params)17 void xnn_f32_vsqr_ukernel__scalar_x2(
18     size_t n,
19     const float* x,
20     float* y,
21     const void* params)
22 {
23   assert(n != 0);
24   assert(n % sizeof(float) == 0);
25   assert(x != NULL);
26   assert(y != NULL);
27 
28   for (; n >= 2 * sizeof(float); n -= 2 * sizeof(float)) {
29     const float vx0 = x[0];
30     const float vx1 = x[1];
31     x += 2;
32 
33     const float vy0 = vx0 * vx0;
34     const float vy1 = vx1 * vx1;
35 
36     y[0] = vy0;
37     y[1] = vy1;
38     y += 2;
39   }
40   if XNN_UNLIKELY(n != 0) {
41     const float vx = *x;
42     const float vy = vx * vx;
43     *y = vy;
44   }
45 }
46