Skip to content

Commit fb5b52f

Browse files
committed
Build/test //kernels/portable/... in unittest-buck
More ATen-mode removal from the OSS build unblocked this.: ghstack-source-id: a8d8cfa ghstack-comment-id: 2706986052 Pull Request resolved: #9042
1 parent 58c042d commit fb5b52f

File tree

5 files changed

+70
-79
lines changed

5 files changed

+70
-79
lines changed

.ci/scripts/unittest-buck2.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,5 +20,5 @@ buck2 query "//backends/apple/... + //backends/example/... + \
2020
# TODO: expand the covered scope of Buck targets.
2121
# //runtime/kernel/... is failing because //third-party:torchgen_files's shell script can't find python on PATH.
2222
# //runtime/test/... requires Python torch, which we don't have in our OSS buck setup.
23-
buck2 test //kernels/portable/cpu/... //runtime/backend/... //runtime/core/... \
23+
buck2 test //kernels/portable/... //runtime/backend/... //runtime/core/... \
2424
//runtime/executor: //runtime/kernel/... //runtime/platform/...

kernels/portable/targets.bzl

Lines changed: 32 additions & 33 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", "get_aten_mode_options", "runtime")
22
load("@fbsource//xplat/executorch/codegen:codegen.bzl", "et_operator_library", "executorch_generated_lib")
33

44
def define_common_targets():
@@ -20,17 +20,18 @@ def define_common_targets():
2020
],
2121
)
2222

23-
runtime.cxx_library(
24-
name = "operators_aten",
25-
srcs = [],
26-
visibility = [
27-
"//executorch/...",
28-
"@EXECUTORCH_CLIENTS",
29-
],
30-
exported_deps = [
31-
"//executorch/kernels/portable/cpu:cpu_aten",
32-
],
33-
)
23+
if True in get_aten_mode_options():
24+
runtime.cxx_library(
25+
name = "operators_aten",
26+
srcs = [],
27+
visibility = [
28+
"//executorch/...",
29+
"@EXECUTORCH_CLIENTS",
30+
],
31+
exported_deps = [
32+
"//executorch/kernels/portable/cpu:cpu_aten",
33+
],
34+
)
3435

3536
runtime.export_file(
3637
name = "functions.yaml",
@@ -79,9 +80,6 @@ def define_common_targets():
7980
)
8081

8182
generated_lib_common_args = {
82-
"custom_ops_aten_kernel_deps": [
83-
"//executorch/kernels/portable:operators_aten",
84-
],
8583
"custom_ops_yaml_target": "//executorch/kernels/portable:custom_ops.yaml",
8684
# size_test expects _static targets to be available for these libraries.
8785
"define_static_targets": True,
@@ -102,21 +100,22 @@ def define_common_targets():
102100
**generated_lib_common_args
103101
)
104102

105-
executorch_generated_lib(
106-
name = "generated_lib_aten",
107-
deps = [
108-
":executorch_aten_ops",
109-
":executorch_custom_ops",
110-
"//executorch/kernels/portable:operators_aten",
111-
],
112-
custom_ops_aten_kernel_deps = [
113-
"//executorch/kernels/portable:operators_aten",
114-
],
115-
custom_ops_yaml_target = "//executorch/kernels/portable:custom_ops.yaml",
116-
aten_mode = True,
117-
visibility = [
118-
"//executorch/...",
119-
"@EXECUTORCH_CLIENTS",
120-
],
121-
define_static_targets = True,
122-
)
103+
if True in get_aten_mode_options():
104+
executorch_generated_lib(
105+
name = "generated_lib_aten",
106+
deps = [
107+
":executorch_aten_ops",
108+
":executorch_custom_ops",
109+
"//executorch/kernels/portable:operators_aten",
110+
],
111+
custom_ops_aten_kernel_deps = [
112+
"//executorch/kernels/portable:operators_aten",
113+
],
114+
custom_ops_yaml_target = "//executorch/kernels/portable:custom_ops.yaml",
115+
aten_mode = True,
116+
visibility = [
117+
"//executorch/...",
118+
"@EXECUTORCH_CLIENTS",
119+
],
120+
define_static_targets = True,
121+
)

kernels/portable/test/TARGETS

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
# targets.bzl. This file can contain fbcode-only targets.
33

44
load(":targets.bzl", "define_common_targets")
5-
load("@fbcode_macros//build_defs:python_unittest.bzl", "python_unittest")
65
load("@fbsource//xplat/executorch/build:runtime_wrapper.bzl", "runtime")
76

87
oncall("executorch")
@@ -28,29 +27,3 @@ runtime.cxx_library(
2827
"libtorch",
2928
],
3029
)
31-
32-
python_unittest(
33-
name = "op_upsample_bilinear2d_test",
34-
srcs = [
35-
"op_upsample_bilinear2d_test.py",
36-
],
37-
preload_deps = [
38-
":aot_ops_test_lib",
39-
],
40-
deps = [
41-
"//caffe2:torch",
42-
],
43-
)
44-
45-
python_unittest(
46-
name = "op_upsample_nearest2d_test",
47-
srcs = [
48-
"op_upsample_nearest2d_test.py",
49-
],
50-
preload_deps = [
51-
":aot_ops_test_lib",
52-
],
53-
deps = [
54-
"//caffe2:torch",
55-
],
56-
)

kernels/portable/test/targets.bzl

Lines changed: 34 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
load("@fbcode_macros//build_defs:python_unittest.bzl", "python_unittest")
12
load("@fbsource//xplat/executorch/build:runtime_wrapper.bzl", "is_xplat", "runtime")
23
load("@fbsource//xplat/executorch/codegen:codegen.bzl", "et_operator_library", "executorch_generated_lib")
34
load("@fbsource//xplat/executorch/kernels/test:util.bzl", "define_supported_features_lib", "op_test")
@@ -8,12 +9,40 @@ def define_common_targets():
89
The directory containing this targets.bzl file should also contain both
910
TARGETS and BUCK files that call this function.
1011
"""
11-
define_supported_features_lib()
12+
if not runtime.is_oss:
13+
define_supported_features_lib()
1214

13-
op_test(name = "op_allclose_test")
14-
op_test(name = "op_div_test")
15-
op_test(name = "op_gelu_test")
16-
op_test(name = "op_mul_test")
15+
if not is_xplat():
16+
python_unittest(
17+
name = "op_upsample_bilinear2d_test",
18+
srcs = [
19+
"op_upsample_bilinear2d_test.py",
20+
],
21+
preload_deps = [
22+
":aot_ops_test_lib",
23+
],
24+
deps = [
25+
"//caffe2:torch",
26+
],
27+
)
28+
29+
python_unittest(
30+
name = "op_upsample_nearest2d_test",
31+
srcs = [
32+
"op_upsample_nearest2d_test.py",
33+
],
34+
preload_deps = [
35+
":aot_ops_test_lib",
36+
],
37+
deps = [
38+
"//caffe2:torch",
39+
],
40+
)
41+
42+
op_test(name = "op_allclose_test")
43+
op_test(name = "op_div_test")
44+
op_test(name = "op_gelu_test")
45+
op_test(name = "op_mul_test")
1746

1847
if is_xplat():
1948
et_operator_library(

runtime/core/portable_type/c10/c10/targets.bzl

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -29,21 +29,11 @@ def define_common_targets():
2929
"util/irange.h",
3030
],
3131
exported_preprocessor_flags = [
32-
# NOTE: If we define C10_EMBEDDED to prevent Half and
33-
# BFloat16 from supporting streams, non-ExecuTorch-core
34-
# uses of other ATen headers that try to print ATen
35-
# primitive types fail to build because, apparently, there
36-
# are implicit conversions from Half/BFloat16 to a variety
37-
# of primitive types, not just float. Since merely
38-
# including <ostream> shouldn't result in any runtime
39-
# artifacts if stream code is never actually called, it
40-
# seems best to just not define C10_EMBEDDED, but if you
41-
# need it, it's there.
42-
# "-DC10_EMBEDDED",
32+
"-DC10_USING_CUSTOM_GENERATED_MACROS",
33+
] + ([] if runtime.is_oss else [
4334
"-DC10_USE_GLOG",
4435
"-DC10_USE_MINIMAL_GLOG",
45-
"-DC10_USING_CUSTOM_GENERATED_MACROS",
46-
],
36+
]),
4737
visibility = [
4838
"//executorch/...",
4939
],

0 commit comments

Comments
 (0)