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