• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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_x8(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_x8(
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 >= 8 * sizeof(uint8_t); n -= 8 * 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     x += 8;
36 
37     const uint32_t vt0 = (uint32_t) t[vx0];
38     const uint32_t vt1 = (uint32_t) t[vx1];
39     const uint32_t vt2 = (uint32_t) t[vx2];
40     const uint32_t vt3 = (uint32_t) t[vx3];
41     const uint32_t vt4 = (uint32_t) t[vx4];
42     const uint32_t vt5 = (uint32_t) t[vx5];
43     const uint32_t vt6 = (uint32_t) t[vx6];
44     const uint32_t vt7 = (uint32_t) t[vx7];
45 
46     y[0] = (uint8_t) vt0;
47     y[1] = (uint8_t) vt1;
48     y[2] = (uint8_t) vt2;
49     y[3] = (uint8_t) vt3;
50     y[4] = (uint8_t) vt4;
51     y[5] = (uint8_t) vt5;
52     y[6] = (uint8_t) vt6;
53     y[7] = (uint8_t) vt7;
54     y += 8;
55   }
56   if XNN_UNLIKELY(n != 0) {
57     do {
58       const size_t vx = (size_t) *x++;
59       const uint32_t vt = (uint32_t) t[vx];
60       *y++ = (uint8_t) vt;
61       n -= sizeof(uint8_t);
62     } while (n != 0);
63   }
64 }
65