blob: c968ee08331812ec90793876bf7daa633f978949 [file] [log] [blame]
Frank Barchard5243bb02019-11-22 16:37:50 -08001// 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
18void xnn_f32_igemm_ukernel_1x8__neon_dup_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,
Marat Dukhaneb09a6b2020-04-08 17:34:32 -070030 const union xnn_f32_minmax_params params[restrict static 1])
Frank Barchard5243bb02019-11-22 16:37:50 -080031{
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 const float32x4_t va0c0 = vdupq_lane_f32(va0, 0);
67 vacc0x0123 = vmlaq_f32(vacc0x0123, va0c0, vb0123c0);
68 vacc0x4567 = vmlaq_f32(vacc0x4567, va0c0, vb4567c0);
69 const float32x4_t vb0123c1 = vld1q_f32(w); w += 4;
70 const float32x4_t vb4567c1 = vld1q_f32(w); w += 4;
71
72 const float32x4_t va0c1 = vdupq_lane_f32(va0, 1);
73 vacc0x0123 = vmlaq_f32(vacc0x0123, va0c1, vb0123c1);
74 vacc0x4567 = vmlaq_f32(vacc0x4567, va0c1, vb4567c1);
75
76 }
77 if XNN_UNLIKELY(k != 0) {
78 const float32x4_t va0 = vld1q_dup_f32(a0);
79
80 const float32x4_t vb0123 = vld1q_f32(w); w += 4;
81 const float32x4_t vb4567 = vld1q_f32(w); w += 4;
82
83 vacc0x0123 = vmlaq_f32(vacc0x0123, va0, vb0123);
84 vacc0x4567 = vmlaq_f32(vacc0x4567, va0, vb4567);
85 }
86 p -= 1 * sizeof(void*);
87 } while (p != 0);
88
89 const float32x4_t vmax = vld1q_dup_f32(&params->scalar.max);
90 vacc0x0123 = vminq_f32(vacc0x0123, vmax);
91 vacc0x4567 = vminq_f32(vacc0x4567, vmax);
92
93 const float32x4_t vmin = vld1q_dup_f32(&params->scalar.min);
94 vacc0x0123 = vmaxq_f32(vacc0x0123, vmin);
95 vacc0x4567 = vmaxq_f32(vacc0x4567, vmin);
96
97 if XNN_LIKELY(nc >= 8) {
98 vst1q_f32(c0, vacc0x0123);
99 vst1q_f32(c0 + 4, vacc0x4567);
100 c0 = (float*) ((uintptr_t) c0 + cn_stride);
101
102 a = (const float**restrict) ((uintptr_t) a - ks);
103 nc -= 8;
104 } else {
105 if (nc & 4) {
106 vst1q_f32(c0, vacc0x0123); c0 += 4;
107
108 vacc0x0123 = vacc0x4567;
109 }
110 float32x2_t vacc0x01 = vget_low_f32(vacc0x0123);
111 if (nc & 2) {
112 vst1_f32(c0, vacc0x01); c0 += 2;
113
114 vacc0x01 = vget_high_f32(vacc0x0123);
115 }
116 if (nc & 1) {
117 vst1_lane_f32(c0, vacc0x01, 0);
118 }
119
120 nc = 0;
121 }
122 } while (nc != 0);
123}