• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Auto-generated file. Do not edit!
2 //   Template: src/f32-vbinary/vopc-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_vmulc_ukernel__wasm_x4(size_t n,const float * a,const float * b,float * y,const union xnn_f32_output_params params[restrict static1])17 void xnn_f32_vmulc_ukernel__wasm_x4(
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   const float vb = *b;
31   for (; n >= 4 * sizeof(float); n -= 4 * sizeof(float)) {
32     const float va0 = a[0];
33     const float va1 = a[1];
34     const float va2 = a[2];
35     const float va3 = a[3];
36     a += 4;
37 
38     float vy0 = va0 * vb;
39     float vy1 = va1 * vb;
40     float vy2 = va2 * vb;
41     float vy3 = va3 * vb;
42 
43     vy0 = __builtin_wasm_max_f32(vy0, vy_min);
44     vy1 = __builtin_wasm_max_f32(vy1, vy_min);
45     vy2 = __builtin_wasm_max_f32(vy2, vy_min);
46     vy3 = __builtin_wasm_max_f32(vy3, vy_min);
47 
48     vy0 = __builtin_wasm_min_f32(vy0, vy_max);
49     vy1 = __builtin_wasm_min_f32(vy1, vy_max);
50     vy2 = __builtin_wasm_min_f32(vy2, vy_max);
51     vy3 = __builtin_wasm_min_f32(vy3, vy_max);
52 
53     y[0] = vy0;
54     y[1] = vy1;
55     y[2] = vy2;
56     y[3] = vy3;
57     y += 4;
58   }
59   if XNN_UNLIKELY(n != 0) {
60     do {
61       const float va = *a++;
62       float vy = va * vb;
63       vy = __builtin_wasm_max_f32(vy, vy_min);
64       vy = __builtin_wasm_min_f32(vy, vy_max);
65       *y++ = vy;
66       n -= sizeof(float);
67     } while (n != 0);
68   }
69 }
70