Skip to content

Commit 5ce8f42

Browse files
committed
[Executorch] enable sleef consistently
Pull Request resolved: #6524 Earlier only android platofrms had support for sleef ghstack-source-id: 250898896 @exported-using-ghexport Differential Revision: [D64571782](https://our.internmc.facebook.com/intern/diff/D64571782/)
1 parent 21ef4cc commit 5ce8f42

File tree

3 files changed

+41
-39
lines changed

3 files changed

+41
-39
lines changed

extension/llm/custom_ops/targets.bzl

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
11
load("@fbsource//xplat/executorch/build:runtime_wrapper.bzl", "runtime")
2+
load(
3+
"@fbsource//xplat/executorch/kernels/optimized:lib_defs.bzl",
4+
"get_vec_preprocessor_flags",
5+
"get_vec_deps",
6+
)
27
load(
38
"@fbsource//xplat/executorch/kernels/portable:op_registration_util.bzl",
49
"get_compiler_optimization_flags",
510
)
611

7-
812
def define_common_targets():
913
"""Defines targets that should be shared between fbcode and xplat.
1014
@@ -26,6 +30,7 @@ def define_common_targets():
2630
"op_sdpa.h",
2731
"op_update_quantized_cache.h",
2832
],
33+
preprocessor_flags = get_vec_preprocessor_flags(),
2934
exported_deps = [
3035
"//executorch/runtime/kernel:kernel_includes",
3136
"//executorch/kernels/portable/cpu:scalar_utils",
@@ -38,7 +43,7 @@ def define_common_targets():
3843
deps = [
3944
"//executorch/kernels/portable/cpu/util:reduce_util",
4045
"//executorch/extension/llm/custom_ops/spinquant:fast_hadamard_transform",
41-
],
46+
] + get_vec_deps(),
4247
compiler_flags = ["-Wno-missing-prototypes", "-Wno-global-constructors"] + get_compiler_optimization_flags(),
4348
visibility = [
4449
"//executorch/...",

kernels/optimized/lib_defs.bzl

Lines changed: 32 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,37 @@ load(
1515
# functions in order to declare the required compiler flags needed in order to
1616
# access CPU vector intrinsics.
1717

18-
def get_vec_android_preprocessor_flags():
19-
preprocessor_flags = [
20-
(
21-
"^android-arm64.*$",
22-
[
23-
"-DET_BUILD_ARM_VEC256_WITH_SLEEF",
24-
],
25-
),
26-
]
18+
def get_vec_preprocessor_flags():
19+
preprocessor_flags = select({
20+
"ovr_config//os:iphoneos": [
21+
"-DET_BUILD_ARM_VEC256_WITH_SLEEF",
22+
] if not runtime.is_oss else [],
23+
"ovr_config//os:macos-arm64": [
24+
"-DET_BUILD_ARM_VEC256_WITH_SLEEF",
25+
] if not runtime.is_oss else [],
26+
"ovr_config//os:android-arm64": [
27+
"-DET_BUILD_ARM_VEC256_WITH_SLEEF",
28+
] if not runtime.is_oss else [],
29+
"DEFAULT": [],
30+
})
31+
return preprocessor_flags
32+
33+
def get_vec_deps():
34+
preprocessor_flags = select({
35+
"ovr_config//os:linux-x86_64": [
36+
"fbsource//third-party/sleef:sleef",
37+
] if not runtime.is_oss else [],
38+
"ovr_config//os:iphoneos": [
39+
"fbsource//third-party/sleef:sleef_arm",
40+
] if not runtime.is_oss else [],
41+
"ovr_config//os:macos-arm64": [
42+
"fbsource//third-party/sleef:sleef_arm",
43+
] if not runtime.is_oss else [],
44+
"ovr_config//os:android-arm64": [
45+
"fbsource//third-party/sleef:sleef_arm",
46+
] if not runtime.is_oss else [],
47+
"DEFAULT": [],
48+
})
2749
return preprocessor_flags
2850

2951
def get_vec_cxx_preprocessor_flags():
@@ -60,32 +82,7 @@ def define_libs():
6082
"//executorch/...",
6183
"@EXECUTORCH_CLIENTS",
6284
],
63-
cxx_platform_deps = select({
64-
"DEFAULT": [
65-
(
66-
DEVSERVER_PLATFORM_REGEX,
67-
[
68-
"fbsource//third-party/sleef:sleef",
69-
],
70-
),
71-
],
72-
"ovr_config//cpu:arm64": [
73-
(
74-
DEVSERVER_PLATFORM_REGEX,
75-
[
76-
"fbsource//third-party/sleef:sleef_arm",
77-
],
78-
),
79-
],
80-
}),
81-
fbandroid_platform_deps = [
82-
(
83-
"^android-arm64.*$",
84-
[
85-
"fbsource//third-party/sleef:sleef_arm",
86-
],
87-
),
88-
],
85+
deps = get_vec_deps(),
8986
)
9087

9188
runtime.cxx_library(

kernels/optimized/op_registration_util.bzl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ load("@fbsource//xplat/executorch/build:runtime_wrapper.bzl", "runtime")
22
load("@fbsource//xplat/executorch/build:selects.bzl", "selects")
33
load(
44
"@fbsource//xplat/executorch/kernels/optimized:lib_defs.bzl",
5-
"get_vec_android_preprocessor_flags",
5+
"get_vec_preprocessor_flags",
66
)
77
load(
88
"@fbsource//xplat/executorch/kernels/portable:op_registration_util.bzl",
@@ -95,7 +95,7 @@ def define_op_library(name, deps):
9595
deps = [
9696
"//executorch/runtime/kernel:kernel_includes",
9797
] + augmented_deps,
98-
fbandroid_platform_preprocessor_flags = get_vec_android_preprocessor_flags(),
98+
preprocessor_flags = get_vec_preprocessor_flags(),
9999
# sleef needs to be added as a direct dependency of the operator target when building for Android,
100100
# or a linker error may occur. Not sure why this happens; it seems that fbandroid_platform_deps of
101101
# dependencies are not transitive

0 commit comments

Comments
 (0)