• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Auto-generated file. Do not edit!
2 //   Template: src/f32-ibilinear/scalar.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 <xnnpack/ibilinear.h>
13 
14 
xnn_f32_ibilinear_ukernel__scalar_c4(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)15 void xnn_f32_ibilinear_ukernel__scalar_c4(
16     size_t output_pixels,
17     size_t channels,
18     const float**restrict input,
19     size_t input_offset,
20     const float*restrict weights,
21     float*restrict output,
22     size_t output_increment)
23 {
24   assert(output_pixels != 0);
25   assert(channels != 0);
26   assert(channels % sizeof(float) == 0);
27 
28   do {
29     const float* i0 = (const float*) ((uintptr_t) input[0] + input_offset);
30     const float* i1 = (const float*) ((uintptr_t) input[1] + input_offset);
31     const float* i2 = (const float*) ((uintptr_t) input[2] + input_offset);
32     const float* i3 = (const float*) ((uintptr_t) input[3] + input_offset);
33     input += 4;
34 
35     const float valphah = weights[0];
36     const float valphav = weights[1];
37     weights += 2;
38 
39     size_t c = channels;
40     for (; c >= 4 * sizeof(float); c -= 4 * sizeof(float)) {
41       const float vtl0 = i0[0];
42       const float vtr0 = i1[0];
43       const float vbl0 = i2[0];
44       const float vbr0 = i3[0];
45       const float vtl1 = i0[1];
46       const float vtr1 = i1[1];
47       const float vbl1 = i2[1];
48       const float vbr1 = i3[1];
49       const float vtl2 = i0[2];
50       const float vtr2 = i1[2];
51       const float vbl2 = i2[2];
52       const float vbr2 = i3[2];
53       const float vtl3 = i0[3];
54       const float vtr3 = i1[3];
55       const float vbl3 = i2[3];
56       const float vbr3 = i3[3];
57       i0 += 4;
58       i1 += 4;
59       i2 += 4;
60       i3 += 4;
61 
62       const float vtd0 = vtr0 - vtl0;
63       const float vbd0 = vbr0 - vbl0;
64       const float vtd1 = vtr1 - vtl1;
65       const float vbd1 = vbr1 - vbl1;
66       const float vtd2 = vtr2 - vtl2;
67       const float vbd2 = vbr2 - vbl2;
68       const float vtd3 = vtr3 - vtl3;
69       const float vbd3 = vbr3 - vbl3;
70 
71       const float vt0 = vtl0 + vtd0 * valphah;
72       const float vb0 = vbl0 + vbd0 * valphah;
73       const float vt1 = vtl1 + vtd1 * valphah;
74       const float vb1 = vbl1 + vbd1 * valphah;
75       const float vt2 = vtl2 + vtd2 * valphah;
76       const float vb2 = vbl2 + vbd2 * valphah;
77       const float vt3 = vtl3 + vtd3 * valphah;
78       const float vb3 = vbl3 + vbd3 * valphah;
79 
80       const float vd0 = vb0 - vt0;
81       const float vd1 = vb1 - vt1;
82       const float vd2 = vb2 - vt2;
83       const float vd3 = vb3 - vt3;
84 
85       const float vo0 = vt0 + vd0 * valphav;
86       const float vo1 = vt1 + vd1 * valphav;
87       const float vo2 = vt2 + vd2 * valphav;
88       const float vo3 = vt3 + vd3 * valphav;
89 
90       output[0] = vo0;
91       output[1] = vo1;
92       output[2] = vo2;
93       output[3] = vo3;
94       output += 4;
95     }
96     for (; c >= sizeof(float); c -= sizeof(float)) {
97       const float vtl = *i0++;
98       const float vtr = *i1++;
99       const float vbl = *i2++;
100       const float vbr = *i3++;
101 
102       const float vtd = vtr - vtl;
103       const float vbd = vbr - vbl;
104 
105       const float vt = vtl + vtd * valphah;
106       const float vb = vbl + vbd * valphah;
107 
108       const float vd = vb - vt;
109 
110       const float vo = vt + vd * valphav;
111 
112       *output++ = vo;
113     }
114 
115     output = (float*) ((uintptr_t) output + output_increment);
116   } while (--output_pixels != 0);
117 }
118