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_x3(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_x3(
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 >= 3; n -= 3) {
37 const int16_t vi0 = input[0];
38 const int16_t vi1 = input[1];
39 const int16_t vi2 = input[2];
40 input += 3;
41
42 const int16_t w0 = w[0];
43 const int16_t w1 = w[1];
44 const int16_t w2 = w[2];
45 w += 3;
46
47 int32_t vout0 = (int32_t) vi0 * (int32_t) w0;
48 int32_t vout1 = (int32_t) vi1 * (int32_t) w1;
49 int32_t vout2 = (int32_t) vi2 * (int32_t) w2;
50
51 vout0 = math_asr_s32(vout0, shift);
52 vout1 = math_asr_s32(vout1, shift);
53 vout2 = math_asr_s32(vout2, shift);
54
55 vout0 = math_max_s32(vout0, INT16_MIN);
56 vout1 = math_max_s32(vout1, INT16_MIN);
57 vout2 = math_max_s32(vout2, INT16_MIN);
58
59 vout0 = math_min_s32(vout0, INT16_MAX);
60 vout1 = math_min_s32(vout1, INT16_MAX);
61 vout2 = math_min_s32(vout2, INT16_MAX);
62
63 output[0] = (int16_t) vout0;
64 output[1] = (int16_t) vout1;
65 output[2] = (int16_t) vout2;
66
67 output += 3;
68 }
69
70 if XNN_UNLIKELY(n != 0) {
71 do {
72 const int32_t vi = (int32_t) *input++;
73 const int32_t vw = (int32_t) *w++;
74 int32_t vout = vi * vw;
75 vout = math_asr_s32(vout, shift);
76 vout = math_max_s32(vout, INT16_MIN);
77 vout = math_min_s32(vout, INT16_MAX);
78 *output++ = (int16_t) vout;
79 } while (--n != 0);
80 }
81 } while (--rows != 0);
82 }
83