Debian Codegraph @

src/f32-vclamp/gen/f32-vclamp-rvv-u4v.c

raw
1 // Auto-generated file. Do not edit!
2 // Template: src/f32-vclamp/rvv.c.in
3 // Generator: tools/xngen
4 //
5 // Copyright 2023 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 <riscv_vector.h>
13
14 #include "xnnpack/common.h"
15 #include "xnnpack/intrinsics-polyfill.h"
16 #include "xnnpack/vunary.h"
17
18
19 void xnn_f32_vclamp_ukernel__rvv_u4v(
20 size_t batch,
21 const float* input,
22 float* output,
23 const union xnn_f32_minmax_params params[restrict XNN_MIN_ELEMENTS(1)])
24 {
25 assert(batch != 0);
26 assert(batch % sizeof(float) == 0);
27 assert(input != NULL);
28 assert(output != NULL);
29
30 const float vmin = params->scalar.min;
31 const float vmax = params->scalar.max;
32
33 batch >>= XNN_LOG2_SIZEOF_FLOAT;
34 do {
35 const size_t n = __riscv_vsetvl_e32m4(batch);
36 vfloat32m4_t vacc = __riscv_vle32_v_f32m4(input, n);
37 input += n;
38 vacc = __riscv_vfmax_vf_f32m4(vacc, vmin, n);
39 vacc = __riscv_vfmin_vf_f32m4(vacc, vmax, n);
40 __riscv_vse32_v_f32m4(output, vacc, n);
41 output += n;
42
43 batch -= n;
44 } while (batch != 0);
45 }