1 // Auto-generated file. Do not edit!
2 // Template: src/f32-igemm/scalar.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 <xnnpack/igemm.h>
13 #include <xnnpack/math.h>
14
15
xnn_f32_igemm_ukernel_1x4__scalar(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_default_params params[restrict XNN_MIN_ELEMENTS (1)])16 void xnn_f32_igemm_ukernel_1x4__scalar(
17 size_t mr,
18 size_t nc,
19 size_t kc,
20 size_t ks,
21 const float**restrict a,
22 const float*restrict w,
23 float*restrict c,
24 size_t cm_stride,
25 size_t cn_stride,
26 size_t a_offset,
27 const float* zero,
28 const union xnn_f32_default_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(ks != 0);
36 assert(ks % (1 * sizeof(void*)) == 0);
37 assert(a_offset % sizeof(float) == 0);
38 assert(a != NULL);
39 assert(w != NULL);
40 assert(c != NULL);
41
42 float* c0 = c;
43
44 do {
45 float vacc00 = w[0];
46 float vacc01 = w[1];
47 float vacc02 = w[2];
48 float vacc03 = w[3];
49 w += 4;
50
51 size_t p = ks;
52 do {
53 const float* restrict a0 = a[0];
54 assert(a0 != NULL);
55 if XNN_UNPREDICTABLE(a0 != zero) {
56 a0 = (const float*) ((uintptr_t) a0 + a_offset);
57 }
58 a += 1;
59
60 size_t k = kc;
61 do {
62 const float va0 = *a0++;
63
64 const float vb0 = w[0];
65 const float vb1 = w[1];
66 const float vb2 = w[2];
67 const float vb3 = w[3];
68 w += 4;
69
70 vacc00 = math_muladd_f32(va0, vb0, vacc00);
71 vacc01 = math_muladd_f32(va0, vb1, vacc01);
72 vacc02 = math_muladd_f32(va0, vb2, vacc02);
73 vacc03 = math_muladd_f32(va0, vb3, vacc03);
74
75 k -= sizeof(float);
76 } while (k != 0);
77 p -= 1 * sizeof(void*);
78 } while (p != 0);
79
80
81 if XNN_LIKELY(nc >= 4) {
82 c0[0] = vacc00;
83 c0[1] = vacc01;
84 c0[2] = vacc02;
85 c0[3] = vacc03;
86 c0 = (float*) ((uintptr_t) c0 + cn_stride);
87
88 a = (const float**restrict) ((uintptr_t) a - ks);
89 nc -= 4;
90 } else {
91 if (nc & 2) {
92 c0[0] = vacc00;
93 c0[1] = vacc01;
94 vacc00 = vacc02;
95 c0 += 2;
96 }
97 if (nc & 1) {
98 c0[0] = vacc00;
99 }
100
101 nc = 0;
102 }
103 } while (nc != 0);
104 }
105