xref: /aosp_15_r20/external/executorch/examples/xnnpack/targets.bzl (revision 523fa7a60841cd1ecfb9cc4201f1ca8b03ed023a)
1load("@fbsource//xplat/executorch/build:runtime_wrapper.bzl", "get_oss_build_kwargs", "runtime")
2
3def define_common_targets():
4    """Defines targets that should be shared between fbcode and xplat.
5
6    The directory containing this targets.bzl file should also contain both
7    TARGETS and BUCK files that call this function.
8    """
9
10    runtime.python_library(
11        name = "models",
12        srcs = [
13            "__init__.py",
14        ],
15        visibility = [
16            "//executorch/examples/xnnpack/...",
17        ],
18        deps = [
19            "//executorch/examples/models:models",  # @manual
20        ],
21    )
22
23    runtime.python_library(
24        name = "xnnpack_aot_lib",
25        srcs = [
26            "aot_compiler.py",
27        ],
28        deps = [
29            ":models",
30            "//executorch/backends/xnnpack/partition:xnnpack_partitioner",
31            "//executorch/extension/export_util:export_util",
32            "//executorch/examples/xnnpack/quantization:quant_utils",
33            "//executorch/exir:lib",
34            "//executorch/exir/backend:backend_api",
35            "//executorch/devtools:lib",
36        ],
37    )
38
39    runtime.python_binary(
40        name = "aot_compiler",
41        main_module = "executorch.examples.xnnpack.aot_compiler",
42        resources = {
43            "//executorch/examples/models/llama/params:params": "params",
44        },
45        deps = [
46            ":xnnpack_aot_lib",
47        ],
48        visibility = [
49            "@EXECUTORCH_CLIENTS",
50        ],
51    )
52
53    # executor_runner for XNNPACK Backend and portable kernels.
54    runtime.cxx_binary(
55        name = "xnn_executor_runner",
56        deps = [
57            "//executorch/examples/portable/executor_runner:executor_runner_lib",
58            "//executorch/backends/xnnpack:xnnpack_backend",
59            "//executorch/kernels/portable:generated_lib",
60        ],
61        define_static_target = True,
62        **get_oss_build_kwargs()
63    )
64