• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Auto-generated file. Do not edit!
2 //   Template: src/f32-igemm/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/igemm.h>
16 
17 
xnn_f32_igemm_minmax_ukernel_1x8__neon_lane_ld64(size_t mr,size_t nc,size_t kc,size_t ks,const float ** restrict a,const float * restrict w,float * restrict c,size_t cm_stride,size_t cn_stride,size_t a_offset,const float * zero,const union xnn_f32_minmax_params params[restrict XNN_MIN_ELEMENTS (1)])18 void xnn_f32_igemm_minmax_ukernel_1x8__neon_lane_ld64(
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,
30     const union xnn_f32_minmax_params params[restrict XNN_MIN_ELEMENTS(1)])
31 {
32   assert(mr != 0);
33   assert(mr <= 1);
34   assert(nc != 0);
35   assert(kc != 0);
36   assert(kc % sizeof(float) == 0);
37   assert(ks != 0);
38   assert(ks % (1 * sizeof(void*)) == 0);
39   assert(a_offset % sizeof(float) == 0);
40   assert(a != NULL);
41   assert(w != NULL);
42   assert(c != NULL);
43 
44   float* c0 = c;
45 
46   do {
47     float32x4_t vacc0x0123 = vld1q_f32(w); w += 4;
48     float32x4_t vacc0x4567 = vld1q_f32(w); w += 4;
49 
50     size_t p = ks;
51     do {
52       const float* restrict a0 = a[0];
53       assert(a0 != NULL);
54       if XNN_UNPREDICTABLE(a0 != zero) {
55         a0 = (const float*) ((uintptr_t) a0 + a_offset);
56       }
57       a += 1;
58 
59       size_t k = kc;
60       for (; k >= 2 * sizeof(float); k -= 2 * sizeof(float)) {
61         const float32x2_t va0 = vld1_f32(a0); a0 += 2;
62 
63         const float32x4_t vb0123c0 = vld1q_f32(w); w += 4;
64         const float32x4_t vb4567c0 = vld1q_f32(w); w += 4;
65 
66         vacc0x0123 = vmlaq_lane_f32(vacc0x0123, vb0123c0, va0, 0);
67         vacc0x4567 = vmlaq_lane_f32(vacc0x4567, vb4567c0, va0, 0);
68         const float32x4_t vb0123c1 = vld1q_f32(w); w += 4;
69         const float32x4_t vb4567c1 = vld1q_f32(w); w += 4;
70 
71         vacc0x0123 = vmlaq_lane_f32(vacc0x0123, vb0123c1, va0, 1);
72         vacc0x4567 = vmlaq_lane_f32(vacc0x4567, vb4567c1, va0, 1);
73 
74       }
75       if XNN_UNLIKELY(k != 0) {
76         const float32x4_t va0 = vld1q_dup_f32(a0);
77 
78         const float32x4_t vb0123 = vld1q_f32(w); w += 4;
79         const float32x4_t vb4567 = vld1q_f32(w); w += 4;
80 
81         vacc0x0123 = vmlaq_f32(vacc0x0123, va0, vb0123);
82         vacc0x4567 = vmlaq_f32(vacc0x4567, va0, vb4567);
83       }
84       p -= 1 * sizeof(void*);
85     } while (p != 0);
86 
87     const float32x4_t vmax = vld1q_dup_f32(&params->scalar.max);
88     vacc0x0123 = vminq_f32(vacc0x0123, vmax);
89     vacc0x4567 = vminq_f32(vacc0x4567, vmax);
90 
91     const float32x4_t vmin = vld1q_dup_f32(&params->scalar.min);
92     vacc0x0123 = vmaxq_f32(vacc0x0123, vmin);
93     vacc0x4567 = vmaxq_f32(vacc0x4567, vmin);
94 
95     if XNN_LIKELY(nc >= 8) {
96       vst1q_f32(c0, vacc0x0123);
97       vst1q_f32(c0 + 4, vacc0x4567);
98       c0 = (float*) ((uintptr_t) c0 + cn_stride);
99 
100       a = (const float**restrict) ((uintptr_t) a - ks);
101       nc -= 8;
102     } else {
103       if (nc & 4) {
104         vst1q_f32(c0, vacc0x0123); c0 += 4;
105 
106         vacc0x0123 = vacc0x4567;
107       }
108       float32x2_t vacc0x01 = vget_low_f32(vacc0x0123);
109       if (nc & 2) {
110         vst1_f32(c0, vacc0x01); c0 += 2;
111 
112         vacc0x01 = vget_high_f32(vacc0x0123);
113       }
114       if (nc & 1) {
115         vst1_lane_f32(c0, vacc0x01, 0);
116       }
117 
118       nc = 0;
119     }
120   } while (nc != 0);
121 }
122