Skip to content

Commit d7b7aef

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 9c22c45 commit d7b7aef

File tree

2 files changed

+20
-30
lines changed

2 files changed

+20
-30
lines changed

kernels/optimized/lib_defs.bzl

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,23 @@ def get_vec_fbcode_preprocessor_flags():
3939
]
4040
return preprocessor_flags
4141

42+
def get_compiler_optimization_flags():
43+
if not runtime.is_oss:
44+
compiler_flags = select({
45+
"DEFAULT": [],
46+
"ovr_config//os:android-arm64": [
47+
"-O2",
48+
],
49+
"ovr_config//os:iphoneos": [
50+
"-O2",
51+
],
52+
"ovr_config//os:macos-arm64": [
53+
"-O2",
54+
],
55+
})
56+
return compiler_flags
57+
return []
58+
4259
# Currently, having a dependency on fbsource//third-party/sleef:sleef may cause
4360
# duplicate symbol errors when linking fbcode targets in opt mode that also
4461
# depend on ATen. This is because ATen accesses sleef via the third-party folder
@@ -121,21 +138,7 @@ def define_libs():
121138
exported_headers = native.glob([
122139
"blas/**/*.h",
123140
]),
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-
}),
141+
compiler_flags = get_compiler_optimization_flags(),
139142
header_namespace = "executorch/kernels/optimized",
140143
visibility = [
141144
"//executorch/...",

kernels/optimized/op_registration_util.bzl

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ load("@fbsource//xplat/executorch/build:selects.bzl", "selects")
33
load(
44
"@fbsource//xplat/executorch/kernels/optimized:lib_defs.bzl",
55
"get_vec_android_preprocessor_flags",
6+
"get_compiler_optimization_flags",
67
)
78

89
def op_target(name, deps = []):
@@ -87,21 +88,7 @@ def define_op_library(name, deps):
8788
],
8889
# kernels often have helpers with no prototypes just disabling the warning here as the headers
8990
# are codegend and linked in later
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-
}),
91+
compiler_flags = ["-Wno-missing-prototypes"] + get_compiler_optimization_flags(),
10592
deps = [
10693
"//executorch/runtime/kernel:kernel_includes",
10794
] + augmented_deps,

0 commit comments

Comments
 (0)