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)])
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 do {
99 const float32x4_t va0 = vld1q_dup_f32(a0); a0 += 1;
100
101 const float32x4_t vb0123 = vld1q_f32(w); w += 4;
102 const float32x4_t vb4567 = vld1q_f32(w); w += 4;
103
104 vacc0x0123 = vfmaq_f32(vacc0x0123, va0, vb0123);
105 vacc0x4567 = vfmaq_f32(vacc0x4567, va0, vb4567);
106
107 k -= sizeof(float);
108 } while (k != 0);
109 }
110
111 p -= 1 * sizeof(void*);
112 } while (p != 0);
113
114 const float32x4_t vmax = vld1q_dup_f32(¶ms->scalar.max);
115 vacc0x0123 = vminq_f32(vacc0x0123, vmax);
116 vacc0x4567 = vminq_f32(vacc0x4567, vmax);
117
118 const float32x4_t vmin = vld1q_dup_f32(¶ms->scalar.min);
119 vacc0x0123 = vmaxq_f32(vacc0x0123, vmin);
120 vacc0x4567 = vmaxq_f32(vacc0x4567, vmin);
121
122 if XNN_LIKELY(nc >= 8) {
123 vst1q_f32(c0, vacc0x0123);
124 vst1q_f32(c0 + 4, vacc0x4567);
125 c0 = (float*) ((uintptr_t) c0 + cn_stride);
126
127 a = (const float**restrict) ((uintptr_t) a - ks);
128 nc -= 8;
129 } else {
130 if (nc & 4) {
131 vst1q_f32(c0, vacc0x0123); c0 += 4;
132
133 vacc0x0123 = vacc0x4567;
134 }
135 float32x2_t vacc0x01 = vget_low_f32(vacc0x0123);
136 if (nc & 2) {
137 vst1_f32(c0, vacc0x01); c0 += 2;
138
139 vacc0x01 = vget_high_f32(vacc0x0123);
140 }
141 if (nc & 1) {
142 vst1_lane_f32(c0, vacc0x01, 0);
143 }
144
145 nc = 0;
146 }
147 } while (nc != 0);
148 }
149