Debian Codegraph @

src/f32-avgpool/gen/f32-avgpool-9x-minmax-rvv-c2v.c

raw
1 // Auto-generated file. Do not edit!
2 // Template: src/f32-avgpool/rvv_9x.c.in
3 // Generator: tools/xngen
4 //
5 // Copyright 2024 Imagination Technologies, 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 "xnnpack/avgpool.h"
12 #include <riscv_vector.h>
13
14 void xnn_f32_avgpool_minmax_ukernel_9x__rvv_c2v(
15 size_t output_pixels,
16 size_t kernel_elements,
17 size_t channels,
18 const float** input,
19 size_t input_offset,
20 const float* zero,
21 float* output,
22 size_t input_increment,
23 size_t output_increment,
24 const struct xnn_f32_scaleminmax_params params[restrict XNN_MIN_ELEMENTS(1)])
25 {
26 assert(output_pixels != 0);
27 assert(kernel_elements != 0);
28 assert(kernel_elements <= 9);
29 assert(channels != 0);
30 assert((input_offset & 3) == 0);
31
32 input_offset >>= XNN_LOG2_SIZEOF_FLOAT;
33
34 const float scale = params->scalar.scale;
35 const float min = params->scalar.min;
36 const float max = params->scalar.max;
37
38 do {
39 const float *i[9];
40 for (size_t kk = 0; kk < kernel_elements; ++kk) {
41 assert(input[kk] != NULL);
42 i[kk] = (input[kk] != zero ? input[kk] + input_offset : zero) ;
43 }
44 for (size_t tail = kernel_elements; tail < 9; ++tail) {
45 i[tail] = zero;
46 }
47 input = (const float**) ((uintptr_t) input + input_increment);
48
49 for (size_t c = channels; c != 0; ) {
50 int32_t n = __riscv_vsetvl_e32m2(c);
51
52 vfloat32m2_t i0_f32v = __riscv_vle32_v_f32m2(i[0], n); i[0] += n;
53 vfloat32m2_t i1_f32v = __riscv_vle32_v_f32m2(i[1], n); i[1] += n;
54 vfloat32m2_t i2_f32v = __riscv_vle32_v_f32m2(i[2], n); i[2] += n;
55 vfloat32m2_t i3_f32v = __riscv_vle32_v_f32m2(i[3], n); i[3] += n;
56 vfloat32m2_t i4_f32v = __riscv_vle32_v_f32m2(i[4], n); i[4] += n;
57 vfloat32m2_t i5_f32v = __riscv_vle32_v_f32m2(i[5], n); i[5] += n;
58 vfloat32m2_t i6_f32v = __riscv_vle32_v_f32m2(i[6], n); i[6] += n;
59 vfloat32m2_t i7_f32v = __riscv_vle32_v_f32m2(i[7], n); i[7] += n;
60 vfloat32m2_t i8_f32v = __riscv_vle32_v_f32m2(i[8], n); i[8] += n;
61
62 vfloat32m2_t sum01_f32v = __riscv_vfadd_vv_f32m2(i0_f32v, i1_f32v, n);
63 vfloat32m2_t sum23_f32v = __riscv_vfadd_vv_f32m2(i2_f32v, i3_f32v, n);
64 vfloat32m2_t sum45_f32v = __riscv_vfadd_vv_f32m2(i4_f32v, i5_f32v, n);
65 vfloat32m2_t sum67_f32v = __riscv_vfadd_vv_f32m2(i6_f32v, i7_f32v, n);
66 vfloat32m2_t sum018_f32v = __riscv_vfadd_vv_f32m2(sum01_f32v, i8_f32v, n);
67 vfloat32m2_t sum2345_f32v = __riscv_vfadd_vv_f32m2(sum23_f32v, sum45_f32v, n);
68 vfloat32m2_t sum01678_f32v = __riscv_vfadd_vv_f32m2(sum018_f32v, sum67_f32v, n);
69 vfloat32m2_t sum_f32v = __riscv_vfadd_vv_f32m2(sum2345_f32v, sum01678_f32v, n);
70 vfloat32m2_t out_f32v = __riscv_vfmul_vf_f32m2(sum_f32v, scale, n);
71 out_f32v = __riscv_vfmin_vf_f32m2(__riscv_vfmax_vf_f32m2(out_f32v, min, n), max, n);
72 __riscv_vse32_v_f32m2(output, out_f32v, n); output += n;
73
74 c -= n;
75 }
76 output = (float*) ((uintptr_t) output + output_increment);
77 } while (--output_pixels != 0);
78 }