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