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_p2(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_p2(
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 >= 2; p -= 2) {
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 i += 2 * 2;
40
41 const float valphah0 = w[0];
42 const float valphav0 = w[1];
43 const float valphah1 = w[2];
44 const float valphav1 = w[3];
45 w += 2 * 2;
46
47 const float vtl0 = itl0[0];
48 const float vtr0 = itl0[1];
49 const float vbl0 = ibl0[0];
50 const float vbr0 = ibl0[1];
51 const float vtl1 = itl1[0];
52 const float vtr1 = itl1[1];
53 const float vbl1 = ibl1[0];
54 const float vbr1 = ibl1[1];
55
56 const float vtd0 = vtr0 - vtl0;
57 const float vbd0 = vbr0 - vbl0;
58 const float vtd1 = vtr1 - vtl1;
59 const float vbd1 = vbr1 - vbl1;
60
61 const float vt0 = vtl0 + vtd0 * valphah0;
62 const float vb0 = vbl0 + vbd0 * valphah0;
63 const float vt1 = vtl1 + vtd1 * valphah1;
64 const float vb1 = vbl1 + vbd1 * valphah1;
65
66 const float vd0 = vb0 - vt0;
67 const float vd1 = vb1 - vt1;
68
69 const float vo0 = vt0 + vd0 * valphav0;
70 const float vo1 = vt1 + vd1 * valphav1;
71
72 output[0] = vo0;
73 output[1] = vo1;
74 output += 2;
75 }
76
77 for (; p >= 1; p -= 1) {
78 const float* itl = (const float*) ((uintptr_t) i[0] + input_offset);
79 const float* ibl = (const float*) ((uintptr_t) i[1] + input_offset);
80 i += 2;
81
82 const float valphah = w[0];
83 const float valphav = w[1];
84 w += 2;
85
86 const float vtl = itl[0];
87 const float vtr = itl[1];
88 const float vbl = ibl[0];
89 const float vbr = ibl[1];
90
91 const float vtd = vtr - vtl;
92 const float vbd = vbr - vbl;
93
94 const float vt = vtl + vtd * valphah;
95 const float vb = vbl + vbd * valphah;
96
97 const float vd = vb - vt;
98
99 const float vo = vt + vd * valphav;
100
101 *output++ = vo;
102 }
103
104 input_offset += input_increment;
105
106 c--;
107 } while (c != 0);
108 }
109