| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
#include <assert.h> |
| 11 |
|
| 12 |
#include <arm_neon.h> |
| 13 |
|
| 14 |
#include "xnnpack/intrinsics-polyfill.h" |
| 15 |
#include "xnnpack/lut.h" |
| 16 |
#include "xnnpack/common.h" |
| 17 |
|
| 18 |
|
| 19 |
void xnn_x8_lut_ukernel__aarch64_neon_tbx128x4_u32( |
| 20 |
size_t batch, |
| 21 |
const uint8_t* input, |
| 22 |
uint8_t* output, |
| 23 |
const uint8_t table[restrict XNN_MIN_ELEMENTS(256)]) |
| 24 |
{ |
| 25 |
assert(batch != 0); |
| 26 |
assert(batch % sizeof(uint8_t) == 0); |
| 27 |
assert(input != NULL); |
| 28 |
assert(output != NULL); |
| 29 |
|
| 30 |
const uint8x16x4_t vtable0123 = vld1q_u8_x4(table); |
| 31 |
const uint8x16x4_t vtable4567 = vld1q_u8_x4(table + 64); |
| 32 |
const uint8x16x4_t vtable89AB = vld1q_u8_x4(table + 128); |
| 33 |
const uint8x16x4_t vtableCDEF = vld1q_u8_x4(table + 192); |
| 34 |
const uint8x16_t voffset = vmovq_n_u8(64); |
| 35 |
for (; batch >= 32 * sizeof(uint8_t); batch -= 32 * sizeof(uint8_t)) { |
| 36 |
uint8x16_t vx0 = vld1q_u8(input); input += 16; |
| 37 |
uint8x16_t vx1 = vld1q_u8(input); input += 16; |
| 38 |
|
| 39 |
uint8x16_t vy0 = vqtbl4q_u8(vtable0123, vx0); |
| 40 |
vx0 = vsubq_u8(vx0, voffset); |
| 41 |
uint8x16_t vy1 = vqtbl4q_u8(vtable0123, vx1); |
| 42 |
vx1 = vsubq_u8(vx1, voffset); |
| 43 |
|
| 44 |
vy0 = vqtbx4q_u8(vy0, vtable4567, vx0); |
| 45 |
vx0 = vsubq_u8(vx0, voffset); |
| 46 |
vy1 = vqtbx4q_u8(vy1, vtable4567, vx1); |
| 47 |
vx1 = vsubq_u8(vx1, voffset); |
| 48 |
|
| 49 |
vy0 = vqtbx4q_u8(vy0, vtable89AB, vx0); |
| 50 |
vx0 = vsubq_u8(vx0, voffset); |
| 51 |
vy1 = vqtbx4q_u8(vy1, vtable89AB, vx1); |
| 52 |
vx1 = vsubq_u8(vx1, voffset); |
| 53 |
|
| 54 |
vy0 = vqtbx4q_u8(vy0, vtableCDEF, vx0); |
| 55 |
vy1 = vqtbx4q_u8(vy1, vtableCDEF, vx1); |
| 56 |
|
| 57 |
vst1q_u8(output, vy0); output += 16; |
| 58 |
vst1q_u8(output, vy1); output += 16; |
| 59 |
} |
| 60 |
for (; batch >= 16 * sizeof(uint8_t); batch -= 16 * sizeof(uint8_t)) { |
| 61 |
uint8x16_t vx = vld1q_u8(input); input += 16; |
| 62 |
|
| 63 |
uint8x16_t vy = vqtbl4q_u8(vtable0123, vx); |
| 64 |
|
| 65 |
vx = vsubq_u8(vx, voffset); |
| 66 |
vy = vqtbx4q_u8(vy, vtable4567, vx); |
| 67 |
|
| 68 |
vx = vsubq_u8(vx, voffset); |
| 69 |
vy = vqtbx4q_u8(vy, vtable89AB, vx); |
| 70 |
|
| 71 |
vx = vsubq_u8(vx, voffset); |
| 72 |
vy = vqtbx4q_u8(vy, vtableCDEF, vx); |
| 73 |
|
| 74 |
vst1q_u8(output, vy); output += 16; |
| 75 |
} |
| 76 |
if XNN_UNLIKELY(batch != 0) { |
| 77 |
uint8x16_t vx = vld1q_u8(input); |
| 78 |
|
| 79 |
uint8x16_t vy = vqtbl4q_u8(vtable0123, vx); |
| 80 |
|
| 81 |
vx = vsubq_u8(vx, voffset); |
| 82 |
vy = vqtbx4q_u8(vy, vtable4567, vx); |
| 83 |
|
| 84 |
vx = vsubq_u8(vx, voffset); |
| 85 |
vy = vqtbx4q_u8(vy, vtable89AB, vx); |
| 86 |
|
| 87 |
vx = vsubq_u8(vx, voffset); |
| 88 |
vy = vqtbx4q_u8(vy, vtableCDEF, vx); |
| 89 |
|
| 90 |
uint8x8_t vy_lo = vget_low_u8(vy); |
| 91 |
if (batch & (8 * sizeof(uint8_t))) { |
| 92 |
vst1_u8(output, vy_lo); output += 8; |
| 93 |
vy_lo = vget_high_u8(vy); |
| 94 |
} |
| 95 |
if (batch & (4 * sizeof(uint8_t))) { |
| 96 |
vst1_lane_u32((void*) output, vreinterpret_u32_u8(vy_lo), 0); output += 4; |
| 97 |
vy_lo = vext_u8(vy_lo, vy_lo, 4); |
| 98 |
} |
| 99 |
if (batch & (2 * sizeof(uint8_t))) { |
| 100 |
vst1_lane_u16((void*) output, vreinterpret_u16_u8(vy_lo), 0); output += 2; |
| 101 |
vy_lo = vext_u8(vy_lo, vy_lo, 2); |
| 102 |
} |
| 103 |
if (batch & (1 * sizeof(uint8_t))) { |
| 104 |
vst1_lane_u8(output, vy_lo, 0); |
| 105 |
} |
| 106 |
} |
| 107 |
} |