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_x1(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_x1(
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
37 if XNN_UNLIKELY(n != 0) {
38 do {
39 const int32_t vi = (int32_t) *input++;
40 const int32_t vw = (int32_t) *w++;
41 int32_t vout = vi * vw;
42 vout = math_asr_s32(vout, shift);
43 vout = math_max_s32(vout, INT16_MIN);
44 vout = math_min_s32(vout, INT16_MAX);
45 *output++ = (int16_t) vout;
46 } while (--n != 0);
47 }
48 } while (--rows != 0);
49 }
50