xref: /aosp_15_r20/external/executorch/kernels/aten/cpu/targets.bzl (revision 523fa7a60841cd1ecfb9cc4201f1ca8b03ed023a)
1load("@fbsource//xplat/executorch/build:runtime_wrapper.bzl", "runtime")
2load("@fbsource//xplat/executorch/kernels/portable:op_registration_util.bzl", "define_op_target", "op_target")
3
4# Operators that are listed in `functions.yaml`, and are thus compatible with
5# the core ATen operators. Every entry here will be backed by a cxx_library
6# target with the given name and deps.
7#
8# Note that a single target (or single .cpp file) can't mix ATen and non-ATen
9# ops, and must be split. They can, however, share common code via a library dep
10# if necessary.
11_EDGE_DIALECT_OPS = (
12    op_target(
13        name = "op__to_dim_order_copy",
14        deps = [
15            "//executorch/kernels/aten/cpu/util:copy_ops_util",
16        ],
17    ),
18)
19
20def define_common_targets():
21    """Defines targets that should be shared between fbcode and xplat.
22
23    The directory containing this targets.bzl file should also contain both
24    TARGETS and BUCK files that call this function.
25    """
26
27    # Define build targets for all operators registered in the tables above.
28    for op in _EDGE_DIALECT_OPS:
29        define_op_target(is_aten_op = False, is_et_op = False, **op)
30
31    all_op_targets = [":{}".format(op["name"]) for op in _EDGE_DIALECT_OPS]
32
33    runtime.cxx_library(
34        name = "cpu",
35        srcs = [],
36        visibility = [
37            "//executorch/kernels/aten/...",
38            "//executorch/kernels/test/...",
39        ],
40        exported_deps = [t + "_aten" for t in all_op_targets],
41    )
42