Skip to content

Commit d135ba4

Browse files
authored
Revert "Switch fbcode builds of ExecuTorch and PyTorch to fbsource sl… (#11374)
…eef (#11352)" This reverts commit 7d0e954. It's already reverted internally, updating OSS and then we can skip the difftrain [D75968042](https://www.internalfb.com/diff/D75968042) ``` git revert 7d0e954 ```
1 parent 2269160 commit d135ba4

File tree

3 files changed

+42
-62
lines changed

3 files changed

+42
-62
lines changed

kernels/optimized/lib_defs.bzl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,10 @@ def get_preprocessor_flags():
111111
return preprocessor_flags
112112

113113

114+
# Currently, having a dependency on fbsource//third-party/sleef:sleef may cause
115+
# duplicate symbol errors when linking fbcode targets in opt mode that also
116+
# depend on ATen. This is because ATen accesses sleef via the third-party folder
117+
# in caffe2 (caffe2/third-party//sleef:sleef).
114118
# TODO(ssjia): Enable -DCPU_CAPABILITY_AVX2 in fbcode, which requires sleef.
115119
def define_libs(is_fbcode=False):
116120
runtime.cxx_library(
Lines changed: 31 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,10 @@
11
load("@fbsource//xplat/executorch/build:runtime_wrapper.bzl", "runtime", "is_arvr_mode")
22

3-
def get_preprocessor_flags(is_fbcode):
4-
flags = ["-DSTANDALONE_TORCH_HEADER"]
5-
if runtime.is_oss:
6-
return flags
7-
arm64_flags = [
8-
"-DCPU_CAPABILITY_DEFAULT",
9-
]
10-
if is_fbcode:
11-
# TODO: enable Sleef in xplat?
12-
arm64_flags = arm64_flags + ["-DAT_BUILD_ARM_VEC256_WITH_SLEEF"]
13-
14-
x86_avx2_flags = [
15-
"-DCPU_CAPABILITY_AVX2",
16-
"-DHAVE_AVX2_CPU_DEFINITION",
17-
]
18-
default_flags = [
19-
"-DCPU_CAPABILITY_DEFAULT",
20-
]
21-
fbcode_flags = select({
22-
"ovr_config//cpu:x86_64": x86_avx2_flags,
23-
"ovr_config//cpu:arm64": arm64_flags,
24-
"DEFAULT": default_flags,
25-
})
26-
non_fbcode_flags = select({
27-
"ovr_config//cpu/x86:avx2": x86_avx2_flags,
28-
"ovr_config//cpu:arm64": arm64_flags,
29-
"DEFAULT": default_flags,
30-
})
31-
return flags + ["-DET_USE_PYTORCH_HEADERS"] + (fbcode_flags if is_fbcode else non_fbcode_flags)
32-
33-
def get_sleef_deps():
3+
def get_sleef_preprocessor_flags():
344
if runtime.is_oss:
355
return []
36-
return select({
37-
"DEFAULT": [],
38-
"ovr_config//cpu:x86_64": [
39-
"fbsource//third-party/sleef:sleef",
40-
],
41-
"ovr_config//cpu:arm64": [
42-
"fbsource//third-party/sleef:sleef",
43-
],
44-
})
6+
return ["-DAT_BUILD_ARM_VEC256_WITH_SLEEF"]
7+
458

469
def define_common_targets():
4710
"""Defines targets that should be shared between fbcode and xplat.
@@ -91,30 +54,42 @@ def define_common_targets():
9154
name = "aten_headers_for_executorch",
9255
srcs = [],
9356
visibility = ["//executorch/kernels/optimized/...", "@EXECUTORCH_CLIENTS"],
94-
# select() on ovr_config//runtime:fbcode does not work
95-
# properly in all cases. I have seen
96-
# //xplat/executorch/runtime/core/portable_type/c10/c10:aten_headers_for_executorch
97-
# pass such a select in (at least) arvr mode. Going back to
98-
# fbcode_exported_deps accordingly.
9957
exported_deps = select({
10058
"DEFAULT": [],
10159
"ovr_config//cpu:arm64": [
10260
"fbsource//third-party/sleef:sleef",
10361
] if not runtime.is_oss else [],
62+
# fbsource//third-party/sleef:sleef currently fails to
63+
# link with missing symbols, hence the fbcode-specific dep below.
10464
}),
105-
xplat_exported_deps = [
106-
"//xplat/caffe2:aten_header",
107-
"//xplat/caffe2/c10:c10_headers",
108-
("//xplat/caffe2:ovrsource_aten_Config.h"
109-
if is_arvr_mode() else "//xplat/caffe2:generated_aten_config_header"),
110-
], # + get_sleef_deps(), # TODO: enable Sleef in xplat?
11165
fbcode_exported_deps = ([
11266
"//caffe2:aten-headers-cpu",
11367
"//caffe2:generated-config-header",
11468
"//caffe2/c10:c10_headers",
115-
] + get_sleef_deps()) if not runtime.is_oss else [],
116-
exported_preprocessor_flags = get_preprocessor_flags(is_fbcode=False)
117-
+ ([] if runtime.is_oss else ["-DET_USE_PYTORCH_HEADERS"]),
118-
fbcode_exported_preprocessor_flags = get_preprocessor_flags(is_fbcode=True)
119-
+ ([] if runtime.is_oss else ["-DET_USE_PYTORCH_HEADERS"]),
69+
] + select({
70+
"DEFAULT": [],
71+
"ovr_config//cpu:x86_64": [
72+
"third-party//sleef:sleef",
73+
]
74+
})) if not runtime.is_oss else [],
75+
fbcode_exported_preprocessor_flags = [
76+
# We don't -DCPU_CAPABILITY=AVX2 because that trips
77+
# -Wmacro-redefined, and we only care about getting
78+
# reasonable vectorization and Sleef support.
79+
"-DCPU_CAPABILITY_AVX2",
80+
"-DET_USE_PYTORCH_HEADERS",
81+
"-DHAVE_AVX2_CPU_DEFINITION",
82+
"-DSTANDALONE_TORCH_HEADER",
83+
] + get_sleef_preprocessor_flags(),
84+
xplat_exported_deps = [
85+
"//xplat/caffe2:aten_header",
86+
"//xplat/caffe2/c10:c10_headers",
87+
] + ["//xplat/caffe2:ovrsource_aten_Config.h" if is_arvr_mode() else "//xplat/caffe2:generated_aten_config_header",],
88+
exported_preprocessor_flags = select({
89+
# Intentionally punting on non-fbcode x86 sleef support
90+
# for now because of fbsource//third-party/sleef:sleef
91+
# linker failure.
92+
"ovr_config//cpu:arm64": get_sleef_preprocessor_flags(),
93+
"DEFAULT": [],
94+
}) + ["-DSTANDALONE_TORCH_HEADER"] + ([] if runtime.is_oss else ["-DET_USE_PYTORCH_HEADERS"]),
12095
)

shim_et/xplat/executorch/kernels/optimized/lib_defs.bzl

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -69,14 +69,15 @@ def get_vec_cxx_preprocessor_flags():
6969
return preprocessor_flags
7070

7171
def get_vec_fbcode_preprocessor_flags():
72-
preprocessor_flags = select({
73-
"ovr_config//cpu/x86:avx2": [
74-
"-DCPU_CAPABILITY_AVX2",
75-
],
76-
"DEFAULT": [],
77-
})
72+
preprocessor_flags = [
73+
"-DCPU_CAPABILITY_AVX2",
74+
]
7875
return preprocessor_flags
7976

77+
# Currently, having a dependency on fbsource//third-party/sleef:sleef may cause
78+
# duplicate symbol errors when linking fbcode targets in opt mode that also
79+
# depend on ATen. This is because ATen accesses sleef via the third-party folder
80+
# in caffe2 (caffe2/third-party//sleef:sleef).
8081
# TODO(ssjia): Enable -DCPU_CAPABILITY_AVX2 in fbcode, which requires sleef.
8182
def define_libs():
8283
runtime.cxx_library(

0 commit comments

Comments
 (0)