xref: /aosp_15_r20/external/XNNPACK/src/s16-vlshift/gen/scalar-x3.c (revision 4bdc94577ba0e567308109d787f7fec7b531ce36)
1 // Auto-generated file. Do not edit!
2 //   Template: src/s16-vlshift/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/vlshift.h>
16 
17 
xnn_s16_vlshift_ukernel__scalar_x3(size_t batch,const int16_t * input,int16_t * output,uint32_t shift)18 void xnn_s16_vlshift_ukernel__scalar_x3(
19     size_t batch,
20     const int16_t* input,
21     int16_t* output,
22     uint32_t shift)
23 {
24   assert(batch != 0);
25   assert(input != NULL);
26   assert(output != NULL);
27   assert(shift < 16);
28 
29   for (; batch >= 3; batch -= 3) {
30     const uint16_t vi0 = (uint16_t) input[0];
31     const uint16_t vi1 = (uint16_t) input[1];
32     const uint16_t vi2 = (uint16_t) input[2];
33     input += 3;
34 
35     const uint16_t vout0 = vi0 << shift;
36     const uint16_t vout1 = vi1 << shift;
37     const uint16_t vout2 = vi2 << shift;
38 
39     output[0] = (int16_t) vout0;
40     output[1] = (int16_t) vout1;
41     output[2] = (int16_t) vout2;
42     output += 3;
43   }
44  if XNN_UNLIKELY(batch != 0) {
45    do {
46      const uint16_t vi = (uint16_t) *input++;
47 
48      const uint16_t vout = vi << shift;
49 
50      *output++ = (int16_t) vout;
51    } while (--batch != 0);
52  }
53 }
54