1 // Auto-generated file. Do not edit!
2 // Template: src/f32-bilinear/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/bilinear.h>
16
17
xnn_f32_bilinear_ukernel__neonfma_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)18 void xnn_f32_bilinear_ukernel__neonfma_c4(
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)
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 #if XNN_ARCH_ARM
40 const float32x4_t valphah = vdupq_lane_f32(valphahv, 0);
41 const float32x4_t valphav = vdupq_lane_f32(valphahv, 1);
42 #endif
43
44 size_t c = channels;
45 for (; c >= 4 * sizeof(float); c -= 4 * sizeof(float)) {
46 const float32x4_t vtl0123 = vld1q_f32(i0); i0 += 4;
47 const float32x4_t vtr0123 = vld1q_f32(i1); i1 += 4;
48 const float32x4_t vbl0123 = vld1q_f32(i2); i2 += 4;
49 const float32x4_t vbr0123 = 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
54 #if XNN_ARCH_ARM
55 const float32x4_t vt0123 = vfmaq_f32(vtl0123, vtd0123, valphah);
56 const float32x4_t vb0123 = vfmaq_f32(vbl0123, vbd0123, valphah);
57 #else
58 const float32x4_t vt0123 = vfmaq_lane_f32(vtl0123, vtd0123, valphahv, 0);
59 const float32x4_t vb0123 = vfmaq_lane_f32(vbl0123, vbd0123, valphahv, 0);
60 #endif
61
62 const float32x4_t vd0123 = vsubq_f32(vb0123, vt0123);
63
64 #if XNN_ARCH_ARM
65 const float32x4_t vo0123 = vfmaq_f32(vt0123, vd0123, valphav);
66 #else
67 const float32x4_t vo0123 = vfmaq_lane_f32(vt0123, vd0123, valphahv, 1);
68 #endif
69
70 vst1q_f32(output, vo0123); output += 4;
71 }
72 if XNN_UNLIKELY(c != 0) {
73 const float32x4_t vtl0123 = vld1q_f32(i0);
74 const float32x4_t vtr0123 = vld1q_f32(i1);
75 const float32x4_t vbl0123 = vld1q_f32(i2);
76 const float32x4_t vbr0123 = vld1q_f32(i3);
77
78 const float32x4_t vtd0123 = vsubq_f32(vtr0123, vtl0123);
79 const float32x4_t vbd0123 = vsubq_f32(vbr0123, vbl0123);
80
81 #if XNN_ARCH_ARM
82 const float32x4_t vt0123 = vfmaq_f32(vtl0123, vtd0123, valphah);
83 const float32x4_t vb0123 = vfmaq_f32(vbl0123, vbd0123, valphah);
84 #else
85 const float32x4_t vt0123 = vfmaq_lane_f32(vtl0123, vtd0123, valphahv, 0);
86 const float32x4_t vb0123 = vfmaq_lane_f32(vbl0123, vbd0123, valphahv, 0);
87 #endif
88
89 const float32x4_t vd0123 = vsubq_f32(vb0123, vt0123);
90
91 #if XNN_ARCH_ARM
92 float32x4_t vo0123 = vfmaq_f32(vt0123, vd0123, valphav);
93 #else
94 float32x4_t vo0123 = vfmaq_lane_f32(vt0123, vd0123, valphahv, 1);
95 #endif
96
97 float32x2_t vo01 = vget_low_f32(vo0123);
98 if (c & (2 * sizeof(float))) {
99 vst1_f32(output, vo01); output += 2;
100 vo01 = vget_high_f32(vo0123);
101 }
102 if (c & (1 * sizeof(float))) {
103 vst1_lane_f32(output, vo01, 0); output += 1;
104 }
105 }
106
107 output = (float*) ((uintptr_t) output + output_increment);
108 } while (--output_pixels != 0);
109 }
110