Frank Barchard | 42f5c50 | 2021-11-16 10:04:21 -0800 | [diff] [blame^] | 1 | // Auto-generated file. Do not edit! |
| 2 | // Template: src/qs8-igemm/c2-neon-mull-dup.c.in |
| 3 | // Generator: tools/xngen |
| 4 | // |
| 5 | // Copyright 2021 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 | void xnn_qs8_igemm_minmax_fp32_ukernel_2x8c2__neon_mlal_ld4r( |
| 18 | size_t mr, |
| 19 | size_t nc, |
| 20 | size_t kc, |
| 21 | size_t ks, |
| 22 | const int8_t** restrict a, |
| 23 | const void* restrict w, |
| 24 | int8_t* restrict c, |
| 25 | size_t cm_stride, |
| 26 | size_t cn_stride, |
| 27 | size_t a_offset, |
| 28 | const int8_t* zero, |
| 29 | const union xnn_qs8_conv_minmax_params params[restrict XNN_MIN_ELEMENTS(1)]) XNN_DISABLE_TSAN XNN_DISABLE_MSAN |
| 30 | { |
| 31 | assert(mr != 0); |
| 32 | assert(mr <= 2); |
| 33 | assert(nc != 0); |
| 34 | assert(kc != 0); |
| 35 | assert(ks != 0); |
| 36 | assert(ks % (2 * sizeof(void*)) == 0); |
| 37 | assert(a_offset % sizeof(int8_t) == 0); |
| 38 | assert(a != NULL); |
| 39 | assert(w != NULL); |
| 40 | assert(c != NULL); |
| 41 | |
| 42 | kc = round_up_po2(kc, 2 * sizeof(int8_t)); |
| 43 | int8_t* c0 = c; |
| 44 | int8_t* c1 = (int8_t*) ((uintptr_t) c0 + cm_stride); |
| 45 | if XNN_UNPREDICTABLE(mr != 2) { |
| 46 | c1 = c0; |
| 47 | } |
| 48 | |
| 49 | do { |
| 50 | int32x4_t vacc0x0123 = vld1q_s32(w); w = (const void*) ((uintptr_t) w + 4 * sizeof(int32_t)); |
| 51 | int32x4_t vacc0x4567 = vld1q_s32(w); w = (const void*) ((uintptr_t) w + 4 * sizeof(int32_t)); |
| 52 | int32x4_t vacc1x0123 = vacc0x0123; |
| 53 | int32x4_t vacc1x4567 = vacc0x4567; |
| 54 | |
| 55 | size_t p = ks; |
| 56 | do { |
| 57 | const int8_t* restrict a0 = a[0]; |
| 58 | if XNN_UNPREDICTABLE(a0 != zero) { |
| 59 | a0 = (const int8_t*) ((uintptr_t) a0 + a_offset); |
| 60 | } |
| 61 | const int8_t* restrict a1 = a[1]; |
| 62 | if XNN_UNPREDICTABLE(a1 != zero) { |
| 63 | a1 = (const int8_t*) ((uintptr_t) a1 + a_offset); |
| 64 | } |
| 65 | a += 2; |
| 66 | |
| 67 | size_t k = kc; |
| 68 | |
| 69 | while (k >= 16 * sizeof(int8_t)) { |
| 70 | const int16x4x4_t va0x0 = vld4_dup_s16((const void*)a0); a0 += 8; |
| 71 | const int16x4x4_t va0x1 = vld4_dup_s16((const void*)a0); a0 += 8; |
| 72 | const int16x4x4_t va1x0 = vld4_dup_s16((const void*)a1); a1 += 8; |
| 73 | const int16x4x4_t va1x1 = vld4_dup_s16((const void*)a1); a1 += 8; |
| 74 | |
| 75 | const int8x8_t vb0123c0x0 = vld1_s8(w); w = (const void*) ((uintptr_t) w + 8 * sizeof(int8_t)); |
| 76 | const int8x8_t vb4567c0x0 = vld1_s8(w); w = (const void*) ((uintptr_t) w + 8 * sizeof(int8_t)); |
| 77 | const int8x8_t vb0123c1x0 = vld1_s8(w); w = (const void*) ((uintptr_t) w + 8 * sizeof(int8_t)); |
| 78 | const int8x8_t vb4567c1x0 = vld1_s8(w); w = (const void*) ((uintptr_t) w + 8 * sizeof(int8_t)); |
| 79 | const int8x8_t vb0123c2x0 = vld1_s8(w); w = (const void*) ((uintptr_t) w + 8 * sizeof(int8_t)); |
| 80 | const int8x8_t vb4567c2x0 = vld1_s8(w); w = (const void*) ((uintptr_t) w + 8 * sizeof(int8_t)); |
| 81 | const int8x8_t vb0123c3x0 = vld1_s8(w); w = (const void*) ((uintptr_t) w + 8 * sizeof(int8_t)); |
| 82 | const int8x8_t vb4567c3x0 = vld1_s8(w); w = (const void*) ((uintptr_t) w + 8 * sizeof(int8_t)); |
| 83 | |
| 84 | const int8x8_t va0c0x0 = vreinterpret_s8_s16(va0x0.val[0]); |
| 85 | const int8x8_t va0c0x1 = vreinterpret_s8_s16(va0x1.val[0]); |
| 86 | const int8x8_t va1c0x0 = vreinterpret_s8_s16(va1x0.val[0]); |
| 87 | const int8x8_t va1c0x1 = vreinterpret_s8_s16(va1x1.val[0]); |
| 88 | int16x8_t vprod0x0123c0 = vmull_s8(vb0123c0x0, va0c0x0); |
| 89 | int16x8_t vprod1x0123c0 = vmull_s8(vb0123c0x0, va1c0x0); |
| 90 | const int8x8_t vb0123c0x1 = vld1_s8(w); w = (const void*) ((uintptr_t) w + 8 * sizeof(int8_t)); |
| 91 | vprod0x0123c0 = vmlal_s8(vprod0x0123c0, vb0123c0x1, va0c0x1); |
| 92 | vprod1x0123c0 = vmlal_s8(vprod1x0123c0, vb0123c0x1, va1c0x1); |
| 93 | vacc0x0123 = vpadalq_s16(vacc0x0123, vprod0x0123c0); |
| 94 | vacc1x0123 = vpadalq_s16(vacc1x0123, vprod1x0123c0); |
| 95 | int16x8_t vprod0x4567c0 = vmull_s8(vb4567c0x0, va0c0x0); |
| 96 | int16x8_t vprod1x4567c0 = vmull_s8(vb4567c0x0, va1c0x0); |
| 97 | const int8x8_t vb4567c0x1 = vld1_s8(w); w = (const void*) ((uintptr_t) w + 8 * sizeof(int8_t)); |
| 98 | vprod0x4567c0 = vmlal_s8(vprod0x4567c0, vb4567c0x1, va0c0x1); |
| 99 | vprod1x4567c0 = vmlal_s8(vprod1x4567c0, vb4567c0x1, va1c0x1); |
| 100 | vacc0x4567 = vpadalq_s16(vacc0x4567, vprod0x4567c0); |
| 101 | vacc1x4567 = vpadalq_s16(vacc1x4567, vprod1x4567c0); |
| 102 | const int8x8_t va0c1x0 = vreinterpret_s8_s16(va0x0.val[1]); |
| 103 | const int8x8_t va0c1x1 = vreinterpret_s8_s16(va0x1.val[1]); |
| 104 | const int8x8_t va1c1x0 = vreinterpret_s8_s16(va1x0.val[1]); |
| 105 | const int8x8_t va1c1x1 = vreinterpret_s8_s16(va1x1.val[1]); |
| 106 | int16x8_t vprod0x0123c1 = vmull_s8(vb0123c1x0, va0c1x0); |
| 107 | int16x8_t vprod1x0123c1 = vmull_s8(vb0123c1x0, va1c1x0); |
| 108 | const int8x8_t vb0123c1x1 = vld1_s8(w); w = (const void*) ((uintptr_t) w + 8 * sizeof(int8_t)); |
| 109 | vprod0x0123c1 = vmlal_s8(vprod0x0123c1, vb0123c1x1, va0c1x1); |
| 110 | vprod1x0123c1 = vmlal_s8(vprod1x0123c1, vb0123c1x1, va1c1x1); |
| 111 | vacc0x0123 = vpadalq_s16(vacc0x0123, vprod0x0123c1); |
| 112 | vacc1x0123 = vpadalq_s16(vacc1x0123, vprod1x0123c1); |
| 113 | int16x8_t vprod0x4567c1 = vmull_s8(vb4567c1x0, va0c1x0); |
| 114 | int16x8_t vprod1x4567c1 = vmull_s8(vb4567c1x0, va1c1x0); |
| 115 | const int8x8_t vb4567c1x1 = vld1_s8(w); w = (const void*) ((uintptr_t) w + 8 * sizeof(int8_t)); |
| 116 | vprod0x4567c1 = vmlal_s8(vprod0x4567c1, vb4567c1x1, va0c1x1); |
| 117 | vprod1x4567c1 = vmlal_s8(vprod1x4567c1, vb4567c1x1, va1c1x1); |
| 118 | vacc0x4567 = vpadalq_s16(vacc0x4567, vprod0x4567c1); |
| 119 | vacc1x4567 = vpadalq_s16(vacc1x4567, vprod1x4567c1); |
| 120 | const int8x8_t va0c2x0 = vreinterpret_s8_s16(va0x0.val[2]); |
| 121 | const int8x8_t va0c2x1 = vreinterpret_s8_s16(va0x1.val[2]); |
| 122 | const int8x8_t va1c2x0 = vreinterpret_s8_s16(va1x0.val[2]); |
| 123 | const int8x8_t va1c2x1 = vreinterpret_s8_s16(va1x1.val[2]); |
| 124 | int16x8_t vprod0x0123c2 = vmull_s8(vb0123c2x0, va0c2x0); |
| 125 | int16x8_t vprod1x0123c2 = vmull_s8(vb0123c2x0, va1c2x0); |
| 126 | const int8x8_t vb0123c2x1 = vld1_s8(w); w = (const void*) ((uintptr_t) w + 8 * sizeof(int8_t)); |
| 127 | vprod0x0123c2 = vmlal_s8(vprod0x0123c2, vb0123c2x1, va0c2x1); |
| 128 | vprod1x0123c2 = vmlal_s8(vprod1x0123c2, vb0123c2x1, va1c2x1); |
| 129 | vacc0x0123 = vpadalq_s16(vacc0x0123, vprod0x0123c2); |
| 130 | vacc1x0123 = vpadalq_s16(vacc1x0123, vprod1x0123c2); |
| 131 | int16x8_t vprod0x4567c2 = vmull_s8(vb4567c2x0, va0c2x0); |
| 132 | int16x8_t vprod1x4567c2 = vmull_s8(vb4567c2x0, va1c2x0); |
| 133 | const int8x8_t vb4567c2x1 = vld1_s8(w); w = (const void*) ((uintptr_t) w + 8 * sizeof(int8_t)); |
| 134 | vprod0x4567c2 = vmlal_s8(vprod0x4567c2, vb4567c2x1, va0c2x1); |
| 135 | vprod1x4567c2 = vmlal_s8(vprod1x4567c2, vb4567c2x1, va1c2x1); |
| 136 | vacc0x4567 = vpadalq_s16(vacc0x4567, vprod0x4567c2); |
| 137 | vacc1x4567 = vpadalq_s16(vacc1x4567, vprod1x4567c2); |
| 138 | const int8x8_t va0c3x0 = vreinterpret_s8_s16(va0x0.val[3]); |
| 139 | const int8x8_t va0c3x1 = vreinterpret_s8_s16(va0x1.val[3]); |
| 140 | const int8x8_t va1c3x0 = vreinterpret_s8_s16(va1x0.val[3]); |
| 141 | const int8x8_t va1c3x1 = vreinterpret_s8_s16(va1x1.val[3]); |
| 142 | int16x8_t vprod0x0123c3 = vmull_s8(vb0123c3x0, va0c3x0); |
| 143 | int16x8_t vprod1x0123c3 = vmull_s8(vb0123c3x0, va1c3x0); |
| 144 | const int8x8_t vb0123c3x1 = vld1_s8(w); w = (const void*) ((uintptr_t) w + 8 * sizeof(int8_t)); |
| 145 | vprod0x0123c3 = vmlal_s8(vprod0x0123c3, vb0123c3x1, va0c3x1); |
| 146 | vprod1x0123c3 = vmlal_s8(vprod1x0123c3, vb0123c3x1, va1c3x1); |
| 147 | vacc0x0123 = vpadalq_s16(vacc0x0123, vprod0x0123c3); |
| 148 | vacc1x0123 = vpadalq_s16(vacc1x0123, vprod1x0123c3); |
| 149 | int16x8_t vprod0x4567c3 = vmull_s8(vb4567c3x0, va0c3x0); |
| 150 | int16x8_t vprod1x4567c3 = vmull_s8(vb4567c3x0, va1c3x0); |
| 151 | const int8x8_t vb4567c3x1 = vld1_s8(w); w = (const void*) ((uintptr_t) w + 8 * sizeof(int8_t)); |
| 152 | vprod0x4567c3 = vmlal_s8(vprod0x4567c3, vb4567c3x1, va0c3x1); |
| 153 | vprod1x4567c3 = vmlal_s8(vprod1x4567c3, vb4567c3x1, va1c3x1); |
| 154 | vacc0x4567 = vpadalq_s16(vacc0x4567, vprod0x4567c3); |
| 155 | vacc1x4567 = vpadalq_s16(vacc1x4567, vprod1x4567c3); |
| 156 | |
| 157 | k -= 16 * sizeof(int8_t); |
| 158 | } |
| 159 | |
| 160 | if (k >= 8 * sizeof(int8_t)) { |
| 161 | const int16x4x4_t va0 = vld4_dup_s16((const void*)a0); a0 += 8; |
| 162 | const int16x4x4_t va1 = vld4_dup_s16((const void*)a1); a1 += 8; |
| 163 | |
| 164 | const int8x8_t vb0123c0 = vld1_s8(w); w = (const void*) ((uintptr_t) w + 8 * sizeof(int8_t)); |
| 165 | const int8x8_t vb4567c0 = vld1_s8(w); w = (const void*) ((uintptr_t) w + 8 * sizeof(int8_t)); |
| 166 | const int8x8_t vb0123c1 = vld1_s8(w); w = (const void*) ((uintptr_t) w + 8 * sizeof(int8_t)); |
| 167 | const int8x8_t vb4567c1 = vld1_s8(w); w = (const void*) ((uintptr_t) w + 8 * sizeof(int8_t)); |
| 168 | const int8x8_t vb0123c2 = vld1_s8(w); w = (const void*) ((uintptr_t) w + 8 * sizeof(int8_t)); |
| 169 | const int8x8_t vb4567c2 = vld1_s8(w); w = (const void*) ((uintptr_t) w + 8 * sizeof(int8_t)); |
| 170 | const int8x8_t vb0123c3 = vld1_s8(w); w = (const void*) ((uintptr_t) w + 8 * sizeof(int8_t)); |
| 171 | const int8x8_t vb4567c3 = vld1_s8(w); w = (const void*) ((uintptr_t) w + 8 * sizeof(int8_t)); |
| 172 | |
| 173 | const int8x8_t va0c0 = vreinterpret_s8_s16(va0.val[0]); |
| 174 | const int8x8_t va1c0 = vreinterpret_s8_s16(va1.val[0]); |
| 175 | |
| 176 | const int16x8_t vprod0x0123c0 = vmull_s8(vb0123c0, va0c0); |
| 177 | const int16x8_t vprod1x0123c0 = vmull_s8(vb0123c0, va1c0); |
| 178 | vacc0x0123 = vpadalq_s16(vacc0x0123, vprod0x0123c0); |
| 179 | vacc1x0123 = vpadalq_s16(vacc1x0123, vprod1x0123c0); |
| 180 | const int16x8_t vprod0x4567c0 = vmull_s8(vb4567c0, va0c0); |
| 181 | const int16x8_t vprod1x4567c0 = vmull_s8(vb4567c0, va1c0); |
| 182 | vacc0x4567 = vpadalq_s16(vacc0x4567, vprod0x4567c0); |
| 183 | vacc1x4567 = vpadalq_s16(vacc1x4567, vprod1x4567c0); |
| 184 | const int8x8_t va0c1 = vreinterpret_s8_s16(va0.val[1]); |
| 185 | const int8x8_t va1c1 = vreinterpret_s8_s16(va1.val[1]); |
| 186 | |
| 187 | const int16x8_t vprod0x0123c1 = vmull_s8(vb0123c1, va0c1); |
| 188 | const int16x8_t vprod1x0123c1 = vmull_s8(vb0123c1, va1c1); |
| 189 | vacc0x0123 = vpadalq_s16(vacc0x0123, vprod0x0123c1); |
| 190 | vacc1x0123 = vpadalq_s16(vacc1x0123, vprod1x0123c1); |
| 191 | const int16x8_t vprod0x4567c1 = vmull_s8(vb4567c1, va0c1); |
| 192 | const int16x8_t vprod1x4567c1 = vmull_s8(vb4567c1, va1c1); |
| 193 | vacc0x4567 = vpadalq_s16(vacc0x4567, vprod0x4567c1); |
| 194 | vacc1x4567 = vpadalq_s16(vacc1x4567, vprod1x4567c1); |
| 195 | const int8x8_t va0c2 = vreinterpret_s8_s16(va0.val[2]); |
| 196 | const int8x8_t va1c2 = vreinterpret_s8_s16(va1.val[2]); |
| 197 | |
| 198 | const int16x8_t vprod0x0123c2 = vmull_s8(vb0123c2, va0c2); |
| 199 | const int16x8_t vprod1x0123c2 = vmull_s8(vb0123c2, va1c2); |
| 200 | vacc0x0123 = vpadalq_s16(vacc0x0123, vprod0x0123c2); |
| 201 | vacc1x0123 = vpadalq_s16(vacc1x0123, vprod1x0123c2); |
| 202 | const int16x8_t vprod0x4567c2 = vmull_s8(vb4567c2, va0c2); |
| 203 | const int16x8_t vprod1x4567c2 = vmull_s8(vb4567c2, va1c2); |
| 204 | vacc0x4567 = vpadalq_s16(vacc0x4567, vprod0x4567c2); |
| 205 | vacc1x4567 = vpadalq_s16(vacc1x4567, vprod1x4567c2); |
| 206 | const int8x8_t va0c3 = vreinterpret_s8_s16(va0.val[3]); |
| 207 | const int8x8_t va1c3 = vreinterpret_s8_s16(va1.val[3]); |
| 208 | |
| 209 | const int16x8_t vprod0x0123c3 = vmull_s8(vb0123c3, va0c3); |
| 210 | const int16x8_t vprod1x0123c3 = vmull_s8(vb0123c3, va1c3); |
| 211 | vacc0x0123 = vpadalq_s16(vacc0x0123, vprod0x0123c3); |
| 212 | vacc1x0123 = vpadalq_s16(vacc1x0123, vprod1x0123c3); |
| 213 | const int16x8_t vprod0x4567c3 = vmull_s8(vb4567c3, va0c3); |
| 214 | const int16x8_t vprod1x4567c3 = vmull_s8(vb4567c3, va1c3); |
| 215 | vacc0x4567 = vpadalq_s16(vacc0x4567, vprod0x4567c3); |
| 216 | vacc1x4567 = vpadalq_s16(vacc1x4567, vprod1x4567c3); |
| 217 | |
| 218 | k -= 8 * sizeof(int8_t); |
| 219 | } |
| 220 | |
| 221 | if XNN_UNLIKELY(k != 0) { |
| 222 | const int8x8_t va0 = vld1_s8(a0); a0 = (const int8_t*) ((uintptr_t) a0 + k); |
| 223 | const int8x8_t va1 = vld1_s8(a1); a1 = (const int8_t*) ((uintptr_t) a1 + k); |
| 224 | |
| 225 | const int8x8_t vb0123c0 = vld1_s8(w); w = (const void*) ((uintptr_t) w + 8 * sizeof(int8_t)); |
| 226 | const int8x8_t vb4567c0 = vld1_s8(w); w = (const void*) ((uintptr_t) w + 8 * sizeof(int8_t)); |
| 227 | |
| 228 | const int8x8_t va0c0 = vreinterpret_s8_s16(vdup_lane_s16(vreinterpret_s16_s8(va0), 0)); |
| 229 | const int16x8_t vprod0x0123c0 = vmull_s8(vb0123c0, va0c0); |
| 230 | vacc0x0123 = vpadalq_s16(vacc0x0123, vprod0x0123c0); |
| 231 | const int16x8_t vprod0x4567c0 = vmull_s8(vb4567c0, va0c0); |
| 232 | vacc0x4567 = vpadalq_s16(vacc0x4567, vprod0x4567c0); |
| 233 | const int8x8_t va1c0 = vreinterpret_s8_s16(vdup_lane_s16(vreinterpret_s16_s8(va1), 0)); |
| 234 | const int16x8_t vprod1x0123c0 = vmull_s8(vb0123c0, va1c0); |
| 235 | vacc1x0123 = vpadalq_s16(vacc1x0123, vprod1x0123c0); |
| 236 | const int16x8_t vprod1x4567c0 = vmull_s8(vb4567c0, va1c0); |
| 237 | vacc1x4567 = vpadalq_s16(vacc1x4567, vprod1x4567c0); |
| 238 | |
| 239 | if (k > 2 * sizeof(int8_t)) { |
| 240 | const int8x8_t vb0123c1 = vld1_s8(w); w = (const void*) ((uintptr_t) w + 8 * sizeof(int8_t)); |
| 241 | const int8x8_t vb4567c1 = vld1_s8(w); w = (const void*) ((uintptr_t) w + 8 * sizeof(int8_t)); |
| 242 | |
| 243 | const int8x8_t va0c1 = vreinterpret_s8_s16(vdup_lane_s16(vreinterpret_s16_s8(va0), 1)); |
| 244 | const int16x8_t vprod0x0123c1 = vmull_s8(vb0123c1, va0c1); |
| 245 | vacc0x0123 = vpadalq_s16(vacc0x0123, vprod0x0123c1); |
| 246 | const int16x8_t vprod0x4567c1 = vmull_s8(vb4567c1, va0c1); |
| 247 | vacc0x4567 = vpadalq_s16(vacc0x4567, vprod0x4567c1); |
| 248 | const int8x8_t va1c1 = vreinterpret_s8_s16(vdup_lane_s16(vreinterpret_s16_s8(va1), 1)); |
| 249 | const int16x8_t vprod1x0123c1 = vmull_s8(vb0123c1, va1c1); |
| 250 | vacc1x0123 = vpadalq_s16(vacc1x0123, vprod1x0123c1); |
| 251 | const int16x8_t vprod1x4567c1 = vmull_s8(vb4567c1, va1c1); |
| 252 | vacc1x4567 = vpadalq_s16(vacc1x4567, vprod1x4567c1); |
| 253 | |
| 254 | if (k > 4 * sizeof(int8_t)) { |
| 255 | const int8x8_t vb0123c2 = vld1_s8(w); w = (const void*) ((uintptr_t) w + 8 * sizeof(int8_t)); |
| 256 | const int8x8_t vb4567c2 = vld1_s8(w); w = (const void*) ((uintptr_t) w + 8 * sizeof(int8_t)); |
| 257 | |
| 258 | const int8x8_t va0c2 = vreinterpret_s8_s16(vdup_lane_s16(vreinterpret_s16_s8(va0), 2)); |
| 259 | const int16x8_t vprod0x0123c2 = vmull_s8(vb0123c2, va0c2); |
| 260 | vacc0x0123 = vpadalq_s16(vacc0x0123, vprod0x0123c2); |
| 261 | const int16x8_t vprod0x4567c2 = vmull_s8(vb4567c2, va0c2); |
| 262 | vacc0x4567 = vpadalq_s16(vacc0x4567, vprod0x4567c2); |
| 263 | const int8x8_t va1c2 = vreinterpret_s8_s16(vdup_lane_s16(vreinterpret_s16_s8(va1), 2)); |
| 264 | const int16x8_t vprod1x0123c2 = vmull_s8(vb0123c2, va1c2); |
| 265 | vacc1x0123 = vpadalq_s16(vacc1x0123, vprod1x0123c2); |
| 266 | const int16x8_t vprod1x4567c2 = vmull_s8(vb4567c2, va1c2); |
| 267 | vacc1x4567 = vpadalq_s16(vacc1x4567, vprod1x4567c2); |
| 268 | } |
| 269 | } |
| 270 | } |
| 271 | p -= 2 * sizeof(void*); |
| 272 | } while (p != 0); |
| 273 | |
| 274 | float32x4_t vfpacc0x0123 = vcvtq_f32_s32(vacc0x0123); |
| 275 | float32x4_t vfpacc0x4567 = vcvtq_f32_s32(vacc0x4567); |
| 276 | float32x4_t vfpacc1x0123 = vcvtq_f32_s32(vacc1x0123); |
| 277 | float32x4_t vfpacc1x4567 = vcvtq_f32_s32(vacc1x4567); |
| 278 | |
| 279 | const float32x4_t vscale = vld1q_dup_f32(¶ms->fp32_neon.scale); |
| 280 | vfpacc0x0123 = vmulq_f32(vfpacc0x0123, vscale); |
| 281 | vfpacc0x4567 = vmulq_f32(vfpacc0x4567, vscale); |
| 282 | vfpacc1x0123 = vmulq_f32(vfpacc1x0123, vscale); |
| 283 | vfpacc1x4567 = vmulq_f32(vfpacc1x4567, vscale); |
| 284 | |
| 285 | const float32x4_t voutput_min_less_zero_point = vld1q_dup_f32(¶ms->fp32_neon.output_min_less_zero_point); |
| 286 | vfpacc0x0123 = vmaxq_f32(vfpacc0x0123, voutput_min_less_zero_point); |
| 287 | vfpacc0x4567 = vmaxq_f32(vfpacc0x4567, voutput_min_less_zero_point); |
| 288 | vfpacc1x0123 = vmaxq_f32(vfpacc1x0123, voutput_min_less_zero_point); |
| 289 | vfpacc1x4567 = vmaxq_f32(vfpacc1x4567, voutput_min_less_zero_point); |
| 290 | |
| 291 | const float32x4_t voutput_max_less_zero_point = vld1q_dup_f32(¶ms->fp32_neon.output_max_less_zero_point); |
| 292 | vfpacc0x0123 = vminq_f32(vfpacc0x0123, voutput_max_less_zero_point); |
| 293 | vfpacc0x4567 = vminq_f32(vfpacc0x4567, voutput_max_less_zero_point); |
| 294 | vfpacc1x0123 = vminq_f32(vfpacc1x0123, voutput_max_less_zero_point); |
| 295 | vfpacc1x4567 = vminq_f32(vfpacc1x4567, voutput_max_less_zero_point); |
| 296 | |
| 297 | const float32x4_t vmagic_bias = vld1q_dup_f32(¶ms->fp32_neon.magic_bias); |
| 298 | vacc0x0123 = vreinterpretq_s32_f32(vaddq_f32(vfpacc0x0123, vmagic_bias)); |
| 299 | vacc0x4567 = vreinterpretq_s32_f32(vaddq_f32(vfpacc0x4567, vmagic_bias)); |
| 300 | vacc1x0123 = vreinterpretq_s32_f32(vaddq_f32(vfpacc1x0123, vmagic_bias)); |
| 301 | vacc1x4567 = vreinterpretq_s32_f32(vaddq_f32(vfpacc1x4567, vmagic_bias)); |
| 302 | |
| 303 | const int32x4_t vmagic_bias_less_zero_point = vld1q_dup_s32(¶ms->fp32_neon.magic_bias_less_zero_point); |
| 304 | vacc0x0123 = vsubq_s32(vacc0x0123, vmagic_bias_less_zero_point); |
| 305 | vacc0x4567 = vsubq_s32(vacc0x4567, vmagic_bias_less_zero_point); |
| 306 | vacc1x0123 = vsubq_s32(vacc1x0123, vmagic_bias_less_zero_point); |
| 307 | vacc1x4567 = vsubq_s32(vacc1x4567, vmagic_bias_less_zero_point); |
| 308 | |
| 309 | #if XNN_ARCH_ARM64 |
| 310 | const int16x8_t vacc0x01234567 = vuzp1q_s16(vreinterpretq_s16_s32(vacc0x0123), vreinterpretq_s16_s32(vacc0x4567)); |
| 311 | const int16x8_t vacc1x01234567 = vuzp1q_s16(vreinterpretq_s16_s32(vacc1x0123), vreinterpretq_s16_s32(vacc1x4567)); |
| 312 | |
| 313 | int8x16_t vout0x01234567_1x01234567 = vuzp1q_s8(vreinterpretq_s8_s16(vacc0x01234567), vreinterpretq_s8_s16(vacc1x01234567)); |
| 314 | #else |
| 315 | const int16x8_t vacc0x01234567 = vcombine_s16(vmovn_s32(vacc0x0123), vmovn_s32(vacc0x4567)); |
| 316 | const int16x8_t vacc1x01234567 = vcombine_s16(vmovn_s32(vacc1x0123), vmovn_s32(vacc1x4567)); |
| 317 | |
| 318 | int8x16_t vout0x01234567_1x01234567 = vcombine_s8(vmovn_s16(vacc0x01234567), vmovn_s16(vacc1x01234567)); |
| 319 | #endif |
| 320 | |
| 321 | if (nc >= 8) { |
| 322 | vst1_s8(c1 + 0, vget_high_s8(vout0x01234567_1x01234567)); |
| 323 | vst1_s8(c0 + 0, vget_low_s8(vout0x01234567_1x01234567)); |
| 324 | |
| 325 | c1 = (int8_t*) ((uintptr_t) c1 + cn_stride); |
| 326 | c0 = (int8_t*) ((uintptr_t) c0 + cn_stride); |
| 327 | |
| 328 | a = (const int8_t**restrict) ((uintptr_t) a - ks); |
| 329 | |
| 330 | nc -= 8; |
| 331 | } else { |
| 332 | if (nc & 4) { |
| 333 | vst1q_lane_u32(__builtin_assume_aligned(c1, 1), vreinterpretq_u32_s8(vout0x01234567_1x01234567), 2); c1 += 4; |
| 334 | vst1q_lane_u32(__builtin_assume_aligned(c0, 1), vreinterpretq_u32_s8(vout0x01234567_1x01234567), 0); c0 += 4; |
| 335 | vout0x01234567_1x01234567 = vextq_s8(vout0x01234567_1x01234567, vout0x01234567_1x01234567, 4); |
| 336 | } |
| 337 | if (nc & 2) { |
| 338 | vst1q_lane_u16(__builtin_assume_aligned(c1, 1), vreinterpretq_u16_s8(vout0x01234567_1x01234567), 4); c1 += 2; |
| 339 | vst1q_lane_u16(__builtin_assume_aligned(c0, 1), vreinterpretq_u16_s8(vout0x01234567_1x01234567), 0); c0 += 2; |
| 340 | vout0x01234567_1x01234567 = vextq_s8(vout0x01234567_1x01234567, vout0x01234567_1x01234567, 2); |
| 341 | } |
| 342 | if (nc & 1) { |
| 343 | vst1q_lane_s8(c1, vout0x01234567_1x01234567, 8); |
| 344 | vst1q_lane_s8(c0, vout0x01234567_1x01234567, 0); |
| 345 | } |
| 346 | |
| 347 | nc = 0; |
| 348 | } |
| 349 | } while (nc != 0); |
| 350 | } |