1 // Auto-generated file. Do not edit!
2 // Template: src/f32-dwconv/up-sse.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 <xmmintrin.h>
13
14 #include <xnnpack/dwconv.h>
15
16
xnn_f32_dwconv_minmax_ukernel_up4x9__sse(size_t channels,size_t output_width,const float ** input,const float * weights,float * output,size_t input_stride,size_t output_increment,size_t input_offset,const float * zero,const union xnn_f32_minmax_params params[restrict XNN_MIN_ELEMENTS (1)])17 void xnn_f32_dwconv_minmax_ukernel_up4x9__sse(
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 size_t input_offset,
26 const float* zero,
27 const union xnn_f32_minmax_params params[restrict XNN_MIN_ELEMENTS(1)]) XNN_DISABLE_TSAN
28 {
29 assert(channels != 0);
30 assert(output_width != 0);
31
32 const __m128 vmax = _mm_load_ps(params->sse.max);
33 const __m128 vmin = _mm_load_ps(params->sse.min);
34 do {
35 const float* i0 = input[0];
36 assert(i0 != NULL);
37 if XNN_UNPREDICTABLE(i0 != zero) {
38 i0 = (const float*) ((uintptr_t) i0 + input_offset);
39 }
40 const float* i1 = input[1];
41 assert(i1 != NULL);
42 if XNN_UNPREDICTABLE(i1 != zero) {
43 i1 = (const float*) ((uintptr_t) i1 + input_offset);
44 }
45 const float* i2 = input[2];
46 assert(i2 != NULL);
47 if XNN_UNPREDICTABLE(i2 != zero) {
48 i2 = (const float*) ((uintptr_t) i2 + input_offset);
49 }
50 const float* i3 = input[3];
51 assert(i3 != NULL);
52 if XNN_UNPREDICTABLE(i3 != zero) {
53 i3 = (const float*) ((uintptr_t) i3 + input_offset);
54 }
55 const float* i4 = input[4];
56 assert(i4 != NULL);
57 if XNN_UNPREDICTABLE(i4 != zero) {
58 i4 = (const float*) ((uintptr_t) i4 + input_offset);
59 }
60 const float* i5 = input[5];
61 assert(i5 != NULL);
62 if XNN_UNPREDICTABLE(i5 != zero) {
63 i5 = (const float*) ((uintptr_t) i5 + input_offset);
64 }
65 const float* i6 = input[6];
66 assert(i6 != NULL);
67 if XNN_UNPREDICTABLE(i6 != zero) {
68 i6 = (const float*) ((uintptr_t) i6 + input_offset);
69 }
70 const float* i7 = input[7];
71 assert(i7 != NULL);
72 if XNN_UNPREDICTABLE(i7 != zero) {
73 i7 = (const float*) ((uintptr_t) i7 + input_offset);
74 }
75 const float* i8 = input[8];
76 assert(i8 != NULL);
77 if XNN_UNPREDICTABLE(i8 != zero) {
78 i8 = (const float*) ((uintptr_t) i8 + input_offset);
79 }
80 input = (const float**) ((uintptr_t) input + input_stride);
81
82 size_t c = channels;
83 const float* w = weights;
84 for (; c >= 4; c -= 4) {
85 __m128 vacc0123p0 = _mm_load_ps(w);
86
87
88 const __m128 vi0x0123 = _mm_loadu_ps(i0);
89 i0 += 4;
90
91 const __m128 vk0x0123 = _mm_load_ps(w + 4);
92 vacc0123p0 = _mm_add_ps(vacc0123p0, _mm_mul_ps(vi0x0123, vk0x0123));
93
94 const __m128 vi1x0123 = _mm_loadu_ps(i1);
95 i1 += 4;
96
97 const __m128 vk1x0123 = _mm_load_ps(w + 8);
98 vacc0123p0 = _mm_add_ps(vacc0123p0, _mm_mul_ps(vi1x0123, vk1x0123));
99
100 const __m128 vi2x0123 = _mm_loadu_ps(i2);
101 i2 += 4;
102
103 const __m128 vk2x0123 = _mm_load_ps(w + 12);
104 vacc0123p0 = _mm_add_ps(vacc0123p0, _mm_mul_ps(vi2x0123, vk2x0123));
105
106 const __m128 vi3x0123 = _mm_loadu_ps(i3);
107 i3 += 4;
108
109 const __m128 vk3x0123 = _mm_load_ps(w + 16);
110 vacc0123p0 = _mm_add_ps(vacc0123p0, _mm_mul_ps(vi3x0123, vk3x0123));
111
112 const __m128 vi4x0123 = _mm_loadu_ps(i4);
113 i4 += 4;
114
115 const __m128 vk4x0123 = _mm_load_ps(w + 20);
116 vacc0123p0 = _mm_add_ps(vacc0123p0, _mm_mul_ps(vi4x0123, vk4x0123));
117
118 const __m128 vi5x0123 = _mm_loadu_ps(i5);
119 i5 += 4;
120
121 const __m128 vk5x0123 = _mm_load_ps(w + 24);
122 vacc0123p0 = _mm_add_ps(vacc0123p0, _mm_mul_ps(vi5x0123, vk5x0123));
123
124 const __m128 vi6x0123 = _mm_loadu_ps(i6);
125 i6 += 4;
126
127 const __m128 vk6x0123 = _mm_load_ps(w + 28);
128 vacc0123p0 = _mm_add_ps(vacc0123p0, _mm_mul_ps(vi6x0123, vk6x0123));
129
130 const __m128 vi7x0123 = _mm_loadu_ps(i7);
131 i7 += 4;
132
133 const __m128 vk7x0123 = _mm_load_ps(w + 32);
134 vacc0123p0 = _mm_add_ps(vacc0123p0, _mm_mul_ps(vi7x0123, vk7x0123));
135
136 const __m128 vi8x0123 = _mm_loadu_ps(i8);
137 i8 += 4;
138
139 const __m128 vk8x0123 = _mm_load_ps(w + 36);
140 vacc0123p0 = _mm_add_ps(vacc0123p0, _mm_mul_ps(vi8x0123, vk8x0123));
141
142 w += 40;
143
144
145 __m128 vacc0123 = _mm_max_ps(vacc0123p0, vmin);
146 vacc0123 = _mm_min_ps(vacc0123, vmax);
147
148 _mm_storeu_ps(output, vacc0123);
149 output += 4;
150 }
151 if XNN_UNLIKELY(c != 0) {
152 __m128 vacc0123p0 = _mm_load_ps(w);
153
154 const __m128 vi0x0123 = _mm_loadu_ps(i0);
155 const __m128 vk0x0123 = _mm_load_ps(w + 4);
156 vacc0123p0 = _mm_add_ps(vacc0123p0, _mm_mul_ps(vi0x0123, vk0x0123));
157
158 const __m128 vi1x0123 = _mm_loadu_ps(i1);
159 const __m128 vk1x0123 = _mm_load_ps(w + 8);
160 vacc0123p0 = _mm_add_ps(vacc0123p0, _mm_mul_ps(vi1x0123, vk1x0123));
161
162 const __m128 vi2x0123 = _mm_loadu_ps(i2);
163 const __m128 vk2x0123 = _mm_load_ps(w + 12);
164 vacc0123p0 = _mm_add_ps(vacc0123p0, _mm_mul_ps(vi2x0123, vk2x0123));
165
166 const __m128 vi3x0123 = _mm_loadu_ps(i3);
167 const __m128 vk3x0123 = _mm_load_ps(w + 16);
168 vacc0123p0 = _mm_add_ps(vacc0123p0, _mm_mul_ps(vi3x0123, vk3x0123));
169
170 const __m128 vi4x0123 = _mm_loadu_ps(i4);
171 const __m128 vk4x0123 = _mm_load_ps(w + 20);
172 vacc0123p0 = _mm_add_ps(vacc0123p0, _mm_mul_ps(vi4x0123, vk4x0123));
173
174 const __m128 vi5x0123 = _mm_loadu_ps(i5);
175 const __m128 vk5x0123 = _mm_load_ps(w + 24);
176 vacc0123p0 = _mm_add_ps(vacc0123p0, _mm_mul_ps(vi5x0123, vk5x0123));
177
178 const __m128 vi6x0123 = _mm_loadu_ps(i6);
179 const __m128 vk6x0123 = _mm_load_ps(w + 28);
180 vacc0123p0 = _mm_add_ps(vacc0123p0, _mm_mul_ps(vi6x0123, vk6x0123));
181
182 const __m128 vi7x0123 = _mm_loadu_ps(i7);
183 const __m128 vk7x0123 = _mm_load_ps(w + 32);
184 vacc0123p0 = _mm_add_ps(vacc0123p0, _mm_mul_ps(vi7x0123, vk7x0123));
185
186 const __m128 vi8x0123 = _mm_loadu_ps(i8);
187 const __m128 vk8x0123 = _mm_load_ps(w + 36);
188 vacc0123p0 = _mm_add_ps(vacc0123p0, _mm_mul_ps(vi8x0123, vk8x0123));
189
190
191 __m128 vacc0123 = _mm_max_ps(vacc0123p0, vmin);
192 vacc0123 = _mm_min_ps(vacc0123, vmax);
193
194 if (c & 2) {
195 _mm_storel_pi((__m64*) output, vacc0123);
196 vacc0123 = _mm_movehl_ps(vacc0123, vacc0123);
197 output += 2;
198 }
199 if (c & 1) {
200 _mm_store_ss(output, vacc0123);
201 output += 1;
202 }
203 }
204
205 output = (float*) ((uintptr_t) output + output_increment);
206 } while (--output_width != 0);
207 }
208