Debian Codegraph @

src/qd8-f16-qc4w-gemm/gen/qd8-f16-qc4w-gemm-7x16c8-minmax-neoni8mm.c

raw
1 // Auto-generated file. Do not edit!
2 // Template: src/qs8-gemm/c8-neoni8mm.c.in
3 // Generator: tools/xngen
4 //
5 // Copyright 2023 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/gemm.h"
15 #include "xnnpack/math.h"
16
17
18 void xnn_qd8_f16_qc4w_gemm_minmax_ukernel_7x16c8__neoni8mm(
19 size_t mr,
20 size_t nc,
21 size_t kc,
22 const int8_t* restrict a,
23 size_t a_stride,
24 const void* restrict w,
25 xnn_float16* restrict c,
26 size_t cm_stride,
27 size_t cn_stride,
28 const struct xnn_f16_qc4w_minmax_params params[restrict XNN_MIN_ELEMENTS(1)],
29 const struct xnn_qd8_quantization_params quantization_params[restrict XNN_MIN_ELEMENTS(1)]) XNN_OOB_READS
30 {
31 assert(mr != 0);
32 assert(mr <= 7);
33 assert(nc != 0);
34 assert(kc != 0);
35 assert(kc % sizeof(int8_t) == 0);
36 assert(a != NULL);
37 assert(w != NULL);
38 assert(c != NULL);
39
40 kc = round_up_po2(kc, 8 * sizeof(int8_t));
41 const int8_t* a0 = a;
42 uint16_t* c0 = (uint16_t*) c;
43 const int8_t* a1 = (const int8_t*) ((uintptr_t) a0 + a_stride);
44 uint16_t* c1 = (uint16_t*) ((uintptr_t) c0 + cm_stride);
45 if XNN_UNPREDICTABLE(mr < 2) {
46 a1 = a0;
47 c1 = c0;
48 }
49 const int8_t* a2 = (const int8_t*) ((uintptr_t) a1 + a_stride);
50 uint16_t* c2 = (uint16_t*) ((uintptr_t) c1 + cm_stride);
51 if XNN_UNPREDICTABLE(mr <= 2) {
52 a2 = a1;
53 c2 = c1;
54 }
55 const int8_t* a3 = (const int8_t*) ((uintptr_t) a2 + a_stride);
56 uint16_t* c3 = (uint16_t*) ((uintptr_t) c2 + cm_stride);
57 if XNN_UNPREDICTABLE(mr < 4) {
58 a3 = a2;
59 c3 = c2;
60 }
61 const int8_t* a4 = (const int8_t*) ((uintptr_t) a3 + a_stride);
62 uint16_t* c4 = (uint16_t*) ((uintptr_t) c3 + cm_stride);
63 if XNN_UNPREDICTABLE(mr <= 4) {
64 a4 = a3;
65 c4 = c3;
66 }
67 const int8_t* a5 = (const int8_t*) ((uintptr_t) a4 + a_stride);
68 uint16_t* c5 = (uint16_t*) ((uintptr_t) c4 + cm_stride);
69 if XNN_UNPREDICTABLE(mr < 6) {
70 a5 = a4;
71 c5 = c4;
72 }
73 const int8_t* a6 = (const int8_t*) ((uintptr_t) a5 + a_stride);
74 uint16_t* c6 = (uint16_t*) ((uintptr_t) c5 + cm_stride);
75 if XNN_UNPREDICTABLE(mr <= 6) {
76 a6 = a5;
77 c6 = c5;
78 }
79 const int8x16_t vmask = vmovq_n_s8(INT8_C(0xF0));
80
81 // Loop over groups of 16 columns.
82 do {
83 // Initialize accumulators with bias. 16 bias values are loaded from the
84 // weight matrix, at the start of the group of 16 columns.
85 const int32x4_t vinput_zero_point01 = vld1q_s32(&quantization_params[0].zero_point);
86 const int32x4_t vksum0123 = vld1q_s32(w); w = (const int32_t*) w + 4;
87 const int32x4_t vksumzp0x0123 = vmulq_lane_s32(vksum0123, vget_low_s32(vinput_zero_point01), 0);
88 const int32x4_t vksumzp1x0123 = vmulq_lane_s32(vksum0123, vget_high_s32(vinput_zero_point01), 0);
89 const int32x4_t vksum4567 = vld1q_s32(w); w = (const int32_t*) w + 4;
90 const int32x4_t vksumzp0x4567 = vmulq_lane_s32(vksum4567, vget_low_s32(vinput_zero_point01), 0);
91 const int32x4_t vksumzp1x4567 = vmulq_lane_s32(vksum4567, vget_high_s32(vinput_zero_point01), 0);
92 const int32x4_t vksum89AB = vld1q_s32(w); w = (const int32_t*) w + 4;
93 const int32x4_t vksumzp0x89AB = vmulq_lane_s32(vksum89AB, vget_low_s32(vinput_zero_point01), 0);
94 const int32x4_t vksumzp1x89AB = vmulq_lane_s32(vksum89AB, vget_high_s32(vinput_zero_point01), 0);
95 const int32x4_t vksumCDEF = vld1q_s32(w); w = (const int32_t*) w + 4;
96 const int32x4_t vksumzp0xCDEF = vmulq_lane_s32(vksumCDEF, vget_low_s32(vinput_zero_point01), 0);
97 const int32x4_t vksumzp1xCDEF = vmulq_lane_s32(vksumCDEF, vget_high_s32(vinput_zero_point01), 0);
98 const int32x4_t vinput_zero_point23 = vld1q_s32(&quantization_params[2].zero_point);
99 const int32x4_t vksumzp2x0123 = vmulq_lane_s32(vksum0123, vget_low_s32(vinput_zero_point23), 0);
100 const int32x4_t vksumzp3x0123 = vmulq_lane_s32(vksum0123, vget_high_s32(vinput_zero_point23), 0);
101 const int32x4_t vksumzp2x4567 = vmulq_lane_s32(vksum4567, vget_low_s32(vinput_zero_point23), 0);
102 const int32x4_t vksumzp3x4567 = vmulq_lane_s32(vksum4567, vget_high_s32(vinput_zero_point23), 0);
103 const int32x4_t vksumzp2x89AB = vmulq_lane_s32(vksum89AB, vget_low_s32(vinput_zero_point23), 0);
104 const int32x4_t vksumzp3x89AB = vmulq_lane_s32(vksum89AB, vget_high_s32(vinput_zero_point23), 0);
105 const int32x4_t vksumzp2xCDEF = vmulq_lane_s32(vksumCDEF, vget_low_s32(vinput_zero_point23), 0);
106 const int32x4_t vksumzp3xCDEF = vmulq_lane_s32(vksumCDEF, vget_high_s32(vinput_zero_point23), 0);
107 const int32x4_t vinput_zero_point45 = vld1q_s32(&quantization_params[4].zero_point);
108 const int32x4_t vksumzp4x0123 = vmulq_lane_s32(vksum0123, vget_low_s32(vinput_zero_point45), 0);
109 const int32x4_t vksumzp5x0123 = vmulq_lane_s32(vksum0123, vget_high_s32(vinput_zero_point45), 0);
110 const int32x4_t vksumzp4x4567 = vmulq_lane_s32(vksum4567, vget_low_s32(vinput_zero_point45), 0);
111 const int32x4_t vksumzp5x4567 = vmulq_lane_s32(vksum4567, vget_high_s32(vinput_zero_point45), 0);
112 const int32x4_t vksumzp4x89AB = vmulq_lane_s32(vksum89AB, vget_low_s32(vinput_zero_point45), 0);
113 const int32x4_t vksumzp5x89AB = vmulq_lane_s32(vksum89AB, vget_high_s32(vinput_zero_point45), 0);
114 const int32x4_t vksumzp4xCDEF = vmulq_lane_s32(vksumCDEF, vget_low_s32(vinput_zero_point45), 0);
115 const int32x4_t vksumzp5xCDEF = vmulq_lane_s32(vksumCDEF, vget_high_s32(vinput_zero_point45), 0);
116 const int32x4_t vinput_zero_point67 = vld1q_dup_s32(&quantization_params[6].zero_point);
117 const int32x4_t vksumzp6x0123 = vmulq_s32(vksum0123, vinput_zero_point67);
118 const int32x4_t vksumzp6x4567 = vmulq_s32(vksum4567, vinput_zero_point67);
119 const int32x4_t vksumzp6x89AB = vmulq_s32(vksum89AB, vinput_zero_point67);
120 const int32x4_t vksumzp6xCDEF = vmulq_s32(vksumCDEF, vinput_zero_point67);
121
122 int32x4_t vacc01x01 = vreinterpretq_s32_u64(vtrn1q_u64(vreinterpretq_u64_s32(vksumzp0x0123), vreinterpretq_u64_s32(vksumzp1x0123)));
123 int32x4_t vacc01x23 = vreinterpretq_s32_u64(vtrn2q_u64(vreinterpretq_u64_s32(vksumzp0x0123), vreinterpretq_u64_s32(vksumzp1x0123)));
124 int32x4_t vacc01x45 = vreinterpretq_s32_u64(vtrn1q_u64(vreinterpretq_u64_s32(vksumzp0x4567), vreinterpretq_u64_s32(vksumzp1x4567)));
125 int32x4_t vacc01x67 = vreinterpretq_s32_u64(vtrn2q_u64(vreinterpretq_u64_s32(vksumzp0x4567), vreinterpretq_u64_s32(vksumzp1x4567)));
126 int32x4_t vacc01x89 = vreinterpretq_s32_u64(vtrn1q_u64(vreinterpretq_u64_s32(vksumzp0x89AB), vreinterpretq_u64_s32(vksumzp1x89AB)));
127 int32x4_t vacc01xAB = vreinterpretq_s32_u64(vtrn2q_u64(vreinterpretq_u64_s32(vksumzp0x89AB), vreinterpretq_u64_s32(vksumzp1x89AB)));
128 int32x4_t vacc01xCD = vreinterpretq_s32_u64(vtrn1q_u64(vreinterpretq_u64_s32(vksumzp0xCDEF), vreinterpretq_u64_s32(vksumzp1xCDEF)));
129 int32x4_t vacc01xEF = vreinterpretq_s32_u64(vtrn2q_u64(vreinterpretq_u64_s32(vksumzp0xCDEF), vreinterpretq_u64_s32(vksumzp1xCDEF)));
130 int32x4_t vacc23x01 = vreinterpretq_s32_u64(vtrn1q_u64(vreinterpretq_u64_s32(vksumzp2x0123), vreinterpretq_u64_s32(vksumzp3x0123)));
131 int32x4_t vacc23x23 = vreinterpretq_s32_u64(vtrn2q_u64(vreinterpretq_u64_s32(vksumzp2x0123), vreinterpretq_u64_s32(vksumzp3x0123)));
132 int32x4_t vacc23x45 = vreinterpretq_s32_u64(vtrn1q_u64(vreinterpretq_u64_s32(vksumzp2x4567), vreinterpretq_u64_s32(vksumzp3x4567)));
133 int32x4_t vacc23x67 = vreinterpretq_s32_u64(vtrn2q_u64(vreinterpretq_u64_s32(vksumzp2x4567), vreinterpretq_u64_s32(vksumzp3x4567)));
134 int32x4_t vacc23x89 = vreinterpretq_s32_u64(vtrn1q_u64(vreinterpretq_u64_s32(vksumzp2x89AB), vreinterpretq_u64_s32(vksumzp3x89AB)));
135 int32x4_t vacc23xAB = vreinterpretq_s32_u64(vtrn2q_u64(vreinterpretq_u64_s32(vksumzp2x89AB), vreinterpretq_u64_s32(vksumzp3x89AB)));
136 int32x4_t vacc23xCD = vreinterpretq_s32_u64(vtrn1q_u64(vreinterpretq_u64_s32(vksumzp2xCDEF), vreinterpretq_u64_s32(vksumzp3xCDEF)));
137 int32x4_t vacc23xEF = vreinterpretq_s32_u64(vtrn2q_u64(vreinterpretq_u64_s32(vksumzp2xCDEF), vreinterpretq_u64_s32(vksumzp3xCDEF)));
138 int32x4_t vacc45x01 = vreinterpretq_s32_u64(vtrn1q_u64(vreinterpretq_u64_s32(vksumzp4x0123), vreinterpretq_u64_s32(vksumzp5x0123)));
139 int32x4_t vacc45x23 = vreinterpretq_s32_u64(vtrn2q_u64(vreinterpretq_u64_s32(vksumzp4x0123), vreinterpretq_u64_s32(vksumzp5x0123)));
140 int32x4_t vacc45x45 = vreinterpretq_s32_u64(vtrn1q_u64(vreinterpretq_u64_s32(vksumzp4x4567), vreinterpretq_u64_s32(vksumzp5x4567)));
141 int32x4_t vacc45x67 = vreinterpretq_s32_u64(vtrn2q_u64(vreinterpretq_u64_s32(vksumzp4x4567), vreinterpretq_u64_s32(vksumzp5x4567)));
142 int32x4_t vacc45x89 = vreinterpretq_s32_u64(vtrn1q_u64(vreinterpretq_u64_s32(vksumzp4x89AB), vreinterpretq_u64_s32(vksumzp5x89AB)));
143 int32x4_t vacc45xAB = vreinterpretq_s32_u64(vtrn2q_u64(vreinterpretq_u64_s32(vksumzp4x89AB), vreinterpretq_u64_s32(vksumzp5x89AB)));
144 int32x4_t vacc45xCD = vreinterpretq_s32_u64(vtrn1q_u64(vreinterpretq_u64_s32(vksumzp4xCDEF), vreinterpretq_u64_s32(vksumzp5xCDEF)));
145 int32x4_t vacc45xEF = vreinterpretq_s32_u64(vtrn2q_u64(vreinterpretq_u64_s32(vksumzp4xCDEF), vreinterpretq_u64_s32(vksumzp5xCDEF)));
146 int32x4_t vacc67x01 = vreinterpretq_s32_u64(vtrn1q_u64(vreinterpretq_u64_s32(vksumzp6x0123), vreinterpretq_u64_s32(vksumzp6x0123)));
147 int32x4_t vacc67x23 = vreinterpretq_s32_u64(vtrn2q_u64(vreinterpretq_u64_s32(vksumzp6x0123), vreinterpretq_u64_s32(vksumzp6x0123)));
148 int32x4_t vacc67x45 = vreinterpretq_s32_u64(vtrn1q_u64(vreinterpretq_u64_s32(vksumzp6x4567), vreinterpretq_u64_s32(vksumzp6x4567)));
149 int32x4_t vacc67x67 = vreinterpretq_s32_u64(vtrn2q_u64(vreinterpretq_u64_s32(vksumzp6x4567), vreinterpretq_u64_s32(vksumzp6x4567)));
150 int32x4_t vacc67x89 = vreinterpretq_s32_u64(vtrn1q_u64(vreinterpretq_u64_s32(vksumzp6x89AB), vreinterpretq_u64_s32(vksumzp6x89AB)));
151 int32x4_t vacc67xAB = vreinterpretq_s32_u64(vtrn2q_u64(vreinterpretq_u64_s32(vksumzp6x89AB), vreinterpretq_u64_s32(vksumzp6x89AB)));
152 int32x4_t vacc67xCD = vreinterpretq_s32_u64(vtrn1q_u64(vreinterpretq_u64_s32(vksumzp6xCDEF), vreinterpretq_u64_s32(vksumzp6xCDEF)));
153 int32x4_t vacc67xEF = vreinterpretq_s32_u64(vtrn2q_u64(vreinterpretq_u64_s32(vksumzp6xCDEF), vreinterpretq_u64_s32(vksumzp6xCDEF)));
154
155 // Inner accumulation loop along the 16 columns.
156 size_t k = kc;
157 // 2x partial unrolled loop to load 8 bytes at a time.
158
159 uint64x2x2_t va01x0123456789ABCDEF;
160 va01x0123456789ABCDEF.val[0] = vdupq_n_u64(0);
161 va01x0123456789ABCDEF.val[1] = vdupq_n_u64(0);
162 uint64x2x2_t va23x0123456789ABCDEF;
163 va23x0123456789ABCDEF.val[0] = vdupq_n_u64(0);
164 va23x0123456789ABCDEF.val[1] = vdupq_n_u64(0);
165 uint64x2x2_t va45x0123456789ABCDEF;
166 va45x0123456789ABCDEF.val[0] = vdupq_n_u64(0);
167 va45x0123456789ABCDEF.val[1] = vdupq_n_u64(0);
168 uint64x2x2_t va67x0123456789ABCDEF;
169 va67x0123456789ABCDEF.val[0] = vdupq_n_u64(0);
170 va67x0123456789ABCDEF.val[1] = vdupq_n_u64(0);
171
172 while (k >= 16 * sizeof(int8_t)) {
173 // Load a 7x16 block of activations.
174 va01x0123456789ABCDEF = vld2q_lane_u64((const void*) a0, va01x0123456789ABCDEF, 0); a0 += 16;
175 va23x0123456789ABCDEF = vld2q_lane_u64((const void*) a2, va23x0123456789ABCDEF, 0); a2 += 16;
176 va45x0123456789ABCDEF = vld2q_lane_u64((const void*) a4, va45x0123456789ABCDEF, 0); a4 += 16;
177 va67x0123456789ABCDEF = vld2q_lane_u64((const void*) a6, va67x0123456789ABCDEF, 0); a6 += 16;
178 va01x0123456789ABCDEF = vld2q_lane_u64((const void*) a1, va01x0123456789ABCDEF, 1); a1 += 16;
179 va23x0123456789ABCDEF = vld2q_lane_u64((const void*) a3, va23x0123456789ABCDEF, 1); a3 += 16;
180 va45x0123456789ABCDEF = vld2q_lane_u64((const void*) a5, va45x0123456789ABCDEF, 1); a5 += 16;
181
182 const int8x16_t va01x01234567 = vreinterpretq_s8_u64(va01x0123456789ABCDEF.val[0]);
183 const int8x16_t va01x89ABCDEF = vreinterpretq_s8_u64(va01x0123456789ABCDEF.val[1]);
184 const int8x16_t va23x01234567 = vreinterpretq_s8_u64(va23x0123456789ABCDEF.val[0]);
185 const int8x16_t va23x89ABCDEF = vreinterpretq_s8_u64(va23x0123456789ABCDEF.val[1]);
186 const int8x16_t va45x01234567 = vreinterpretq_s8_u64(va45x0123456789ABCDEF.val[0]);
187 const int8x16_t va45x89ABCDEF = vreinterpretq_s8_u64(va45x0123456789ABCDEF.val[1]);
188 const int8x16_t va67x01234567 = vreinterpretq_s8_u64(va67x0123456789ABCDEF.val[0]);
189 const int8x16_t va67x89ABCDEF = vreinterpretq_s8_u64(va67x0123456789ABCDEF.val[1]);
190
191 // Load a 16x16 block of weights.
192 const int8x16_t vb01x0123456789ABCDEF = vld1q_s8(w); w = (const int8_t*) w + 16;
193 const int8x16_t vb23x0123456789ABCDEF = vld1q_s8(w); w = (const int8_t*) w + 16;
194 const int8x16_t vb45x0123456789ABCDEF = vld1q_s8(w); w = (const int8_t*) w + 16;
195 const int8x16_t vb67x0123456789ABCDEF = vld1q_s8(w); w = (const int8_t*) w + 16;
196 const int8x16_t vb89x0123456789ABCDEF = vld1q_s8(w); w = (const int8_t*) w + 16;
197 const int8x16_t vbABx0123456789ABCDEF = vld1q_s8(w); w = (const int8_t*) w + 16;
198 const int8x16_t vbCDx0123456789ABCDEF = vld1q_s8(w); w = (const int8_t*) w + 16;
199 const int8x16_t vbEFx0123456789ABCDEF = vld1q_s8(w); w = (const int8_t*) w + 16;
200 const int8x16_t vb01x01234567 = vshlq_n_s8(vb01x0123456789ABCDEF, 4);
201 const int8x16_t vb23x01234567 = vshlq_n_s8(vb23x0123456789ABCDEF, 4);
202 const int8x16_t vb45x01234567 = vshlq_n_s8(vb45x0123456789ABCDEF, 4);
203 const int8x16_t vb67x01234567 = vshlq_n_s8(vb67x0123456789ABCDEF, 4);
204 const int8x16_t vb89x01234567 = vshlq_n_s8(vb89x0123456789ABCDEF, 4);
205 const int8x16_t vbABx01234567 = vshlq_n_s8(vbABx0123456789ABCDEF, 4);
206 const int8x16_t vbCDx01234567 = vshlq_n_s8(vbCDx0123456789ABCDEF, 4);
207 const int8x16_t vbEFx01234567 = vshlq_n_s8(vbEFx0123456789ABCDEF, 4);
208 const int8x16_t vb01x89ABCDEF = vandq_s8(vb01x0123456789ABCDEF, vmask);
209 const int8x16_t vb23x89ABCDEF = vandq_s8(vb23x0123456789ABCDEF, vmask);
210 const int8x16_t vb45x89ABCDEF = vandq_s8(vb45x0123456789ABCDEF, vmask);
211 const int8x16_t vb67x89ABCDEF = vandq_s8(vb67x0123456789ABCDEF, vmask);
212 const int8x16_t vb89x89ABCDEF = vandq_s8(vb89x0123456789ABCDEF, vmask);
213 const int8x16_t vbABx89ABCDEF = vandq_s8(vbABx0123456789ABCDEF, vmask);
214 const int8x16_t vbCDx89ABCDEF = vandq_s8(vbCDx0123456789ABCDEF, vmask);
215 const int8x16_t vbEFx89ABCDEF = vandq_s8(vbEFx0123456789ABCDEF, vmask);
216
217 // Multiply-accumulate: 7x8 * 8x16 --> 7x16.
218 vacc01x01 = vmmlaq_s32(vacc01x01, va01x01234567, vb01x01234567);
219 vacc01x23 = vmmlaq_s32(vacc01x23, va01x01234567, vb23x01234567);
220 vacc01x45 = vmmlaq_s32(vacc01x45, va01x01234567, vb45x01234567);
221 vacc01x67 = vmmlaq_s32(vacc01x67, va01x01234567, vb67x01234567);
222 vacc01x89 = vmmlaq_s32(vacc01x89, va01x01234567, vb89x01234567);
223 vacc01xAB = vmmlaq_s32(vacc01xAB, va01x01234567, vbABx01234567);
224 vacc01xCD = vmmlaq_s32(vacc01xCD, va01x01234567, vbCDx01234567);
225 vacc01xEF = vmmlaq_s32(vacc01xEF, va01x01234567, vbEFx01234567);
226 vacc23x01 = vmmlaq_s32(vacc23x01, va23x01234567, vb01x01234567);
227 vacc23x23 = vmmlaq_s32(vacc23x23, va23x01234567, vb23x01234567);
228 vacc23x45 = vmmlaq_s32(vacc23x45, va23x01234567, vb45x01234567);
229 vacc23x67 = vmmlaq_s32(vacc23x67, va23x01234567, vb67x01234567);
230 vacc23x89 = vmmlaq_s32(vacc23x89, va23x01234567, vb89x01234567);
231 vacc23xAB = vmmlaq_s32(vacc23xAB, va23x01234567, vbABx01234567);
232 vacc23xCD = vmmlaq_s32(vacc23xCD, va23x01234567, vbCDx01234567);
233 vacc23xEF = vmmlaq_s32(vacc23xEF, va23x01234567, vbEFx01234567);
234 vacc45x01 = vmmlaq_s32(vacc45x01, va45x01234567, vb01x01234567);
235 vacc45x23 = vmmlaq_s32(vacc45x23, va45x01234567, vb23x01234567);
236 vacc45x45 = vmmlaq_s32(vacc45x45, va45x01234567, vb45x01234567);
237 vacc45x67 = vmmlaq_s32(vacc45x67, va45x01234567, vb67x01234567);
238 vacc45x89 = vmmlaq_s32(vacc45x89, va45x01234567, vb89x01234567);
239 vacc45xAB = vmmlaq_s32(vacc45xAB, va45x01234567, vbABx01234567);
240 vacc45xCD = vmmlaq_s32(vacc45xCD, va45x01234567, vbCDx01234567);
241 vacc45xEF = vmmlaq_s32(vacc45xEF, va45x01234567, vbEFx01234567);
242 vacc67x01 = vmmlaq_s32(vacc67x01, va67x01234567, vb01x01234567);
243 vacc67x23 = vmmlaq_s32(vacc67x23, va67x01234567, vb23x01234567);
244 vacc67x45 = vmmlaq_s32(vacc67x45, va67x01234567, vb45x01234567);
245 vacc67x67 = vmmlaq_s32(vacc67x67, va67x01234567, vb67x01234567);
246 vacc67x89 = vmmlaq_s32(vacc67x89, va67x01234567, vb89x01234567);
247 vacc67xAB = vmmlaq_s32(vacc67xAB, va67x01234567, vbABx01234567);
248 vacc67xCD = vmmlaq_s32(vacc67xCD, va67x01234567, vbCDx01234567);
249 vacc67xEF = vmmlaq_s32(vacc67xEF, va67x01234567, vbEFx01234567);
250 vacc01x01 = vmmlaq_s32(vacc01x01, va01x89ABCDEF, vb01x89ABCDEF);
251 vacc01x23 = vmmlaq_s32(vacc01x23, va01x89ABCDEF, vb23x89ABCDEF);
252 vacc01x45 = vmmlaq_s32(vacc01x45, va01x89ABCDEF, vb45x89ABCDEF);
253 vacc01x67 = vmmlaq_s32(vacc01x67, va01x89ABCDEF, vb67x89ABCDEF);
254 vacc01x89 = vmmlaq_s32(vacc01x89, va01x89ABCDEF, vb89x89ABCDEF);
255 vacc01xAB = vmmlaq_s32(vacc01xAB, va01x89ABCDEF, vbABx89ABCDEF);
256 vacc01xCD = vmmlaq_s32(vacc01xCD, va01x89ABCDEF, vbCDx89ABCDEF);
257 vacc01xEF = vmmlaq_s32(vacc01xEF, va01x89ABCDEF, vbEFx89ABCDEF);
258 vacc23x01 = vmmlaq_s32(vacc23x01, va23x89ABCDEF, vb01x89ABCDEF);
259 vacc23x23 = vmmlaq_s32(vacc23x23, va23x89ABCDEF, vb23x89ABCDEF);
260 vacc23x45 = vmmlaq_s32(vacc23x45, va23x89ABCDEF, vb45x89ABCDEF);
261 vacc23x67 = vmmlaq_s32(vacc23x67, va23x89ABCDEF, vb67x89ABCDEF);
262 vacc23x89 = vmmlaq_s32(vacc23x89, va23x89ABCDEF, vb89x89ABCDEF);
263 vacc23xAB = vmmlaq_s32(vacc23xAB, va23x89ABCDEF, vbABx89ABCDEF);
264 vacc23xCD = vmmlaq_s32(vacc23xCD, va23x89ABCDEF, vbCDx89ABCDEF);
265 vacc23xEF = vmmlaq_s32(vacc23xEF, va23x89ABCDEF, vbEFx89ABCDEF);
266 vacc45x01 = vmmlaq_s32(vacc45x01, va45x89ABCDEF, vb01x89ABCDEF);
267 vacc45x23 = vmmlaq_s32(vacc45x23, va45x89ABCDEF, vb23x89ABCDEF);
268 vacc45x45 = vmmlaq_s32(vacc45x45, va45x89ABCDEF, vb45x89ABCDEF);
269 vacc45x67 = vmmlaq_s32(vacc45x67, va45x89ABCDEF, vb67x89ABCDEF);
270 vacc45x89 = vmmlaq_s32(vacc45x89, va45x89ABCDEF, vb89x89ABCDEF);
271 vacc45xAB = vmmlaq_s32(vacc45xAB, va45x89ABCDEF, vbABx89ABCDEF);
272 vacc45xCD = vmmlaq_s32(vacc45xCD, va45x89ABCDEF, vbCDx89ABCDEF);
273 vacc45xEF = vmmlaq_s32(vacc45xEF, va45x89ABCDEF, vbEFx89ABCDEF);
274 vacc67x01 = vmmlaq_s32(vacc67x01, va67x89ABCDEF, vb01x89ABCDEF);
275 vacc67x23 = vmmlaq_s32(vacc67x23, va67x89ABCDEF, vb23x89ABCDEF);
276 vacc67x45 = vmmlaq_s32(vacc67x45, va67x89ABCDEF, vb45x89ABCDEF);
277 vacc67x67 = vmmlaq_s32(vacc67x67, va67x89ABCDEF, vb67x89ABCDEF);
278 vacc67x89 = vmmlaq_s32(vacc67x89, va67x89ABCDEF, vb89x89ABCDEF);
279 vacc67xAB = vmmlaq_s32(vacc67xAB, va67x89ABCDEF, vbABx89ABCDEF);
280 vacc67xCD = vmmlaq_s32(vacc67xCD, va67x89ABCDEF, vbCDx89ABCDEF);
281 vacc67xEF = vmmlaq_s32(vacc67xEF, va67x89ABCDEF, vbEFx89ABCDEF);
282
283 k -= 16 * sizeof(int8_t);
284 }
285 // Handle up to 8 final positions of `k`
286 if XNN_UNLIKELY(k != 0) {
287 // Load a 7x8 block of activations.
288 uint64x2_t va01x01234567 = vld1q_dup_u64((const void*) a0); a0 += 8;
289 uint64x2_t va23x01234567 = vld1q_dup_u64((const void*) a2); a2 += 8;
290 uint64x2_t va45x01234567 = vld1q_dup_u64((const void*) a4); a4 += 8;
291 uint64x2_t va67x01234567 = vld1q_dup_u64((const void*) a6); a6 += 8;
292 va01x01234567 = vld1q_lane_u64((const void*) a1, va01x01234567, 1); a1 += 8;
293 va23x01234567 = vld1q_lane_u64((const void*) a3, va23x01234567, 1); a3 += 8;
294 va45x01234567 = vld1q_lane_u64((const void*) a5, va45x01234567, 1); a5 += 8;
295
296 // Load a 16x16 block of weights.
297 const int8x16_t vb01x0123456789ABCDEF = vld1q_s8(w); w = (const int8_t*) w + 16;
298 const int8x16_t vb23x0123456789ABCDEF = vld1q_s8(w); w = (const int8_t*) w + 16;
299 const int8x16_t vb45x0123456789ABCDEF = vld1q_s8(w); w = (const int8_t*) w + 16;
300 const int8x16_t vb67x0123456789ABCDEF = vld1q_s8(w); w = (const int8_t*) w + 16;
301 const int8x16_t vb89x0123456789ABCDEF = vld1q_s8(w); w = (const int8_t*) w + 16;
302 const int8x16_t vbABx0123456789ABCDEF = vld1q_s8(w); w = (const int8_t*) w + 16;
303 const int8x16_t vbCDx0123456789ABCDEF = vld1q_s8(w); w = (const int8_t*) w + 16;
304 const int8x16_t vbEFx0123456789ABCDEF = vld1q_s8(w); w = (const int8_t*) w + 16;
305 const int8x16_t vb01x01234567 = vshlq_n_s8(vb01x0123456789ABCDEF, 4);
306 const int8x16_t vb23x01234567 = vshlq_n_s8(vb23x0123456789ABCDEF, 4);
307 const int8x16_t vb45x01234567 = vshlq_n_s8(vb45x0123456789ABCDEF, 4);
308 const int8x16_t vb67x01234567 = vshlq_n_s8(vb67x0123456789ABCDEF, 4);
309 const int8x16_t vb89x01234567 = vshlq_n_s8(vb89x0123456789ABCDEF, 4);
310 const int8x16_t vbABx01234567 = vshlq_n_s8(vbABx0123456789ABCDEF, 4);
311 const int8x16_t vbCDx01234567 = vshlq_n_s8(vbCDx0123456789ABCDEF, 4);
312 const int8x16_t vbEFx01234567 = vshlq_n_s8(vbEFx0123456789ABCDEF, 4);
313
314 // Multiply-accumulate: 7x4 * 4x16 --> 7x16.
315 vacc01x01 = vmmlaq_s32(vacc01x01, vreinterpretq_s8_u64(va01x01234567), vb01x01234567);
316 vacc01x23 = vmmlaq_s32(vacc01x23, vreinterpretq_s8_u64(va01x01234567), vb23x01234567);
317 vacc01x45 = vmmlaq_s32(vacc01x45, vreinterpretq_s8_u64(va01x01234567), vb45x01234567);
318 vacc01x67 = vmmlaq_s32(vacc01x67, vreinterpretq_s8_u64(va01x01234567), vb67x01234567);
319 vacc01x89 = vmmlaq_s32(vacc01x89, vreinterpretq_s8_u64(va01x01234567), vb89x01234567);
320 vacc01xAB = vmmlaq_s32(vacc01xAB, vreinterpretq_s8_u64(va01x01234567), vbABx01234567);
321 vacc01xCD = vmmlaq_s32(vacc01xCD, vreinterpretq_s8_u64(va01x01234567), vbCDx01234567);
322 vacc01xEF = vmmlaq_s32(vacc01xEF, vreinterpretq_s8_u64(va01x01234567), vbEFx01234567);
323 vacc23x01 = vmmlaq_s32(vacc23x01, vreinterpretq_s8_u64(va23x01234567), vb01x01234567);
324 vacc23x23 = vmmlaq_s32(vacc23x23, vreinterpretq_s8_u64(va23x01234567), vb23x01234567);
325 vacc23x45 = vmmlaq_s32(vacc23x45, vreinterpretq_s8_u64(va23x01234567), vb45x01234567);
326 vacc23x67 = vmmlaq_s32(vacc23x67, vreinterpretq_s8_u64(va23x01234567), vb67x01234567);
327 vacc23x89 = vmmlaq_s32(vacc23x89, vreinterpretq_s8_u64(va23x01234567), vb89x01234567);
328 vacc23xAB = vmmlaq_s32(vacc23xAB, vreinterpretq_s8_u64(va23x01234567), vbABx01234567);
329 vacc23xCD = vmmlaq_s32(vacc23xCD, vreinterpretq_s8_u64(va23x01234567), vbCDx01234567);
330 vacc23xEF = vmmlaq_s32(vacc23xEF, vreinterpretq_s8_u64(va23x01234567), vbEFx01234567);
331 vacc45x01 = vmmlaq_s32(vacc45x01, vreinterpretq_s8_u64(va45x01234567), vb01x01234567);
332 vacc45x23 = vmmlaq_s32(vacc45x23, vreinterpretq_s8_u64(va45x01234567), vb23x01234567);
333 vacc45x45 = vmmlaq_s32(vacc45x45, vreinterpretq_s8_u64(va45x01234567), vb45x01234567);
334 vacc45x67 = vmmlaq_s32(vacc45x67, vreinterpretq_s8_u64(va45x01234567), vb67x01234567);
335 vacc45x89 = vmmlaq_s32(vacc45x89, vreinterpretq_s8_u64(va45x01234567), vb89x01234567);
336 vacc45xAB = vmmlaq_s32(vacc45xAB, vreinterpretq_s8_u64(va45x01234567), vbABx01234567);
337 vacc45xCD = vmmlaq_s32(vacc45xCD, vreinterpretq_s8_u64(va45x01234567), vbCDx01234567);
338 vacc45xEF = vmmlaq_s32(vacc45xEF, vreinterpretq_s8_u64(va45x01234567), vbEFx01234567);
339 vacc67x01 = vmmlaq_s32(vacc67x01, vreinterpretq_s8_u64(va67x01234567), vb01x01234567);
340 vacc67x23 = vmmlaq_s32(vacc67x23, vreinterpretq_s8_u64(va67x01234567), vb23x01234567);
341 vacc67x45 = vmmlaq_s32(vacc67x45, vreinterpretq_s8_u64(va67x01234567), vb45x01234567);
342 vacc67x67 = vmmlaq_s32(vacc67x67, vreinterpretq_s8_u64(va67x01234567), vb67x01234567);
343 vacc67x89 = vmmlaq_s32(vacc67x89, vreinterpretq_s8_u64(va67x01234567), vb89x01234567);
344 vacc67xAB = vmmlaq_s32(vacc67xAB, vreinterpretq_s8_u64(va67x01234567), vbABx01234567);
345 vacc67xCD = vmmlaq_s32(vacc67xCD, vreinterpretq_s8_u64(va67x01234567), vbCDx01234567);
346 vacc67xEF = vmmlaq_s32(vacc67xEF, vreinterpretq_s8_u64(va67x01234567), vbEFx01234567);
347 }
348
349 int32x4_t vacc0x0123 = vreinterpretq_s32_u64(vtrn1q_u64(vreinterpretq_u64_s32(vacc01x01), vreinterpretq_u64_s32(vacc01x23)));
350 int32x4_t vacc1x0123 = vreinterpretq_s32_u64(vtrn2q_u64(vreinterpretq_u64_s32(vacc01x01), vreinterpretq_u64_s32(vacc01x23)));
351 int32x4_t vacc0x4567 = vreinterpretq_s32_u64(vtrn1q_u64(vreinterpretq_u64_s32(vacc01x45), vreinterpretq_u64_s32(vacc01x67)));
352 int32x4_t vacc1x4567 = vreinterpretq_s32_u64(vtrn2q_u64(vreinterpretq_u64_s32(vacc01x45), vreinterpretq_u64_s32(vacc01x67)));
353 int32x4_t vacc0x89AB = vreinterpretq_s32_u64(vtrn1q_u64(vreinterpretq_u64_s32(vacc01x89), vreinterpretq_u64_s32(vacc01xAB)));
354 int32x4_t vacc1x89AB = vreinterpretq_s32_u64(vtrn2q_u64(vreinterpretq_u64_s32(vacc01x89), vreinterpretq_u64_s32(vacc01xAB)));
355 int32x4_t vacc0xCDEF = vreinterpretq_s32_u64(vtrn1q_u64(vreinterpretq_u64_s32(vacc01xCD), vreinterpretq_u64_s32(vacc01xEF)));
356 int32x4_t vacc1xCDEF = vreinterpretq_s32_u64(vtrn2q_u64(vreinterpretq_u64_s32(vacc01xCD), vreinterpretq_u64_s32(vacc01xEF)));
357 int32x4_t vacc2x0123 = vreinterpretq_s32_u64(vtrn1q_u64(vreinterpretq_u64_s32(vacc23x01), vreinterpretq_u64_s32(vacc23x23)));
358 int32x4_t vacc3x0123 = vreinterpretq_s32_u64(vtrn2q_u64(vreinterpretq_u64_s32(vacc23x01), vreinterpretq_u64_s32(vacc23x23)));
359 int32x4_t vacc2x4567 = vreinterpretq_s32_u64(vtrn1q_u64(vreinterpretq_u64_s32(vacc23x45), vreinterpretq_u64_s32(vacc23x67)));
360 int32x4_t vacc3x4567 = vreinterpretq_s32_u64(vtrn2q_u64(vreinterpretq_u64_s32(vacc23x45), vreinterpretq_u64_s32(vacc23x67)));
361 int32x4_t vacc2x89AB = vreinterpretq_s32_u64(vtrn1q_u64(vreinterpretq_u64_s32(vacc23x89), vreinterpretq_u64_s32(vacc23xAB)));
362 int32x4_t vacc3x89AB = vreinterpretq_s32_u64(vtrn2q_u64(vreinterpretq_u64_s32(vacc23x89), vreinterpretq_u64_s32(vacc23xAB)));
363 int32x4_t vacc2xCDEF = vreinterpretq_s32_u64(vtrn1q_u64(vreinterpretq_u64_s32(vacc23xCD), vreinterpretq_u64_s32(vacc23xEF)));
364 int32x4_t vacc3xCDEF = vreinterpretq_s32_u64(vtrn2q_u64(vreinterpretq_u64_s32(vacc23xCD), vreinterpretq_u64_s32(vacc23xEF)));
365 int32x4_t vacc4x0123 = vreinterpretq_s32_u64(vtrn1q_u64(vreinterpretq_u64_s32(vacc45x01), vreinterpretq_u64_s32(vacc45x23)));
366 int32x4_t vacc5x0123 = vreinterpretq_s32_u64(vtrn2q_u64(vreinterpretq_u64_s32(vacc45x01), vreinterpretq_u64_s32(vacc45x23)));
367 int32x4_t vacc4x4567 = vreinterpretq_s32_u64(vtrn1q_u64(vreinterpretq_u64_s32(vacc45x45), vreinterpretq_u64_s32(vacc45x67)));
368 int32x4_t vacc5x4567 = vreinterpretq_s32_u64(vtrn2q_u64(vreinterpretq_u64_s32(vacc45x45), vreinterpretq_u64_s32(vacc45x67)));
369 int32x4_t vacc4x89AB = vreinterpretq_s32_u64(vtrn1q_u64(vreinterpretq_u64_s32(vacc45x89), vreinterpretq_u64_s32(vacc45xAB)));
370 int32x4_t vacc5x89AB = vreinterpretq_s32_u64(vtrn2q_u64(vreinterpretq_u64_s32(vacc45x89), vreinterpretq_u64_s32(vacc45xAB)));
371 int32x4_t vacc4xCDEF = vreinterpretq_s32_u64(vtrn1q_u64(vreinterpretq_u64_s32(vacc45xCD), vreinterpretq_u64_s32(vacc45xEF)));
372 int32x4_t vacc5xCDEF = vreinterpretq_s32_u64(vtrn2q_u64(vreinterpretq_u64_s32(vacc45xCD), vreinterpretq_u64_s32(vacc45xEF)));
373 int32x4_t vacc6x0123 = vreinterpretq_s32_u64(vtrn1q_u64(vreinterpretq_u64_s32(vacc67x01), vreinterpretq_u64_s32(vacc67x23)));
374 int32x4_t vacc6x4567 = vreinterpretq_s32_u64(vtrn1q_u64(vreinterpretq_u64_s32(vacc67x45), vreinterpretq_u64_s32(vacc67x67)));
375 int32x4_t vacc6x89AB = vreinterpretq_s32_u64(vtrn1q_u64(vreinterpretq_u64_s32(vacc67x89), vreinterpretq_u64_s32(vacc67xAB)));
376 int32x4_t vacc6xCDEF = vreinterpretq_s32_u64(vtrn1q_u64(vreinterpretq_u64_s32(vacc67xCD), vreinterpretq_u64_s32(vacc67xEF)));
377 float32x4_t vout0x0123 = vcvtq_n_f32_s32(vacc0x0123, 4);
378 float32x4_t vout0x4567 = vcvtq_n_f32_s32(vacc0x4567, 4);
379 float32x4_t vout0x89AB = vcvtq_n_f32_s32(vacc0x89AB, 4);
380 float32x4_t vout0xCDEF = vcvtq_n_f32_s32(vacc0xCDEF, 4);
381 float32x4_t vout1x0123 = vcvtq_n_f32_s32(vacc1x0123, 4);
382 float32x4_t vout1x4567 = vcvtq_n_f32_s32(vacc1x4567, 4);
383 float32x4_t vout1x89AB = vcvtq_n_f32_s32(vacc1x89AB, 4);
384 float32x4_t vout1xCDEF = vcvtq_n_f32_s32(vacc1xCDEF, 4);
385 float32x4_t vout2x0123 = vcvtq_n_f32_s32(vacc2x0123, 4);
386 float32x4_t vout2x4567 = vcvtq_n_f32_s32(vacc2x4567, 4);
387 float32x4_t vout2x89AB = vcvtq_n_f32_s32(vacc2x89AB, 4);
388 float32x4_t vout2xCDEF = vcvtq_n_f32_s32(vacc2xCDEF, 4);
389 float32x4_t vout3x0123 = vcvtq_n_f32_s32(vacc3x0123, 4);
390 float32x4_t vout3x4567 = vcvtq_n_f32_s32(vacc3x4567, 4);
391 float32x4_t vout3x89AB = vcvtq_n_f32_s32(vacc3x89AB, 4);
392 float32x4_t vout3xCDEF = vcvtq_n_f32_s32(vacc3xCDEF, 4);
393 float32x4_t vout4x0123 = vcvtq_n_f32_s32(vacc4x0123, 4);
394 float32x4_t vout4x4567 = vcvtq_n_f32_s32(vacc4x4567, 4);
395 float32x4_t vout4x89AB = vcvtq_n_f32_s32(vacc4x89AB, 4);
396 float32x4_t vout4xCDEF = vcvtq_n_f32_s32(vacc4xCDEF, 4);
397 float32x4_t vout5x0123 = vcvtq_n_f32_s32(vacc5x0123, 4);
398 float32x4_t vout5x4567 = vcvtq_n_f32_s32(vacc5x4567, 4);
399 float32x4_t vout5x89AB = vcvtq_n_f32_s32(vacc5x89AB, 4);
400 float32x4_t vout5xCDEF = vcvtq_n_f32_s32(vacc5xCDEF, 4);
401 float32x4_t vout6x0123 = vcvtq_n_f32_s32(vacc6x0123, 4);
402 float32x4_t vout6x4567 = vcvtq_n_f32_s32(vacc6x4567, 4);
403 float32x4_t vout6x89AB = vcvtq_n_f32_s32(vacc6x89AB, 4);
404 float32x4_t vout6xCDEF = vcvtq_n_f32_s32(vacc6xCDEF, 4);
405
406 const float32x4_t vinput_scale01 = vreinterpretq_f32_s32(vld1q_s32(&quantization_params[0].zero_point));
407 vout0x0123 = vmulq_lane_f32(vout0x0123, vget_low_f32(vinput_scale01), 1);
408 vout1x0123 = vmulq_lane_f32(vout1x0123, vget_high_f32(vinput_scale01), 1);
409 vout0x4567 = vmulq_lane_f32(vout0x4567, vget_low_f32(vinput_scale01), 1);
410 vout1x4567 = vmulq_lane_f32(vout1x4567, vget_high_f32(vinput_scale01), 1);
411 vout0x89AB = vmulq_lane_f32(vout0x89AB, vget_low_f32(vinput_scale01), 1);
412 vout1x89AB = vmulq_lane_f32(vout1x89AB, vget_high_f32(vinput_scale01), 1);
413 vout0xCDEF = vmulq_lane_f32(vout0xCDEF, vget_low_f32(vinput_scale01), 1);
414 vout1xCDEF = vmulq_lane_f32(vout1xCDEF, vget_high_f32(vinput_scale01), 1);
415 const float32x4_t vinput_scale23 = vreinterpretq_f32_s32(vld1q_s32(&quantization_params[2].zero_point));
416 vout2x0123 = vmulq_lane_f32(vout2x0123, vget_low_f32(vinput_scale23), 1);
417 vout3x0123 = vmulq_lane_f32(vout3x0123, vget_high_f32(vinput_scale23), 1);
418 vout2x4567 = vmulq_lane_f32(vout2x4567, vget_low_f32(vinput_scale23), 1);
419 vout3x4567 = vmulq_lane_f32(vout3x4567, vget_high_f32(vinput_scale23), 1);
420 vout2x89AB = vmulq_lane_f32(vout2x89AB, vget_low_f32(vinput_scale23), 1);
421 vout3x89AB = vmulq_lane_f32(vout3x89AB, vget_high_f32(vinput_scale23), 1);
422 vout2xCDEF = vmulq_lane_f32(vout2xCDEF, vget_low_f32(vinput_scale23), 1);
423 vout3xCDEF = vmulq_lane_f32(vout3xCDEF, vget_high_f32(vinput_scale23), 1);
424 const float32x4_t vinput_scale45 = vreinterpretq_f32_s32(vld1q_s32(&quantization_params[4].zero_point));
425 vout4x0123 = vmulq_lane_f32(vout4x0123, vget_low_f32(vinput_scale45), 1);
426 vout5x0123 = vmulq_lane_f32(vout5x0123, vget_high_f32(vinput_scale45), 1);
427 vout4x4567 = vmulq_lane_f32(vout4x4567, vget_low_f32(vinput_scale45), 1);
428 vout5x4567 = vmulq_lane_f32(vout5x4567, vget_high_f32(vinput_scale45), 1);
429 vout4x89AB = vmulq_lane_f32(vout4x89AB, vget_low_f32(vinput_scale45), 1);
430 vout5x89AB = vmulq_lane_f32(vout5x89AB, vget_high_f32(vinput_scale45), 1);
431 vout4xCDEF = vmulq_lane_f32(vout4xCDEF, vget_low_f32(vinput_scale45), 1);
432 vout5xCDEF = vmulq_lane_f32(vout5xCDEF, vget_high_f32(vinput_scale45), 1);
433 const float32x4_t vinput_scale6 = vld1q_dup_f32(&quantization_params[6].inv_scale);
434 vout6x0123 = vmulq_f32(vout6x0123, vinput_scale6);
435 vout6x4567 = vmulq_f32(vout6x4567, vinput_scale6);
436 vout6x89AB = vmulq_f32(vout6x89AB, vinput_scale6);
437 vout6xCDEF = vmulq_f32(vout6xCDEF, vinput_scale6);
438
439 const float32x4_t vfilter_output_scale0123 = vld1q_f32(w); w = (const float*) w + 4;
440 const float32x4_t vfilter_output_scale4567 = vld1q_f32(w); w = (const float*) w + 4;
441 const float32x4_t vfilter_output_scale89AB = vld1q_f32(w); w = (const float*) w + 4;
442 const float32x4_t vfilter_output_scaleCDEF = vld1q_f32(w); w = (const float*) w + 4;
443
444 const float32x4_t vbias0123 = vld1q_f32(w); w = (const float*) w + 4;
445 vout0x0123 = vfmaq_f32(vbias0123, vout0x0123, vfilter_output_scale0123);
446 vout1x0123 = vfmaq_f32(vbias0123, vout1x0123, vfilter_output_scale0123);
447 vout2x0123 = vfmaq_f32(vbias0123, vout2x0123, vfilter_output_scale0123);
448 vout3x0123 = vfmaq_f32(vbias0123, vout3x0123, vfilter_output_scale0123);
449 vout4x0123 = vfmaq_f32(vbias0123, vout4x0123, vfilter_output_scale0123);
450 vout5x0123 = vfmaq_f32(vbias0123, vout5x0123, vfilter_output_scale0123);
451 vout6x0123 = vfmaq_f32(vbias0123, vout6x0123, vfilter_output_scale0123);
452 const float32x4_t vbias4567 = vld1q_f32(w); w = (const float*) w + 4;
453 vout0x4567 = vfmaq_f32(vbias4567, vout0x4567, vfilter_output_scale4567);
454 vout1x4567 = vfmaq_f32(vbias4567, vout1x4567, vfilter_output_scale4567);
455 vout2x4567 = vfmaq_f32(vbias4567, vout2x4567, vfilter_output_scale4567);
456 vout3x4567 = vfmaq_f32(vbias4567, vout3x4567, vfilter_output_scale4567);
457 vout4x4567 = vfmaq_f32(vbias4567, vout4x4567, vfilter_output_scale4567);
458 vout5x4567 = vfmaq_f32(vbias4567, vout5x4567, vfilter_output_scale4567);
459 vout6x4567 = vfmaq_f32(vbias4567, vout6x4567, vfilter_output_scale4567);
460 const float32x4_t vbias89AB = vld1q_f32(w); w = (const float*) w + 4;
461 vout0x89AB = vfmaq_f32(vbias89AB, vout0x89AB, vfilter_output_scale89AB);
462 vout1x89AB = vfmaq_f32(vbias89AB, vout1x89AB, vfilter_output_scale89AB);
463 vout2x89AB = vfmaq_f32(vbias89AB, vout2x89AB, vfilter_output_scale89AB);
464 vout3x89AB = vfmaq_f32(vbias89AB, vout3x89AB, vfilter_output_scale89AB);
465 vout4x89AB = vfmaq_f32(vbias89AB, vout4x89AB, vfilter_output_scale89AB);
466 vout5x89AB = vfmaq_f32(vbias89AB, vout5x89AB, vfilter_output_scale89AB);
467 vout6x89AB = vfmaq_f32(vbias89AB, vout6x89AB, vfilter_output_scale89AB);
468 const float32x4_t vbiasCDEF = vld1q_f32(w); w = (const float*) w + 4;
469 vout0xCDEF = vfmaq_f32(vbiasCDEF, vout0xCDEF, vfilter_output_scaleCDEF);
470 vout1xCDEF = vfmaq_f32(vbiasCDEF, vout1xCDEF, vfilter_output_scaleCDEF);
471 vout2xCDEF = vfmaq_f32(vbiasCDEF, vout2xCDEF, vfilter_output_scaleCDEF);
472 vout3xCDEF = vfmaq_f32(vbiasCDEF, vout3xCDEF, vfilter_output_scaleCDEF);
473 vout4xCDEF = vfmaq_f32(vbiasCDEF, vout4xCDEF, vfilter_output_scaleCDEF);
474 vout5xCDEF = vfmaq_f32(vbiasCDEF, vout5xCDEF, vfilter_output_scaleCDEF);
475 vout6xCDEF = vfmaq_f32(vbiasCDEF, vout6xCDEF, vfilter_output_scaleCDEF);
476
477 float16x8_t vfp16out0x01234567 = vcombine_f16(vcvt_f16_f32(vout0x0123), vcvt_f16_f32(vout0x4567));
478 float16x8_t vfp16out0x89ABCDEF = vcombine_f16(vcvt_f16_f32(vout0x89AB), vcvt_f16_f32(vout0xCDEF));
479 float16x8_t vfp16out1x01234567 = vcombine_f16(vcvt_f16_f32(vout1x0123), vcvt_f16_f32(vout1x4567));
480 float16x8_t vfp16out1x89ABCDEF = vcombine_f16(vcvt_f16_f32(vout1x89AB), vcvt_f16_f32(vout1xCDEF));
481 float16x8_t vfp16out2x01234567 = vcombine_f16(vcvt_f16_f32(vout2x0123), vcvt_f16_f32(vout2x4567));
482 float16x8_t vfp16out2x89ABCDEF = vcombine_f16(vcvt_f16_f32(vout2x89AB), vcvt_f16_f32(vout2xCDEF));
483 float16x8_t vfp16out3x01234567 = vcombine_f16(vcvt_f16_f32(vout3x0123), vcvt_f16_f32(vout3x4567));
484 float16x8_t vfp16out3x89ABCDEF = vcombine_f16(vcvt_f16_f32(vout3x89AB), vcvt_f16_f32(vout3xCDEF));
485 float16x8_t vfp16out4x01234567 = vcombine_f16(vcvt_f16_f32(vout4x0123), vcvt_f16_f32(vout4x4567));
486 float16x8_t vfp16out4x89ABCDEF = vcombine_f16(vcvt_f16_f32(vout4x89AB), vcvt_f16_f32(vout4xCDEF));
487 float16x8_t vfp16out5x01234567 = vcombine_f16(vcvt_f16_f32(vout5x0123), vcvt_f16_f32(vout5x4567));
488 float16x8_t vfp16out5x89ABCDEF = vcombine_f16(vcvt_f16_f32(vout5x89AB), vcvt_f16_f32(vout5xCDEF));
489 float16x8_t vfp16out6x01234567 = vcombine_f16(vcvt_f16_f32(vout6x0123), vcvt_f16_f32(vout6x4567));
490 float16x8_t vfp16out6x89ABCDEF = vcombine_f16(vcvt_f16_f32(vout6x89AB), vcvt_f16_f32(vout6xCDEF));
491
492 const float16x8_t voutput_min = vreinterpretq_f16_u16(vld1q_dup_u16((const uint16_t*) &params->scalar.min));
493 vfp16out0x01234567 = vmaxq_f16(vfp16out0x01234567, voutput_min);
494 vfp16out0x89ABCDEF = vmaxq_f16(vfp16out0x89ABCDEF, voutput_min);
495 vfp16out1x01234567 = vmaxq_f16(vfp16out1x01234567, voutput_min);
496 vfp16out1x89ABCDEF = vmaxq_f16(vfp16out1x89ABCDEF, voutput_min);
497 vfp16out2x01234567 = vmaxq_f16(vfp16out2x01234567, voutput_min);
498 vfp16out2x89ABCDEF = vmaxq_f16(vfp16out2x89ABCDEF, voutput_min);
499 vfp16out3x01234567 = vmaxq_f16(vfp16out3x01234567, voutput_min);
500 vfp16out3x89ABCDEF = vmaxq_f16(vfp16out3x89ABCDEF, voutput_min);
501 vfp16out4x01234567 = vmaxq_f16(vfp16out4x01234567, voutput_min);
502 vfp16out4x89ABCDEF = vmaxq_f16(vfp16out4x89ABCDEF, voutput_min);
503 vfp16out5x01234567 = vmaxq_f16(vfp16out5x01234567, voutput_min);
504 vfp16out5x89ABCDEF = vmaxq_f16(vfp16out5x89ABCDEF, voutput_min);
505 vfp16out6x01234567 = vmaxq_f16(vfp16out6x01234567, voutput_min);
506 vfp16out6x89ABCDEF = vmaxq_f16(vfp16out6x89ABCDEF, voutput_min);
507 const float16x8_t voutput_max = vreinterpretq_f16_u16(vld1q_dup_u16((const uint16_t*) &params->scalar.max));
508 vfp16out0x01234567 = vminq_f16(vfp16out0x01234567, voutput_max);
509 vfp16out0x89ABCDEF = vminq_f16(vfp16out0x89ABCDEF, voutput_max);
510 vfp16out1x01234567 = vminq_f16(vfp16out1x01234567, voutput_max);
511 vfp16out1x89ABCDEF = vminq_f16(vfp16out1x89ABCDEF, voutput_max);
512 vfp16out2x01234567 = vminq_f16(vfp16out2x01234567, voutput_max);
513 vfp16out2x89ABCDEF = vminq_f16(vfp16out2x89ABCDEF, voutput_max);
514 vfp16out3x01234567 = vminq_f16(vfp16out3x01234567, voutput_max);
515 vfp16out3x89ABCDEF = vminq_f16(vfp16out3x89ABCDEF, voutput_max);
516 vfp16out4x01234567 = vminq_f16(vfp16out4x01234567, voutput_max);
517 vfp16out4x89ABCDEF = vminq_f16(vfp16out4x89ABCDEF, voutput_max);
518 vfp16out5x01234567 = vminq_f16(vfp16out5x01234567, voutput_max);
519 vfp16out5x89ABCDEF = vminq_f16(vfp16out5x89ABCDEF, voutput_max);
520 vfp16out6x01234567 = vminq_f16(vfp16out6x01234567, voutput_max);
521 vfp16out6x89ABCDEF = vminq_f16(vfp16out6x89ABCDEF, voutput_max);
522 if XNN_LIKELY(nc >= 16) {
523 vst1q_u16(c0, vreinterpretq_u16_f16(vfp16out0x01234567));
524 vst1q_u16(c0 + 8, vreinterpretq_u16_f16(vfp16out0x89ABCDEF));
525 vst1q_u16(c1, vreinterpretq_u16_f16(vfp16out1x01234567));
526 vst1q_u16(c1 + 8, vreinterpretq_u16_f16(vfp16out1x89ABCDEF));
527 vst1q_u16(c2, vreinterpretq_u16_f16(vfp16out2x01234567));
528 vst1q_u16(c2 + 8, vreinterpretq_u16_f16(vfp16out2x89ABCDEF));
529 vst1q_u16(c3, vreinterpretq_u16_f16(vfp16out3x01234567));
530 vst1q_u16(c3 + 8, vreinterpretq_u16_f16(vfp16out3x89ABCDEF));
531 vst1q_u16(c4, vreinterpretq_u16_f16(vfp16out4x01234567));
532 vst1q_u16(c4 + 8, vreinterpretq_u16_f16(vfp16out4x89ABCDEF));
533 vst1q_u16(c5, vreinterpretq_u16_f16(vfp16out5x01234567));
534 vst1q_u16(c5 + 8, vreinterpretq_u16_f16(vfp16out5x89ABCDEF));
535 vst1q_u16(c6, vreinterpretq_u16_f16(vfp16out6x01234567));
536 vst1q_u16(c6 + 8, vreinterpretq_u16_f16(vfp16out6x89ABCDEF));
537
538 a0 = (const int8_t*) ((uintptr_t) a0 - kc);
539 a1 = (const int8_t*) ((uintptr_t) a1 - kc);
540 a2 = (const int8_t*) ((uintptr_t) a2 - kc);
541 a3 = (const int8_t*) ((uintptr_t) a3 - kc);
542 a4 = (const int8_t*) ((uintptr_t) a4 - kc);
543 a5 = (const int8_t*) ((uintptr_t) a5 - kc);
544 a6 = (const int8_t*) ((uintptr_t) a6 - kc);
545
546 c0 = (uint16_t*) ((uintptr_t) c0 + cn_stride);
547 c1 = (uint16_t*) ((uintptr_t) c1 + cn_stride);
548 c2 = (uint16_t*) ((uintptr_t) c2 + cn_stride);
549 c3 = (uint16_t*) ((uintptr_t) c3 + cn_stride);
550 c4 = (uint16_t*) ((uintptr_t) c4 + cn_stride);
551 c5 = (uint16_t*) ((uintptr_t) c5 + cn_stride);
552 c6 = (uint16_t*) ((uintptr_t) c6 + cn_stride);
553
554 nc -= 16;
555 } else {
556 if (nc & 8) {
557 vst1q_u16(c0, vreinterpretq_u16_f16(vfp16out0x01234567)); c0 += 8;
558 vfp16out0x01234567 = vfp16out0x89ABCDEF;
559 vst1q_u16(c1, vreinterpretq_u16_f16(vfp16out1x01234567)); c1 += 8;
560 vfp16out1x01234567 = vfp16out1x89ABCDEF;
561 vst1q_u16(c2, vreinterpretq_u16_f16(vfp16out2x01234567)); c2 += 8;
562 vfp16out2x01234567 = vfp16out2x89ABCDEF;
563 vst1q_u16(c3, vreinterpretq_u16_f16(vfp16out3x01234567)); c3 += 8;
564 vfp16out3x01234567 = vfp16out3x89ABCDEF;
565 vst1q_u16(c4, vreinterpretq_u16_f16(vfp16out4x01234567)); c4 += 8;
566 vfp16out4x01234567 = vfp16out4x89ABCDEF;
567 vst1q_u16(c5, vreinterpretq_u16_f16(vfp16out5x01234567)); c5 += 8;
568 vfp16out5x01234567 = vfp16out5x89ABCDEF;
569 vst1q_u16(c6, vreinterpretq_u16_f16(vfp16out6x01234567)); c6 += 8;
570 vfp16out6x01234567 = vfp16out6x89ABCDEF;
571 }
572 float16x4_t vfp16out0x0123 = vget_low_f16(vfp16out0x01234567);
573 float16x4_t vfp16out1x0123 = vget_low_f16(vfp16out1x01234567);
574 float16x4_t vfp16out2x0123 = vget_low_f16(vfp16out2x01234567);
575 float16x4_t vfp16out3x0123 = vget_low_f16(vfp16out3x01234567);
576 float16x4_t vfp16out4x0123 = vget_low_f16(vfp16out4x01234567);
577 float16x4_t vfp16out5x0123 = vget_low_f16(vfp16out5x01234567);
578 float16x4_t vfp16out6x0123 = vget_low_f16(vfp16out6x01234567);
579 if (nc & 4) {
580 vst1_u16(c0, vreinterpret_u16_f16(vfp16out0x0123)); c0 += 4;
581 vst1_u16(c1, vreinterpret_u16_f16(vfp16out1x0123)); c1 += 4;
582 vst1_u16(c2, vreinterpret_u16_f16(vfp16out2x0123)); c2 += 4;
583 vst1_u16(c3, vreinterpret_u16_f16(vfp16out3x0123)); c3 += 4;
584 vst1_u16(c4, vreinterpret_u16_f16(vfp16out4x0123)); c4 += 4;
585 vst1_u16(c5, vreinterpret_u16_f16(vfp16out5x0123)); c5 += 4;
586 vst1_u16(c6, vreinterpret_u16_f16(vfp16out6x0123)); c6 += 4;
587 vfp16out0x0123 = vget_high_f16(vfp16out0x01234567);
588 vfp16out1x0123 = vget_high_f16(vfp16out1x01234567);
589 vfp16out2x0123 = vget_high_f16(vfp16out2x01234567);
590 vfp16out3x0123 = vget_high_f16(vfp16out3x01234567);
591 vfp16out4x0123 = vget_high_f16(vfp16out4x01234567);
592 vfp16out5x0123 = vget_high_f16(vfp16out5x01234567);
593 vfp16out6x0123 = vget_high_f16(vfp16out6x01234567);
594 }
595 if (nc & 2) {
596 vst1_lane_u32((void*) c0, vreinterpret_u32_f16(vfp16out0x0123), 0); c0 += 2;
597 vst1_lane_u32((void*) c1, vreinterpret_u32_f16(vfp16out1x0123), 0); c1 += 2;
598 vst1_lane_u32((void*) c2, vreinterpret_u32_f16(vfp16out2x0123), 0); c2 += 2;
599 vst1_lane_u32((void*) c3, vreinterpret_u32_f16(vfp16out3x0123), 0); c3 += 2;
600 vst1_lane_u32((void*) c4, vreinterpret_u32_f16(vfp16out4x0123), 0); c4 += 2;
601 vst1_lane_u32((void*) c5, vreinterpret_u32_f16(vfp16out5x0123), 0); c5 += 2;
602 vst1_lane_u32((void*) c6, vreinterpret_u32_f16(vfp16out6x0123), 0); c6 += 2;
603 vfp16out0x0123 = vext_f16(vfp16out0x0123, vfp16out0x0123, 2);
604 vfp16out1x0123 = vext_f16(vfp16out1x0123, vfp16out1x0123, 2);
605 vfp16out2x0123 = vext_f16(vfp16out2x0123, vfp16out2x0123, 2);
606 vfp16out3x0123 = vext_f16(vfp16out3x0123, vfp16out3x0123, 2);
607 vfp16out4x0123 = vext_f16(vfp16out4x0123, vfp16out4x0123, 2);
608 vfp16out5x0123 = vext_f16(vfp16out5x0123, vfp16out5x0123, 2);
609 vfp16out6x0123 = vext_f16(vfp16out6x0123, vfp16out6x0123, 2);
610 }
611 if (nc & 1) {
612 vst1_lane_u16(c0, vreinterpret_u16_f16(vfp16out0x0123), 0);
613 vst1_lane_u16(c1, vreinterpret_u16_f16(vfp16out1x0123), 0);
614 vst1_lane_u16(c2, vreinterpret_u16_f16(vfp16out2x0123), 0);
615 vst1_lane_u16(c3, vreinterpret_u16_f16(vfp16out3x0123), 0);
616 vst1_lane_u16(c4, vreinterpret_u16_f16(vfp16out4x0123), 0);
617 vst1_lane_u16(c5, vreinterpret_u16_f16(vfp16out5x0123), 0);
618 vst1_lane_u16(c6, vreinterpret_u16_f16(vfp16out6x0123), 0);
619 }
620 nc = 0;
621 }
622 } while (nc != 0);
623 }