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
17
xnn_f16_igemm_minmax_ukernel_1x8__neonfp16arith_ld64(size_t mr,size_t nc,size_t kc,size_t ks,const void ** restrict a,const void * restrict w,void * restrict c,size_t cm_stride,size_t cn_stride,size_t a_offset,const void * zero,const union xnn_f16_minmax_params params[restrict XNN_MIN_ELEMENTS (1)])18 void xnn_f16_igemm_minmax_ukernel_1x8__neonfp16arith_ld64(
19 size_t mr,
20 size_t nc,
21 size_t kc,
22 size_t ks,
23 const void** restrict a,
24 const void* restrict w,
25 void* restrict c,
26 size_t cm_stride,
27 size_t cn_stride,
28 size_t a_offset,
29 const void* zero,
30 const union xnn_f16_minmax_params params[restrict XNN_MIN_ELEMENTS(1)])
31 {
32 assert(mr != 0);
33 assert(mr <= 1);
34 assert(nc != 0);
35 assert(kc != 0);
36 assert(kc % sizeof(__fp16) == 0);
37 assert(ks != 0);
38 assert(ks % (1 * sizeof(void*)) == 0);
39 assert(a_offset % sizeof(__fp16) == 0);
40 assert(a != NULL);
41 assert(w != NULL);
42 assert(c != NULL);
43
44 __fp16* c0 = (__fp16*) c;
45
46 do {
47 float16x8_t vacc0x01234567 = vld1q_f16(w); w = (const void*) ((uintptr_t) w + sizeof(float16x8_t));
48
49 size_t p = ks;
50 do {
51 const __fp16* restrict a0 = (const __fp16*) a[0];
52 assert(a0 != NULL);
53 if XNN_UNPREDICTABLE(a0 != zero) {
54 a0 = (const __fp16*) ((uintptr_t) a0 + a_offset);
55 }
56 a += 1;
57
58 size_t k = kc;
59 for (; k >= 4 * sizeof(__fp16); k -= 4 * sizeof(__fp16)) {
60 const float16x4_t va0 = vld1_f16(a0); a0 += 4;
61
62 const float16x8_t vb01234567c0 = vld1q_f16(w); w = (const void*) ((uintptr_t) w + sizeof(float16x8_t));
63
64 #if XNN_ARCH_ARM64
65 vacc0x01234567 = vfmaq_lane_f16(vacc0x01234567, vb01234567c0, va0, 0);
66 #else
67 const float16x8_t va0c0 = vdupq_lane_f16(va0, 0);
68
69 vacc0x01234567 = vfmaq_f16(vacc0x01234567, va0c0, vb01234567c0);
70 #endif
71 const float16x8_t vb01234567c1 = vld1q_f16(w); w = (const void*) ((uintptr_t) w + sizeof(float16x8_t));
72
73 #if XNN_ARCH_ARM64
74 vacc0x01234567 = vfmaq_lane_f16(vacc0x01234567, vb01234567c1, va0, 1);
75 #else
76 const float16x8_t va0c1 = vdupq_lane_f16(va0, 1);
77
78 vacc0x01234567 = vfmaq_f16(vacc0x01234567, va0c1, vb01234567c1);
79 #endif
80 const float16x8_t vb01234567c2 = vld1q_f16(w); w = (const void*) ((uintptr_t) w + sizeof(float16x8_t));
81
82 #if XNN_ARCH_ARM64
83 vacc0x01234567 = vfmaq_lane_f16(vacc0x01234567, vb01234567c2, va0, 2);
84 #else
85 const float16x8_t va0c2 = vdupq_lane_f16(va0, 2);
86
87 vacc0x01234567 = vfmaq_f16(vacc0x01234567, va0c2, vb01234567c2);
88 #endif
89 const float16x8_t vb01234567c3 = vld1q_f16(w); w = (const void*) ((uintptr_t) w + sizeof(float16x8_t));
90
91 #if XNN_ARCH_ARM64
92 vacc0x01234567 = vfmaq_lane_f16(vacc0x01234567, vb01234567c3, va0, 3);
93 #else
94 const float16x8_t va0c3 = vdupq_lane_f16(va0, 3);
95
96 vacc0x01234567 = vfmaq_f16(vacc0x01234567, va0c3, vb01234567c3);
97 #endif
98 }
99 if XNN_UNLIKELY(k != 0) {
100 do {
101 const float16x8_t va0 = vld1q_dup_f16(a0); a0 += 1;
102
103 const float16x8_t vb01234567 = vld1q_f16(w); w = (const void*) ((uintptr_t) w + sizeof(float16x8_t));
104
105 vacc0x01234567 = vfmaq_f16(vacc0x01234567, va0, vb01234567);
106
107 k -= sizeof(__fp16);
108 } while (k != 0);
109 }
110 p -= 1 * sizeof(void*);
111 } while (p != 0);
112
113
114 const float16x8_t vmax = vreinterpretq_f16_u16(vld1q_dup_u16(¶ms->neon.max));
115 vacc0x01234567 = vminq_f16(vacc0x01234567, vmax);
116
117 const float16x8_t vmin = vreinterpretq_f16_u16(vld1q_dup_u16(¶ms->neon.min));
118 vacc0x01234567 = vmaxq_f16(vacc0x01234567, vmin);
119
120 if XNN_LIKELY(nc >= 8) {
121 vst1q_f16(c0, vacc0x01234567);
122 c0 = (__fp16*) ((uintptr_t) c0 + cn_stride);
123
124 a = (const void**restrict) ((uintptr_t) a - ks);
125 nc -= 8;
126 } else {
127 float16x4_t vacc0x0123 = vget_low_f16(vacc0x01234567);
128 if (nc & 4) {
129 vst1_f16(c0, vacc0x0123); c0 += 4;
130
131 vacc0x0123 = vget_high_f16(vacc0x01234567);
132 }
133 if (nc & 2) {
134 vst1_lane_u32((void*) c0, vreinterpret_u32_f16(vacc0x0123), 0); c0 += 2;
135
136 vacc0x0123 = vext_f16(vacc0x0123, vacc0x0123, 2);
137 }
138 if (nc & 1) {
139 vst1_lane_f16(c0, vacc0x0123, 0);
140 }
141
142 nc = 0;
143 }
144 } while (nc != 0);
145 }
146