XNNPACK Team | b455b12 | 2019-09-27 18:10:33 -0700 | [diff] [blame] | 1 | // Auto-generated file. Do not edit! |
| 2 | // Template: src/f32-igemm/MRx2-neon-ld64.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 | |
Marat Dukhan | c72fa1e | 2019-11-27 11:54:03 -0800 | [diff] [blame] | 14 | #include <xnnpack/common.h> |
XNNPACK Team | b455b12 | 2019-09-27 18:10:33 -0700 | [diff] [blame] | 15 | #include <xnnpack/igemm.h> |
| 16 | |
| 17 | |
Frank Barchard | 91317c5 | 2019-11-22 10:54:35 -0800 | [diff] [blame] | 18 | void xnn_f32_igemm_ukernel_4x2__neon_lane_ld64( |
XNNPACK Team | b455b12 | 2019-09-27 18:10:33 -0700 | [diff] [blame] | 19 | size_t mr, |
| 20 | size_t nc, |
| 21 | size_t kc, |
| 22 | size_t ks, |
| 23 | const float**restrict a, |
| 24 | const float*restrict w, |
| 25 | float*restrict c, |
| 26 | size_t cm_stride, |
| 27 | size_t cn_stride, |
| 28 | size_t a_offset, |
| 29 | const float* zero, |
Marat Dukhan | eb09a6b | 2020-04-08 17:34:32 -0700 | [diff] [blame] | 30 | const union xnn_f32_minmax_params params[restrict static 1]) |
XNNPACK Team | b455b12 | 2019-09-27 18:10:33 -0700 | [diff] [blame] | 31 | { |
| 32 | assert(mr != 0); |
| 33 | assert(mr <= 4); |
| 34 | assert(nc != 0); |
| 35 | assert(kc != 0); |
| 36 | assert(kc % sizeof(float) == 0); |
| 37 | assert(ks != 0); |
| 38 | assert(ks % (4 * sizeof(void*)) == 0); |
| 39 | assert(a_offset % sizeof(float) == 0); |
Frank Barchard | 7ccaab6 | 2019-11-19 14:19:23 -0800 | [diff] [blame] | 40 | assert(a != NULL); |
| 41 | assert(w != NULL); |
| 42 | assert(c != NULL); |
XNNPACK Team | b455b12 | 2019-09-27 18:10:33 -0700 | [diff] [blame] | 43 | |
| 44 | float* c0 = c; |
| 45 | float* c1 = (float*) ((uintptr_t) c0 + cm_stride); |
| 46 | if XNN_UNPREDICTABLE(mr < 2) { |
| 47 | c1 = c0; |
| 48 | } |
| 49 | float* c2 = (float*) ((uintptr_t) c1 + cm_stride); |
| 50 | if XNN_UNPREDICTABLE(mr <= 2) { |
| 51 | c2 = c1; |
| 52 | } |
| 53 | float* c3 = (float*) ((uintptr_t) c2 + cm_stride); |
| 54 | if XNN_UNPREDICTABLE(mr != 4) { |
| 55 | c3 = c2; |
| 56 | } |
| 57 | |
| 58 | do { |
| 59 | float32x2_t vacc0x01 = vld1_f32(w); w += 2; |
| 60 | float32x2_t vacc1x01 = vacc0x01; |
| 61 | float32x2_t vacc2x01 = vacc0x01; |
| 62 | float32x2_t vacc3x01 = vacc0x01; |
| 63 | |
| 64 | size_t p = ks; |
| 65 | do { |
| 66 | const float* restrict a0 = a[0]; |
Frank Barchard | 7ccaab6 | 2019-11-19 14:19:23 -0800 | [diff] [blame] | 67 | assert(a0 != NULL); |
XNNPACK Team | b455b12 | 2019-09-27 18:10:33 -0700 | [diff] [blame] | 68 | if XNN_UNPREDICTABLE(a0 != zero) { |
| 69 | a0 = (const float*) ((uintptr_t) a0 + a_offset); |
| 70 | } |
| 71 | const float* restrict a1 = a[1]; |
Frank Barchard | 7ccaab6 | 2019-11-19 14:19:23 -0800 | [diff] [blame] | 72 | assert(a1 != NULL); |
XNNPACK Team | b455b12 | 2019-09-27 18:10:33 -0700 | [diff] [blame] | 73 | if XNN_UNPREDICTABLE(a1 != zero) { |
| 74 | a1 = (const float*) ((uintptr_t) a1 + a_offset); |
| 75 | } |
| 76 | const float* restrict a2 = a[2]; |
Frank Barchard | 7ccaab6 | 2019-11-19 14:19:23 -0800 | [diff] [blame] | 77 | assert(a2 != NULL); |
XNNPACK Team | b455b12 | 2019-09-27 18:10:33 -0700 | [diff] [blame] | 78 | if XNN_UNPREDICTABLE(a2 != zero) { |
| 79 | a2 = (const float*) ((uintptr_t) a2 + a_offset); |
| 80 | } |
| 81 | const float* restrict a3 = a[3]; |
Frank Barchard | 7ccaab6 | 2019-11-19 14:19:23 -0800 | [diff] [blame] | 82 | assert(a3 != NULL); |
XNNPACK Team | b455b12 | 2019-09-27 18:10:33 -0700 | [diff] [blame] | 83 | if XNN_UNPREDICTABLE(a3 != zero) { |
| 84 | a3 = (const float*) ((uintptr_t) a3 + a_offset); |
| 85 | } |
| 86 | a += 4; |
| 87 | |
| 88 | size_t k = kc; |
| 89 | for (; k >= 2 * sizeof(float); k -= 2 * sizeof(float)) { |
| 90 | const float32x2_t va0 = vld1_f32(a0); a0 += 2; |
| 91 | const float32x2_t va1 = vld1_f32(a1); a1 += 2; |
| 92 | const float32x2_t va2 = vld1_f32(a2); a2 += 2; |
| 93 | const float32x2_t va3 = vld1_f32(a3); a3 += 2; |
| 94 | |
| 95 | const float32x2_t vb01c0 = vld1_f32(w); w += 2; |
| 96 | |
| 97 | vacc0x01 = vmla_lane_f32(vacc0x01, vb01c0, va0, 0); |
| 98 | vacc1x01 = vmla_lane_f32(vacc1x01, vb01c0, va1, 0); |
| 99 | vacc2x01 = vmla_lane_f32(vacc2x01, vb01c0, va2, 0); |
| 100 | vacc3x01 = vmla_lane_f32(vacc3x01, vb01c0, va3, 0); |
| 101 | const float32x2_t vb01c1 = vld1_f32(w); w += 2; |
| 102 | |
| 103 | vacc0x01 = vmla_lane_f32(vacc0x01, vb01c1, va0, 1); |
| 104 | vacc1x01 = vmla_lane_f32(vacc1x01, vb01c1, va1, 1); |
| 105 | vacc2x01 = vmla_lane_f32(vacc2x01, vb01c1, va2, 1); |
| 106 | vacc3x01 = vmla_lane_f32(vacc3x01, vb01c1, va3, 1); |
| 107 | } |
| 108 | if XNN_UNLIKELY(k != 0) { |
| 109 | const float32x2_t va0 = vld1_dup_f32(a0); |
| 110 | const float32x2_t va1 = vld1_dup_f32(a1); |
| 111 | const float32x2_t va2 = vld1_dup_f32(a2); |
| 112 | const float32x2_t va3 = vld1_dup_f32(a3); |
| 113 | |
| 114 | const float32x2_t vb01 = vld1_f32(w); w += 2; |
| 115 | |
| 116 | vacc0x01 = vmla_f32(vacc0x01, va0, vb01); |
| 117 | vacc1x01 = vmla_f32(vacc1x01, va1, vb01); |
| 118 | vacc2x01 = vmla_f32(vacc2x01, va2, vb01); |
| 119 | vacc3x01 = vmla_f32(vacc3x01, va3, vb01); |
| 120 | } |
| 121 | p -= 4 * sizeof(void*); |
| 122 | } while (p != 0); |
| 123 | |
| 124 | const float32x2_t vmax = vld1_dup_f32(¶ms->scalar.max); |
| 125 | vacc0x01 = vmin_f32(vacc0x01, vmax); |
| 126 | vacc1x01 = vmin_f32(vacc1x01, vmax); |
| 127 | vacc2x01 = vmin_f32(vacc2x01, vmax); |
| 128 | vacc3x01 = vmin_f32(vacc3x01, vmax); |
| 129 | |
| 130 | const float32x2_t vmin = vld1_dup_f32(¶ms->scalar.min); |
| 131 | vacc0x01 = vmax_f32(vacc0x01, vmin); |
| 132 | vacc1x01 = vmax_f32(vacc1x01, vmin); |
| 133 | vacc2x01 = vmax_f32(vacc2x01, vmin); |
| 134 | vacc3x01 = vmax_f32(vacc3x01, vmin); |
| 135 | |
| 136 | if XNN_LIKELY(nc >= 2) { |
| 137 | vst1_f32(c3, vacc3x01); |
| 138 | c3 = (float*) ((uintptr_t) c3 + cn_stride); |
| 139 | vst1_f32(c2, vacc2x01); |
| 140 | c2 = (float*) ((uintptr_t) c2 + cn_stride); |
| 141 | vst1_f32(c1, vacc1x01); |
| 142 | c1 = (float*) ((uintptr_t) c1 + cn_stride); |
| 143 | vst1_f32(c0, vacc0x01); |
| 144 | c0 = (float*) ((uintptr_t) c0 + cn_stride); |
| 145 | |
| 146 | a = (const float**restrict) ((uintptr_t) a - ks); |
| 147 | nc -= 2; |
| 148 | } else { |
| 149 | assert(nc == 1); |
| 150 | vst1_lane_f32(c3, vacc3x01, 0); |
| 151 | vst1_lane_f32(c2, vacc2x01, 0); |
| 152 | vst1_lane_f32(c1, vacc1x01, 0); |
| 153 | vst1_lane_f32(c0, vacc0x01, 0); |
| 154 | |
| 155 | nc = 0; |
| 156 | } |
| 157 | } while (nc != 0); |
| 158 | } |