Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace lut yaml with table header #7446

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,7 @@ MICROKERNEL_DEFS = [
"src/xx-fill/xx-fill.h",
"src/xx-pad/xx-pad.h",
"src/xx-transposev/xx-transposev.h",
"src/x8-lut/x8-lut.h",
"src/x8-packq/x8-packq.h",
"src/x8-packw/x8-packw.h",
"src/x8-transposec/x8-transposec.h",
Expand Down
3 changes: 0 additions & 3 deletions scripts/generate-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -192,9 +192,6 @@ tools/generate-rdsum-test.py --spec test/f32-rdsum.yaml --output test/f32-rdsum.
tools/generate-rdsum-test.py --spec test/qs8-rdsum-minmax-fp32.yaml --output test/qs8-rdsum-minmax-fp32.cc &
tools/generate-rdsum-test.py --spec test/qu8-rdsum.yaml --output test/qu8-rdsum.cc &

### Tests for LUT micro-kernels
tools/generate-lut-test.py --spec test/x8-lut.yaml --output test/x8-lut.cc &

### Tests for Conv HWC layout micro-kernels
tools/generate-conv-hwc-test.py --spec test/f32-conv-hwc.yaml --output test/f32-conv-hwc.cc &

Expand Down
80 changes: 80 additions & 0 deletions src/x8-lut/x8-lut.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
// Copyright 2023 Google LLC
//
// This source code is licensed under the BSD-style license found in the
// LICENSE file in the root directory of this source tree.

#ifndef XNN_UKERNEL_WITH_PARAMS
#define XNN_UKERNEL_WITH_PARAMS(arch_flags, ukernel, batch_size, datatype, params_type, init_params) \
XNN_UKERNEL(arch_flags, ukernel, batch_size, datatype)
#define XNN_DEFINED_UKERNEL_WITH_PARAMS
#endif

#ifndef XNN_UKERNEL
#define XNN_UKERNEL(arch_flags, ukernel, batch_size, datatype) \
XNN_UKERNEL_WITH_PARAMS(arch_flags, ukernel, batch_size, datatype, void, /*init_params=*/nullptr)
#define XNN_DEFINED_UKERNEL
#endif

XNN_UKERNEL_WITH_PARAMS(0, xnn_x8_lut_ukernel__scalar_u1, 1, uint8_t, void, nullptr)
XNN_UKERNEL_WITH_PARAMS(0, xnn_x8_lut_ukernel__scalar_u2, 2, uint8_t, void, nullptr)
XNN_UKERNEL_WITH_PARAMS(0, xnn_x8_lut_ukernel__scalar_u4, 4, uint8_t, void, nullptr)
XNN_UKERNEL_WITH_PARAMS(0, xnn_x8_lut_ukernel__scalar_u8, 8, uint8_t, void, nullptr)
XNN_UKERNEL_WITH_PARAMS(0, xnn_x8_lut_ukernel__scalar_u16, 16, uint8_t, void, nullptr)

#if XNN_ARCH_ARM64
XNN_UKERNEL_WITH_PARAMS(xnn_arch_arm_neon, xnn_x8_lut_ukernel__aarch64_neon_tbx128x4_u16, 16, uint8_t, void, nullptr)
XNN_UKERNEL_WITH_PARAMS(xnn_arch_arm_neon, xnn_x8_lut_ukernel__aarch64_neon_tbx128x4_u32, 32, uint8_t, void, nullptr)
XNN_UKERNEL_WITH_PARAMS(xnn_arch_arm_neon, xnn_x8_lut_ukernel__aarch64_neon_tbx128x4_u48, 48, uint8_t, void, nullptr)
XNN_UKERNEL_WITH_PARAMS(xnn_arch_arm_neon, xnn_x8_lut_ukernel__aarch64_neon_tbx128x4_u64, 64, uint8_t, void, nullptr)
#endif // XNN_ARCH_ARM64

#if XNN_ARCH_X86 || XNN_ARCH_X86_64
XNN_UKERNEL_WITH_PARAMS(xnn_arch_x86_ssse3, xnn_x8_lut_ukernel__ssse3_u16, 16, uint8_t, void, nullptr)
XNN_UKERNEL_WITH_PARAMS(xnn_arch_x86_ssse3, xnn_x8_lut_ukernel__ssse3_u32, 32, uint8_t, void, nullptr)
XNN_UKERNEL_WITH_PARAMS(xnn_arch_x86_ssse3, xnn_x8_lut_ukernel__avx_u16, 16, uint8_t, void, nullptr)
XNN_UKERNEL_WITH_PARAMS(xnn_arch_x86_ssse3, xnn_x8_lut_ukernel__avx_u32, 32, uint8_t, void, nullptr)
XNN_UKERNEL_WITH_PARAMS(xnn_arch_x86_ssse3, xnn_x8_lut_ukernel__avx_u48, 48, uint8_t, void, nullptr)
XNN_UKERNEL_WITH_PARAMS(xnn_arch_x86_ssse3, xnn_x8_lut_ukernel__avx_u64, 64, uint8_t, void, nullptr)
XNN_UKERNEL_WITH_PARAMS(xnn_arch_x86_ssse3, xnn_x8_lut_ukernel__avx2_u32, 32, uint8_t, void, nullptr)
XNN_UKERNEL_WITH_PARAMS(xnn_arch_x86_ssse3, xnn_x8_lut_ukernel__avx2_u64, 64, uint8_t, void, nullptr)
XNN_UKERNEL_WITH_PARAMS(xnn_arch_x86_ssse3, xnn_x8_lut_ukernel__avx2_u96, 96, uint8_t, void, nullptr)
XNN_UKERNEL_WITH_PARAMS(xnn_arch_x86_ssse3, xnn_x8_lut_ukernel__avx2_u128, 128, uint8_t, void, nullptr)
#endif // XNN_ARCH_X86 || XNN_ARCH_X86_64

#if XNN_ENABLE_AVX512VBMI && (XNN_ARCH_X86 || XNN_ARCH_X86_64)
XNN_UKERNEL_WITH_PARAMS(xnn_arch_x86_avx512vbmi, xnn_x8_lut_ukernel__avx512vbmi_vpermx2b_u64, 64, uint8_t, void, nullptr)
XNN_UKERNEL_WITH_PARAMS(xnn_arch_x86_avx512vbmi, xnn_x8_lut_ukernel__avx512vbmi_vpermx2b_u128, 128, uint8_t, void, nullptr)
XNN_UKERNEL_WITH_PARAMS(xnn_arch_x86_avx512vbmi, xnn_x8_lut_ukernel__avx512vbmi_vpermx2b_u192, 192, uint8_t, void, nullptr)
XNN_UKERNEL_WITH_PARAMS(xnn_arch_x86_avx512vbmi, xnn_x8_lut_ukernel__avx512vbmi_vpermx2b_u256, 256, uint8_t, void, nullptr)
#endif // XNN_ENABLE_AVX512VBMI && (XNN_ARCH_X86 || XNN_ARCH_X86_64)

#if XNN_ENABLE_AVX512SKX && (XNN_ARCH_X86 || XNN_ARCH_X86_64)
XNN_UKERNEL_WITH_PARAMS(xnn_arch_x86_avx512skx, xnn_x8_lut_ukernel__avx512skx_vpshufb_u64, 64, uint8_t, void, nullptr)
XNN_UKERNEL_WITH_PARAMS(xnn_arch_x86_avx512skx, xnn_x8_lut_ukernel__avx512skx_vpshufb_u128, 128, uint8_t, void, nullptr)
XNN_UKERNEL_WITH_PARAMS(xnn_arch_x86_avx512skx, xnn_x8_lut_ukernel__avx512skx_vpshufb_u192, 192, uint8_t, void, nullptr)
XNN_UKERNEL_WITH_PARAMS(xnn_arch_x86_avx512skx, xnn_x8_lut_ukernel__avx512skx_vpshufb_u256, 256, uint8_t, void, nullptr)
#endif // XNN_ENABLE_AVX512SKX && (XNN_ARCH_X86 || XNN_ARCH_X86_64)

#if XNN_ARCH_WASMSIMD || XNN_ARCH_WASMRELAXEDSIMD
XNN_UKERNEL_WITH_PARAMS(xnn_arch_wasmsimd, xnn_x8_lut_ukernel__wasmsimd_u16, 16, uint8_t, void, nullptr)
XNN_UKERNEL_WITH_PARAMS(xnn_arch_wasmsimd, xnn_x8_lut_ukernel__wasmsimd_u32, 32, uint8_t, void, nullptr)
XNN_UKERNEL_WITH_PARAMS(xnn_arch_wasmsimd, xnn_x8_lut_ukernel__wasmsimd_u48, 48, uint8_t, void, nullptr)
XNN_UKERNEL_WITH_PARAMS(xnn_arch_wasmsimd, xnn_x8_lut_ukernel__wasmsimd_u64, 64, uint8_t, void, nullptr)
#endif // XNN_ARCH_WASMSIMD || XNN_ARCH_WASMRELAXEDSIMD

#if XNN_ARCH_WASMRELAXEDSIMD
XNN_UKERNEL_WITH_PARAMS(xnn_arch_wasmsimd, xnn_x8_lut_ukernel__wasmpshufb_u16, 16, uint8_t, void, nullptr)
XNN_UKERNEL_WITH_PARAMS(xnn_arch_wasmsimd, xnn_x8_lut_ukernel__wasmpshufb_u32, 32, uint8_t, void, nullptr)
XNN_UKERNEL_WITH_PARAMS(xnn_arch_wasmsimd, xnn_x8_lut_ukernel__wasmpshufb_u48, 48, uint8_t, void, nullptr)
XNN_UKERNEL_WITH_PARAMS(xnn_arch_wasmsimd, xnn_x8_lut_ukernel__wasmpshufb_u64, 64, uint8_t, void, nullptr)
#endif // XNN_ARCH_WASMRELAXEDSIMD

#ifdef XNN_DEFINED_UKERNEL_WITH_PARAMS
#undef XNN_DEFINED_UKERNEL_WITH_PARAMS
#undef XNN_UKERNEL_WITH_PARAMS
#endif

#ifdef XNN_DEFINED_UKERNEL
#undef XNN_DEFINED_UKERNEL
#undef XNN_UKERNEL
#endif
48 changes: 3 additions & 45 deletions src/xnnpack/lut.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,56 +18,14 @@ extern "C" {
#endif


#define DECLARE_X8_LUT_UKERNEL_FUNCTION(fn_name) \
#define XNN_UKERNEL(arch_flags, fn_name, batch_tile, datatype) \
XNN_INTERNAL void fn_name( \
size_t n, \
const uint8_t* x, \
uint8_t* y, \
const uint8_t table[XNN_RESTRICT XNN_MIN_ELEMENTS(256)]);

DECLARE_X8_LUT_UKERNEL_FUNCTION(xnn_x8_lut_ukernel__scalar_u1)
DECLARE_X8_LUT_UKERNEL_FUNCTION(xnn_x8_lut_ukernel__scalar_u2)
DECLARE_X8_LUT_UKERNEL_FUNCTION(xnn_x8_lut_ukernel__scalar_u4)
DECLARE_X8_LUT_UKERNEL_FUNCTION(xnn_x8_lut_ukernel__scalar_u8)
DECLARE_X8_LUT_UKERNEL_FUNCTION(xnn_x8_lut_ukernel__scalar_u16)

DECLARE_X8_LUT_UKERNEL_FUNCTION(xnn_x8_lut_ukernel__aarch64_neon_tbx128x4_u16)
DECLARE_X8_LUT_UKERNEL_FUNCTION(xnn_x8_lut_ukernel__aarch64_neon_tbx128x4_u32)
DECLARE_X8_LUT_UKERNEL_FUNCTION(xnn_x8_lut_ukernel__aarch64_neon_tbx128x4_u48)
DECLARE_X8_LUT_UKERNEL_FUNCTION(xnn_x8_lut_ukernel__aarch64_neon_tbx128x4_u64)

DECLARE_X8_LUT_UKERNEL_FUNCTION(xnn_x8_lut_ukernel__ssse3_u16)
DECLARE_X8_LUT_UKERNEL_FUNCTION(xnn_x8_lut_ukernel__ssse3_u32)

DECLARE_X8_LUT_UKERNEL_FUNCTION(xnn_x8_lut_ukernel__avx_u16)
DECLARE_X8_LUT_UKERNEL_FUNCTION(xnn_x8_lut_ukernel__avx_u32)
DECLARE_X8_LUT_UKERNEL_FUNCTION(xnn_x8_lut_ukernel__avx_u48)
DECLARE_X8_LUT_UKERNEL_FUNCTION(xnn_x8_lut_ukernel__avx_u64)

DECLARE_X8_LUT_UKERNEL_FUNCTION(xnn_x8_lut_ukernel__avx2_u32)
DECLARE_X8_LUT_UKERNEL_FUNCTION(xnn_x8_lut_ukernel__avx2_u64)
DECLARE_X8_LUT_UKERNEL_FUNCTION(xnn_x8_lut_ukernel__avx2_u96)
DECLARE_X8_LUT_UKERNEL_FUNCTION(xnn_x8_lut_ukernel__avx2_u128)

DECLARE_X8_LUT_UKERNEL_FUNCTION(xnn_x8_lut_ukernel__avx512skx_vpshufb_u64)
DECLARE_X8_LUT_UKERNEL_FUNCTION(xnn_x8_lut_ukernel__avx512skx_vpshufb_u128)
DECLARE_X8_LUT_UKERNEL_FUNCTION(xnn_x8_lut_ukernel__avx512skx_vpshufb_u192)
DECLARE_X8_LUT_UKERNEL_FUNCTION(xnn_x8_lut_ukernel__avx512skx_vpshufb_u256)

DECLARE_X8_LUT_UKERNEL_FUNCTION(xnn_x8_lut_ukernel__avx512vbmi_vpermx2b_u64)
DECLARE_X8_LUT_UKERNEL_FUNCTION(xnn_x8_lut_ukernel__avx512vbmi_vpermx2b_u128)
DECLARE_X8_LUT_UKERNEL_FUNCTION(xnn_x8_lut_ukernel__avx512vbmi_vpermx2b_u192)
DECLARE_X8_LUT_UKERNEL_FUNCTION(xnn_x8_lut_ukernel__avx512vbmi_vpermx2b_u256)

DECLARE_X8_LUT_UKERNEL_FUNCTION(xnn_x8_lut_ukernel__wasmpshufb_u16)
DECLARE_X8_LUT_UKERNEL_FUNCTION(xnn_x8_lut_ukernel__wasmpshufb_u32)
DECLARE_X8_LUT_UKERNEL_FUNCTION(xnn_x8_lut_ukernel__wasmpshufb_u48)
DECLARE_X8_LUT_UKERNEL_FUNCTION(xnn_x8_lut_ukernel__wasmpshufb_u64)

DECLARE_X8_LUT_UKERNEL_FUNCTION(xnn_x8_lut_ukernel__wasmsimd_u16)
DECLARE_X8_LUT_UKERNEL_FUNCTION(xnn_x8_lut_ukernel__wasmsimd_u32)
DECLARE_X8_LUT_UKERNEL_FUNCTION(xnn_x8_lut_ukernel__wasmsimd_u48)
DECLARE_X8_LUT_UKERNEL_FUNCTION(xnn_x8_lut_ukernel__wasmsimd_u64)
#include "x8-lut/x8-lut.h"
#undef XNN_UKERNEL


#define DECLARE_U8_LUT32NORM_UKERNEL_FUNCTION(fn_name) \
Expand Down
1 change: 0 additions & 1 deletion test/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -1059,7 +1059,6 @@ xnnpack_unit_test(
xnnpack_unit_test(
name = "x8_lut_test",
srcs = [
"lut-microkernel-tester.h",
"x8-lut.cc",
],
deps = MICROKERNEL_TEST_DEPS,
Expand Down
99 changes: 0 additions & 99 deletions test/lut-microkernel-tester.h

This file was deleted.

Loading
Loading