1 // Auto-generated file. Do not edit!
2 // Template: src/f32-ibilinear/neon.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 <arm_neon.h>
13
14 #include <xnnpack/common.h>
15 #include <xnnpack/ibilinear.h>
16
17
xnn_f32_ibilinear_ukernel__neon_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)18 void xnn_f32_ibilinear_ukernel__neon_c8(
19 size_t output_pixels,
20 size_t channels,
21 const float**restrict input,
22 size_t input_offset,
23 const float*restrict weights,
24 float*restrict output,
25 size_t output_increment) XNN_DISABLE_TSAN
26 {
27 assert(output_pixels != 0);
28 assert(channels != 0);
29 assert(channels % sizeof(float) == 0);
30
31 do {
32 const float* i0 = (const float*) ((uintptr_t) input[0] + input_offset);
33 const float* i1 = (const float*) ((uintptr_t) input[1] + input_offset);
34 const float* i2 = (const float*) ((uintptr_t) input[2] + input_offset);
35 const float* i3 = (const float*) ((uintptr_t) input[3] + input_offset);
36 input += 4;
37
38 const float32x2_t valphahv = vld1_f32(weights); weights += 2;
39
40 size_t c = channels;
41 for (; c >= 8 * sizeof(float); c -= 8 * sizeof(float)) {
42 const float32x4_t vtl0123 = vld1q_f32(i0); i0 += 4;
43 const float32x4_t vtr0123 = vld1q_f32(i1); i1 += 4;
44 const float32x4_t vbl0123 = vld1q_f32(i2); i2 += 4;
45 const float32x4_t vbr0123 = vld1q_f32(i3); i3 += 4;
46 const float32x4_t vtl4567 = vld1q_f32(i0); i0 += 4;
47 const float32x4_t vtr4567 = vld1q_f32(i1); i1 += 4;
48 const float32x4_t vbl4567 = vld1q_f32(i2); i2 += 4;
49 const float32x4_t vbr4567 = vld1q_f32(i3); i3 += 4;
50
51 const float32x4_t vtd0123 = vsubq_f32(vtr0123, vtl0123);
52 const float32x4_t vbd0123 = vsubq_f32(vbr0123, vbl0123);
53 const float32x4_t vtd4567 = vsubq_f32(vtr4567, vtl4567);
54 const float32x4_t vbd4567 = vsubq_f32(vbr4567, vbl4567);
55
56 const float32x4_t vt0123 = vmlaq_lane_f32(vtl0123, vtd0123, valphahv, 0);
57 const float32x4_t vb0123 = vmlaq_lane_f32(vbl0123, vbd0123, valphahv, 0);
58 const float32x4_t vt4567 = vmlaq_lane_f32(vtl4567, vtd4567, valphahv, 0);
59 const float32x4_t vb4567 = vmlaq_lane_f32(vbl4567, vbd4567, valphahv, 0);
60
61 const float32x4_t vd0123 = vsubq_f32(vb0123, vt0123);
62 const float32x4_t vd4567 = vsubq_f32(vb4567, vt4567);
63
64 const float32x4_t vo0123 = vmlaq_lane_f32(vt0123, vd0123, valphahv, 1);
65 const float32x4_t vo4567 = vmlaq_lane_f32(vt4567, vd4567, valphahv, 1);
66
67 vst1q_f32(output, vo0123); output += 4;
68 vst1q_f32(output, vo4567); output += 4;
69 }
70 for (; c >= 4 * sizeof(float); c -= 4 * sizeof(float)) {
71 const float32x4_t vtl0123 = vld1q_f32(i0); i0 += 4;
72 const float32x4_t vtr0123 = vld1q_f32(i1); i1 += 4;
73 const float32x4_t vbl0123 = vld1q_f32(i2); i2 += 4;
74 const float32x4_t vbr0123 = vld1q_f32(i3); i3 += 4;
75
76 const float32x4_t vtd0123 = vsubq_f32(vtr0123, vtl0123);
77 const float32x4_t vbd0123 = vsubq_f32(vbr0123, vbl0123);
78
79 const float32x4_t vt0123 = vmlaq_lane_f32(vtl0123, vtd0123, valphahv, 0);
80 const float32x4_t vb0123 = vmlaq_lane_f32(vbl0123, vbd0123, valphahv, 0);
81
82 const float32x4_t vd0123 = vsubq_f32(vb0123, vt0123);
83
84 const float32x4_t vo0123 = vmlaq_lane_f32(vt0123, vd0123, valphahv, 1);
85
86 vst1q_f32(output, vo0123);
87 output += 4;
88 }
89 if XNN_UNLIKELY(c != 0) {
90 const float32x4_t vtl0123 = vld1q_f32(i0);
91 const float32x4_t vtr0123 = vld1q_f32(i1);
92 const float32x4_t vbl0123 = vld1q_f32(i2);
93 const float32x4_t vbr0123 = vld1q_f32(i3);
94
95 const float32x4_t vtd0123 = vsubq_f32(vtr0123, vtl0123);
96 const float32x4_t vbd0123 = vsubq_f32(vbr0123, vbl0123);
97
98 const float32x4_t vt0123 = vmlaq_lane_f32(vtl0123, vtd0123, valphahv, 0);
99 const float32x4_t vb0123 = vmlaq_lane_f32(vbl0123, vbd0123, valphahv, 0);
100
101 const float32x4_t vd0123 = vsubq_f32(vb0123, vt0123);
102
103 const float32x4_t vo0123 = vmlaq_lane_f32(vt0123, vd0123, valphahv, 1);
104
105 float32x2_t vo01 = vget_low_f32(vo0123);
106 if (c & (2 * sizeof(float))) {
107 vst1_f32(output, vo01); output += 2;
108 vo01 = vget_high_f32(vo0123);
109 }
110 if (c & (1 * sizeof(float))) {
111 vst1_lane_f32(output, vo01, 0); output += 1;
112 }
113 }
114
115 output = (float*) ((uintptr_t) output + output_increment);
116 } while (--output_pixels != 0);
117 }
118