Skip to content

Commit aca3f5f

Browse files
committed
Update on "[Executorch][Kernels] Build optimized lib with -O2"
Dont rely on top level config for optimization and rather set our own for optimized kernels Differential Revision: [D64910575](https://our.internmc.facebook.com/intern/diff/D64910575/) [ghstack-poisoned]
2 parents 98a110e + afff64e commit aca3f5f

File tree

3 files changed

+25
-17
lines changed

3 files changed

+25
-17
lines changed

kernels/optimized/lib_defs.bzl

Lines changed: 4 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@ 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+
load(
6+
"@fbsource//xplat/executorch/kernels/portable:op_registration_util.bzl",
7+
"get_compiler_optimization_flags",
8+
)
59

610
# Because vec exists as a collection of header files, compile and preprocessor
711
# flags applied to the vec target do not have any effect, since no compilation
@@ -39,23 +43,6 @@ def get_vec_fbcode_preprocessor_flags():
3943
]
4044
return preprocessor_flags
4145

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-
5946
# Currently, having a dependency on fbsource//third-party/sleef:sleef may cause
6047
# duplicate symbol errors when linking fbcode targets in opt mode that also
6148
# depend on ATen. This is because ATen accesses sleef via the third-party folder

kernels/optimized/op_registration_util.bzl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@ 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+
)
7+
load(
8+
"@fbsource//xplat/executorch/kernels/portable:op_registration_util.bzl",
69
"get_compiler_optimization_flags",
710
)
811

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

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

4+
def get_compiler_optimization_flags():
5+
# various ovr_configs are not available in oss
6+
if not runtime.is_oss:
7+
compiler_flags = select({
8+
"DEFAULT": [],
9+
"ovr_config//os:android-arm64": [
10+
"-O2",
11+
],
12+
"ovr_config//os:iphoneos": [
13+
"-O2",
14+
],
15+
"ovr_config//os:macos-arm64": [
16+
"-O2",
17+
],
18+
})
19+
return compiler_flags
20+
return []
21+
422
def op_target(name, deps = [], android_deps = [], _allow_third_party_deps = False, _aten_mode_deps = []):
523
"""Registers an implementation of an operator overload group.
624

0 commit comments

Comments
 (0)