From bd8fb10e83ac8af1b68eba45bb8a9244940c10a2 Mon Sep 17 00:00:00 2001 From: Chen Lai Date: Mon, 10 Feb 2025 17:59:59 -0800 Subject: [PATCH] Add buck file for qnn executor runner and export script Summary: As title, add more buck files Reviewed By: billmguo Differential Revision: D69276339 --- examples/qualcomm/TARGETS | 11 ++++++ examples/qualcomm/executor_runner/TARGETS | 8 ++++ examples/qualcomm/executor_runner/targets.bzl | 38 +++++++++++++++++++ 3 files changed, 57 insertions(+) create mode 100644 examples/qualcomm/executor_runner/TARGETS create mode 100644 examples/qualcomm/executor_runner/targets.bzl diff --git a/examples/qualcomm/TARGETS b/examples/qualcomm/TARGETS index 8a625bdad21..47f4fa422ce 100644 --- a/examples/qualcomm/TARGETS +++ b/examples/qualcomm/TARGETS @@ -3,6 +3,8 @@ load("@fbcode_macros//build_defs:python_library.bzl", "python_library") load("@fbcode_macros//build_defs:python_binary.bzl", "python_binary") +load("@fbsource//xplat/executorch/build:runtime_wrapper.bzl", "runtime") +load("@fbsource//xplat/executorch/backends/qualcomm/qnn_version.bzl", "get_qnn_library_verision") oncall("executorch") @@ -22,6 +24,15 @@ python_binary( ], ) +runtime.command_alias( + name = "export_example_qnn", + env = { + "LD_LIBRARY_PATH": "$(location fbsource//third-party/qualcomm/qnn/qnn-{0}:qnn_offline_compile_libs)".format(get_qnn_library_verision()), + "QNN_SDK_ROOT": "$(location fbsource//third-party/qualcomm/qnn/qnn-{0}:__dir__)".format(get_qnn_library_verision()), + }, + exe = ":export_example", +) + python_library( name = "utils", srcs = ["utils.py"], diff --git a/examples/qualcomm/executor_runner/TARGETS b/examples/qualcomm/executor_runner/TARGETS new file mode 100644 index 00000000000..1e8cc179228 --- /dev/null +++ b/examples/qualcomm/executor_runner/TARGETS @@ -0,0 +1,8 @@ +# Any targets that should be shared between fbcode and xplat must be defined in +# targets.bzl. This file can contain xplat-only targets. + +load(":targets.bzl", "define_common_targets") + +oncall("executorch") + +define_common_targets() diff --git a/examples/qualcomm/executor_runner/targets.bzl b/examples/qualcomm/executor_runner/targets.bzl new file mode 100644 index 00000000000..6250c25b614 --- /dev/null +++ b/examples/qualcomm/executor_runner/targets.bzl @@ -0,0 +1,38 @@ +load( + "@fbsource//tools/build_defs:default_platform_defs.bzl", + "ANDROID", + "APPLE", + "CXX", + "is_apple_platform", +) +load("@fbsource//tools/build_defs:fbsource_utils.bzl", "is_fbcode") +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(): + """Defines targets that should be shared between fbcode and xplat. + + The directory containing this targets.bzl file should also contain both + TARGETS and BUCK files that call this function. + """ + + runtime.cxx_binary( + name = "qnn_executor_runner", + srcs = ["qnn_executor_runner.cpp"], + deps = [ + "//executorch/runtime/executor/test:test_backend_compiler_lib", + "//executorch/runtime/executor/test:test_backend_with_delegate_mapping", + "//executorch/runtime/executor:program", + "//executorch/devtools/etdump:etdump_flatcc", + "//executorch/devtools/bundled_program:runtime", + "//executorch/extension/data_loader:buffer_data_loader", + "//executorch/extension/data_loader:file_data_loader", + "//executorch/extension/tensor:tensor", + "//executorch/extension/runner_util:inputs", + "//executorch/backends/qualcomm/runtime:runtime", + ], + external_deps = [ + "gflags", + ], + )