• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Auto-generated file. Do not edit!
2 //   Template: src/f32-vbinary/vop-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_vdiv_ukernel__scalar_x2(size_t n,const float * a,const float * b,float * y,const union xnn_f32_output_params params[restrict static1])17 void xnn_f32_vdiv_ukernel__scalar_x2(
18     size_t n,
19     const float* a,
20     const float* b,
21     float* y,
22     const union xnn_f32_output_params params[restrict static 1])
23 {
24   assert(n != 0);
25   assert(n % sizeof(float) == 0);
26 
27   const float vy_min = params->scalar.min;
28   const float vy_max = params->scalar.max;
29 
30   for (; n >= 2 * sizeof(float); n -= 2 * sizeof(float)) {
31     const float va0 = a[0];
32     const float va1 = a[1];
33     a += 2;
34 
35     const float vb0 = b[0];
36     const float vb1 = b[1];
37     b += 2;
38 
39     float vy0 = va0 / vb0;
40     float vy1 = va1 / vb1;
41 
42     vy0 = math_max_f32(vy0, vy_min);
43     vy1 = math_max_f32(vy1, vy_min);
44 
45     vy0 = math_min_f32(vy0, vy_max);
46     vy1 = math_min_f32(vy1, vy_max);
47 
48     y[0] = vy0;
49     y[1] = vy1;
50     y += 2;
51   }
52   if XNN_UNLIKELY(n != 0) {
53     const float va = *a;
54     const float vb = *b;
55     float vy = va / vb;
56     vy = math_max_f32(vy, vy_min);
57     vy = math_min_f32(vy, vy_max);
58     *y = vy;
59   }
60 }
61