1 // Auto-generated file. Do not edit!
2 // Template: src/s16-window/scalar.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 <xnnpack/math.h>
15 #include <xnnpack/window.h>
16
17
xnn_s16_window_ukernel__scalar_x2(size_t rows,size_t batch_size,const int16_t * input,const int16_t * weights,int16_t * output,uint32_t shift)18 void xnn_s16_window_ukernel__scalar_x2(
19 size_t rows,
20 size_t batch_size,
21 const int16_t* input,
22 const int16_t* weights,
23 int16_t* output,
24 uint32_t shift)
25 {
26 assert(rows > 0);
27 assert(batch_size != 0);
28 assert(input != NULL);
29 assert(weights != NULL);
30 assert(output != NULL);
31 assert(shift < 32);
32
33 do {
34 size_t n = batch_size;
35 const int16_t* w = weights;
36 for (; n >= 2; n -= 2) {
37 const int16_t vi0 = input[0];
38 const int16_t vi1 = input[1];
39 input += 2;
40
41 const int16_t w0 = w[0];
42 const int16_t w1 = w[1];
43 w += 2;
44
45 int32_t vout0 = (int32_t) vi0 * (int32_t) w0;
46 int32_t vout1 = (int32_t) vi1 * (int32_t) w1;
47
48 vout0 = math_asr_s32(vout0, shift);
49 vout1 = math_asr_s32(vout1, shift);
50
51 vout0 = math_max_s32(vout0, INT16_MIN);
52 vout1 = math_max_s32(vout1, INT16_MIN);
53
54 vout0 = math_min_s32(vout0, INT16_MAX);
55 vout1 = math_min_s32(vout1, INT16_MAX);
56
57 output[0] = (int16_t) vout0;
58 output[1] = (int16_t) vout1;
59
60 output += 2;
61 }
62
63 if XNN_UNLIKELY(n != 0) {
64 do {
65 const int32_t vi = (int32_t) *input++;
66 const int32_t vw = (int32_t) *w++;
67 int32_t vout = vi * vw;
68 vout = math_asr_s32(vout, shift);
69 vout = math_max_s32(vout, INT16_MIN);
70 vout = math_min_s32(vout, INT16_MAX);
71 *output++ = (int16_t) vout;
72 } while (--n != 0);
73 }
74 } while (--rows != 0);
75 }
76