Debian Codegraph @

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

raw symbols SCIP
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_relu_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 struct xnn_f32_relu_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 = 0.0f;
44 float* c0 = c;
45
46 const size_t nr = __riscv_vsetvlmax_e32m4();
47 size_t vl = nr;
48 do {
49 if XNN_UNLIKELY(nc < nr) {
50 vl = __riscv_vsetvl_e32m4(nc);
51 }
52 nc = nc - vl;
53 vfloat32m4_t vacc0 = __riscv_vle32_v_f32m4(w, vl);
54 w = w + nr;
55
56 size_t p = ks;
57 do {
58 const float* restrict a0 = a[0];
59 assert(a0 != NULL);
60 if XNN_UNPREDICTABLE(a0 != zero) {
61 a0 = (const float*) ((uintptr_t) a0 + a_offset);
62 }
63 a += 1;
64
65 size_t k = kc;
66 do {
67 const float va0 = *a0++;
68 vfloat32m4_t vb = __riscv_vle32_v_f32m4(w, vl);
69 w = w + nr;
70 vacc0 = __riscv_vfmacc_vf_f32m4(vacc0, va0, vb, vl);
71
72 k -= sizeof(float);
73 } while (k != 0);
74 p -= 1 * sizeof(void*);
75 } while (p != 0);
76 // apply ReLU to results
77 vacc0 = __riscv_vfmax_vf_f32m4(vacc0, vmin, vl);
78 // store 1 x vl results to c
79 __riscv_vse32_v_f32m4(c0, vacc0, vl);
80 c0 = (float*) ((uintptr_t) c0 + cn_stride);
81
82 a = (const float**restrict) ((uintptr_t) a - ks);
83 } while (nc != 0);
84 }