1 // Auto-generated file. Do not edit!
2 // Template: src/f32-igemm/neon-shuffle.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 #include <assert.h>
11
12 #include <arm_neon.h>
13
14 #include <xnnpack/igemm.h>
15
16
xnn_f32_igemm_minmax_ukernel_1x8s4__neonfma(size_t mr,size_t nc,size_t kc,size_t ks,const float ** restrict a,const float * restrict w,float * restrict c,size_t cm_stride,size_t cn_stride,size_t a_offset,const float * zero,const union xnn_f32_minmax_params params[restrict XNN_MIN_ELEMENTS (1)])17 void xnn_f32_igemm_minmax_ukernel_1x8s4__neonfma(
18 size_t mr,
19 size_t nc,
20 size_t kc,
21 size_t ks,
22 const float**restrict a,
23 const float*restrict w,
24 float*restrict c,
25 size_t cm_stride,
26 size_t cn_stride,
27 size_t a_offset,
28 const float* zero,
29 const union xnn_f32_minmax_params params[restrict XNN_MIN_ELEMENTS(1)]) XNN_OOB_READS
30 {
31 assert(mr != 0);
32 assert(mr <= 1);
33 assert(nc != 0);
34 assert(kc != 0);
35 assert(kc % sizeof(float) == 0);
36 assert(ks != 0);
37 assert(ks % (1 * sizeof(void*)) == 0);
38 assert(a_offset % sizeof(float) == 0);
39 assert(a != NULL);
40 assert(w != NULL);
41 assert(c != NULL);
42
43 float* c0 = c;
44
45 do {
46 float32x4_t vacc0x0123 = vld1q_f32(w); w += 4;
47 float32x4_t vacc0x4567 = vld1q_f32(w); w += 4;
48
49 size_t p = ks;
50 do {
51 const float* restrict a0 = a[0];
52 assert(a0 != NULL);
53 if XNN_UNPREDICTABLE(a0 != zero) {
54 a0 = (const float*) ((uintptr_t) a0 + a_offset);
55 }
56 a += 1;
57
58 size_t k = kc;
59 while (k >= 4 * sizeof(float)) {
60 float32x4_t va0 = vld1q_f32(a0); a0 += 4;
61
62
63 const float32x4_t vb0123c0 = vld1q_f32(w + 0);
64 const float32x4_t vb4567c0 = vld1q_f32(w + 4);
65
66 vacc0x0123 = vfmaq_f32(vacc0x0123, va0, vb0123c0);
67 vacc0x4567 = vfmaq_f32(vacc0x4567, va0, vb4567c0);
68
69 va0 = vextq_f32(va0, va0, 1);
70
71 const float32x4_t vb0123c1 = vld1q_f32(w + 8);
72 const float32x4_t vb4567c1 = vld1q_f32(w + 12);
73
74 vacc0x0123 = vfmaq_f32(vacc0x0123, va0, vb0123c1);
75 vacc0x4567 = vfmaq_f32(vacc0x4567, va0, vb4567c1);
76
77 va0 = vextq_f32(va0, va0, 1);
78
79 const float32x4_t vb0123c2 = vld1q_f32(w + 16);
80 const float32x4_t vb4567c2 = vld1q_f32(w + 20);
81
82 vacc0x0123 = vfmaq_f32(vacc0x0123, va0, vb0123c2);
83 vacc0x4567 = vfmaq_f32(vacc0x4567, va0, vb4567c2);
84
85 va0 = vextq_f32(va0, va0, 1);
86
87 const float32x4_t vb0123c3 = vld1q_f32(w + 24);
88 const float32x4_t vb4567c3 = vld1q_f32(w + 28);
89
90 vacc0x0123 = vfmaq_f32(vacc0x0123, va0, vb0123c3);
91 vacc0x4567 = vfmaq_f32(vacc0x4567, va0, vb4567c3);
92
93
94 w += 32;
95 k -= 4 * sizeof(float);
96 }
97 if XNN_UNLIKELY(k != 0) {
98 float32x4_t va0 = vld1q_f32(a0); a0 = (const float*) ((uintptr_t) a0 + k);
99
100
101 const float32x4_t vb0123c0 = vld1q_f32(w); w += 4;
102 const float32x4_t vb4567c0 = vld1q_f32(w); w += 4;
103
104 const float32x4_t vmska0x0123c0 = vreinterpretq_f32_u32(vbicq_u32(vreinterpretq_u32_f32(va0), vceqq_f32(vb0123c0, vmovq_n_f32(0.0f))));
105 vacc0x0123 = vfmaq_f32(vacc0x0123, vmska0x0123c0, vb0123c0);
106 const float32x4_t vmska0x4567c0 = vreinterpretq_f32_u32(vbicq_u32(vreinterpretq_u32_f32(va0), vceqq_f32(vb4567c0, vmovq_n_f32(0.0f))));
107 vacc0x4567 = vfmaq_f32(vacc0x4567, vmska0x4567c0, vb4567c0);
108
109 va0 = vextq_f32(va0, va0, 1);
110
111 const float32x4_t vb0123c1 = vld1q_f32(w); w += 4;
112 const float32x4_t vb4567c1 = vld1q_f32(w); w += 4;
113
114 const float32x4_t vmska0x0123c1 = vreinterpretq_f32_u32(vbicq_u32(vreinterpretq_u32_f32(va0), vceqq_f32(vb0123c1, vmovq_n_f32(0.0f))));
115 vacc0x0123 = vfmaq_f32(vacc0x0123, vmska0x0123c1, vb0123c1);
116 const float32x4_t vmska0x4567c1 = vreinterpretq_f32_u32(vbicq_u32(vreinterpretq_u32_f32(va0), vceqq_f32(vb4567c1, vmovq_n_f32(0.0f))));
117 vacc0x4567 = vfmaq_f32(vacc0x4567, vmska0x4567c1, vb4567c1);
118
119 va0 = vextq_f32(va0, va0, 1);
120
121 const float32x4_t vb0123c2 = vld1q_f32(w); w += 4;
122 const float32x4_t vb4567c2 = vld1q_f32(w); w += 4;
123
124 const float32x4_t vmska0x0123c2 = vreinterpretq_f32_u32(vbicq_u32(vreinterpretq_u32_f32(va0), vceqq_f32(vb0123c2, vmovq_n_f32(0.0f))));
125 vacc0x0123 = vfmaq_f32(vacc0x0123, vmska0x0123c2, vb0123c2);
126 const float32x4_t vmska0x4567c2 = vreinterpretq_f32_u32(vbicq_u32(vreinterpretq_u32_f32(va0), vceqq_f32(vb4567c2, vmovq_n_f32(0.0f))));
127 vacc0x4567 = vfmaq_f32(vacc0x4567, vmska0x4567c2, vb4567c2);
128
129 va0 = vextq_f32(va0, va0, 1);
130
131 const float32x4_t vb0123c3 = vld1q_f32(w); w += 4;
132 const float32x4_t vb4567c3 = vld1q_f32(w); w += 4;
133
134 const float32x4_t vmska0x0123c3 = vreinterpretq_f32_u32(vbicq_u32(vreinterpretq_u32_f32(va0), vceqq_f32(vb0123c3, vmovq_n_f32(0.0f))));
135 vacc0x0123 = vfmaq_f32(vacc0x0123, vmska0x0123c3, vb0123c3);
136 const float32x4_t vmska0x4567c3 = vreinterpretq_f32_u32(vbicq_u32(vreinterpretq_u32_f32(va0), vceqq_f32(vb4567c3, vmovq_n_f32(0.0f))));
137 vacc0x4567 = vfmaq_f32(vacc0x4567, vmska0x4567c3, vb4567c3);
138
139 }
140
141 p -= 1 * sizeof(void*);
142 } while (p != 0);
143
144 const float32x4_t vmax = vld1q_dup_f32(¶ms->scalar.max);
145 vacc0x0123 = vminq_f32(vacc0x0123, vmax);
146 vacc0x4567 = vminq_f32(vacc0x4567, vmax);
147
148 const float32x4_t vmin = vld1q_dup_f32(¶ms->scalar.min);
149 vacc0x0123 = vmaxq_f32(vacc0x0123, vmin);
150 vacc0x4567 = vmaxq_f32(vacc0x4567, vmin);
151
152 if XNN_LIKELY(nc >= 8) {
153 vst1q_f32(c0, vacc0x0123);
154 vst1q_f32(c0 + 4, vacc0x4567);
155 c0 = (float*) ((uintptr_t) c0 + cn_stride);
156
157 a = (const float**restrict) ((uintptr_t) a - ks);
158 nc -= 8;
159 } else {
160 if (nc & 4) {
161 vst1q_f32(c0, vacc0x0123); c0 += 4;
162
163 vacc0x0123 = vacc0x4567;
164 }
165 float32x2_t vacc0x01 = vget_low_f32(vacc0x0123);
166 if (nc & 2) {
167 vst1_f32(c0, vacc0x01); c0 += 2;
168
169 vacc0x01 = vget_high_f32(vacc0x0123);
170 }
171 if (nc & 1) {
172 vst1_lane_f32(c0, vacc0x01, 0);
173 }
174
175 nc = 0;
176 }
177 } while (nc != 0);
178 }
179