Skip to content

Use optimized library if op available #324

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
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
3 changes: 3 additions & 0 deletions kernels/optimized/targets.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ def define_common_targets():
et_operator_library(
name = "optimized_oplist",
ops_schema_yaml_target = ":optimized.yaml",
visibility = [
"@EXECUTORCH_CLIENTS",
],
)

# Used mainly for operator testing. In practice, a generated lib specific
Expand Down
34 changes: 30 additions & 4 deletions sdk/runners/targets.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ load(
"CXX",
)
load("@fbsource//xplat/executorch/build:runtime_wrapper.bzl", "runtime")
load("@fbsource//xplat/executorch/codegen:codegen.bzl", "executorch_generated_lib")
load("@fbsource//xplat/executorch/extension/pybindings:pybindings.bzl", "MODELS_ATEN_OPS_ATEN_MODE_GENERATED_LIB", "MODELS_ATEN_OPS_LEAN_MODE_GENERATED_LIB")

def define_common_targets():
Expand All @@ -13,11 +14,34 @@ def define_common_targets():
TARGETS and BUCK files that call this function.
"""

# Test driver for models, uses all portable kernels.
for aten_mode in (True, False):
executorch_generated_lib(
name = "generated_op_lib_for_runner",
deps = [
"//executorch/kernels/optimized:optimized_operators",
"//executorch/kernels/optimized:optimized_oplist",
"//executorch/kernels/portable:executorch_aten_ops",
"//executorch/kernels/portable:executorch_custom_ops",
"//executorch/kernels/portable:operators",
],
custom_ops_aten_kernel_deps = [
"//executorch/kernels/portable:operators_aten",
],
functions_yaml_target = "//executorch/kernels/optimized:optimized.yaml",
custom_ops_yaml_target = "//executorch/kernels/portable:custom_ops.yaml",
fallback_yaml_target = "//executorch/kernels/portable:functions.yaml",
define_static_targets = True,
)

# Test driver for models, uses one of the following kernels:
# (1) all portable kernels
# (2) aten kernels
# (3) optimized kernels, with portable kernels as fallback
for kernel_mode in ["portable", "aten", "optimized"]:
aten_mode = kernel_mode == "aten"
aten_suffix = ("_aten" if aten_mode else "")
binary_name = "executor_runner" if kernel_mode == "portable" else ("executor_runner_" + kernel_mode)
runtime.cxx_binary(
name = "executor_runner" + aten_suffix,
name = binary_name,
srcs = ["executor_runner.cpp"],
deps = [
"//executorch/runtime/executor/test:test_backend_compiler_lib" + aten_suffix,
Expand All @@ -31,7 +55,9 @@ def define_common_targets():
] + (MODELS_ATEN_OPS_ATEN_MODE_GENERATED_LIB if aten_mode else [
"//executorch/configurations:executor_cpu_optimized",
"//executorch/kernels/quantized:generated_lib",
] + MODELS_ATEN_OPS_LEAN_MODE_GENERATED_LIB),
] + (MODELS_ATEN_OPS_LEAN_MODE_GENERATED_LIB if kernel_mode == "portable" else [
":generated_op_lib_for_runner",
])),
preprocessor_flags = ["-DUSE_ATEN_LIB"] if aten_mode else [],
external_deps = [
"gflags",
Expand Down