1 // Auto-generated file. Do not edit!
2 // Template: src/f32-ibilinear-chw/scalar.c.in
3 // Generator: tools/xngen
4 //
5 // Copyright 2020 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_chw_ukernel__scalar_p4(size_t output_pixels,size_t channels,const float ** restrict input,size_t input_offset,const float * restrict weights,float * restrict output,size_t input_increment)15 void xnn_f32_ibilinear_chw_ukernel__scalar_p4(
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 input_increment)
23 {
24 assert(output_pixels != 0);
25 assert(channels != 0);
26 assert(input_increment % sizeof(float) == 0);
27
28 size_t c = channels;
29 do {
30 const float** i = input;
31 const float* w = weights;
32
33 size_t p = output_pixels;
34 for (; p >= 4; p -= 4) {
35 const float* itl0 = (const float*) ((uintptr_t) i[0] + input_offset);
36 const float* ibl0 = (const float*) ((uintptr_t) i[1] + input_offset);
37 const float* itl1 = (const float*) ((uintptr_t) i[2] + input_offset);
38 const float* ibl1 = (const float*) ((uintptr_t) i[3] + input_offset);
39 const float* itl2 = (const float*) ((uintptr_t) i[4] + input_offset);
40 const float* ibl2 = (const float*) ((uintptr_t) i[5] + input_offset);
41 const float* itl3 = (const float*) ((uintptr_t) i[6] + input_offset);
42 const float* ibl3 = (const float*) ((uintptr_t) i[7] + input_offset);
43 i += 4 * 2;
44
45 const float valphah0 = w[0];
46 const float valphav0 = w[1];
47 const float valphah1 = w[2];
48 const float valphav1 = w[3];
49 const float valphah2 = w[4];
50 const float valphav2 = w[5];
51 const float valphah3 = w[6];
52 const float valphav3 = w[7];
53 w += 4 * 2;
54
55 const float vtl0 = itl0[0];
56 const float vtr0 = itl0[1];
57 const float vbl0 = ibl0[0];
58 const float vbr0 = ibl0[1];
59 const float vtl1 = itl1[0];
60 const float vtr1 = itl1[1];
61 const float vbl1 = ibl1[0];
62 const float vbr1 = ibl1[1];
63 const float vtl2 = itl2[0];
64 const float vtr2 = itl2[1];
65 const float vbl2 = ibl2[0];
66 const float vbr2 = ibl2[1];
67 const float vtl3 = itl3[0];
68 const float vtr3 = itl3[1];
69 const float vbl3 = ibl3[0];
70 const float vbr3 = ibl3[1];
71
72 const float vtd0 = vtr0 - vtl0;
73 const float vbd0 = vbr0 - vbl0;
74 const float vtd1 = vtr1 - vtl1;
75 const float vbd1 = vbr1 - vbl1;
76 const float vtd2 = vtr2 - vtl2;
77 const float vbd2 = vbr2 - vbl2;
78 const float vtd3 = vtr3 - vtl3;
79 const float vbd3 = vbr3 - vbl3;
80
81 const float vt0 = vtl0 + vtd0 * valphah0;
82 const float vb0 = vbl0 + vbd0 * valphah0;
83 const float vt1 = vtl1 + vtd1 * valphah1;
84 const float vb1 = vbl1 + vbd1 * valphah1;
85 const float vt2 = vtl2 + vtd2 * valphah2;
86 const float vb2 = vbl2 + vbd2 * valphah2;
87 const float vt3 = vtl3 + vtd3 * valphah3;
88 const float vb3 = vbl3 + vbd3 * valphah3;
89
90 const float vd0 = vb0 - vt0;
91 const float vd1 = vb1 - vt1;
92 const float vd2 = vb2 - vt2;
93 const float vd3 = vb3 - vt3;
94
95 const float vo0 = vt0 + vd0 * valphav0;
96 const float vo1 = vt1 + vd1 * valphav1;
97 const float vo2 = vt2 + vd2 * valphav2;
98 const float vo3 = vt3 + vd3 * valphav3;
99
100 output[0] = vo0;
101 output[1] = vo1;
102 output[2] = vo2;
103 output[3] = vo3;
104 output += 4;
105 }
106
107 for (; p >= 1; p -= 1) {
108 const float* itl = (const float*) ((uintptr_t) i[0] + input_offset);
109 const float* ibl = (const float*) ((uintptr_t) i[1] + input_offset);
110 i += 2;
111
112 const float valphah = w[0];
113 const float valphav = w[1];
114 w += 2;
115
116 const float vtl = itl[0];
117 const float vtr = itl[1];
118 const float vbl = ibl[0];
119 const float vbr = ibl[1];
120
121 const float vtd = vtr - vtl;
122 const float vbd = vbr - vbl;
123
124 const float vt = vtl + vtd * valphah;
125 const float vb = vbl + vbd * valphah;
126
127 const float vd = vb - vt;
128
129 const float vo = vt + vd * valphav;
130
131 *output++ = vo;
132 }
133
134 input_offset += input_increment;
135
136 c--;
137 } while (c != 0);
138 }
139