Frank Barchard | 6fa8078 | 2021-02-15 16:18:26 -0800 | [diff] [blame] | 1 | // Auto-generated file. Do not edit! |
| 2 | // Template: src/qs8-igemm/c2-neon-mull-padal-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 | |
Frank Barchard | 6fa8078 | 2021-02-15 16:18:26 -0800 | [diff] [blame] | 14 | #include <xnnpack/gemm.h> |
Frank Barchard | 6d8ca7d | 2021-03-01 11:05:08 -0800 | [diff] [blame] | 15 | #include <xnnpack/math.h> |
Frank Barchard | 6fa8078 | 2021-02-15 16:18:26 -0800 | [diff] [blame] | 16 | |
| 17 | |
Marat Dukhan | b07c26a | 2021-05-24 19:44:51 -0700 | [diff] [blame] | 18 | void xnn_qs8_igemm_minmax_gemmlowp_ukernel_1x16c2__neon_mlal_padal_dup( |
Frank Barchard | 6fa8078 | 2021-02-15 16:18:26 -0800 | [diff] [blame] | 19 | size_t mr, |
| 20 | size_t nc, |
| 21 | size_t kc, |
| 22 | size_t ks, |
| 23 | const int8_t** restrict a, |
| 24 | const void* restrict w, |
| 25 | int8_t* restrict c, |
| 26 | size_t cm_stride, |
| 27 | size_t cn_stride, |
| 28 | size_t a_offset, |
| 29 | const int8_t* zero, |
Marat Dukhan | e3d17bf | 2021-05-24 22:22:43 -0700 | [diff] [blame] | 30 | const union xnn_qs8_conv_minmax_params params[restrict XNN_MIN_ELEMENTS(1)]) XNN_DISABLE_TSAN XNN_DISABLE_MSAN |
Frank Barchard | 6fa8078 | 2021-02-15 16:18:26 -0800 | [diff] [blame] | 31 | { |
| 32 | assert(mr != 0); |
| 33 | assert(mr <= 1); |
| 34 | assert(nc != 0); |
| 35 | assert(kc != 0); |
| 36 | assert(ks != 0); |
| 37 | assert(ks % (1 * sizeof(void*)) == 0); |
| 38 | assert(a_offset % sizeof(int8_t) == 0); |
| 39 | assert(a != NULL); |
| 40 | assert(w != NULL); |
| 41 | assert(c != NULL); |
| 42 | |
Frank Barchard | 6d8ca7d | 2021-03-01 11:05:08 -0800 | [diff] [blame] | 43 | kc = round_up_po2(kc, 2); |
Frank Barchard | 6fa8078 | 2021-02-15 16:18:26 -0800 | [diff] [blame] | 44 | int8_t* c0 = c; |
| 45 | |
| 46 | do { |
| 47 | int32x4_t vacc0x0123 = vld1q_s32(w); w = (const void*) ((uintptr_t) w + 4 * sizeof(int32_t)); |
| 48 | int32x4_t vacc0x4567 = vld1q_s32(w); w = (const void*) ((uintptr_t) w + 4 * sizeof(int32_t)); |
| 49 | int32x4_t vacc0x89AB = vld1q_s32(w); w = (const void*) ((uintptr_t) w + 4 * sizeof(int32_t)); |
| 50 | int32x4_t vacc0xCDEF = vld1q_s32(w); w = (const void*) ((uintptr_t) w + 4 * sizeof(int32_t)); |
| 51 | |
| 52 | size_t p = ks; |
| 53 | do { |
| 54 | const int8_t* restrict a0 = a[0]; |
| 55 | if XNN_UNPREDICTABLE(a0 != zero) { |
| 56 | a0 = (const int8_t*) ((uintptr_t) a0 + a_offset); |
| 57 | } |
| 58 | a += 1; |
| 59 | |
| 60 | size_t k = kc; |
| 61 | |
| 62 | while (k >= 16 * sizeof(int8_t)) { |
| 63 | const int8x8_t va0x0 = vld1_s8(a0); a0 += 8; |
| 64 | const int8x8_t va0x1 = vld1_s8(a0); a0 += 8; |
| 65 | |
| 66 | const int8x8_t vb0123c0x0 = vld1_s8(w); w = (const void*) ((uintptr_t) w + 8 * sizeof(int8_t)); |
| 67 | const int8x8_t vb4567c0x0 = vld1_s8(w); w = (const void*) ((uintptr_t) w + 8 * sizeof(int8_t)); |
| 68 | const int8x8_t vb89ABc0x0 = vld1_s8(w); w = (const void*) ((uintptr_t) w + 8 * sizeof(int8_t)); |
| 69 | const int8x8_t vbCDEFc0x0 = vld1_s8(w); w = (const void*) ((uintptr_t) w + 8 * sizeof(int8_t)); |
| 70 | const int8x8_t vb0123c1x0 = vld1_s8(w); w = (const void*) ((uintptr_t) w + 8 * sizeof(int8_t)); |
| 71 | const int8x8_t vb4567c1x0 = vld1_s8(w); w = (const void*) ((uintptr_t) w + 8 * sizeof(int8_t)); |
| 72 | const int8x8_t vb89ABc1x0 = vld1_s8(w); w = (const void*) ((uintptr_t) w + 8 * sizeof(int8_t)); |
| 73 | const int8x8_t vbCDEFc1x0 = vld1_s8(w); w = (const void*) ((uintptr_t) w + 8 * sizeof(int8_t)); |
| 74 | const int8x8_t vb0123c2x0 = vld1_s8(w); w = (const void*) ((uintptr_t) w + 8 * sizeof(int8_t)); |
| 75 | const int8x8_t vb4567c2x0 = vld1_s8(w); w = (const void*) ((uintptr_t) w + 8 * sizeof(int8_t)); |
| 76 | const int8x8_t vb89ABc2x0 = vld1_s8(w); w = (const void*) ((uintptr_t) w + 8 * sizeof(int8_t)); |
| 77 | const int8x8_t vbCDEFc2x0 = vld1_s8(w); w = (const void*) ((uintptr_t) w + 8 * sizeof(int8_t)); |
| 78 | const int8x8_t vb0123c3x0 = vld1_s8(w); w = (const void*) ((uintptr_t) w + 8 * sizeof(int8_t)); |
| 79 | const int8x8_t vb4567c3x0 = vld1_s8(w); w = (const void*) ((uintptr_t) w + 8 * sizeof(int8_t)); |
| 80 | const int8x8_t vb89ABc3x0 = vld1_s8(w); w = (const void*) ((uintptr_t) w + 8 * sizeof(int8_t)); |
| 81 | const int8x8_t vbCDEFc3x0 = vld1_s8(w); w = (const void*) ((uintptr_t) w + 8 * sizeof(int8_t)); |
| 82 | |
| 83 | int16x8_t vprod0x0123c0 = vmull_s8(vb0123c0x0, vreinterpret_s8_s16(vdup_lane_s16(vreinterpret_s16_s8(va0x0), 0))); |
| 84 | const int8x8_t vb0123c0x1 = vld1_s8(w); w = (const void*) ((uintptr_t) w + 8 * sizeof(int8_t)); |
| 85 | vprod0x0123c0 = vmlal_s8(vprod0x0123c0, vb0123c0x1, vreinterpret_s8_s16(vdup_lane_s16(vreinterpret_s16_s8(va0x1), 0))); |
| 86 | vacc0x0123 = vpadalq_s16(vacc0x0123, vprod0x0123c0); |
| 87 | int16x8_t vprod0x4567c0 = vmull_s8(vb4567c0x0, vreinterpret_s8_s16(vdup_lane_s16(vreinterpret_s16_s8(va0x0), 0))); |
| 88 | const int8x8_t vb4567c0x1 = vld1_s8(w); w = (const void*) ((uintptr_t) w + 8 * sizeof(int8_t)); |
| 89 | vprod0x4567c0 = vmlal_s8(vprod0x4567c0, vb4567c0x1, vreinterpret_s8_s16(vdup_lane_s16(vreinterpret_s16_s8(va0x1), 0))); |
| 90 | vacc0x4567 = vpadalq_s16(vacc0x4567, vprod0x4567c0); |
| 91 | int16x8_t vprod0x89ABc0 = vmull_s8(vb89ABc0x0, vreinterpret_s8_s16(vdup_lane_s16(vreinterpret_s16_s8(va0x0), 0))); |
| 92 | const int8x8_t vb89ABc0x1 = vld1_s8(w); w = (const void*) ((uintptr_t) w + 8 * sizeof(int8_t)); |
| 93 | vprod0x89ABc0 = vmlal_s8(vprod0x89ABc0, vb89ABc0x1, vreinterpret_s8_s16(vdup_lane_s16(vreinterpret_s16_s8(va0x1), 0))); |
| 94 | vacc0x89AB = vpadalq_s16(vacc0x89AB, vprod0x89ABc0); |
| 95 | int16x8_t vprod0xCDEFc0 = vmull_s8(vbCDEFc0x0, vreinterpret_s8_s16(vdup_lane_s16(vreinterpret_s16_s8(va0x0), 0))); |
| 96 | const int8x8_t vbCDEFc0x1 = vld1_s8(w); w = (const void*) ((uintptr_t) w + 8 * sizeof(int8_t)); |
| 97 | vprod0xCDEFc0 = vmlal_s8(vprod0xCDEFc0, vbCDEFc0x1, vreinterpret_s8_s16(vdup_lane_s16(vreinterpret_s16_s8(va0x1), 0))); |
| 98 | vacc0xCDEF = vpadalq_s16(vacc0xCDEF, vprod0xCDEFc0); |
| 99 | int16x8_t vprod0x0123c1 = vmull_s8(vb0123c1x0, vreinterpret_s8_s16(vdup_lane_s16(vreinterpret_s16_s8(va0x0), 1))); |
| 100 | const int8x8_t vb0123c1x1 = vld1_s8(w); w = (const void*) ((uintptr_t) w + 8 * sizeof(int8_t)); |
| 101 | vprod0x0123c1 = vmlal_s8(vprod0x0123c1, vb0123c1x1, vreinterpret_s8_s16(vdup_lane_s16(vreinterpret_s16_s8(va0x1), 1))); |
| 102 | vacc0x0123 = vpadalq_s16(vacc0x0123, vprod0x0123c1); |
| 103 | int16x8_t vprod0x4567c1 = vmull_s8(vb4567c1x0, vreinterpret_s8_s16(vdup_lane_s16(vreinterpret_s16_s8(va0x0), 1))); |
| 104 | const int8x8_t vb4567c1x1 = vld1_s8(w); w = (const void*) ((uintptr_t) w + 8 * sizeof(int8_t)); |
| 105 | vprod0x4567c1 = vmlal_s8(vprod0x4567c1, vb4567c1x1, vreinterpret_s8_s16(vdup_lane_s16(vreinterpret_s16_s8(va0x1), 1))); |
| 106 | vacc0x4567 = vpadalq_s16(vacc0x4567, vprod0x4567c1); |
| 107 | int16x8_t vprod0x89ABc1 = vmull_s8(vb89ABc1x0, vreinterpret_s8_s16(vdup_lane_s16(vreinterpret_s16_s8(va0x0), 1))); |
| 108 | const int8x8_t vb89ABc1x1 = vld1_s8(w); w = (const void*) ((uintptr_t) w + 8 * sizeof(int8_t)); |
| 109 | vprod0x89ABc1 = vmlal_s8(vprod0x89ABc1, vb89ABc1x1, vreinterpret_s8_s16(vdup_lane_s16(vreinterpret_s16_s8(va0x1), 1))); |
| 110 | vacc0x89AB = vpadalq_s16(vacc0x89AB, vprod0x89ABc1); |
| 111 | int16x8_t vprod0xCDEFc1 = vmull_s8(vbCDEFc1x0, vreinterpret_s8_s16(vdup_lane_s16(vreinterpret_s16_s8(va0x0), 1))); |
| 112 | const int8x8_t vbCDEFc1x1 = vld1_s8(w); w = (const void*) ((uintptr_t) w + 8 * sizeof(int8_t)); |
| 113 | vprod0xCDEFc1 = vmlal_s8(vprod0xCDEFc1, vbCDEFc1x1, vreinterpret_s8_s16(vdup_lane_s16(vreinterpret_s16_s8(va0x1), 1))); |
| 114 | vacc0xCDEF = vpadalq_s16(vacc0xCDEF, vprod0xCDEFc1); |
| 115 | int16x8_t vprod0x0123c2 = vmull_s8(vb0123c2x0, vreinterpret_s8_s16(vdup_lane_s16(vreinterpret_s16_s8(va0x0), 2))); |
| 116 | const int8x8_t vb0123c2x1 = vld1_s8(w); w = (const void*) ((uintptr_t) w + 8 * sizeof(int8_t)); |
| 117 | vprod0x0123c2 = vmlal_s8(vprod0x0123c2, vb0123c2x1, vreinterpret_s8_s16(vdup_lane_s16(vreinterpret_s16_s8(va0x1), 2))); |
| 118 | vacc0x0123 = vpadalq_s16(vacc0x0123, vprod0x0123c2); |
| 119 | int16x8_t vprod0x4567c2 = vmull_s8(vb4567c2x0, vreinterpret_s8_s16(vdup_lane_s16(vreinterpret_s16_s8(va0x0), 2))); |
| 120 | const int8x8_t vb4567c2x1 = vld1_s8(w); w = (const void*) ((uintptr_t) w + 8 * sizeof(int8_t)); |
| 121 | vprod0x4567c2 = vmlal_s8(vprod0x4567c2, vb4567c2x1, vreinterpret_s8_s16(vdup_lane_s16(vreinterpret_s16_s8(va0x1), 2))); |
| 122 | vacc0x4567 = vpadalq_s16(vacc0x4567, vprod0x4567c2); |
| 123 | int16x8_t vprod0x89ABc2 = vmull_s8(vb89ABc2x0, vreinterpret_s8_s16(vdup_lane_s16(vreinterpret_s16_s8(va0x0), 2))); |
| 124 | const int8x8_t vb89ABc2x1 = vld1_s8(w); w = (const void*) ((uintptr_t) w + 8 * sizeof(int8_t)); |
| 125 | vprod0x89ABc2 = vmlal_s8(vprod0x89ABc2, vb89ABc2x1, vreinterpret_s8_s16(vdup_lane_s16(vreinterpret_s16_s8(va0x1), 2))); |
| 126 | vacc0x89AB = vpadalq_s16(vacc0x89AB, vprod0x89ABc2); |
| 127 | int16x8_t vprod0xCDEFc2 = vmull_s8(vbCDEFc2x0, vreinterpret_s8_s16(vdup_lane_s16(vreinterpret_s16_s8(va0x0), 2))); |
| 128 | const int8x8_t vbCDEFc2x1 = vld1_s8(w); w = (const void*) ((uintptr_t) w + 8 * sizeof(int8_t)); |
| 129 | vprod0xCDEFc2 = vmlal_s8(vprod0xCDEFc2, vbCDEFc2x1, vreinterpret_s8_s16(vdup_lane_s16(vreinterpret_s16_s8(va0x1), 2))); |
| 130 | vacc0xCDEF = vpadalq_s16(vacc0xCDEF, vprod0xCDEFc2); |
| 131 | int16x8_t vprod0x0123c3 = vmull_s8(vb0123c3x0, vreinterpret_s8_s16(vdup_lane_s16(vreinterpret_s16_s8(va0x0), 3))); |
| 132 | const int8x8_t vb0123c3x1 = vld1_s8(w); w = (const void*) ((uintptr_t) w + 8 * sizeof(int8_t)); |
| 133 | vprod0x0123c3 = vmlal_s8(vprod0x0123c3, vb0123c3x1, vreinterpret_s8_s16(vdup_lane_s16(vreinterpret_s16_s8(va0x1), 3))); |
| 134 | vacc0x0123 = vpadalq_s16(vacc0x0123, vprod0x0123c3); |
| 135 | int16x8_t vprod0x4567c3 = vmull_s8(vb4567c3x0, vreinterpret_s8_s16(vdup_lane_s16(vreinterpret_s16_s8(va0x0), 3))); |
| 136 | const int8x8_t vb4567c3x1 = vld1_s8(w); w = (const void*) ((uintptr_t) w + 8 * sizeof(int8_t)); |
| 137 | vprod0x4567c3 = vmlal_s8(vprod0x4567c3, vb4567c3x1, vreinterpret_s8_s16(vdup_lane_s16(vreinterpret_s16_s8(va0x1), 3))); |
| 138 | vacc0x4567 = vpadalq_s16(vacc0x4567, vprod0x4567c3); |
| 139 | int16x8_t vprod0x89ABc3 = vmull_s8(vb89ABc3x0, vreinterpret_s8_s16(vdup_lane_s16(vreinterpret_s16_s8(va0x0), 3))); |
| 140 | const int8x8_t vb89ABc3x1 = vld1_s8(w); w = (const void*) ((uintptr_t) w + 8 * sizeof(int8_t)); |
| 141 | vprod0x89ABc3 = vmlal_s8(vprod0x89ABc3, vb89ABc3x1, vreinterpret_s8_s16(vdup_lane_s16(vreinterpret_s16_s8(va0x1), 3))); |
| 142 | vacc0x89AB = vpadalq_s16(vacc0x89AB, vprod0x89ABc3); |
| 143 | int16x8_t vprod0xCDEFc3 = vmull_s8(vbCDEFc3x0, vreinterpret_s8_s16(vdup_lane_s16(vreinterpret_s16_s8(va0x0), 3))); |
| 144 | const int8x8_t vbCDEFc3x1 = vld1_s8(w); w = (const void*) ((uintptr_t) w + 8 * sizeof(int8_t)); |
| 145 | vprod0xCDEFc3 = vmlal_s8(vprod0xCDEFc3, vbCDEFc3x1, vreinterpret_s8_s16(vdup_lane_s16(vreinterpret_s16_s8(va0x1), 3))); |
| 146 | vacc0xCDEF = vpadalq_s16(vacc0xCDEF, vprod0xCDEFc3); |
| 147 | |
| 148 | k -= 16 * sizeof(int8_t); |
| 149 | } |
| 150 | |
| 151 | if (k >= 8 * sizeof(int8_t)) { |
| 152 | const int8x8_t va0 = vld1_s8(a0); a0 += 8; |
| 153 | |
| 154 | const int8x8_t vb0123c0 = vld1_s8(w); w = (const void*) ((uintptr_t) w + 8 * sizeof(int8_t)); |
| 155 | const int8x8_t vb4567c0 = vld1_s8(w); w = (const void*) ((uintptr_t) w + 8 * sizeof(int8_t)); |
| 156 | const int8x8_t vb89ABc0 = vld1_s8(w); w = (const void*) ((uintptr_t) w + 8 * sizeof(int8_t)); |
| 157 | const int8x8_t vbCDEFc0 = vld1_s8(w); w = (const void*) ((uintptr_t) w + 8 * sizeof(int8_t)); |
| 158 | const int8x8_t vb0123c1 = vld1_s8(w); w = (const void*) ((uintptr_t) w + 8 * sizeof(int8_t)); |
| 159 | const int8x8_t vb4567c1 = vld1_s8(w); w = (const void*) ((uintptr_t) w + 8 * sizeof(int8_t)); |
| 160 | const int8x8_t vb89ABc1 = vld1_s8(w); w = (const void*) ((uintptr_t) w + 8 * sizeof(int8_t)); |
| 161 | const int8x8_t vbCDEFc1 = vld1_s8(w); w = (const void*) ((uintptr_t) w + 8 * sizeof(int8_t)); |
| 162 | const int8x8_t vb0123c2 = vld1_s8(w); w = (const void*) ((uintptr_t) w + 8 * sizeof(int8_t)); |
| 163 | const int8x8_t vb4567c2 = vld1_s8(w); w = (const void*) ((uintptr_t) w + 8 * sizeof(int8_t)); |
| 164 | const int8x8_t vb89ABc2 = vld1_s8(w); w = (const void*) ((uintptr_t) w + 8 * sizeof(int8_t)); |
| 165 | const int8x8_t vbCDEFc2 = vld1_s8(w); w = (const void*) ((uintptr_t) w + 8 * sizeof(int8_t)); |
| 166 | const int8x8_t vb0123c3 = vld1_s8(w); w = (const void*) ((uintptr_t) w + 8 * sizeof(int8_t)); |
| 167 | const int8x8_t vb4567c3 = vld1_s8(w); w = (const void*) ((uintptr_t) w + 8 * sizeof(int8_t)); |
| 168 | const int8x8_t vb89ABc3 = vld1_s8(w); w = (const void*) ((uintptr_t) w + 8 * sizeof(int8_t)); |
| 169 | const int8x8_t vbCDEFc3 = vld1_s8(w); w = (const void*) ((uintptr_t) w + 8 * sizeof(int8_t)); |
| 170 | |
| 171 | const int16x8_t vprod0x0123c0 = vmull_s8(vb0123c0, vreinterpret_s8_s16(vdup_lane_s16(vreinterpret_s16_s8(va0), 0))); |
| 172 | const int16x8_t vprod0x0123c1 = vmull_s8(vb0123c1, vreinterpret_s8_s16(vdup_lane_s16(vreinterpret_s16_s8(va0), 1))); |
| 173 | const int16x8_t vprod0x0123c2 = vmull_s8(vb0123c2, vreinterpret_s8_s16(vdup_lane_s16(vreinterpret_s16_s8(va0), 2))); |
| 174 | const int16x8_t vprod0x0123c3 = vmull_s8(vb0123c3, vreinterpret_s8_s16(vdup_lane_s16(vreinterpret_s16_s8(va0), 3))); |
| 175 | vacc0x0123 = vpadalq_s16(vacc0x0123, vprod0x0123c0); |
| 176 | vacc0x0123 = vpadalq_s16(vacc0x0123, vprod0x0123c1); |
| 177 | vacc0x0123 = vpadalq_s16(vacc0x0123, vprod0x0123c2); |
| 178 | vacc0x0123 = vpadalq_s16(vacc0x0123, vprod0x0123c3); |
| 179 | const int16x8_t vprod0x4567c0 = vmull_s8(vb4567c0, vreinterpret_s8_s16(vdup_lane_s16(vreinterpret_s16_s8(va0), 0))); |
| 180 | const int16x8_t vprod0x4567c1 = vmull_s8(vb4567c1, vreinterpret_s8_s16(vdup_lane_s16(vreinterpret_s16_s8(va0), 1))); |
| 181 | const int16x8_t vprod0x4567c2 = vmull_s8(vb4567c2, vreinterpret_s8_s16(vdup_lane_s16(vreinterpret_s16_s8(va0), 2))); |
| 182 | const int16x8_t vprod0x4567c3 = vmull_s8(vb4567c3, vreinterpret_s8_s16(vdup_lane_s16(vreinterpret_s16_s8(va0), 3))); |
| 183 | vacc0x4567 = vpadalq_s16(vacc0x4567, vprod0x4567c0); |
| 184 | vacc0x4567 = vpadalq_s16(vacc0x4567, vprod0x4567c1); |
| 185 | vacc0x4567 = vpadalq_s16(vacc0x4567, vprod0x4567c2); |
| 186 | vacc0x4567 = vpadalq_s16(vacc0x4567, vprod0x4567c3); |
| 187 | const int16x8_t vprod0x89ABc0 = vmull_s8(vb89ABc0, vreinterpret_s8_s16(vdup_lane_s16(vreinterpret_s16_s8(va0), 0))); |
| 188 | const int16x8_t vprod0x89ABc1 = vmull_s8(vb89ABc1, vreinterpret_s8_s16(vdup_lane_s16(vreinterpret_s16_s8(va0), 1))); |
| 189 | const int16x8_t vprod0x89ABc2 = vmull_s8(vb89ABc2, vreinterpret_s8_s16(vdup_lane_s16(vreinterpret_s16_s8(va0), 2))); |
| 190 | const int16x8_t vprod0x89ABc3 = vmull_s8(vb89ABc3, vreinterpret_s8_s16(vdup_lane_s16(vreinterpret_s16_s8(va0), 3))); |
| 191 | vacc0x89AB = vpadalq_s16(vacc0x89AB, vprod0x89ABc0); |
| 192 | vacc0x89AB = vpadalq_s16(vacc0x89AB, vprod0x89ABc1); |
| 193 | vacc0x89AB = vpadalq_s16(vacc0x89AB, vprod0x89ABc2); |
| 194 | vacc0x89AB = vpadalq_s16(vacc0x89AB, vprod0x89ABc3); |
| 195 | const int16x8_t vprod0xCDEFc0 = vmull_s8(vbCDEFc0, vreinterpret_s8_s16(vdup_lane_s16(vreinterpret_s16_s8(va0), 0))); |
| 196 | const int16x8_t vprod0xCDEFc1 = vmull_s8(vbCDEFc1, vreinterpret_s8_s16(vdup_lane_s16(vreinterpret_s16_s8(va0), 1))); |
| 197 | const int16x8_t vprod0xCDEFc2 = vmull_s8(vbCDEFc2, vreinterpret_s8_s16(vdup_lane_s16(vreinterpret_s16_s8(va0), 2))); |
| 198 | const int16x8_t vprod0xCDEFc3 = vmull_s8(vbCDEFc3, vreinterpret_s8_s16(vdup_lane_s16(vreinterpret_s16_s8(va0), 3))); |
| 199 | vacc0xCDEF = vpadalq_s16(vacc0xCDEF, vprod0xCDEFc0); |
| 200 | vacc0xCDEF = vpadalq_s16(vacc0xCDEF, vprod0xCDEFc1); |
| 201 | vacc0xCDEF = vpadalq_s16(vacc0xCDEF, vprod0xCDEFc2); |
| 202 | vacc0xCDEF = vpadalq_s16(vacc0xCDEF, vprod0xCDEFc3); |
| 203 | |
| 204 | k -= 8 * sizeof(int8_t); |
| 205 | } |
| 206 | |
| 207 | if XNN_UNLIKELY(k != 0) { |
| 208 | const int8x8_t va0 = vld1_s8(a0); a0 = (const int8_t*) ((uintptr_t) a0 + k); |
| 209 | |
| 210 | const int8x8_t vb0123c0 = vld1_s8(w); w = (const void*) ((uintptr_t) w + 8 * sizeof(int8_t)); |
| 211 | const int8x8_t vb4567c0 = vld1_s8(w); w = (const void*) ((uintptr_t) w + 8 * sizeof(int8_t)); |
| 212 | const int8x8_t vb89ABc0 = vld1_s8(w); w = (const void*) ((uintptr_t) w + 8 * sizeof(int8_t)); |
| 213 | const int8x8_t vbCDEFc0 = vld1_s8(w); w = (const void*) ((uintptr_t) w + 8 * sizeof(int8_t)); |
| 214 | |
| 215 | const int16x8_t vprod0x0123c0 = vmull_s8(vb0123c0, vreinterpret_s8_s16(vdup_lane_s16(vreinterpret_s16_s8(va0), 0))); |
| 216 | vacc0x0123 = vpadalq_s16(vacc0x0123, vprod0x0123c0); |
| 217 | const int16x8_t vprod0x4567c0 = vmull_s8(vb4567c0, vreinterpret_s8_s16(vdup_lane_s16(vreinterpret_s16_s8(va0), 0))); |
| 218 | vacc0x4567 = vpadalq_s16(vacc0x4567, vprod0x4567c0); |
| 219 | const int16x8_t vprod0x89ABc0 = vmull_s8(vb89ABc0, vreinterpret_s8_s16(vdup_lane_s16(vreinterpret_s16_s8(va0), 0))); |
| 220 | vacc0x89AB = vpadalq_s16(vacc0x89AB, vprod0x89ABc0); |
| 221 | const int16x8_t vprod0xCDEFc0 = vmull_s8(vbCDEFc0, vreinterpret_s8_s16(vdup_lane_s16(vreinterpret_s16_s8(va0), 0))); |
| 222 | vacc0xCDEF = vpadalq_s16(vacc0xCDEF, vprod0xCDEFc0); |
| 223 | |
| 224 | if (k > 2 * sizeof(int8_t)) { |
| 225 | const int8x8_t vb0123c1 = vld1_s8(w); w = (const void*) ((uintptr_t) w + 8 * sizeof(int8_t)); |
| 226 | const int8x8_t vb4567c1 = vld1_s8(w); w = (const void*) ((uintptr_t) w + 8 * sizeof(int8_t)); |
| 227 | const int8x8_t vb89ABc1 = vld1_s8(w); w = (const void*) ((uintptr_t) w + 8 * sizeof(int8_t)); |
| 228 | const int8x8_t vbCDEFc1 = vld1_s8(w); w = (const void*) ((uintptr_t) w + 8 * sizeof(int8_t)); |
| 229 | |
| 230 | const int16x8_t vprod0x0123c1 = vmull_s8(vb0123c1, vreinterpret_s8_s16(vdup_lane_s16(vreinterpret_s16_s8(va0), 1))); |
| 231 | vacc0x0123 = vpadalq_s16(vacc0x0123, vprod0x0123c1); |
| 232 | const int16x8_t vprod0x4567c1 = vmull_s8(vb4567c1, vreinterpret_s8_s16(vdup_lane_s16(vreinterpret_s16_s8(va0), 1))); |
| 233 | vacc0x4567 = vpadalq_s16(vacc0x4567, vprod0x4567c1); |
| 234 | const int16x8_t vprod0x89ABc1 = vmull_s8(vb89ABc1, vreinterpret_s8_s16(vdup_lane_s16(vreinterpret_s16_s8(va0), 1))); |
| 235 | vacc0x89AB = vpadalq_s16(vacc0x89AB, vprod0x89ABc1); |
| 236 | const int16x8_t vprod0xCDEFc1 = vmull_s8(vbCDEFc1, vreinterpret_s8_s16(vdup_lane_s16(vreinterpret_s16_s8(va0), 1))); |
| 237 | vacc0xCDEF = vpadalq_s16(vacc0xCDEF, vprod0xCDEFc1); |
| 238 | |
| 239 | if (k > 4 * sizeof(int8_t)) { |
| 240 | const int8x8_t vb0123c2 = vld1_s8(w); w = (const void*) ((uintptr_t) w + 8 * sizeof(int8_t)); |
| 241 | const int8x8_t vb4567c2 = vld1_s8(w); w = (const void*) ((uintptr_t) w + 8 * sizeof(int8_t)); |
| 242 | const int8x8_t vb89ABc2 = vld1_s8(w); w = (const void*) ((uintptr_t) w + 8 * sizeof(int8_t)); |
| 243 | const int8x8_t vbCDEFc2 = vld1_s8(w); w = (const void*) ((uintptr_t) w + 8 * sizeof(int8_t)); |
| 244 | |
| 245 | const int16x8_t vprod0x0123c2 = vmull_s8(vb0123c2, vreinterpret_s8_s16(vdup_lane_s16(vreinterpret_s16_s8(va0), 2))); |
| 246 | vacc0x0123 = vpadalq_s16(vacc0x0123, vprod0x0123c2); |
| 247 | const int16x8_t vprod0x4567c2 = vmull_s8(vb4567c2, vreinterpret_s8_s16(vdup_lane_s16(vreinterpret_s16_s8(va0), 2))); |
| 248 | vacc0x4567 = vpadalq_s16(vacc0x4567, vprod0x4567c2); |
| 249 | const int16x8_t vprod0x89ABc2 = vmull_s8(vb89ABc2, vreinterpret_s8_s16(vdup_lane_s16(vreinterpret_s16_s8(va0), 2))); |
| 250 | vacc0x89AB = vpadalq_s16(vacc0x89AB, vprod0x89ABc2); |
| 251 | const int16x8_t vprod0xCDEFc2 = vmull_s8(vbCDEFc2, vreinterpret_s8_s16(vdup_lane_s16(vreinterpret_s16_s8(va0), 2))); |
| 252 | vacc0xCDEF = vpadalq_s16(vacc0xCDEF, vprod0xCDEFc2); |
Frank Barchard | 6fa8078 | 2021-02-15 16:18:26 -0800 | [diff] [blame] | 253 | } |
| 254 | } |
| 255 | } |
| 256 | p -= 1 * sizeof(void*); |
| 257 | } while (p != 0); |
| 258 | |
Marat Dukhan | 9b474cf | 2021-05-25 16:37:48 -0700 | [diff] [blame] | 259 | const int32x4_t vmultiplier = vld1q_dup_s32(¶ms->gemmlowp_neon.multiplier); |
Frank Barchard | 6fa8078 | 2021-02-15 16:18:26 -0800 | [diff] [blame] | 260 | vacc0x0123 = vqrdmulhq_s32(vacc0x0123, vmultiplier); |
| 261 | vacc0x4567 = vqrdmulhq_s32(vacc0x4567, vmultiplier); |
| 262 | vacc0x89AB = vqrdmulhq_s32(vacc0x89AB, vmultiplier); |
| 263 | vacc0xCDEF = vqrdmulhq_s32(vacc0xCDEF, vmultiplier); |
| 264 | |
Marat Dukhan | 9b474cf | 2021-05-25 16:37:48 -0700 | [diff] [blame] | 265 | const int32x4_t vright_shift = vld1q_dup_s32(¶ms->gemmlowp_neon.right_shift); |
Frank Barchard | 6fa8078 | 2021-02-15 16:18:26 -0800 | [diff] [blame] | 266 | const int32x4_t vzero_shift_mask = vreinterpretq_s32_u32(vceqq_s32(vright_shift, vmovq_n_s32(0))); |
| 267 | vacc0x0123 = vsraq_n_s32(vacc0x0123, vbicq_s32(vacc0x0123, vzero_shift_mask), 31); |
| 268 | vacc0x4567 = vsraq_n_s32(vacc0x4567, vbicq_s32(vacc0x4567, vzero_shift_mask), 31); |
| 269 | vacc0x89AB = vsraq_n_s32(vacc0x89AB, vbicq_s32(vacc0x89AB, vzero_shift_mask), 31); |
| 270 | vacc0xCDEF = vsraq_n_s32(vacc0xCDEF, vbicq_s32(vacc0xCDEF, vzero_shift_mask), 31); |
| 271 | |
| 272 | vacc0x0123 = vrshlq_s32(vacc0x0123, vright_shift); |
| 273 | vacc0x4567 = vrshlq_s32(vacc0x4567, vright_shift); |
| 274 | vacc0x89AB = vrshlq_s32(vacc0x89AB, vright_shift); |
| 275 | vacc0xCDEF = vrshlq_s32(vacc0xCDEF, vright_shift); |
| 276 | |
Marat Dukhan | 9b474cf | 2021-05-25 16:37:48 -0700 | [diff] [blame] | 277 | const int16x8_t voutput_zero_point = vld1q_dup_s16(¶ms->gemmlowp_neon.output_zero_point); |
Frank Barchard | 6fa8078 | 2021-02-15 16:18:26 -0800 | [diff] [blame] | 278 | #if XNN_ARCH_ARM64 |
| 279 | const int16x8_t vacc0x01234567 = vqaddq_s16(vqmovn_high_s32(vqmovn_s32(vacc0x0123), vacc0x4567), voutput_zero_point); |
| 280 | const int16x8_t vacc0x89ABCDEF = vqaddq_s16(vqmovn_high_s32(vqmovn_s32(vacc0x89AB), vacc0xCDEF), voutput_zero_point); |
| 281 | |
| 282 | int8x16_t vout0x0123456789ABCDEF = vqmovn_high_s16(vqmovn_s16(vacc0x01234567), vacc0x89ABCDEF); |
| 283 | #else |
| 284 | const int16x8_t vacc0x01234567 = vqaddq_s16(vcombine_s16(vqmovn_s32(vacc0x0123), vqmovn_s32(vacc0x4567)), voutput_zero_point); |
| 285 | const int16x8_t vacc0x89ABCDEF = vqaddq_s16(vcombine_s16(vqmovn_s32(vacc0x89AB), vqmovn_s32(vacc0xCDEF)), voutput_zero_point); |
| 286 | |
| 287 | int8x16_t vout0x0123456789ABCDEF = vcombine_s8(vqmovn_s16(vacc0x01234567), vqmovn_s16(vacc0x89ABCDEF)); |
| 288 | #endif |
Marat Dukhan | 9b474cf | 2021-05-25 16:37:48 -0700 | [diff] [blame] | 289 | const int8x16_t voutput_min = vld1q_dup_s8(¶ms->gemmlowp_neon.output_min); |
| 290 | const int8x16_t voutput_max = vld1q_dup_s8(¶ms->gemmlowp_neon.output_max); |
Frank Barchard | 6fa8078 | 2021-02-15 16:18:26 -0800 | [diff] [blame] | 291 | |
| 292 | vout0x0123456789ABCDEF = vmaxq_s8(vout0x0123456789ABCDEF, voutput_min); |
| 293 | |
| 294 | vout0x0123456789ABCDEF = vminq_s8(vout0x0123456789ABCDEF, voutput_max); |
| 295 | |
| 296 | if (nc >= 16) { |
| 297 | vst1q_s8(c0 + 0, vout0x0123456789ABCDEF); |
| 298 | |
| 299 | c0 = (int8_t*) ((uintptr_t) c0 + cn_stride); |
| 300 | |
| 301 | a = (const int8_t**restrict) ((uintptr_t) a - ks); |
| 302 | |
| 303 | nc -= 16; |
| 304 | } else { |
| 305 | int8x8_t vout0x01234567 = vget_low_s8(vout0x0123456789ABCDEF); |
| 306 | if (nc & 8) { |
| 307 | vst1_s8(c0, vout0x01234567); c0 += 8; |
| 308 | vout0x01234567 = vget_high_s8(vout0x0123456789ABCDEF); |
| 309 | } |
| 310 | if (nc & 4) { |
| 311 | vst1_lane_u32(__builtin_assume_aligned(c0, 1), vreinterpret_u32_s8(vout0x01234567), 0); c0 += 4; |
| 312 | vout0x01234567 = vext_s8(vout0x01234567, vout0x01234567, 4); |
| 313 | } |
| 314 | if (nc & 2) { |
| 315 | vst1_lane_u16(__builtin_assume_aligned(c0, 1), vreinterpret_u16_s8(vout0x01234567), 0); c0 += 2; |
| 316 | vout0x01234567 = vext_s8(vout0x01234567, vout0x01234567, 2); |
| 317 | } |
| 318 | if (nc & 1) { |
| 319 | vst1_lane_s8(c0, vout0x01234567, 0); |
| 320 | } |
| 321 | |
| 322 | nc = 0; |
| 323 | } |
| 324 | } while (nc != 0); |
| 325 | } |