1 // Auto-generated file. Do not edit!
2 // Template: src/f32-dwconv/up-psimd.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 <psimd.h>
13
14 #include <xnnpack/dwconv.h>
15
16
xnn_f32_dwconv_ukernel_up4x4__psimd(size_t channels,size_t output_width,const float ** input,const float * weights,float * output,size_t input_stride,size_t output_increment,const union xnn_f32_output_params params[restrict static1])17 void xnn_f32_dwconv_ukernel_up4x4__psimd(
18 size_t channels,
19 size_t output_width,
20 const float** input,
21 const float* weights,
22 float* output,
23 size_t input_stride,
24 size_t output_increment,
25 const union xnn_f32_output_params params[restrict static 1])
26 {
27 assert(channels != 0);
28 assert(output_width != 0);
29
30 const psimd_f32 vmax = psimd_load_splat_f32(¶ms->scalar.max);
31 const psimd_f32 vmin = psimd_load_splat_f32(¶ms->scalar.min);
32 do {
33 const float* i0 = input[0];
34 assert(i0 != NULL);
35 const float* i1 = input[1];
36 assert(i1 != NULL);
37 const float* i2 = input[2];
38 assert(i2 != NULL);
39 const float* i3 = input[3];
40 assert(i3 != NULL);
41 input = (const float**) ((uintptr_t) input + input_stride);
42
43 size_t c = channels;
44 const float* w = weights;
45 for (; c >= 4; c -= 4) {
46 psimd_f32 vacc0123p0 = psimd_load_f32(w);
47
48
49 const psimd_f32 vi0x0123 = psimd_load_f32(i0);
50 i0 += 4;
51
52 const psimd_f32 vk0x0123 = psimd_load_f32(w + 4);
53 vacc0123p0 = psimd_qfma_f32(vacc0123p0, vi0x0123, vk0x0123);
54
55 const psimd_f32 vi1x0123 = psimd_load_f32(i1);
56 i1 += 4;
57
58 const psimd_f32 vk1x0123 = psimd_load_f32(w + 8);
59 vacc0123p0 = psimd_qfma_f32(vacc0123p0, vi1x0123, vk1x0123);
60
61 const psimd_f32 vi2x0123 = psimd_load_f32(i2);
62 i2 += 4;
63
64 const psimd_f32 vk2x0123 = psimd_load_f32(w + 12);
65 vacc0123p0 = psimd_qfma_f32(vacc0123p0, vi2x0123, vk2x0123);
66
67 const psimd_f32 vi3x0123 = psimd_load_f32(i3);
68 i3 += 4;
69
70 const psimd_f32 vk3x0123 = psimd_load_f32(w + 16);
71 vacc0123p0 = psimd_qfma_f32(vacc0123p0, vi3x0123, vk3x0123);
72
73 w += 20;
74
75
76 psimd_f32 vacc0123 = psimd_max_f32(vacc0123p0, vmin);
77 vacc0123 = psimd_min_f32(vacc0123, vmax);
78
79 psimd_store_f32(output, vacc0123);
80 output += 4;
81 }
82 if XNN_UNLIKELY(c != 0) {
83 psimd_f32 vacc0123p0 = psimd_load_f32(w);
84
85 const psimd_f32 vi0x0123 = psimd_load_f32(i0);
86 const psimd_f32 vk0x0123 = psimd_load_f32(w + 4);
87 vacc0123p0 = psimd_qfma_f32(vacc0123p0, vi0x0123, vk0x0123);
88
89 const psimd_f32 vi1x0123 = psimd_load_f32(i1);
90 const psimd_f32 vk1x0123 = psimd_load_f32(w + 8);
91 vacc0123p0 = psimd_qfma_f32(vacc0123p0, vi1x0123, vk1x0123);
92
93 const psimd_f32 vi2x0123 = psimd_load_f32(i2);
94 const psimd_f32 vk2x0123 = psimd_load_f32(w + 12);
95 vacc0123p0 = psimd_qfma_f32(vacc0123p0, vi2x0123, vk2x0123);
96
97 const psimd_f32 vi3x0123 = psimd_load_f32(i3);
98 const psimd_f32 vk3x0123 = psimd_load_f32(w + 16);
99 vacc0123p0 = psimd_qfma_f32(vacc0123p0, vi3x0123, vk3x0123);
100
101
102 psimd_f32 vacc0123 = psimd_max_f32(vacc0123p0, vmin);
103 vacc0123 = psimd_min_f32(vacc0123, vmax);
104
105 if (c & 2) {
106 psimd_store2_f32(output, vacc0123);
107 vacc0123 = psimd_concat_hi_f32(vacc0123, vacc0123);
108 output += 2;
109 }
110 if (c & 1) {
111 psimd_store1_f32(output, vacc0123);
112 output += 1;
113 }
114 }
115
116 output = (float*) ((uintptr_t) output + output_increment);
117 } while (--output_width != 0);
118 }
119