Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion extension/llm/custom_ops/targets.bzl
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
load("@fbsource//xplat/executorch/build:runtime_wrapper.bzl", "runtime")
load(
"@fbsource//xplat/executorch/kernels/portable:op_registration_util.bzl",
"get_compiler_optimization_flags",
)


def define_common_targets():
"""Defines targets that should be shared between fbcode and xplat.
Expand Down Expand Up @@ -34,7 +39,7 @@ def define_common_targets():
"//executorch/kernels/portable/cpu/util:reduce_util",
"//executorch/extension/llm/custom_ops/spinquant:fast_hadamard_transform",
],
compiler_flags = ["-Wno-missing-prototypes", "-Wno-global-constructors"],
compiler_flags = ["-Wno-missing-prototypes", "-Wno-global-constructors"] + get_compiler_optimization_flags(),
visibility = [
"//executorch/...",
"//executorch/extension/llm/custom_ops/...",
Expand Down
5 changes: 5 additions & 0 deletions kernels/optimized/lib_defs.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@ load("@fbsource//tools/build_defs:default_platform_defs.bzl", "DEVSERVER_PLATFOR
load("@fbsource//tools/build_defs:fb_native_wrapper.bzl", "fb_native")
load("@fbsource//xplat/executorch/backends/xnnpack/third-party:third_party_libs.bzl", "third_party_dep")
load("@fbsource//xplat/executorch/build:runtime_wrapper.bzl", "runtime")
load(
"@fbsource//xplat/executorch/kernels/portable:op_registration_util.bzl",
"get_compiler_optimization_flags",
)

# Because vec exists as a collection of header files, compile and preprocessor
# flags applied to the vec target do not have any effect, since no compilation
Expand Down Expand Up @@ -121,6 +125,7 @@ def define_libs():
exported_headers = native.glob([
"blas/**/*.h",
]),
compiler_flags = get_compiler_optimization_flags(),
header_namespace = "executorch/kernels/optimized",
visibility = [
"//executorch/...",
Expand Down
6 changes: 5 additions & 1 deletion kernels/optimized/op_registration_util.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ load(
"@fbsource//xplat/executorch/kernels/optimized:lib_defs.bzl",
"get_vec_android_preprocessor_flags",
)
load(
"@fbsource//xplat/executorch/kernels/portable:op_registration_util.bzl",
"get_compiler_optimization_flags",
)

def op_target(name, deps = []):
"""Registers an optimized implementation for an operator overload group.
Expand Down Expand Up @@ -87,7 +91,7 @@ def define_op_library(name, deps):
],
# kernels often have helpers with no prototypes just disabling the warning here as the headers
# are codegend and linked in later
compiler_flags = ["-Wno-missing-prototypes"],
compiler_flags = ["-Wno-missing-prototypes"] + get_compiler_optimization_flags(),
deps = [
"//executorch/runtime/kernel:kernel_includes",
] + augmented_deps,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,24 @@
load("@fbsource//xplat/executorch/build:runtime_wrapper.bzl", "is_xplat", "runtime")
load("@fbsource//xplat/executorch/build:selects.bzl", "selects")

def get_compiler_optimization_flags():
# various ovr_configs are not available in oss
if not runtime.is_oss:
compiler_flags = select({
"DEFAULT": [],
"ovr_config//os:android-arm64": [
"-O2",
],
"ovr_config//os:iphoneos": [
"-O2",
],
"ovr_config//os:macos-arm64": [
"-O2",
],
})
return compiler_flags
return []

def op_target(name, deps = [], android_deps = [], _allow_third_party_deps = False, _aten_mode_deps = []):
"""Registers an implementation of an operator overload group.

Expand Down Expand Up @@ -132,7 +150,7 @@ def define_op_library(name, deps, android_deps, aten_target, _allow_third_party_
# library, and it blocks users like unit tests to use kernel
# implementation directly. So we enable this for xplat only.
["-fvisibility=hidden"] if is_xplat() else []
),
) + get_compiler_optimization_flags(),
deps = [
"//executorch/runtime/kernel:kernel_includes" + aten_suffix,
] + deps,
Expand Down
Loading