Debian Codegraph @

src/f16-f32acc-rsum/gen/f16-f32acc-rsum-neonfp16arith-u8.c

raw
1 // Auto-generated file. Do not edit!
2 // Template: src/f16-f32acc-rsum/neonfp16arith.c.in
3 // Generator: tools/xngen
4 //
5 // Copyright 2023 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 <arm_neon.h>
13
14 #include "xnnpack/common.h"
15 #include "xnnpack/reduce.h"
16
17
18 void xnn_f16_f32acc_rsum_ukernel__neonfp16arith_u8(
19 size_t batch,
20 const xnn_float16* input,
21 float* output,
22 const struct xnn_f16_f32acc_scale_params params[restrict XNN_MIN_ELEMENTS(1)])
23 {
24 assert(batch != 0);
25 assert(batch % sizeof(uint16_t) == 0);
26 assert(input != NULL);
27 assert(output != NULL);
28
29 const uint16_t* i = (const uint16_t*) input;
30 float32x4_t vacc0 = vmovq_n_f32(0.0f);
31 for (; batch >= 4 * sizeof(uint16_t); batch -= 4 * sizeof(uint16_t)) {
32 const float16x4_t vh = vreinterpret_f16_u16(vld1_u16(i)); i += 4;
33 const float32x4_t vt = vcvt_f32_f16(vh);
34 vacc0 = vaddq_f32(vacc0, vt);
35 }
36 const float32x2_t vscale = vld1_dup_f32(&params->scalar.scale);
37 float32x2_t vacc = vadd_f32(vget_low_f32(vacc0), vget_high_f32(vacc0));
38 if XNN_UNLIKELY(batch & (2 * sizeof(uint16_t))) {
39 const float16x4_t vh = vreinterpret_f16_u32(vld1_dup_u32((const void*) i)); i += 2;
40 const float32x4_t vt = vcvt_f32_f16(vh);
41 vacc = vadd_f32(vacc, vget_low_f32(vt));
42 }
43 vacc = vpadd_f32(vacc, vacc);
44 if XNN_UNLIKELY(batch & (1 * sizeof(uint16_t))) {
45 const float16x4_t vh = vreinterpret_f16_u16(vld1_dup_u16(i));
46 const float32x4_t vt = vcvt_f32_f16(vh);
47 vacc = vadd_f32(vacc, vget_low_f32(vt));
48 }
49 vacc = vmul_f32(vacc, vscale);
50
51 float vout = vget_lane_f32(vacc, 0);
52 *output += vout;
53 }