1 // Auto-generated file. Do not edit!
2 // Template: src/f32-gemm/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
11 #include <assert.h>
12
13 #include <arm_neon.h>
14
15 #include <xnnpack/gemm.h>
16
17
xnn_f32_gemm_minmax_ukernel_1x8__neon_lane_ld64(size_t mr,size_t nc,size_t kc,const float * restrict a,size_t a_stride,const float * restrict w,float * restrict c,size_t cm_stride,size_t cn_stride,const union xnn_f32_minmax_params params[restrict XNN_MIN_ELEMENTS (1)])18 void xnn_f32_gemm_minmax_ukernel_1x8__neon_lane_ld64(
19 size_t mr,
20 size_t nc,
21 size_t kc,
22 const float* restrict a,
23 size_t a_stride,
24 const float* restrict w,
25 float* restrict c,
26 size_t cm_stride,
27 size_t cn_stride,
28 const union xnn_f32_minmax_params params[restrict XNN_MIN_ELEMENTS(1)])
29 {
30 assert(mr != 0);
31 assert(mr <= 1);
32 assert(nc != 0);
33 assert(kc != 0);
34 assert(kc % sizeof(float) == 0);
35 assert(a != NULL);
36 assert(w != NULL);
37 assert(c != NULL);
38
39 const float* a0 = a;
40 float* c0 = c;
41
42 do {
43 float32x4_t vacc0x0123 = vld1q_f32(w); w += 4;
44 float32x4_t vacc0x4567 = vld1q_f32(w); w += 4;
45
46 size_t k = kc;
47 for (; k >= 2 * sizeof(float); k -= 2 * sizeof(float)) {
48 const float32x2_t va0 = vld1_f32(a0); a0 += 2;
49
50 const float32x4_t vb0123c0 = vld1q_f32(w); w += 4;
51 const float32x4_t vb4567c0 = vld1q_f32(w); w += 4;
52
53 vacc0x0123 = vmlaq_lane_f32(vacc0x0123, vb0123c0, va0, 0);
54 vacc0x4567 = vmlaq_lane_f32(vacc0x4567, vb4567c0, va0, 0);
55 const float32x4_t vb0123c1 = vld1q_f32(w); w += 4;
56 const float32x4_t vb4567c1 = vld1q_f32(w); w += 4;
57
58 vacc0x0123 = vmlaq_lane_f32(vacc0x0123, vb0123c1, va0, 1);
59 vacc0x4567 = vmlaq_lane_f32(vacc0x4567, vb4567c1, va0, 1);
60 }
61 if XNN_UNLIKELY(k != 0) {
62 const float32x4_t va0 = vld1q_dup_f32(a0); a0 += 1;
63
64 const float32x4_t vb0123 = vld1q_f32(w); w += 4;
65 const float32x4_t vb4567 = vld1q_f32(w); w += 4;
66
67 vacc0x0123 = vmlaq_f32(vacc0x0123, va0, vb0123);
68 vacc0x4567 = vmlaq_f32(vacc0x4567, va0, vb4567);
69 }
70 const float32x4_t vmax = vld1q_dup_f32(¶ms->scalar.max);
71 vacc0x0123 = vminq_f32(vacc0x0123, vmax);
72 vacc0x4567 = vminq_f32(vacc0x4567, vmax);
73
74 const float32x4_t vmin = vld1q_dup_f32(¶ms->scalar.min);
75 vacc0x0123 = vmaxq_f32(vacc0x0123, vmin);
76 vacc0x4567 = vmaxq_f32(vacc0x4567, vmin);
77
78 if XNN_LIKELY(nc >= 8) {
79 vst1q_f32(c0, vacc0x0123);
80 vst1q_f32(c0 + 4, vacc0x4567);
81 c0 = (float*) ((uintptr_t) c0 + cn_stride);
82
83 a0 = (const float*) ((uintptr_t) a0 - kc);
84
85 nc -= 8;
86
87 } else {
88 if (nc & 4) {
89 vst1q_f32(c0, vacc0x0123); c0 += 4;
90
91 vacc0x0123 = vacc0x4567;
92 }
93 float32x2_t vacc0x01 = vget_low_f32(vacc0x0123);
94 if (nc & 2) {
95 vst1_f32(c0, vacc0x01); c0 += 2;
96
97 vacc0x01 = vget_high_f32(vacc0x0123);
98 }
99 if (nc & 1) {
100 vst1_lane_f32(c0, vacc0x01, 0);
101 }
102
103 nc = 0;
104 }
105 } while (nc != 0);
106 }
107