• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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_acc2(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_acc2(
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(&params->scalar.max);
31   const psimd_f32 vmin = psimd_load_splat_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     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       psimd_f32 vacc0123p1 = psimd_mul_f32(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       vacc0123p1 = psimd_qfma_f32(vacc0123p1, vi3x0123, vk3x0123);
72 
73       w += 20;
74 
75       // Add up all accumulators to vacc0123p0
76       vacc0123p0 = psimd_add_f32(vacc0123p0, vacc0123p1);
77 
78       psimd_f32 vacc0123 = psimd_max_f32(vacc0123p0, vmin);
79       vacc0123 = psimd_min_f32(vacc0123, vmax);
80 
81       psimd_store_f32(output, vacc0123);
82       output += 4;
83     }
84     if XNN_UNLIKELY(c != 0) {
85       psimd_f32 vacc0123p0 = psimd_load_f32(w);
86 
87       const psimd_f32 vi0x0123 = psimd_load_f32(i0);
88       const psimd_f32 vk0x0123 = psimd_load_f32(w + 4);
89       vacc0123p0 = psimd_qfma_f32(vacc0123p0, vi0x0123, vk0x0123);
90 
91       const psimd_f32 vi1x0123 = psimd_load_f32(i1);
92       const psimd_f32 vk1x0123 = psimd_load_f32(w + 8);
93       psimd_f32 vacc0123p1 = psimd_mul_f32(vi1x0123, vk1x0123);
94 
95       const psimd_f32 vi2x0123 = psimd_load_f32(i2);
96       const psimd_f32 vk2x0123 = psimd_load_f32(w + 12);
97       vacc0123p0 = psimd_qfma_f32(vacc0123p0, vi2x0123, vk2x0123);
98 
99       const psimd_f32 vi3x0123 = psimd_load_f32(i3);
100       const psimd_f32 vk3x0123 = psimd_load_f32(w + 16);
101       vacc0123p1 = psimd_qfma_f32(vacc0123p1, vi3x0123, vk3x0123);
102 
103       // Add up all accumulators to vacc0123p0
104       vacc0123p0 = psimd_add_f32(vacc0123p0, vacc0123p1);
105 
106       psimd_f32 vacc0123 = psimd_max_f32(vacc0123p0, vmin);
107       vacc0123 = psimd_min_f32(vacc0123, vmax);
108 
109       if (c & 2) {
110         psimd_store2_f32(output, vacc0123);
111         vacc0123 = psimd_concat_hi_f32(vacc0123, vacc0123);
112         output += 2;
113       }
114       if (c & 1) {
115         psimd_store1_f32(output, vacc0123);
116         output += 1;
117       }
118     }
119 
120     output = (float*) ((uintptr_t) output + output_increment);
121   } while (--output_width != 0);
122 }
123