Debian Codegraph @

src/f16-vclamp/gen/f16-vclamp-rvvfp16arith-u4v.c

raw
1 // Auto-generated file. Do not edit!
2 // Template: src/f16-vclamp/rvvfp16arith.c.in
3 // Generator: tools/xngen
4 //
5 // Copyright 2024 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/vunary.h"
16
17
18 void xnn_f16_vclamp_ukernel__rvvfp16arith_u4v(
19 size_t batch,
20 const xnn_float16* input,
21 xnn_float16* output,
22 const union xnn_f16_minmax_params params[restrict XNN_MIN_ELEMENTS(1)])
23 {
24 assert(batch != 0);
25 assert(batch % sizeof(_Float16) == 0);
26 assert(input != NULL);
27 assert(output != NULL);
28
29 const uint16_t* i = (const uint16_t*) input;
30 uint16_t* o = (uint16_t*) output;
31
32 const _Float16 vmin = *(const _Float16*) &params->scalar.min;
33 const _Float16 vmax = *(const _Float16*) &params->scalar.max;
34
35 batch >>= XNN_LOG2_SIZEOF_HALF;
36 do {
37 const size_t n = __riscv_vsetvl_e16m4(batch);
38 vfloat16m4_t vacc = __riscv_vle16_v_f16m4((const void*) i, n);
39 i += n;
40 vacc = __riscv_vfmax_vf_f16m4(vacc, vmin, n);
41 vacc = __riscv_vfmin_vf_f16m4(vacc, vmax, n);
42 __riscv_vse16_v_f16m4((void*) o, vacc, n);
43 o += n;
44
45 batch -= n;
46 } while (batch != 0);
47 }