Debian Codegraph @

src/f32-igemm/gen/f32-igemm-1x4v-minmax-rvv.c

raw
1 // Auto-generated file. Do not edit!
2 // Template: src/f32-igemm/MRxNRv-rvv.c.in
3 // Generator: tools/xngen
4 //
5 // Copyright 2024 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
12 #include <riscv_vector.h>
13
14 #include "xnnpack/igemm.h"
15
16
17 void xnn_f32_igemm_minmax_ukernel_1x4v__rvv(
18 size_t mr,
19 size_t nc,
20 size_t kc,
21 size_t ks,
22 const float** restrict a,
23 const float* restrict w,
24 float* restrict c,
25 size_t cm_stride,
26 size_t cn_stride,
27 size_t a_offset,
28 const float* zero,
29 const union xnn_f32_minmax_params params[restrict XNN_MIN_ELEMENTS(1)])
30 {
31 assert(mr != 0);
32 assert(mr <= 1);
33 assert(nc != 0);
34 assert(kc != 0);
35 assert(kc % sizeof(float) == 0);
36 assert(ks != 0);
37 assert(ks % (1 * sizeof(void*)) == 0);
38 assert(a_offset % sizeof(float) == 0);
39 assert(a != NULL);
40 assert(w != NULL);
41 assert(c != NULL);
42
43 const float vmin = params->scalar.min;
44 const float vmax = params->scalar.max;
45 float* c0 = c;
46
47 const size_t nr = __riscv_vsetvlmax_e32m4();
48 size_t vl = nr;
49 do {
50 if XNN_UNLIKELY(nc < nr) {
51 vl = __riscv_vsetvl_e32m4(nc);
52 }
53 nc = nc - vl;
54 vfloat32m4_t vacc0 = __riscv_vle32_v_f32m4(w, vl);
55 w = w + nr;
56
57 size_t p = ks;
58 do {
59 const float* restrict a0 = a[0];
60 assert(a0 != NULL);
61 if XNN_UNPREDICTABLE(a0 != zero) {
62 a0 = (const float*) ((uintptr_t) a0 + a_offset);
63 }
64 a += 1;
65
66 size_t k = kc;
67 do {
68 const float va0 = *a0++;
69 vfloat32m4_t vb = __riscv_vle32_v_f32m4(w, vl);
70 w = w + nr;
71 vacc0 = __riscv_vfmacc_vf_f32m4(vacc0, va0, vb, vl);
72
73 k -= sizeof(float);
74 } while (k != 0);
75 p -= 1 * sizeof(void*);
76 } while (p != 0);
77 // clamp results with min & max
78 vacc0 = __riscv_vfmax_vf_f32m4(vacc0, vmin, vl);
79
80 vacc0 = __riscv_vfmin_vf_f32m4(vacc0, vmax, vl);
81 // store 1 x vl results to c
82 __riscv_vse32_v_f32m4(c0, vacc0, vl);
83 c0 = (float*) ((uintptr_t) c0 + cn_stride);
84
85 a = (const float**restrict) ((uintptr_t) a - ks);
86 } while (nc != 0);
87 }