• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Auto-generated file. Do not edit!
2 //   Template: src/f32-bilinear/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/bilinear.h>
15 
16 
xnn_f32_bilinear_ukernel__psimd_c8(size_t output_pixels,size_t channels,const float ** restrict input,size_t input_offset,const float * restrict weights,float * restrict output,size_t output_increment)17 void xnn_f32_bilinear_ukernel__psimd_c8(
18     size_t output_pixels,
19     size_t channels,
20     const float**restrict input,
21     size_t input_offset,
22     const float*restrict weights,
23     float*restrict output,
24     size_t output_increment)
25 {
26   assert(output_pixels != 0);
27   assert(channels != 0);
28   assert(channels % sizeof(float) == 0);
29 
30   do {
31     const float* i0 = (const float*) ((uintptr_t) input[0] + input_offset);
32     const float* i1 = (const float*) ((uintptr_t) input[1] + input_offset);
33     const float* i2 = (const float*) ((uintptr_t) input[2] + input_offset);
34     const float* i3 = (const float*) ((uintptr_t) input[3] + input_offset);
35     input += 4;
36 
37     const psimd_f32 valphah = psimd_load_splat_f32(weights);
38     const psimd_f32 valphav = psimd_load_splat_f32(weights + 1);
39     weights += 2;
40 
41     size_t c = channels;
42     for (; c >= 8 * sizeof(float); c -= 8 * sizeof(float)) {
43       const psimd_f32 vtl0123 = psimd_load_f32(i0);
44       const psimd_f32 vtr0123 = psimd_load_f32(i1);
45       const psimd_f32 vbl0123 = psimd_load_f32(i2);
46       const psimd_f32 vbr0123 = psimd_load_f32(i3);
47       const psimd_f32 vtl4567 = psimd_load_f32(i0 + 4);
48       const psimd_f32 vtr4567 = psimd_load_f32(i1 + 4);
49       const psimd_f32 vbl4567 = psimd_load_f32(i2 + 4);
50       const psimd_f32 vbr4567 = psimd_load_f32(i3 + 4);
51       i0 += 8;
52       i1 += 8;
53       i2 += 8;
54       i3 += 8;
55 
56       const psimd_f32 vtd0123 = psimd_sub_f32(vtr0123, vtl0123);
57       const psimd_f32 vbd0123 = psimd_sub_f32(vbr0123, vbl0123);
58       const psimd_f32 vtd4567 = psimd_sub_f32(vtr4567, vtl4567);
59       const psimd_f32 vbd4567 = psimd_sub_f32(vbr4567, vbl4567);
60 
61       const psimd_f32 vt0123 = psimd_qfma_f32(vtl0123, vtd0123, valphah);
62       const psimd_f32 vb0123 = psimd_qfma_f32(vbl0123, vbd0123, valphah);
63       const psimd_f32 vt4567 = psimd_qfma_f32(vtl4567, vtd4567, valphah);
64       const psimd_f32 vb4567 = psimd_qfma_f32(vbl4567, vbd4567, valphah);
65 
66       const psimd_f32 vd0123 = psimd_sub_f32(vb0123, vt0123);
67       const psimd_f32 vd4567 = psimd_sub_f32(vb4567, vt4567);
68 
69       const psimd_f32 vo0123 = psimd_qfma_f32(vt0123, vd0123, valphav);
70       const psimd_f32 vo4567 = psimd_qfma_f32(vt4567, vd4567, valphav);
71 
72       psimd_store_f32(output, vo0123);
73       psimd_store_f32(output + 4, vo4567);
74       output += 8;
75     }
76     for (; c >= 4 * sizeof(float); c -= 4 * sizeof(float)) {
77       const psimd_f32 vtl0123 = psimd_load_f32(i0);
78       const psimd_f32 vtr0123 = psimd_load_f32(i1);
79       const psimd_f32 vbl0123 = psimd_load_f32(i2);
80       const psimd_f32 vbr0123 = psimd_load_f32(i3);
81       i0 += 4;
82       i1 += 4;
83       i2 += 4;
84       i3 += 4;
85 
86       const psimd_f32 vtd0123 = psimd_sub_f32(vtr0123, vtl0123);
87       const psimd_f32 vbd0123 = psimd_sub_f32(vbr0123, vbl0123);
88 
89       const psimd_f32 vt0123 = psimd_qfma_f32(vtl0123, vtd0123, valphah);
90       const psimd_f32 vb0123 = psimd_qfma_f32(vbl0123, vbd0123, valphah);
91 
92       const psimd_f32 vd0123 = psimd_sub_f32(vb0123, vt0123);
93 
94       const psimd_f32 vo0123 = psimd_qfma_f32(vt0123, vd0123, valphav);
95 
96       psimd_store_f32(output, vo0123);
97       output += 4;
98     }
99     if XNN_UNLIKELY(c != 0) {
100       const psimd_f32 vtl0123 = psimd_load_f32(i0);
101       const psimd_f32 vtr0123 = psimd_load_f32(i1);
102       const psimd_f32 vbl0123 = psimd_load_f32(i2);
103       const psimd_f32 vbr0123 = psimd_load_f32(i3);
104 
105       const psimd_f32 vtd0123 = psimd_sub_f32(vtr0123, vtl0123);
106       const psimd_f32 vbd0123 = psimd_sub_f32(vbr0123, vbl0123);
107 
108       const psimd_f32 vt0123 = psimd_qfma_f32(vtl0123, vtd0123, valphah);
109       const psimd_f32 vb0123 = psimd_qfma_f32(vbl0123, vbd0123, valphah);
110 
111       const psimd_f32 vd0123 = psimd_sub_f32(vb0123, vt0123);
112 
113       psimd_f32 vo0123 = psimd_qfma_f32(vt0123, vd0123, valphav);
114 
115       if (c & (2 * sizeof(float))) {
116         psimd_store2_f32(output, vo0123);
117         vo0123 = psimd_concat_hi_f32(vo0123, vo0123);
118         output += 2;
119       }
120       if (c & (1 * sizeof(float))) {
121         psimd_store1_f32(output, vo0123);
122         output += 1;
123       }
124     }
125 
126     output = (float*) ((uintptr_t) output + output_increment);
127   } while (--output_pixels != 0);
128 }
129