xref: /aosp_15_r20/external/XNNPACK/src/x8-lut/gen/lut-scalar-x16.c (revision 4bdc94577ba0e567308109d787f7fec7b531ce36)
1 // Auto-generated file. Do not edit!
2 //   Template: src/x8-lut/scalar.c.in
3 //   Generator: tools/xngen
4 //
5 // Copyright 2021 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 
12 #include <xnnpack/lut.h>
13 #include <xnnpack/common.h>
14 
15 
xnn_x8_lut_ukernel__scalar_x16(size_t n,const uint8_t * x,uint8_t * y,const uint8_t t[restrict XNN_MIN_ELEMENTS (256)])16 void xnn_x8_lut_ukernel__scalar_x16(
17     size_t n,
18     const uint8_t* x,
19     uint8_t* y,
20     const uint8_t t[restrict XNN_MIN_ELEMENTS(256)])
21 {
22   assert(n != 0);
23   assert(x != NULL);
24   assert(y != NULL);
25 
26   for (; n >= 16 * sizeof(uint8_t); n -= 16 * sizeof(uint8_t)) {
27     const size_t vx0 = (size_t) x[0];
28     const size_t vx1 = (size_t) x[1];
29     const size_t vx2 = (size_t) x[2];
30     const size_t vx3 = (size_t) x[3];
31     const size_t vx4 = (size_t) x[4];
32     const size_t vx5 = (size_t) x[5];
33     const size_t vx6 = (size_t) x[6];
34     const size_t vx7 = (size_t) x[7];
35     const size_t vx8 = (size_t) x[8];
36     const size_t vx9 = (size_t) x[9];
37     const size_t vx10 = (size_t) x[10];
38     const size_t vx11 = (size_t) x[11];
39     const size_t vx12 = (size_t) x[12];
40     const size_t vx13 = (size_t) x[13];
41     const size_t vx14 = (size_t) x[14];
42     const size_t vx15 = (size_t) x[15];
43     x += 16;
44 
45     const uint32_t vt0 = (uint32_t) t[vx0];
46     const uint32_t vt1 = (uint32_t) t[vx1];
47     const uint32_t vt2 = (uint32_t) t[vx2];
48     const uint32_t vt3 = (uint32_t) t[vx3];
49     const uint32_t vt4 = (uint32_t) t[vx4];
50     const uint32_t vt5 = (uint32_t) t[vx5];
51     const uint32_t vt6 = (uint32_t) t[vx6];
52     const uint32_t vt7 = (uint32_t) t[vx7];
53     const uint32_t vt8 = (uint32_t) t[vx8];
54     const uint32_t vt9 = (uint32_t) t[vx9];
55     const uint32_t vt10 = (uint32_t) t[vx10];
56     const uint32_t vt11 = (uint32_t) t[vx11];
57     const uint32_t vt12 = (uint32_t) t[vx12];
58     const uint32_t vt13 = (uint32_t) t[vx13];
59     const uint32_t vt14 = (uint32_t) t[vx14];
60     const uint32_t vt15 = (uint32_t) t[vx15];
61 
62     y[0] = (uint8_t) vt0;
63     y[1] = (uint8_t) vt1;
64     y[2] = (uint8_t) vt2;
65     y[3] = (uint8_t) vt3;
66     y[4] = (uint8_t) vt4;
67     y[5] = (uint8_t) vt5;
68     y[6] = (uint8_t) vt6;
69     y[7] = (uint8_t) vt7;
70     y[8] = (uint8_t) vt8;
71     y[9] = (uint8_t) vt9;
72     y[10] = (uint8_t) vt10;
73     y[11] = (uint8_t) vt11;
74     y[12] = (uint8_t) vt12;
75     y[13] = (uint8_t) vt13;
76     y[14] = (uint8_t) vt14;
77     y[15] = (uint8_t) vt15;
78     y += 16;
79   }
80   if XNN_UNLIKELY(n != 0) {
81     do {
82       const size_t vx = (size_t) *x++;
83       const uint32_t vt = (uint32_t) t[vx];
84       *y++ = (uint8_t) vt;
85       n -= sizeof(uint8_t);
86     } while (n != 0);
87   }
88 }
89