Debian Codegraph @

src/f32-rminmax/gen/f32-rminmax-rvv-u1v.c

raw
1 // Auto-generated file. Do not edit!
2 // Template: src/f32-rminmax/rvv.c.in
3 // Generator: tools/xngen
4 //
5 // Copyright 2023 SiFive, Inc.
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 #include <math.h>
12
13 #include <riscv_vector.h>
14
15 #include "xnnpack/common.h"
16 #include "xnnpack/intrinsics-polyfill.h"
17 #include "xnnpack/vunary.h"
18
19
20 void xnn_f32_rminmax_ukernel__rvv_u1v(
21 size_t batch,
22 const float* input,
23 float* output,
24 const struct xnn_f32_default_params params[restrict XNN_MIN_ELEMENTS(1)])
25 {
26 assert(batch != 0);
27 assert(batch % sizeof(float) == 0);
28 assert(input != NULL);
29 assert(output != NULL);
30
31 size_t N = batch >> 2;
32 size_t avl;
33 size_t vl = __riscv_vsetvl_e32m1(N);
34
35 vfloat32m1_t t0 = __riscv_vle32_v_f32m1(input, vl);
36 input += vl;
37 vfloat32m1_t t1 = __riscv_vmv_v_v_f32m1(t0, vl);
38
39 for (avl = N - vl; avl; avl -= vl, input += vl) {
40 vl = __riscv_vsetvl_e32m1(avl);
41 vfloat32m1_t vec = __riscv_vle32_v_f32m1(input, vl);
42 t0 = __riscv_vfmin_vv_f32m1_tu(t0, t0, vec, vl);
43 t1 = __riscv_vfmax_vv_f32m1_tu(t1, t1, vec, vl);
44 }
45
46 vfloat32m1_t fmin = __riscv_vfmv_s_f_f32m1(INFINITY, 1);
47 vfloat32m1_t fmax = __riscv_vfmv_s_f_f32m1(-INFINITY, 1);
48 output[0] = __riscv_vfmv_f_s_f32m1_f32(__riscv_vfredmin_vs_f32m1_f32m1(t0, fmin, N));
49 output[1] = __riscv_vfmv_f_s_f32m1_f32(__riscv_vfredmax_vs_f32m1_f32m1(t1, fmax, N));
50 }