Skip to content

Commit

Permalink
Add partial support for building/testing/benchmarking XNNPACK on Hexa…
Browse files Browse the repository at this point in the history
…gon. Additional work would need to be done to get this fully working in the Bazel build (notably, connecting to a Qualcomm SDK) but this extends the basic build rules enough to add specializations for Hexagon to XNNPACK.

PiperOrigin-RevId: 625361939
  • Loading branch information
xnnpack-bot committed May 6, 2024
1 parent 0994a40 commit 15a787c
Show file tree
Hide file tree
Showing 4 changed files with 83 additions and 18 deletions.
11 changes: 11 additions & 0 deletions BUILD.bazel
Expand Up @@ -2937,6 +2937,14 @@ xnnpack_cc_library(
wasmsimd_srcs = WASM32_ASM_MICROKERNEL_SRCS,
)

xnnpack_cc_library(
name = "hvx_microkernels",
gcc_copts = xnnpack_gcc_std_copts(),
hvx_srcs = ALL_HEXAGON_MICROKERNEL_SRCS,
msvc_copts = xnnpack_msvc_std_copts(),
deps = [":microkernels_h"],
)

xnnpack_cc_library(
name = "log_level_default",
defines = select({
Expand Down Expand Up @@ -3087,6 +3095,7 @@ xnnpack_aggregate_library(
":avxvnni_enabled": [":avxvnni_bench_microkernels"],
"//conditions:default": [],
}),
hvx_deps = [":hvx_microkernels"],
wasm_deps = [
":wasm_bench_microkernels",
":asm_microkernels",
Expand Down Expand Up @@ -3195,6 +3204,7 @@ xnnpack_aggregate_library(
":avx512fp16_enabled": [":avx512fp16_prod_microkernels"],
"//conditions:default": [],
}),
hvx_deps = [":hvx_microkernels"],
wasm_deps = [
":wasm_prod_microkernels",
":asm_microkernels",
Expand Down Expand Up @@ -3310,6 +3320,7 @@ xnnpack_aggregate_library(
":avx512fp16_enabled": [":avx512fp16_test_microkernels"],
"//conditions:default": [],
}),
hvx_deps = [":hvx_microkernels"],
wasm_deps = [
":wasm_test_microkernels",
":asm_microkernels",
Expand Down
10 changes: 10 additions & 0 deletions build_defs.bzl
Expand Up @@ -26,6 +26,10 @@ def xnnpack_std_cxxopts():
"""Compiler flags to specify language standard for C++ sources."""
return ["-std=gnu++14"]

def xnnpack_gunit_deps_for_library():
"""Depencies needed for a library to use gunit."""
return ["@com_google_googletest//:gtest_main"]

def xnnpack_optional_ruy_copts():
"""Compiler flags to optionally enable Ruy benchmarks."""
return []
Expand Down Expand Up @@ -73,6 +77,7 @@ def xnnpack_cc_library(
x86_srcs = [],
aarch32_srcs = [],
aarch64_srcs = [],
hvx_srcs = [],
riscv_srcs = [],
wasm_srcs = [],
wasmsimd_srcs = [],
Expand All @@ -88,6 +93,7 @@ def xnnpack_cc_library(
msvc_x86_64_copts = [],
aarch32_copts = [],
aarch64_copts = [],
hvx_copts = [],
riscv_copts = [],
wasm_copts = [],
wasmsimd_copts = [],
Expand All @@ -110,6 +116,7 @@ def xnnpack_cc_library(
x86_srcs: The list of x86-specific source files.
aarch32_srcs: The list of AArch32-specific source files.
aarch64_srcs: The list of AArch64-specific source files.
hvx_srcs: The list of HVX-specific source files.
riscv_srcs: The list of RISC-V-specific source files.
wasm_srcs: The list of WebAssembly 1.0-specific source files.
wasmsimd_srcs: The list of WebAssembly SIMD-specific source files.
Expand All @@ -131,6 +138,7 @@ def xnnpack_cc_library(
builds.
aarch32_copts: The list of compiler flags to use in AArch32 builds.
aarch64_copts: The list of compiler flags to use in AArch64 builds.
hvx_copts: The list of compiler flags to use in HVX builds.
riscv_copts: The list of compiler flags to use in RISC-V builds.
wasm_copts: The list of compiler flags to use in WebAssembly 1.0 builds.
wasmsimd_copts: The list of compiler flags to use in WebAssembly SIMD
Expand Down Expand Up @@ -226,6 +234,7 @@ def xnnpack_aggregate_library(
x86_deps = [],
aarch32_deps = [],
aarch64_deps = [],
hvx_deps = [],
riscv_deps = [],
wasm_deps = [],
wasmsimd_deps = [],
Expand All @@ -240,6 +249,7 @@ def xnnpack_aggregate_library(
x86_deps: The list of libraries to link in x86 and x86-64 builds.
aarch32_deps: The list of libraries to link in AArch32 builds.
aarch64_deps: The list of libraries to link in AArch64 builds.
hvx_deps: The list of libraries to link in HVX builds.
riscv_deps: The list of libraries to link in RISC-V builds.
wasm_deps: The list of libraries to link in WebAssembly 1.0 builds.
wasmsimd_deps: The list of libraries to link in WebAssembly SIMD builds.
Expand Down
4 changes: 2 additions & 2 deletions eval/BUILD.bazel
Expand Up @@ -7,6 +7,7 @@ load(
"//:build_defs.bzl",
"xnnpack_benchmark",
"xnnpack_cc_library",
"xnnpack_gunit_deps_for_library",
"xnnpack_unit_test",
)

Expand Down Expand Up @@ -226,14 +227,13 @@ xnnpack_cc_library(
testonly = True,
srcs = ["math-evaluation-tester.cc"],
hdrs = ["math-evaluation-tester.h"],
deps = [
deps = xnnpack_gunit_deps_for_library() + [
"@FP16",
"//:aligned_allocator",
"//:common",
"//:math",
"//:math_stubs",
"@pthreadpool",
"@com_google_googletest//:gtest_main",
],
)

Expand Down

0 comments on commit 15a787c

Please sign in to comment.