Skip to content

Commit 8d12f97

Browse files
committed
Update on "[Executorch] Make apple take accelerate path for blas"
For some reason fbobjc_exported_preprocessor_flags does not seems to work. Thus taking 'select' route which seems to work. Differential Revision: [D64499608](https://our.internmc.facebook.com/intern/diff/D64499608/) [ghstack-poisoned]
2 parents 27d9a6d + 7967835 commit 8d12f97

File tree

4 files changed

+60
-15
lines changed

4 files changed

+60
-15
lines changed

extension/llm/custom_ops/targets.bzl

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
load("@fbsource//xplat/executorch/build:runtime_wrapper.bzl", "runtime")
2-
lobd("@fbsource//tools/build_defs/apple/build_mode_defs.bzl", "is_local_build")
3-
lobd("@fbsource//tools/build_defs/android/build_mode_defs.bzl", "is_production_build")
42

53
def define_common_targets():
64
"""Defines targets that should be shared between fbcode and xplat.
@@ -36,9 +34,21 @@ def define_common_targets():
3634
"//executorch/kernels/portable/cpu/util:reduce_util",
3735
"//executorch/extension/llm/custom_ops/spinquant:fast_hadamard_transform",
3836
],
39-
compiler_flags = ["-Wno-missing-prototypes", "-Wno-global-constructors"],
40-
fbobjc_compiler_flags = [] if is_local_build() else ["-O2"],
41-
fbandroid_compiler_flags = ["-O2"] if is_production_build() else [],
37+
compiler_flags = ["-Wno-missing-prototypes", "-Wno-global-constructors"] + select({
38+
"DEFAULT": [],
39+
"ovr_config//os:android-arm64": [
40+
"-O2",
41+
] if not runtime.is_oss else [],
42+
"ovr_config//os:iphoneos": [
43+
"-O2",
44+
] if not runtime.is_oss else [],
45+
"ovr_config//os:macos-arm64": [
46+
"-O2",
47+
] if not runtime.is_oss else [],
48+
"ovr_config//os:macos-x86_64": [
49+
"-O2",
50+
] if not runtime.is_oss else [],
51+
}),
4252
visibility = [
4353
"//executorch/...",
4454
"//executorch/extension/llm/custom_ops/...",

kernels/optimized/lib_defs.bzl

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@ load("@fbsource//tools/build_defs:default_platform_defs.bzl", "DEVSERVER_PLATFOR
22
load("@fbsource//tools/build_defs:fb_native_wrapper.bzl", "fb_native")
33
load("@fbsource//xplat/executorch/backends/xnnpack/third-party:third_party_libs.bzl", "third_party_dep")
44
load("@fbsource//xplat/executorch/build:runtime_wrapper.bzl", "runtime")
5-
lobd("@fbsource//tools/build_defs/apple/build_mode_defs.bzl", "is_local_build")
6-
lobd("@fbsource//tools/build_defs/android/build_mode_defs.bzl", "is_production_build")
75

86
# Because vec exists as a collection of header files, compile and preprocessor
97
# flags applied to the vec target do not have any effect, since no compilation
@@ -123,8 +121,21 @@ def define_libs():
123121
exported_headers = native.glob([
124122
"blas/**/*.h",
125123
]),
126-
fbobjc_compiler_flags = [] if is_local_build() else ["-O2"],
127-
fbandroid_compiler_flags = ["-O2"] if is_production_build() else [],
124+
compiler_flags = select({
125+
"DEFAULT": [],
126+
"ovr_config//os:android-arm64": [
127+
"-O2",
128+
] if not runtime.is_oss else [],
129+
"ovr_config//os:iphoneos": [
130+
"-O2",
131+
] if not runtime.is_oss else [],
132+
"ovr_config//os:macos-arm64": [
133+
"-O2",
134+
] if not runtime.is_oss else [],
135+
"ovr_config//os:macos-x86_64": [
136+
"-O2",
137+
] if not runtime.is_oss else [],
138+
}),
128139
header_namespace = "executorch/kernels/optimized",
129140
visibility = [
130141
"//executorch/...",

kernels/optimized/op_registration_util.bzl

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,21 @@ def define_op_library(name, deps):
8787
],
8888
# kernels often have helpers with no prototypes just disabling the warning here as the headers
8989
# are codegend and linked in later
90-
compiler_flags = ["-Wno-missing-prototypes", "-O2"],
90+
compiler_flags = ["-Wno-missing-prototypes"] + select({
91+
"DEFAULT": [],
92+
"ovr_config//os:android": [
93+
"-O2",
94+
] if not runtime.is_oss else [],
95+
"ovr_config//os:iphoneos": [
96+
"-O2",
97+
] if not runtime.is_oss else [],
98+
"ovr_config//os:macos-arm64": [
99+
"-O2",
100+
] if not runtime.is_oss else [],
101+
"ovr_config//os:macos-x86_64": [
102+
"-O2",
103+
] if not runtime.is_oss else [],
104+
}),
91105
deps = [
92106
"//executorch/runtime/kernel:kernel_includes",
93107
] + augmented_deps,

shim/xplat/executorch/kernels/portable/op_registration_util.bzl

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
load("@fbsource//xplat/executorch/build:runtime_wrapper.bzl", "is_xplat", "runtime")
22
load("@fbsource//xplat/executorch/build:selects.bzl", "selects")
3-
lobd("@fbsource//tools/build_defs/apple/build_mode_defs.bzl", "is_local_build")
4-
lobd("@fbsource//tools/build_defs/android/build_mode_defs.bzl", "is_production_build")
53

64
def op_target(name, deps = [], android_deps = [], _allow_third_party_deps = False, _aten_mode_deps = []):
75
"""Registers an implementation of an operator overload group.
@@ -134,9 +132,21 @@ def define_op_library(name, deps, android_deps, aten_target, _allow_third_party_
134132
# library, and it blocks users like unit tests to use kernel
135133
# implementation directly. So we enable this for xplat only.
136134
["-fvisibility=hidden"] if is_xplat() else []
137-
),
138-
fbobjc_compiler_flags = [] if is_local_build() else ["-O2"],
139-
fbandroid_compiler_flags = ["-O2"] if is_production_build() else [],
135+
) + select({
136+
"DEFAULT": [],
137+
"ovr_config//os:android-arm64": [
138+
"-O2",
139+
] if not runtime.is_oss else [],
140+
"ovr_config//os:iphoneos": [
141+
"-O2",
142+
] if not runtime.is_oss else [],
143+
"ovr_config//os:macos-arm64": [
144+
"-O2",
145+
] if not runtime.is_oss else [],
146+
"ovr_config//os:macos-x86_64": [
147+
"-O2",
148+
] if not runtime.is_oss else [],
149+
}),
140150
deps = [
141151
"//executorch/runtime/kernel:kernel_includes" + aten_suffix,
142152
] + deps,

0 commit comments

Comments
 (0)