Skip to content

Commit 5faf36e

Browse files
authored
Restrict XOR python export targets to fbcode (#19316)
Summary: `xplat/executorch/extension/training/examples/XOR/BUCK` invokes `define_common_targets()` for both fbcode (`fbcode_target`) and xplat (`non_fbcode_target`). The python targets in this example (`model`, `export_model_lib`, `export_model`) depend on `//caffe2:torch` and `//executorch/exir:lib`, neither of which is defined as an xplat target — `xplat/executorch/exir/BUCK` only declares the `:lib` target via `fbcode_target(...)`. As a result the xplat configuration of `fbsource//xplat/executorch/extension/training/examples/XOR:export_model` fails analysis with: Unknown target `lib` from package `fbsource//xplat/executorch/exir`. Did you mean one of the 0 targets in fbsource//xplat/executorch/exir:BUCK? This produced 218/218 BUILD_RULE failures on the `fbsource//xplat/executorch/extension/training/examples/XOR:export_model` target with no successful run on record (linked to T168807700). Wrap the three python rules with `if not is_xplat():` so they only register when called from fbcode, matching the established precedent in `xplat/executorch/kernels/portable/test/targets.bzl`. The `train_xor` C++ binary continues to be defined for both cells since its dependencies are xplat-compatible. Differential Revision: D103951555
1 parent 0f9de6a commit 5faf36e

1 file changed

Lines changed: 30 additions & 26 deletions

File tree

Lines changed: 30 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
load("@fbsource//xplat/executorch/build:runtime_wrapper.bzl", "runtime")
1+
load("@fbsource//xplat/executorch/build:runtime_wrapper.bzl", "is_xplat", "runtime")
22

33
def define_common_targets():
44
"""Defines targets that should be shared between fbcode and xplat.
@@ -23,30 +23,34 @@ def define_common_targets():
2323
define_static_target = True,
2424
)
2525

26-
runtime.python_library(
27-
name = "model",
28-
srcs = ["model.py"],
29-
visibility = [], # Private
30-
deps = [
31-
"//caffe2:torch",
32-
],
33-
)
26+
# The Python export targets depend on `//caffe2:torch` and
27+
# `//executorch/exir:lib`, neither of which exist as xplat (fbsource)
28+
# targets. Restrict these to fbcode only.
29+
if not is_xplat():
30+
runtime.python_library(
31+
name = "model",
32+
srcs = ["model.py"],
33+
visibility = [], # Private
34+
deps = [
35+
"//caffe2:torch",
36+
],
37+
)
3438

35-
runtime.python_library(
36-
name = "export_model_lib",
37-
srcs = ["export_model.py"],
38-
visibility = ["//executorch/extension/training/examples/XOR/..."],
39-
deps = [
40-
":model",
41-
"//caffe2:torch",
42-
"//executorch/exir:lib",
43-
],
44-
)
39+
runtime.python_library(
40+
name = "export_model_lib",
41+
srcs = ["export_model.py"],
42+
visibility = ["//executorch/extension/training/examples/XOR/..."],
43+
deps = [
44+
":model",
45+
"//caffe2:torch",
46+
"//executorch/exir:lib",
47+
],
48+
)
4549

46-
runtime.python_binary(
47-
name = "export_model",
48-
main_module = "executorch.extension.training.examples.XOR.export_model",
49-
deps = [
50-
":export_model_lib",
51-
],
52-
)
50+
runtime.python_binary(
51+
name = "export_model",
52+
main_module = "executorch.extension.training.examples.XOR.export_model",
53+
deps = [
54+
":export_model_lib",
55+
],
56+
)

0 commit comments

Comments
 (0)