• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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_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_ibilinear_ukernel__neon_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) 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 >= 4 * sizeof(float); c -= 4 * 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 
47       const float32x4_t vtd0123 = vsubq_f32(vtr0123, vtl0123);
48       const float32x4_t vbd0123 = vsubq_f32(vbr0123, vbl0123);
49 
50       const float32x4_t vt0123 = vmlaq_lane_f32(vtl0123, vtd0123, valphahv, 0);
51       const float32x4_t vb0123 = vmlaq_lane_f32(vbl0123, vbd0123, valphahv, 0);
52 
53       const float32x4_t vd0123 = vsubq_f32(vb0123, vt0123);
54 
55       const float32x4_t vo0123 = vmlaq_lane_f32(vt0123, vd0123, valphahv, 1);
56 
57       vst1q_f32(output, vo0123); output += 4;
58     }
59     if XNN_UNLIKELY(c != 0) {
60       const float32x4_t vtl0123 = vld1q_f32(i0);
61       const float32x4_t vtr0123 = vld1q_f32(i1);
62       const float32x4_t vbl0123 = vld1q_f32(i2);
63       const float32x4_t vbr0123 = vld1q_f32(i3);
64 
65       const float32x4_t vtd0123 = vsubq_f32(vtr0123, vtl0123);
66       const float32x4_t vbd0123 = vsubq_f32(vbr0123, vbl0123);
67 
68         const float32x4_t vt0123 = vmlaq_lane_f32(vtl0123, vtd0123, valphahv, 0);
69         const float32x4_t vb0123 = vmlaq_lane_f32(vbl0123, vbd0123, valphahv, 0);
70 
71       const float32x4_t vd0123 = vsubq_f32(vb0123, vt0123);
72 
73       const float32x4_t vo0123 = vmlaq_lane_f32(vt0123, vd0123, valphahv, 1);
74 
75       float32x2_t vo01 = vget_low_f32(vo0123);
76       if (c & (2 * sizeof(float))) {
77         vst1_f32(output, vo01); output += 2;
78         vo01 = vget_high_f32(vo0123);
79       }
80       if (c & (1 * sizeof(float))) {
81         vst1_lane_f32(output, vo01, 0); output += 1;
82       }
83     }
84 
85     output = (float*) ((uintptr_t) output + output_increment);
86   } while (--output_pixels != 0);
87 }
88