Skip to content

Commit 42c25b5

Browse files
committed
Update base for Update on "Reuse GELU implementation from PyTorch core"
kernels/optimized doesn't need to support embedded systems, so it can just take a header-only dep on PyTorch. Note that, because we will pick up Sleef internally and ignore it externally thanks to ATen vec, this PR gets to enable optimized GELU in OSS. Testing: CI to make sure this doesn't break mobile build modes; happy to take advice on anything not currently covered that might break. Differential Revision: [D66335522](https://our.internmc.facebook.com/intern/diff/D66335522/) [ghstack-poisoned]
1 parent a7d0513 commit 42c25b5

File tree

1 file changed

+51
-0
lines changed

1 file changed

+51
-0
lines changed

runtime/core/portable_type/c10/targets.bzl

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

3+
def get_sleef_preprocessor_flags():
4+
if runtime.is_oss:
5+
return []
6+
return ["-DAT_BUILD_ARM_VEC256_WITH_SLEEF"]
7+
8+
39
def define_common_targets():
410
"""Defines targets that should be shared between fbcode and xplat.
511
@@ -40,4 +46,49 @@ def define_common_targets():
4046
visibility = [
4147
"//executorch/runtime/core/portable_type/...",
4248
],
49+
deps = select({
50+
"DEFAULT": [],
51+
# Half-inl.h depends on vec_half.h from ATen, but only when building for x86.
52+
"ovr_config//cpu:x86_64": [
53+
":aten_headers_for_executorch",
54+
],
55+
}),
56+
)
57+
58+
runtime.cxx_library(
59+
name = "aten_headers_for_executorch",
60+
srcs = [],
61+
visibility = ["//executorch/kernels/optimized/..."],
62+
exported_deps = select({
63+
"DEFAULT": [],
64+
"ovr_config//cpu:arm64": [
65+
"fbsource//third-party/sleef:sleef_arm",
66+
] if not runtime.is_oss else [],
67+
# fbsource//third-party/sleef:sleef currently fails to
68+
# link with missing symbols, hence the fbcode-specific dep below.
69+
}),
70+
fbcode_exported_deps = [
71+
"//caffe2:aten-headers-cpu",
72+
"//caffe2:generated-config-header",
73+
"//caffe2/c10/core:base",
74+
] + select({
75+
"DEFAULT": [],
76+
"ovr_config//cpu:x86_64": [
77+
"third-party//sleef:sleef",
78+
]
79+
}),
80+
xplat_exported_deps = [
81+
"//xplat/caffe2:aten_header",
82+
"//xplat/caffe2:generated_aten_config_header",
83+
"//xplat/caffe2/c10:c10",
84+
],
85+
exported_preprocessor_flags = select({
86+
"ovr_config//cpu:x86_64": [
87+
"-DCPU_CAPABILITY=AVX2",
88+
"-DCPU_CAPABILITY_AVX2",
89+
"-DHAVE_AVX2_CPU_DEFINITION",
90+
] + get_sleef_preprocessor_flags(),
91+
"ovr_config//cpu:arm64": get_sleef_preprocessor_flags(),
92+
"DEFAULT": [],
93+
}) + ["-DSTANDALONE_TORCH_HEADER"],
4394
)

0 commit comments

Comments
 (0)