Skip to content

Commit 9c22c45

Browse files
committed
Update base for Update on "[Executorch][llm] Compile custom op with -O2"
This enable some optimizations for inlining vectorized lib functions Differential Revision: [D64910576](https://our.internmc.facebook.com/intern/diff/D64910576/) [ghstack-poisoned]
1 parent aecacee commit 9c22c45

File tree

2 files changed

+30
-5
lines changed

2 files changed

+30
-5
lines changed

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,

0 commit comments

Comments
 (0)