Skip to content

Commit f61b600

Browse files
mcr229facebook-github-bot
authored andcommitted
map third party deps between OSS and Internal
Summary: In order for the XNNPACK delegate's buck targets to work both internally and for OSS, we need to be able to switch the third-party XNNPACK dependency depending on whether or not we are building for OSS or for Internal use. We have something similar in PyTorch, so we are doing something similar here. We disentangle this from ExecuTorch runtime wrapper in order to separate the XNNPACK delegate's third-party dependency from Core Executorch's Third-Party Dependencies. Reviewed By: dbort Differential Revision: D48214072 fbshipit-source-id: f12505f6b96a4bf7066a46f2f9035cc4ce64f3b6
1 parent e3da931 commit f61b600

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

backends/xnnpack/targets.bzl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
load("@fbsource//xplat/executorch/backends/xnnpack/third-party:third_party_libs.bzl", "third_party_dep")
12
load("@fbsource//xplat/executorch/build:runtime_wrapper.bzl", "runtime")
23

34
def define_common_targets():
@@ -49,7 +50,7 @@ def define_common_targets():
4950
"@EXECUTORCH_CLIENTS",
5051
],
5152
deps = [
52-
"//xplat/third-party/XNNPACK:XNNPACK",
53+
third_party_dep("XNNPACK"),
5354
":xnnpack_schema",
5455
"//executorch/runtime/backend:backend_registry",
5556
"//executorch/backends/qnnpack:qnnpack_utils", # TODO Use (1) portable for choose_qparams(), (2) xnnpack for quantize_per_tensor()
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
load("@fbsource//xplat/executorch/build:runtime_wrapper.bzl", "runtime")
2+
3+
# Dictionary mappping third-party library name to the correct OSS/Internal target dependencies.
4+
# the values of the dictionary are lists where the first element is the internal dep and the
5+
# second element is the OSS dep
6+
_THIRD_PARTY_LIBS = {
7+
"FP16": ["//xplat/third-party/FP16:FP16", "//backends/xnnpack/third-party:FP16"],
8+
"FXdiv": ["//xplat/third-party/FXdiv:FXdiv", "//backends/xnnpack/third-party:FXdiv"],
9+
"XNNPACK": ["//xplat/third-party/XNNPACK:XNNPACK", "//backends/xnnpack/third-party:XNNPACK"],
10+
"clog": ["//xplat/third-party/clog:clog", "//backends/xnnpack/third-party:clog"],
11+
"cpuinfo": ["//third-party/cpuinfo:cpuinfo", "//backends/xnnpack/third-party:cpuinfo"],
12+
"pthreadpool": ["//xplat/third-party/pthreadpool:pthreadpool", "//backends/xnnpack/third-party:pthreadpool"],
13+
"pthreadpool_header": ["//xplat/third-party/pthreadpool:pthreadpool_header", "//backends/xnnpack/third-party:pthreadpool_header"],
14+
}
15+
16+
def third_party_dep(name):
17+
if name not in _THIRD_PARTY_LIBS:
18+
fail("Cannot find third party library " + name + ", please register it in THIRD_PARTY_LIBS first!")
19+
20+
return _THIRD_PARTY_LIBS[name][1] if runtime.is_oss else _THIRD_PARTY_LIBS[name][0]

0 commit comments

Comments
 (0)