xref: /aosp_15_r20/external/executorch/configurations/targets.bzl (revision 523fa7a60841cd1ecfb9cc4201f1ca8b03ed023a)
1"""Client build configurations.
2
3This package contains useful build targets for executorch clients, assembling
4common collections of deps into self-contained targets.
5"""
6
7load("@fbsource//xplat/executorch/backends:backends.bzl", "get_all_cpu_backend_targets")
8load("@fbsource//xplat/executorch/build:runtime_wrapper.bzl", "runtime")
9load("@fbsource//xplat/executorch/codegen:codegen.bzl", "executorch_generated_lib")
10
11def define_common_targets():
12    """Defines targets that should be shared between fbcode and xplat.
13
14    The directory containing this targets.bzl file should also contain both
15    TARGETS and BUCK files that call this function.
16    """
17
18    # An extended executor library that includes all CPU backend targets and
19    # helper deps.
20    runtime.cxx_library(
21        name = "executor_cpu_optimized",
22        exported_deps = [
23            "//executorch/extension/threadpool:threadpool",
24        ] + get_all_cpu_backend_targets(),
25        visibility = [
26            "//executorch/test/...",
27            "@EXECUTORCH_CLIENTS",
28        ],
29    )
30
31    # Add a common configuration of cpu optimized operators. This adds a bit of confusion
32    # with the above executorch_cpu_optimized target. Generally it would make sense
33    # to just add optimized operators to that target but because executorch_cpu_optimized
34    # might be used elsewhere, I dont want to include ops in that target and find out
35    # size implication. Aim to simplify this later.
36    # File a task, TODO(task), for llama work
37    executorch_generated_lib(
38        name = "optimized_native_cpu_ops",
39        deps = [
40            "//executorch/kernels/optimized:optimized_operators",
41            "//executorch/kernels/optimized:optimized_oplist",
42            "//executorch/kernels/portable:executorch_aten_ops",
43            "//executorch/kernels/portable:operators",
44        ],
45        functions_yaml_target = "//executorch/kernels/optimized:optimized.yaml",
46        fallback_yaml_target = "//executorch/kernels/portable:functions.yaml",
47        define_static_targets = True,
48        visibility = [
49            "//executorch/examples/...",
50            "@EXECUTORCH_CLIENTS",
51        ],
52    )
53
54    # TODO(T183193812): delete this target after optimized-oss.yaml is gone
55    executorch_generated_lib(
56        name = "optimized_native_cpu_ops_oss",
57        deps = [
58            "//executorch/kernels/optimized:optimized_operators",
59            "//executorch/kernels/optimized:optimized_oplist",
60            "//executorch/kernels/portable:executorch_aten_ops",
61            "//executorch/kernels/portable:operators",
62        ],
63        functions_yaml_target = "//executorch/kernels/optimized:optimized-oss.yaml",
64        fallback_yaml_target = "//executorch/kernels/portable:functions.yaml",
65        define_static_targets = True,
66        visibility = [
67            "//executorch/examples/...",
68            "@EXECUTORCH_CLIENTS",
69        ],
70    )
71