• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Auto-generated file. Do not edit!
2 //   Template: src/f32-dwconv/up-neon.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 <arm_neon.h>
13 
14 #include <xnnpack/dwconv.h>
15 
16 
xnn_f32_dwconv_ukernel_up4x9__neonfma(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_up4x9__neonfma(
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 float32x4_t vmax = vld1q_dup_f32(&params->scalar.max);
31   const float32x4_t vmin = vld1q_dup_f32(&params->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     const float* i4 = input[4];
42     assert(i4 != NULL);
43     const float* i5 = input[5];
44     assert(i5 != NULL);
45     const float* i6 = input[6];
46     assert(i6 != NULL);
47     const float* i7 = input[7];
48     assert(i7 != NULL);
49     const float* i8 = input[8];
50     assert(i8 != NULL);
51     input = (const float**) ((uintptr_t) input + input_stride);
52 
53     size_t c = channels;
54     const float* w = weights;
55     for (; c >= 4; c -= 4) {
56       float32x4_t vacc0123p0 = vld1q_f32(w); w += 4;
57 
58 
59       const float32x4_t vi0x0123 = vld1q_f32(i0); i0 += 4;
60       const float32x4_t vk0x0123 = vld1q_f32(w); w += 4;
61       vacc0123p0 = vfmaq_f32(vacc0123p0, vi0x0123, vk0x0123);
62 
63       const float32x4_t vi1x0123 = vld1q_f32(i1); i1 += 4;
64       const float32x4_t vk1x0123 = vld1q_f32(w); w += 4;
65       vacc0123p0 = vfmaq_f32(vacc0123p0, vi1x0123, vk1x0123);
66 
67       const float32x4_t vi2x0123 = vld1q_f32(i2); i2 += 4;
68       const float32x4_t vk2x0123 = vld1q_f32(w); w += 4;
69       vacc0123p0 = vfmaq_f32(vacc0123p0, vi2x0123, vk2x0123);
70 
71       const float32x4_t vi3x0123 = vld1q_f32(i3); i3 += 4;
72       const float32x4_t vk3x0123 = vld1q_f32(w); w += 4;
73       vacc0123p0 = vfmaq_f32(vacc0123p0, vi3x0123, vk3x0123);
74 
75       const float32x4_t vi4x0123 = vld1q_f32(i4); i4 += 4;
76       const float32x4_t vk4x0123 = vld1q_f32(w); w += 4;
77       vacc0123p0 = vfmaq_f32(vacc0123p0, vi4x0123, vk4x0123);
78 
79       const float32x4_t vi5x0123 = vld1q_f32(i5); i5 += 4;
80       const float32x4_t vk5x0123 = vld1q_f32(w); w += 4;
81       vacc0123p0 = vfmaq_f32(vacc0123p0, vi5x0123, vk5x0123);
82 
83       const float32x4_t vi6x0123 = vld1q_f32(i6); i6 += 4;
84       const float32x4_t vk6x0123 = vld1q_f32(w); w += 4;
85       vacc0123p0 = vfmaq_f32(vacc0123p0, vi6x0123, vk6x0123);
86 
87       const float32x4_t vi7x0123 = vld1q_f32(i7); i7 += 4;
88       const float32x4_t vk7x0123 = vld1q_f32(w); w += 4;
89       vacc0123p0 = vfmaq_f32(vacc0123p0, vi7x0123, vk7x0123);
90 
91       const float32x4_t vi8x0123 = vld1q_f32(i8); i8 += 4;
92       const float32x4_t vk8x0123 = vld1q_f32(w); w += 4;
93       vacc0123p0 = vfmaq_f32(vacc0123p0, vi8x0123, vk8x0123);
94 
95 
96       float32x4_t vacc0123 = vmaxq_f32(vacc0123p0, vmin);
97       vacc0123 = vminq_f32(vacc0123, vmax);
98 
99       vst1q_f32(output, vacc0123); output += 4;
100     }
101     if XNN_UNLIKELY(c != 0) {
102       float32x4_t vacc0123p0 = vld1q_f32(w); w += 4;
103 
104 
105       const float32x4_t vi0x0123 = vld1q_f32(i0);
106       const float32x4_t vk0x0123 = vld1q_f32(w); w += 4;
107       vacc0123p0 = vfmaq_f32(vacc0123p0, vi0x0123, vk0x0123);
108 
109       const float32x4_t vi1x0123 = vld1q_f32(i1);
110       const float32x4_t vk1x0123 = vld1q_f32(w); w += 4;
111       vacc0123p0 = vfmaq_f32(vacc0123p0, vi1x0123, vk1x0123);
112 
113       const float32x4_t vi2x0123 = vld1q_f32(i2);
114       const float32x4_t vk2x0123 = vld1q_f32(w); w += 4;
115       vacc0123p0 = vfmaq_f32(vacc0123p0, vi2x0123, vk2x0123);
116 
117       const float32x4_t vi3x0123 = vld1q_f32(i3);
118       const float32x4_t vk3x0123 = vld1q_f32(w); w += 4;
119       vacc0123p0 = vfmaq_f32(vacc0123p0, vi3x0123, vk3x0123);
120 
121       const float32x4_t vi4x0123 = vld1q_f32(i4);
122       const float32x4_t vk4x0123 = vld1q_f32(w); w += 4;
123       vacc0123p0 = vfmaq_f32(vacc0123p0, vi4x0123, vk4x0123);
124 
125       const float32x4_t vi5x0123 = vld1q_f32(i5);
126       const float32x4_t vk5x0123 = vld1q_f32(w); w += 4;
127       vacc0123p0 = vfmaq_f32(vacc0123p0, vi5x0123, vk5x0123);
128 
129       const float32x4_t vi6x0123 = vld1q_f32(i6);
130       const float32x4_t vk6x0123 = vld1q_f32(w); w += 4;
131       vacc0123p0 = vfmaq_f32(vacc0123p0, vi6x0123, vk6x0123);
132 
133       const float32x4_t vi7x0123 = vld1q_f32(i7);
134       const float32x4_t vk7x0123 = vld1q_f32(w); w += 4;
135       vacc0123p0 = vfmaq_f32(vacc0123p0, vi7x0123, vk7x0123);
136 
137       const float32x4_t vi8x0123 = vld1q_f32(i8);
138       const float32x4_t vk8x0123 = vld1q_f32(w); w += 4;
139       vacc0123p0 = vfmaq_f32(vacc0123p0, vi8x0123, vk8x0123);
140 
141 
142       float32x4_t vacc0123 = vmaxq_f32(vacc0123p0, vmin);
143       vacc0123 = vminq_f32(vacc0123, vmax);
144 
145       float32x2_t vacc01 = vget_low_f32(vacc0123);
146       if (c & 2) {
147         vst1_f32(output, vacc01); output += 2;
148         vacc01 = vget_high_f32(vacc0123);
149       }
150       if (c & 1) {
151         vst1_lane_f32(output, vacc01, 0); output += 1;
152       }
153     }
154 
155     output = (float*) ((uintptr_t) output + output_increment);
156   } while (--output_width != 0);
157 }
158