blob: 45164744d06e17e55dbcef07cfa2f0f82849f2b4 [file] [log] [blame]
Marat Dukhan436ebe62019-12-04 15:10:12 -08001// 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
Marat Dukhan91cd2b72020-04-09 23:57:31 -070017void xnn_f32_vadd_minmax_ukernel__wasm_x1(
Marat Dukhan436ebe62019-12-04 15:10:12 -080018 size_t n,
19 const float* a,
20 const float* b,
21 float* y,
Marat Dukhanf196d012020-04-15 11:50:03 -070022 const union xnn_f32_minmax_params params[restrict XNN_MIN_ELEMENTS(1)])
Marat Dukhan436ebe62019-12-04 15:10:12 -080023{
24 assert(n != 0);
25 assert(n % sizeof(float) == 0);
Frank Barchard0822dde2020-07-04 12:47:24 -070026 assert(a != NULL);
27 assert(b != NULL);
28 assert(y != NULL);
Marat Dukhan436ebe62019-12-04 15:10:12 -080029
30 const float vy_min = params->scalar.min;
31 const float vy_max = params->scalar.max;
32
33 for (; n >= sizeof(float); n -= sizeof(float)) {
34 const float va = *a++;
35 const float vb = *b++;
36 float vy = va + vb;
37 vy = __builtin_wasm_max_f32(vy, vy_min);
38 vy = __builtin_wasm_min_f32(vy, vy_max);
39 *y++ = vy;
40 }
41}