• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Auto-generated file. Do not edit!
2 //   Template: src/f16-dwconv/up-neonfp16arith.c.in
3 //   Generator: tools/xngen
4 //
5 // Copyright 2020 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 <arm_neon.h>
13 
14 #include <xnnpack/dwconv.h>
15 
16 
xnn_f16_dwconv_minmax_ukernel_up16x9__neonfp16arith(size_t channels,size_t output_width,const void ** input,const void * weights,void * output_ptr,size_t input_stride,size_t output_increment,size_t input_offset,const void * zero,const union xnn_f16_minmax_params params[restrict XNN_MIN_ELEMENTS (1)])17 void xnn_f16_dwconv_minmax_ukernel_up16x9__neonfp16arith(
18     size_t channels,
19     size_t output_width,
20     const void** input,
21     const void* weights,
22     void* output_ptr,
23     size_t input_stride,
24     size_t output_increment,
25     size_t input_offset,
26     const void* zero,
27     const union xnn_f16_minmax_params params[restrict XNN_MIN_ELEMENTS(1)]) XNN_OOB_READS
28 {
29   assert(channels != 0);
30   assert(output_width != 0);
31 
32   __fp16* output = (__fp16*) output_ptr;
33   const float16x8_t vmax = vreinterpretq_f16_u16(vld1q_dup_u16(&params->neon.max));
34   const float16x8_t vmin = vreinterpretq_f16_u16(vld1q_dup_u16(&params->neon.min));
35   do {
36     const __fp16* i0 = (const __fp16*) input[0];
37     assert(i0 != NULL);
38     if XNN_UNPREDICTABLE(i0 != (const __fp16*) zero) {
39       i0 = (const __fp16*) ((uintptr_t) i0 + input_offset);
40     }
41     const __fp16* i1 = (const __fp16*) input[1];
42     assert(i1 != NULL);
43     if XNN_UNPREDICTABLE(i1 != (const __fp16*) zero) {
44       i1 = (const __fp16*) ((uintptr_t) i1 + input_offset);
45     }
46     const __fp16* i2 = (const __fp16*) input[2];
47     assert(i2 != NULL);
48     if XNN_UNPREDICTABLE(i2 != (const __fp16*) zero) {
49       i2 = (const __fp16*) ((uintptr_t) i2 + input_offset);
50     }
51     const __fp16* i3 = (const __fp16*) input[3];
52     assert(i3 != NULL);
53     if XNN_UNPREDICTABLE(i3 != (const __fp16*) zero) {
54       i3 = (const __fp16*) ((uintptr_t) i3 + input_offset);
55     }
56     const __fp16* i4 = (const __fp16*) input[4];
57     assert(i4 != NULL);
58     if XNN_UNPREDICTABLE(i4 != (const __fp16*) zero) {
59       i4 = (const __fp16*) ((uintptr_t) i4 + input_offset);
60     }
61     const __fp16* i5 = (const __fp16*) input[5];
62     assert(i5 != NULL);
63     if XNN_UNPREDICTABLE(i5 != (const __fp16*) zero) {
64       i5 = (const __fp16*) ((uintptr_t) i5 + input_offset);
65     }
66     const __fp16* i6 = (const __fp16*) input[6];
67     assert(i6 != NULL);
68     if XNN_UNPREDICTABLE(i6 != (const __fp16*) zero) {
69       i6 = (const __fp16*) ((uintptr_t) i6 + input_offset);
70     }
71     const __fp16* i7 = (const __fp16*) input[7];
72     assert(i7 != NULL);
73     if XNN_UNPREDICTABLE(i7 != (const __fp16*) zero) {
74       i7 = (const __fp16*) ((uintptr_t) i7 + input_offset);
75     }
76     const __fp16* i8 = (const __fp16*) input[8];
77     assert(i8 != NULL);
78     if XNN_UNPREDICTABLE(i8 != (const __fp16*) zero) {
79       i8 = (const __fp16*) ((uintptr_t) i8 + input_offset);
80     }
81 
82     input = (const void**) ((uintptr_t) input + input_stride);
83 
84     size_t c = channels;
85     const __fp16* w = (const __fp16*) weights;
86     for (; c >= 16; c -= 16) {
87       float16x8_t vacc01234567p0 = vld1q_f16(w); w += 8;
88       float16x8_t vacc89ABCDEFp0 = vld1q_f16(w); w += 8;
89 
90 
91       const float16x8_t vi0x01234567 = vld1q_f16(i0); i0 += 8;
92       const float16x8_t vi0x89ABCDEF = vld1q_f16(i0); i0 += 8;
93       const float16x8_t vk0x01234567 = vld1q_f16(w); w += 8;
94       const float16x8_t vk0x89ABCDEF = vld1q_f16(w); w += 8;
95       vacc01234567p0 = vfmaq_f16(vacc01234567p0, vi0x01234567, vk0x01234567);
96       vacc89ABCDEFp0 = vfmaq_f16(vacc89ABCDEFp0, vi0x89ABCDEF, vk0x89ABCDEF);
97 
98       const float16x8_t vi1x01234567 = vld1q_f16(i1); i1 += 8;
99       const float16x8_t vi1x89ABCDEF = vld1q_f16(i1); i1 += 8;
100       const float16x8_t vk1x01234567 = vld1q_f16(w); w += 8;
101       const float16x8_t vk1x89ABCDEF = vld1q_f16(w); w += 8;
102       vacc01234567p0 = vfmaq_f16(vacc01234567p0, vi1x01234567, vk1x01234567);
103       vacc89ABCDEFp0 = vfmaq_f16(vacc89ABCDEFp0, vi1x89ABCDEF, vk1x89ABCDEF);
104 
105       const float16x8_t vi2x01234567 = vld1q_f16(i2); i2 += 8;
106       const float16x8_t vi2x89ABCDEF = vld1q_f16(i2); i2 += 8;
107       const float16x8_t vk2x01234567 = vld1q_f16(w); w += 8;
108       const float16x8_t vk2x89ABCDEF = vld1q_f16(w); w += 8;
109       vacc01234567p0 = vfmaq_f16(vacc01234567p0, vi2x01234567, vk2x01234567);
110       vacc89ABCDEFp0 = vfmaq_f16(vacc89ABCDEFp0, vi2x89ABCDEF, vk2x89ABCDEF);
111 
112       const float16x8_t vi3x01234567 = vld1q_f16(i3); i3 += 8;
113       const float16x8_t vi3x89ABCDEF = vld1q_f16(i3); i3 += 8;
114       const float16x8_t vk3x01234567 = vld1q_f16(w); w += 8;
115       const float16x8_t vk3x89ABCDEF = vld1q_f16(w); w += 8;
116       vacc01234567p0 = vfmaq_f16(vacc01234567p0, vi3x01234567, vk3x01234567);
117       vacc89ABCDEFp0 = vfmaq_f16(vacc89ABCDEFp0, vi3x89ABCDEF, vk3x89ABCDEF);
118 
119       const float16x8_t vi4x01234567 = vld1q_f16(i4); i4 += 8;
120       const float16x8_t vi4x89ABCDEF = vld1q_f16(i4); i4 += 8;
121       const float16x8_t vk4x01234567 = vld1q_f16(w); w += 8;
122       const float16x8_t vk4x89ABCDEF = vld1q_f16(w); w += 8;
123       vacc01234567p0 = vfmaq_f16(vacc01234567p0, vi4x01234567, vk4x01234567);
124       vacc89ABCDEFp0 = vfmaq_f16(vacc89ABCDEFp0, vi4x89ABCDEF, vk4x89ABCDEF);
125 
126       const float16x8_t vi5x01234567 = vld1q_f16(i5); i5 += 8;
127       const float16x8_t vi5x89ABCDEF = vld1q_f16(i5); i5 += 8;
128       const float16x8_t vk5x01234567 = vld1q_f16(w); w += 8;
129       const float16x8_t vk5x89ABCDEF = vld1q_f16(w); w += 8;
130       vacc01234567p0 = vfmaq_f16(vacc01234567p0, vi5x01234567, vk5x01234567);
131       vacc89ABCDEFp0 = vfmaq_f16(vacc89ABCDEFp0, vi5x89ABCDEF, vk5x89ABCDEF);
132 
133       const float16x8_t vi6x01234567 = vld1q_f16(i6); i6 += 8;
134       const float16x8_t vi6x89ABCDEF = vld1q_f16(i6); i6 += 8;
135       const float16x8_t vk6x01234567 = vld1q_f16(w); w += 8;
136       const float16x8_t vk6x89ABCDEF = vld1q_f16(w); w += 8;
137       vacc01234567p0 = vfmaq_f16(vacc01234567p0, vi6x01234567, vk6x01234567);
138       vacc89ABCDEFp0 = vfmaq_f16(vacc89ABCDEFp0, vi6x89ABCDEF, vk6x89ABCDEF);
139 
140       const float16x8_t vi7x01234567 = vld1q_f16(i7); i7 += 8;
141       const float16x8_t vi7x89ABCDEF = vld1q_f16(i7); i7 += 8;
142       const float16x8_t vk7x01234567 = vld1q_f16(w); w += 8;
143       const float16x8_t vk7x89ABCDEF = vld1q_f16(w); w += 8;
144       vacc01234567p0 = vfmaq_f16(vacc01234567p0, vi7x01234567, vk7x01234567);
145       vacc89ABCDEFp0 = vfmaq_f16(vacc89ABCDEFp0, vi7x89ABCDEF, vk7x89ABCDEF);
146 
147       const float16x8_t vi8x01234567 = vld1q_f16(i8); i8 += 8;
148       const float16x8_t vi8x89ABCDEF = vld1q_f16(i8); i8 += 8;
149       const float16x8_t vk8x01234567 = vld1q_f16(w); w += 8;
150       const float16x8_t vk8x89ABCDEF = vld1q_f16(w); w += 8;
151       vacc01234567p0 = vfmaq_f16(vacc01234567p0, vi8x01234567, vk8x01234567);
152       vacc89ABCDEFp0 = vfmaq_f16(vacc89ABCDEFp0, vi8x89ABCDEF, vk8x89ABCDEF);
153 
154 
155       float16x8_t vacc01234567 = vmaxq_f16(vacc01234567p0, vmin);
156       float16x8_t vacc89ABCDEF = vmaxq_f16(vacc89ABCDEFp0, vmin);
157       vacc01234567 = vminq_f16(vacc01234567, vmax);
158       vacc89ABCDEF = vminq_f16(vacc89ABCDEF, vmax);
159 
160       vst1q_f16(output, vacc01234567); output += 8;
161       vst1q_f16(output, vacc89ABCDEF); output += 8;
162     }
163     for (; c >= 8; c -= 8) {
164       float16x8_t vacc01234567p0 = vld1q_f16(w); w += 8;
165 
166 
167       const float16x8_t vi0x01234567 = vld1q_f16(i0); i0 += 8;
168       const float16x8_t vk0x01234567 = vld1q_f16(w + 8);
169       vacc01234567p0 = vfmaq_f16(vacc01234567p0, vi0x01234567, vk0x01234567);
170 
171       const float16x8_t vi1x01234567 = vld1q_f16(i1); i1 += 8;
172       const float16x8_t vk1x01234567 = vld1q_f16(w + 24);
173       vacc01234567p0 = vfmaq_f16(vacc01234567p0, vi1x01234567, vk1x01234567);
174 
175       const float16x8_t vi2x01234567 = vld1q_f16(i2); i2 += 8;
176       const float16x8_t vk2x01234567 = vld1q_f16(w + 40);
177       vacc01234567p0 = vfmaq_f16(vacc01234567p0, vi2x01234567, vk2x01234567);
178 
179       const float16x8_t vi3x01234567 = vld1q_f16(i3); i3 += 8;
180       const float16x8_t vk3x01234567 = vld1q_f16(w + 56);
181       vacc01234567p0 = vfmaq_f16(vacc01234567p0, vi3x01234567, vk3x01234567);
182 
183       const float16x8_t vi4x01234567 = vld1q_f16(i4); i4 += 8;
184       const float16x8_t vk4x01234567 = vld1q_f16(w + 72);
185       vacc01234567p0 = vfmaq_f16(vacc01234567p0, vi4x01234567, vk4x01234567);
186 
187       const float16x8_t vi5x01234567 = vld1q_f16(i5); i5 += 8;
188       const float16x8_t vk5x01234567 = vld1q_f16(w + 88);
189       vacc01234567p0 = vfmaq_f16(vacc01234567p0, vi5x01234567, vk5x01234567);
190 
191       const float16x8_t vi6x01234567 = vld1q_f16(i6); i6 += 8;
192       const float16x8_t vk6x01234567 = vld1q_f16(w + 104);
193       vacc01234567p0 = vfmaq_f16(vacc01234567p0, vi6x01234567, vk6x01234567);
194 
195       const float16x8_t vi7x01234567 = vld1q_f16(i7); i7 += 8;
196       const float16x8_t vk7x01234567 = vld1q_f16(w + 120);
197       vacc01234567p0 = vfmaq_f16(vacc01234567p0, vi7x01234567, vk7x01234567);
198 
199       const float16x8_t vi8x01234567 = vld1q_f16(i8); i8 += 8;
200       const float16x8_t vk8x01234567 = vld1q_f16(w + 136);
201       vacc01234567p0 = vfmaq_f16(vacc01234567p0, vi8x01234567, vk8x01234567);
202 
203 
204       float16x8_t vacc01234567 = vmaxq_f16(vacc01234567p0, vmin);
205       vacc01234567 = vminq_f16(vacc01234567, vmax);
206 
207       vst1q_f16(output, vacc01234567); output += 8;
208     }
209     if XNN_UNLIKELY(c != 0) {
210       float16x8_t vacc01234567p0 = vld1q_f16(w);
211 
212 
213       const float16x8_t vi0x01234567 = vld1q_f16(i0);
214       const float16x8_t vk0x01234567 = vld1q_f16(w + 16);
215       vacc01234567p0 = vfmaq_f16(vacc01234567p0, vi0x01234567, vk0x01234567);
216 
217       const float16x8_t vi1x01234567 = vld1q_f16(i1);
218       const float16x8_t vk1x01234567 = vld1q_f16(w + 32);
219       vacc01234567p0 = vfmaq_f16(vacc01234567p0, vi1x01234567, vk1x01234567);
220 
221       const float16x8_t vi2x01234567 = vld1q_f16(i2);
222       const float16x8_t vk2x01234567 = vld1q_f16(w + 48);
223       vacc01234567p0 = vfmaq_f16(vacc01234567p0, vi2x01234567, vk2x01234567);
224 
225       const float16x8_t vi3x01234567 = vld1q_f16(i3);
226       const float16x8_t vk3x01234567 = vld1q_f16(w + 64);
227       vacc01234567p0 = vfmaq_f16(vacc01234567p0, vi3x01234567, vk3x01234567);
228 
229       const float16x8_t vi4x01234567 = vld1q_f16(i4);
230       const float16x8_t vk4x01234567 = vld1q_f16(w + 80);
231       vacc01234567p0 = vfmaq_f16(vacc01234567p0, vi4x01234567, vk4x01234567);
232 
233       const float16x8_t vi5x01234567 = vld1q_f16(i5);
234       const float16x8_t vk5x01234567 = vld1q_f16(w + 96);
235       vacc01234567p0 = vfmaq_f16(vacc01234567p0, vi5x01234567, vk5x01234567);
236 
237       const float16x8_t vi6x01234567 = vld1q_f16(i6);
238       const float16x8_t vk6x01234567 = vld1q_f16(w + 112);
239       vacc01234567p0 = vfmaq_f16(vacc01234567p0, vi6x01234567, vk6x01234567);
240 
241       const float16x8_t vi7x01234567 = vld1q_f16(i7);
242       const float16x8_t vk7x01234567 = vld1q_f16(w + 128);
243       vacc01234567p0 = vfmaq_f16(vacc01234567p0, vi7x01234567, vk7x01234567);
244 
245       const float16x8_t vi8x01234567 = vld1q_f16(i8);
246       const float16x8_t vk8x01234567 = vld1q_f16(w + 144);
247       vacc01234567p0 = vfmaq_f16(vacc01234567p0, vi8x01234567, vk8x01234567);
248 
249 
250       float16x8_t vacc01234567 = vmaxq_f16(vacc01234567p0, vmin);
251       vacc01234567 = vminq_f16(vacc01234567, vmax);
252 
253       float16x4_t vacc0123 = vget_low_f16(vacc01234567);
254       if (c & 4) {
255         vst1_f16(output, vacc0123); output += 4;
256         vacc0123 = vget_high_f16(vacc01234567);
257       }
258       if (c & 2) {
259         vst1_lane_u32((void*) output, vreinterpret_u32_f16(vacc0123), 0); output += 2;
260         vacc0123 = vext_f16(vacc0123, vacc0123, 2);
261       }
262       if (c & 1) {
263         vst1_lane_f16(output, vacc0123, 0); output += 1;
264       }
265     }
266 
267     output = (__fp16*) ((uintptr_t) output + output_increment);
268   } while (--output_width != 0);
269 }
270