1 // Auto-generated file. Do not edit!
2 // Template: src/s16-window/neon.c.in
3 // Generator: tools/xngen
4 //
5 // Copyright 2022 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 #include <stddef.h>
12 #include <stdint.h>
13
14 #include <arm_neon.h>
15
16 #include <xnnpack/math.h>
17 #include <xnnpack/window.h>
18
19
xnn_s16_window_shift15_ukernel__neon_x32(size_t rows,size_t batch_size,const int16_t * input,const int16_t * weights,int16_t * output,uint32_t shift)20 void xnn_s16_window_shift15_ukernel__neon_x32(
21 size_t rows,
22 size_t batch_size,
23 const int16_t* input,
24 const int16_t* weights,
25 int16_t* output,
26 uint32_t shift)
27 {
28 assert(rows != 0);
29 assert(batch_size != 0);
30 assert(input != NULL);
31 assert(weights != NULL);
32 assert(output != NULL);
33 assert(shift == 15);
34
35
36 do {
37 const int16_t* w = weights;
38 size_t n = batch_size * sizeof(int16_t);
39 for (; n >= 32 * sizeof(int16_t); n -= 32 * sizeof(int16_t)) {
40 const int16x8_t vi0 = vld1q_s16(input); input += 8;
41 const int16x8_t vi1 = vld1q_s16(input); input += 8;
42 const int16x8_t vi2 = vld1q_s16(input); input += 8;
43 const int16x8_t vi3 = vld1q_s16(input); input += 8;
44
45 const int16x8_t vw0 = vld1q_s16(w); w += 8;
46 const int16x8_t vw1 = vld1q_s16(w); w += 8;
47 const int16x8_t vw2 = vld1q_s16(w); w += 8;
48 const int16x8_t vw3 = vld1q_s16(w); w += 8;
49
50 const int16x8_t vout0 = vqdmulhq_s16(vi0, vw0);
51 const int16x8_t vout1 = vqdmulhq_s16(vi1, vw1);
52 const int16x8_t vout2 = vqdmulhq_s16(vi2, vw2);
53 const int16x8_t vout3 = vqdmulhq_s16(vi3, vw3);
54
55 vst1q_s16(output, vout0); output += 8;
56 vst1q_s16(output, vout1); output += 8;
57 vst1q_s16(output, vout2); output += 8;
58 vst1q_s16(output, vout3); output += 8;
59 }
60
61 // Remainder of full vectors
62 for (; n >= 8 * sizeof(int16_t); n -= 8 * sizeof(int16_t)) {
63 const int16x8_t vi = vld1q_s16(input); input += 8;
64 const int16x8_t vw = vld1q_s16(w); w += 8;
65 const int16x8_t vout = vqdmulhq_s16(vi, vw);
66 vst1q_s16(output, vout); output += 8;
67 }
68
69 assert(n % 2 == 0);
70 // Remainder of 1 to 7 batch_size
71 if XNN_UNLIKELY(n != 0) {
72 const int16x8_t vi = vld1q_s16(input); input = (const int16_t*) ((uintptr_t) input + n);
73 const int16x8_t vw = vld1q_s16(w);
74 int16x4_t vout = vqdmulh_s16(vget_low_s16(vi), vget_low_s16(vw));
75 if (n & (4 * sizeof(int16_t))) {
76 vst1_s16(output, vout); output += 4;
77 vout = vqdmulh_s16(vget_high_s16(vi), vget_high_s16(vw));
78 }
79 if (n & (2 * sizeof(int16_t))) {
80 vst1_lane_u32((void*) output, vreinterpret_u32_s16(vout), 0); output += 2;
81 vout = vext_s16(vout, vout, 2);
82 }
83 if (n & (1 * sizeof(int16_t))) {
84 vst1_lane_s16(output, vout, 0); output += 1;
85 }
86 }
87
88 } while (--rows != 0);
89 }
90