forked from pytorch/executorch
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtargets.bzl
More file actions
74 lines (68 loc) · 2.83 KB
/
targets.bzl
File metadata and controls
74 lines (68 loc) · 2.83 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
load("@fbsource//xplat/executorch/backends/xnnpack/third-party:third_party_libs.bzl", "third_party_dep")
load("@fbsource//xplat/executorch/build:build_variables.bzl", "XNNPACK_BACKEND_BUCK_SRCS")
load("@fbsource//xplat/executorch/build:runtime_wrapper.bzl", "get_aten_mode_options", "runtime")
def _get_preprocessor_flags():
"""
Disable if someone explictly specified a config option,
else Enable otherwise
"""
preprocessor_flags = []
if native.read_config("executorch", "xnnpack_workspace_sharing", "0") != "0":
preprocessor_flags.append("-DENABLE_XNNPACK_SHARED_WORKSPACE")
if native.read_config("executorch", "xnnpack_weights_cache", "0") != "0":
preprocessor_flags.append("-DENABLE_XNNPACK_WEIGHTS_CACHE")
# Enable if not disabled through config
return preprocessor_flags
def define_common_targets():
runtime.cxx_library(
name = "dynamic_quant_utils",
srcs = [
"runtime/utils/utils.cpp",
],
exported_headers = ["runtime/utils/utils.h"],
deps = [
"//executorch/runtime/core/exec_aten:lib",
"//executorch/runtime/backend:interface",
],
visibility = ["PUBLIC"],
)
for aten_mode in get_aten_mode_options():
aten_suffix = "_aten" if aten_mode else ""
runtime.cxx_library(
name = "xnnpack_backend" + aten_suffix,
srcs = XNNPACK_BACKEND_BUCK_SRCS,
headers = native.glob([
"runtime/*.h",
"runtime/profiling/*.h",
]),
visibility = ["PUBLIC"],
preprocessor_flags = [
# Uncomment to enable per operator timings
# "-DENABLE_XNNPACK_PROFILING",
# Uncomment to enable using KleidiAI Kernels
# "-DENABLE_XNNPACK_KLEIDI"
] + _get_preprocessor_flags(),
exported_deps = [
"//executorch/runtime/backend:interface" + aten_suffix,
],
exported_headers = [
"runtime/XNNPACKBackend.h",
],
deps = [
third_party_dep("XNNPACK"),
"//executorch/backends/xnnpack/serialization:xnnpack_flatbuffer_header",
"//executorch/extension/threadpool:threadpool",
"//executorch/runtime/core/exec_aten/util:tensor_util" + aten_suffix,
"//executorch/runtime/executor:pte_data_map" + aten_suffix,
],
# XnnpackBackend.cpp needs to compile with executor as whole
# @lint-ignore BUCKLINT: Avoid `link_whole=True` (https://fburl.com/avoid-link-whole)
link_whole = True,
)
runtime.cxx_library(
name = "xnnpack_interface",
visibility = ["PUBLIC"],
exported_headers = [
"runtime/XNNPACKBackend.h",
],
)