• 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_minmax_ukernel_up8x3__neonfma(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_up8x3__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     size_t input_offset,
26     const float* zero,
27     const union xnn_f32_minmax_params params[restrict XNN_MIN_ELEMENTS(1)]) XNN_OOB_READS
28 {
29   assert(channels != 0);
30   assert(output_width != 0);
31 
32   const float32x4_t vmax = vld1q_dup_f32(&params->scalar.max);
33   const float32x4_t vmin = vld1q_dup_f32(&params->scalar.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 
51     input = (const float**) ((uintptr_t) input + input_stride);
52 
53     size_t c = channels;
54     const float* w = weights;
55     for (; c >= 8; c -= 8) {
56       float32x4_t vacc0123p0 = vld1q_f32(w); w += 4;
57       float32x4_t vacc4567p0 = vld1q_f32(w); w += 4;
58 
59 
60       const float32x4_t vi0x0123 = vld1q_f32(i0); i0 += 4;
61       const float32x4_t vi0x4567 = vld1q_f32(i0); i0 += 4;
62       const float32x4_t vk0x0123 = vld1q_f32(w); w += 4;
63       const float32x4_t vk0x4567 = vld1q_f32(w); w += 4;
64       vacc0123p0 = vfmaq_f32(vacc0123p0, vi0x0123, vk0x0123);
65       vacc4567p0 = vfmaq_f32(vacc4567p0, vi0x4567, vk0x4567);
66 
67       const float32x4_t vi1x0123 = vld1q_f32(i1); i1 += 4;
68       const float32x4_t vi1x4567 = vld1q_f32(i1); i1 += 4;
69       const float32x4_t vk1x0123 = vld1q_f32(w); w += 4;
70       const float32x4_t vk1x4567 = vld1q_f32(w); w += 4;
71       vacc0123p0 = vfmaq_f32(vacc0123p0, vi1x0123, vk1x0123);
72       vacc4567p0 = vfmaq_f32(vacc4567p0, vi1x4567, vk1x4567);
73 
74       const float32x4_t vi2x0123 = vld1q_f32(i2); i2 += 4;
75       const float32x4_t vi2x4567 = vld1q_f32(i2); i2 += 4;
76       const float32x4_t vk2x0123 = vld1q_f32(w); w += 4;
77       const float32x4_t vk2x4567 = vld1q_f32(w); w += 4;
78       vacc0123p0 = vfmaq_f32(vacc0123p0, vi2x0123, vk2x0123);
79       vacc4567p0 = vfmaq_f32(vacc4567p0, vi2x4567, vk2x4567);
80 
81 
82       float32x4_t vacc0123 = vmaxq_f32(vacc0123p0, vmin);
83       float32x4_t vacc4567 = vmaxq_f32(vacc4567p0, vmin);
84       vacc0123 = vminq_f32(vacc0123, vmax);
85       vacc4567 = vminq_f32(vacc4567, vmax);
86 
87       vst1q_f32(output, vacc0123); output += 4;
88       vst1q_f32(output, vacc4567); output += 4;
89     }
90     for (; c >= 4; c -= 4) {
91       float32x4_t vacc0123p0 = vld1q_f32(w); w += 4;
92 
93 
94       const float32x4_t vi0x0123 = vld1q_f32(i0); i0 += 4;
95       const float32x4_t vk0x0123 = vld1q_f32(w + 4);
96       vacc0123p0 = vfmaq_f32(vacc0123p0, vi0x0123, vk0x0123);
97 
98       const float32x4_t vi1x0123 = vld1q_f32(i1); i1 += 4;
99       const float32x4_t vk1x0123 = vld1q_f32(w + 12);
100       vacc0123p0 = vfmaq_f32(vacc0123p0, vi1x0123, vk1x0123);
101 
102       const float32x4_t vi2x0123 = vld1q_f32(i2); i2 += 4;
103       const float32x4_t vk2x0123 = vld1q_f32(w + 20);
104       vacc0123p0 = vfmaq_f32(vacc0123p0, vi2x0123, vk2x0123);
105 
106 
107       float32x4_t vacc0123 = vmaxq_f32(vacc0123p0, vmin);
108       vacc0123 = vminq_f32(vacc0123, vmax);
109 
110       vst1q_f32(output, vacc0123); output += 4;
111     }
112     if XNN_UNLIKELY(c != 0) {
113       float32x4_t vacc0123p0 = vld1q_f32(w);
114 
115 
116       const float32x4_t vi0x0123 = vld1q_f32(i0);
117       const float32x4_t vk0x0123 = vld1q_f32(w + 8);
118       vacc0123p0 = vfmaq_f32(vacc0123p0, vi0x0123, vk0x0123);
119 
120       const float32x4_t vi1x0123 = vld1q_f32(i1);
121       const float32x4_t vk1x0123 = vld1q_f32(w + 16);
122       vacc0123p0 = vfmaq_f32(vacc0123p0, vi1x0123, vk1x0123);
123 
124       const float32x4_t vi2x0123 = vld1q_f32(i2);
125       const float32x4_t vk2x0123 = vld1q_f32(w + 24);
126       vacc0123p0 = vfmaq_f32(vacc0123p0, vi2x0123, vk2x0123);
127 
128 
129       float32x4_t vacc0123 = vmaxq_f32(vacc0123p0, vmin);
130       vacc0123 = vminq_f32(vacc0123, vmax);
131 
132       float32x2_t vacc01 = vget_low_f32(vacc0123);
133       if (c & 2) {
134         vst1_f32(output, vacc01); output += 2;
135         vacc01 = vget_high_f32(vacc0123);
136       }
137       if (c & 1) {
138         vst1_lane_f32(output, vacc01, 0); output += 1;
139       }
140     }
141 
142     output = (float*) ((uintptr_t) output + output_increment);
143   } while (--output_width != 0);
144 }
145