• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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    # Wraps a commandline executable that can be linked against any desired
11    # kernel or backend implementations. Contains a main() function.
12    runtime.cxx_library(
13        name = "executor_runner_lib",
14        srcs = ["executor_runner.cpp"],
15        deps = [
16            "//executorch/runtime/executor:program",
17            "//executorch/extension/data_loader:file_data_loader",
18            "//executorch/extension/evalue_util:print_evalue",
19            "//executorch/extension/runner_util:inputs",
20        ],
21        external_deps = [
22            "gflags",
23        ],
24        define_static_target = True,
25        visibility = [
26            "//executorch/examples/...",
27        ],
28    )
29
30    register_custom_op = native.read_config("executorch", "register_custom_op", "0")
31    register_quantized_ops = native.read_config("executorch", "register_quantized_ops", "0")
32
33    # Include quantized ops to be able to run quantized model with portable ops
34    custom_ops_lib = ["//executorch/kernels/quantized:generated_lib"]
35    if register_custom_op == "1":
36        custom_ops_lib.append("//executorch/examples/portable/custom_ops:lib_1")
37    elif register_custom_op == "2":
38        custom_ops_lib.append("//executorch/examples/portable/custom_ops:lib_2")
39
40    # Test driver for models, uses all portable kernels and a demo backend. This
41    # is intended to have minimal dependencies. If you want a runner that links
42    # against a different backend or kernel library, define a new executable
43    # based on :executor_runner_lib.
44    runtime.cxx_binary(
45        name = "executor_runner",
46        srcs = [],
47        deps = [
48            ":executor_runner_lib",
49            "//executorch/runtime/executor/test:test_backend_compiler_lib",
50            "//executorch/kernels/portable:generated_lib",
51        ] + custom_ops_lib,
52        define_static_target = True,
53        **get_oss_build_kwargs()
54    )
55