Debian Codegraph @

src/f16-vrnd/gen/f16-vrndd-neonfp16arith-u16.c

raw symbols SCIP
1 // Auto-generated file. Do not edit!
2 // Template: src/f16-vrnd/neonfp16arith.c.in
3 // Generator: tools/xngen
4 //
5 // Copyright 2022 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/math.h"
16 #include "xnnpack/vunary.h"
17
18
19 void xnn_f16_vrndd_ukernel__neonfp16arith_u16(
20 size_t batch,
21 const xnn_float16* input,
22 xnn_float16* output,
23 const struct xnn_f16_default_params params[restrict XNN_MIN_ELEMENTS(1)]) XNN_OOB_READS
24 {
25 assert(batch != 0);
26 assert(batch % sizeof(uint16_t) == 0);
27 assert(input != NULL);
28 assert(output != NULL);
29
30 const uint16_t* i = (const uint16_t*) input;
31 uint16_t* o = (uint16_t*) output;
32 for (; batch >= 16 * sizeof(uint16_t); batch -= 16 * sizeof(uint16_t)) {
33 float16x8_t vacc0 = vreinterpretq_f16_u16(vld1q_u16(i)); i += 8;
34 float16x8_t vacc1 = vreinterpretq_f16_u16(vld1q_u16(i)); i += 8;
35
36 vacc0 = vrndmq_f16(vacc0);
37 vacc1 = vrndmq_f16(vacc1);
38
39 vst1q_u16(o, vreinterpretq_u16_f16(vacc0)); o += 8;
40 vst1q_u16(o, vreinterpretq_u16_f16(vacc1)); o += 8;
41 }
42 for (; batch >= 8 * sizeof(uint16_t); batch -= 8 * sizeof(uint16_t)) {
43 float16x8_t vacc = vreinterpretq_f16_u16(vld1q_u16(i)); i += 8;
44 vacc = vrndmq_f16(vacc);
45 vst1q_u16(o, vreinterpretq_u16_f16(vacc)); o += 8;
46 }
47 if XNN_UNLIKELY(batch != 0) {
48 float16x8_t vacc = vreinterpretq_f16_u16(vld1q_u16(i));
49 vacc = vrndmq_f16(vacc);
50 float16x4_t vacc_lo = vget_low_f16(vacc);
51 if (batch & (4 * sizeof(uint16_t))) {
52 vst1_u16(o, vreinterpret_u16_f16(vacc_lo)); o += 4;
53 vacc_lo = vget_high_f16(vacc);
54 }
55 if (batch & (2 * sizeof(uint16_t))) {
56 vst1_lane_u32((void*) o, vreinterpret_u32_f16(vacc_lo), 0); o += 2;
57 vacc_lo = vext_f16(vacc_lo, vacc_lo, 2);
58 }
59 if (batch & (1 * sizeof(uint16_t))) {
60 vst1_lane_u16(o, vreinterpret_u16_f16(vacc_lo), 0);
61 }
62 }
63 }