• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright (c) Facebook, Inc. and its affiliates.
2 // All rights reserved.
3 //
4 // Copyright 2019 Google LLC
5 //
6 // This source code is licensed under the BSD-style license found in the
7 // LICENSE file in the root directory of this source tree.
8 
9 #include <assert.h>
10 
11 #include <xnnpack/lut.h>
12 
13 
xnn_x8_lut_ukernel__scalar(size_t n,const uint8_t * x,const uint8_t t[restrict XNN_MIN_ELEMENTS (256)],uint8_t * y)14 void xnn_x8_lut_ukernel__scalar(
15     size_t n,
16     const uint8_t* x,
17     const uint8_t t[restrict XNN_MIN_ELEMENTS(256)],
18     uint8_t* y)
19 {
20   assert(n != 0);
21 
22   while (n >= 4) {
23     const size_t vx0 = x[0];
24     const size_t vx1 = x[1];
25     const size_t vx2 = x[2];
26     const size_t vx3 = x[3];
27     x += 4;
28 
29     const uint8_t vt0 = t[vx0];
30     const uint8_t vt1 = t[vx1];
31     const uint8_t vt2 = t[vx2];
32     const uint8_t vt3 = t[vx3];
33 
34     y[0] = vt0;
35     y[1] = vt1;
36     y[2] = vt2;
37     y[3] = vt3;
38     y += 4;
39 
40     n -= 4;
41   }
42   while (n != 0) {
43     const size_t vx = *x++;
44     const uint8_t vt = t[vx];
45     *y++ = vt;
46 
47     n--;
48   };
49 }
50