Debian Codegraph @

src/f16-igemm/gen/f16-igemm-1x8-minmax-neonfp16arith-ld64.c

raw symbols SCIP
1 // Auto-generated file. Do not edit!
2 // Template: src/f16-igemm/neonfp16arith-ld64.c.in
3 // Generator: tools/xngen
4 //
5 // Copyright 2019 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
11 #include <assert.h>
12
13 #include <arm_neon.h>
14
15 #include "xnnpack/igemm.h"
16 #include "xnnpack/intrinsics-polyfill.h"
17
18
19 void xnn_f16_igemm_minmax_ukernel_1x8__neonfp16arith_ld64(
20 size_t mr,
21 size_t nc,
22 size_t kc,
23 size_t ks,
24 const xnn_float16** restrict a,
25 const xnn_float16* restrict w,
26 xnn_float16* restrict c,
27 size_t cm_stride,
28 size_t cn_stride,
29 size_t a_offset,
30 const xnn_float16* zero,
31 const union xnn_f16_minmax_params params[restrict XNN_MIN_ELEMENTS(1)])
32 {
33 assert(mr != 0);
34 assert(mr <= 1);
35 assert(nc != 0);
36 assert(kc != 0);
37 assert(kc % sizeof(uint16_t) == 0);
38 assert(ks != 0);
39 assert(ks % (1 * sizeof(void*)) == 0);
40 assert(a_offset % sizeof(uint16_t) == 0);
41 assert(a != NULL);
42 assert(w != NULL);
43 assert(c != NULL);
44
45 uint16_t* c0 = (uint16_t*) c;
46
47 do {
48 float16x8_t vacc0x0 = vreinterpretq_f16_u16(vld1q_u16((const uint16_t*) w)); w = (const xnn_float16*) w + 8;
49
50 size_t p = ks;
51 do {
52 const uint16_t* restrict a0 = (const uint16_t*) a[0];
53 assert(a0 != NULL);
54 if XNN_UNPREDICTABLE(a0 != (const uint16_t*) zero) {
55 a0 = (const uint16_t*) ((uintptr_t) a0 + a_offset);
56 }
57 a += 1;
58
59 size_t k = kc;
60 for (; k >= 4 * sizeof(uint16_t); k -= 4 * sizeof(uint16_t)) {
61 const float16x4_t va0 = vreinterpret_f16_u16(vld1_u16(a0)); a0 += 4;
62
63 const float16x8_t vb0c0 = vreinterpretq_f16_u16(vld1q_u16((const uint16_t*) w)); w = (const xnn_float16*) w + 8;
64
65 #if XNN_ARCH_ARM64
66 vacc0x0 = vfmaq_lane_f16(vacc0x0, vb0c0, va0, 0);
67 #else
68 vacc0x0 = vmlaq_lane_f16(vacc0x0, vb0c0, va0, 0);
69 #endif
70 const float16x8_t vb0c1 = vreinterpretq_f16_u16(vld1q_u16((const uint16_t*) w)); w = (const xnn_float16*) w + 8;
71
72 #if XNN_ARCH_ARM64
73 vacc0x0 = vfmaq_lane_f16(vacc0x0, vb0c1, va0, 1);
74 #else
75 vacc0x0 = vmlaq_lane_f16(vacc0x0, vb0c1, va0, 1);
76 #endif
77 const float16x8_t vb0c2 = vreinterpretq_f16_u16(vld1q_u16((const uint16_t*) w)); w = (const xnn_float16*) w + 8;
78
79 #if XNN_ARCH_ARM64
80 vacc0x0 = vfmaq_lane_f16(vacc0x0, vb0c2, va0, 2);
81 #else
82 vacc0x0 = vmlaq_lane_f16(vacc0x0, vb0c2, va0, 2);
83 #endif
84 const float16x8_t vb0c3 = vreinterpretq_f16_u16(vld1q_u16((const uint16_t*) w)); w = (const xnn_float16*) w + 8;
85
86 #if XNN_ARCH_ARM64
87 vacc0x0 = vfmaq_lane_f16(vacc0x0, vb0c3, va0, 3);
88 #else
89 vacc0x0 = vmlaq_lane_f16(vacc0x0, vb0c3, va0, 3);
90 #endif
91 }
92 if XNN_UNLIKELY(k != 0) {
93 do {
94 const float16x8_t va0 = vreinterpretq_f16_u16(vld1q_dup_u16(a0)); a0 += 1;
95
96 const float16x8_t vb0 = vreinterpretq_f16_u16(vld1q_u16((const uint16_t*) w)); w = (const xnn_float16*) w + 8;
97
98 vacc0x0 = vfmaq_f16(vacc0x0, va0, vb0);
99
100 k -= sizeof(uint16_t);
101 } while (k != 0);
102 }
103 p -= 1 * sizeof(void*);
104 } while (p != 0);
105
106
107 const float16x8_t vmin = vreinterpretq_f16_u16(vld1q_dup_u16((const uint16_t*) &params->scalar.min));
108 vacc0x0 = vmaxq_f16(vacc0x0, vmin);
109
110 const float16x8_t vmax = vreinterpretq_f16_u16(vld1q_dup_u16((const uint16_t*) &params->scalar.max));
111 vacc0x0 = vminq_f16(vacc0x0, vmax);
112
113 if XNN_LIKELY(nc >= 8) {
114 vst1q_u16(c0, vreinterpretq_u16_f16(vacc0x0));
115 c0 = (uint16_t*) ((uintptr_t) c0 + cn_stride);
116
117 a = (const xnn_float16**restrict) ((uintptr_t) a - ks);
118 nc -= 8;
119 } else {
120 float16x4_t vacc0 = vget_low_f16(vacc0x0);
121 if (nc & 4) {
122 vst1_u16(c0, vreinterpret_u16_f16(vacc0)); c0 += 4;
123
124 vacc0 = vget_high_f16(vacc0x0);
125 }
126 if (nc & 2) {
127 vst1_lane_u32((void*) c0, vreinterpret_u32_f16(vacc0), 0); c0 += 2;
128
129 vacc0 = vext_f16(vacc0, vacc0, 2);
130 }
131 if (nc & 1) {
132 vst1_lane_u16(c0, vreinterpret_u16_f16(vacc0), 0);
133 }
134
135 nc = 0;
136 }
137 } while (nc != 0);
138 }