Skip to content

Commit 16b780b

Browse files
authored
migrate dirs whose runtime.python_binary kwargs are fbcode-only (pytorch#21388)
Differential Revision: D109082048 Pull Request resolved: pytorch#21388
1 parent 82a63fd commit 16b780b

7 files changed

Lines changed: 138 additions & 83 deletions

File tree

Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
# Any targets that should be shared between fbcode and xplat must be defined in
2-
# targets.bzl. This file can contain fbcode-only targets.
2+
# targets.bzl.
33

4+
load("@fbsource//tools/build_defs:fbsource_utils.bzl", "is_fbcode")
45
load(":targets.bzl", "define_common_targets")
56

67
oncall("executorch")
78

8-
define_common_targets()
9+
define_common_targets(is_fbcode = is_fbcode())

‎devtools/inspector/TARGETS‎

Lines changed: 0 additions & 78 deletions
This file was deleted.

‎devtools/inspector/targets.bzl‎

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
load("@fbsource//xplat/executorch/build:runtime_wrapper.bzl", "runtime")
2+
3+
def define_common_targets(is_fbcode = False):
4+
if not is_fbcode:
5+
return
6+
7+
runtime.python_library(
8+
name = "inspector",
9+
srcs = [
10+
"_inspector.py",
11+
],
12+
deps = [
13+
"fbsource//third-party/pypi/ipython:ipython",
14+
"fbsource//third-party/pypi/numpy:numpy",
15+
"fbsource//third-party/pypi/pandas:pandas",
16+
"fbsource//third-party/pypi/tabulate:tabulate",
17+
":inspector_utils",
18+
":vgf_neural_statistics",
19+
"//executorch/devtools/debug_format:et_schema",
20+
"//executorch/devtools/etdump:schema_flatcc",
21+
"//executorch/devtools/etrecord:etrecord",
22+
"//executorch/exir:lib",
23+
"//executorch/devtools/inspector:intermediate_output_capturer",
24+
"//executorch/devtools/inspector/numerical_comparator:lib",
25+
],
26+
)
27+
28+
runtime.python_library(
29+
name = "vgf_neural_statistics",
30+
srcs = [
31+
"vgf_neural_statistics.py",
32+
],
33+
)
34+
35+
runtime.python_binary(
36+
name = "inspector_cli",
37+
main_function = ".inspector_cli.main",
38+
main_src = "inspector_cli.py",
39+
deps = [
40+
"//executorch/devtools:lib",
41+
"//executorch/devtools/inspector:lib",
42+
],
43+
)
44+
45+
runtime.python_library(
46+
name = "inspector_utils",
47+
srcs = [
48+
"_inspector_utils.py",
49+
],
50+
deps = [
51+
"fbsource//third-party/pypi/matplotlib:matplotlib",
52+
"fbsource//third-party/pypi/numpy:numpy",
53+
"//caffe2:torch",
54+
"//executorch/devtools/debug_format:base_schema",
55+
"//executorch/devtools/debug_format:et_schema",
56+
"//executorch/devtools/etdump:schema_flatcc",
57+
"//executorch/devtools/etdump:serialize",
58+
"//executorch/devtools/etrecord:etrecord",
59+
],
60+
)
61+
62+
runtime.python_library(
63+
name = "intermediate_output_capturer",
64+
srcs = [
65+
"_intermediate_output_capturer.py",
66+
],
67+
deps = [
68+
"//executorch/devtools/inspector:inspector_utils",
69+
],
70+
)
71+
72+
runtime.python_library(
73+
name = "lib",
74+
srcs = ["__init__.py"],
75+
deps = [
76+
":inspector",
77+
":inspector_utils",
78+
":vgf_neural_statistics",
79+
],
80+
)

‎examples/devtools/scripts/BUCK‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# Any targets that should be shared between fbcode and xplat must be defined in
2+
# targets.bzl.
3+
4+
load("@fbsource//tools/build_defs:fbsource_utils.bzl", "is_fbcode")
5+
load(":targets.bzl", "define_common_targets")
6+
7+
oncall("executorch")
8+
9+
define_common_targets(is_fbcode = is_fbcode())
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
load("@fbsource//xplat/executorch/build:runtime_wrapper.bzl", "runtime")
2+
3+
def define_common_targets(is_fbcode = False):
4+
if not is_fbcode:
5+
return
6+
7+
runtime.python_binary(
8+
name = "export_bundled_program",
9+
main_function = ".export_bundled_program.main",
10+
main_src = "export_bundled_program.py",
11+
deps = [
12+
"//caffe2:torch",
13+
"//executorch/devtools:lib",
14+
"//executorch/devtools/bundled_program:config",
15+
"//executorch/devtools/bundled_program/serialize:lib",
16+
"//executorch/examples/models:models",
17+
"//executorch/extension/export_util:export_util",
18+
],
19+
)
20+
21+
runtime.python_binary(
22+
name = "gen_sample_etrecord",
23+
srcs = ["gen_sample_etrecord.py"],
24+
main_function = "executorch.examples.devtools.scripts.gen_sample_etrecord.main",
25+
deps = [
26+
"//executorch/devtools:lib",
27+
"//executorch/devtools/etrecord:etrecord",
28+
"//executorch/examples/models:models",
29+
"//executorch/exir:lib",
30+
],
31+
)
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# Any targets that should be shared between fbcode and xplat must be defined in
2+
# targets.bzl.
3+
4+
load("@fbsource//tools/build_defs:fbsource_utils.bzl", "is_fbcode")
5+
load(":targets.bzl", "define_common_targets")
6+
7+
oncall("executorch")
8+
9+
define_common_targets(is_fbcode = is_fbcode())

‎extension/training/examples/CIFAR/targets.bzl‎

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
11
load("@fbsource//xplat/executorch/build:runtime_wrapper.bzl", "runtime")
22

3-
def define_common_targets():
3+
def define_common_targets(is_fbcode = False):
44
"""Defines targets that should be shared between fbcode and xplat.
55
6-
The directory containing this targets.bzl file should also contain both
7-
TARGETS and BUCK files that call this function.
6+
Originally an fbcode-only TARGETS dir; the runtime.python_binary calls
7+
here use srcs=[...] which the xplat python_binary macro rejects, so the
8+
body is gated on is_fbcode to preserve pre-migration behavior.
89
"""
10+
if not is_fbcode:
11+
return
912

1013
runtime.python_library(
1114
name = "model",

0 commit comments

Comments
 (0)