diff --git a/examples/qualcomm/oss_scripts/whisper/TARGETS b/examples/qualcomm/oss_scripts/whisper/TARGETS new file mode 100644 index 00000000000..a0ba19ee766 --- /dev/null +++ b/examples/qualcomm/oss_scripts/whisper/TARGETS @@ -0,0 +1,48 @@ +load("@fbcode_macros//build_defs:python_library.bzl", "python_library") +load("@fbcode_macros//build_defs:python_binary.bzl", "python_binary") +load("@fbsource//xplat/executorch/backends/qualcomm/qnn_version.bzl", "get_qnn_library_version") +load("@fbsource//xplat/executorch/build:runtime_wrapper.bzl", "runtime") + +oncall("executorch") + +python_library( + name = "whisper_model_lib", + srcs = [ + "whisper_model.py", + ], + deps = [ + "//caffe2:torch", + "fbsource//third-party/pypi/transformers:transformers", + ], +) + +python_library( + name = "whisper_lib", + srcs = ["whisper.py"], + deps = [ + ":whisper_model_lib", + "//caffe2:torch", + "//executorch/backends/qualcomm/_passes:passes", + "//executorch/backends/qualcomm/partition:partition", + "//executorch/backends/qualcomm/quantizer:quantizer", + "//executorch/backends/qualcomm/serialization:serialization", + "//executorch/backends/qualcomm/utils:utils", + "//executorch/devtools/backend_debug:delegation_info", + "//executorch/examples/qualcomm:utils", + "//executorch/exir/capture:config", + "//executorch/exir/passes:memory_planning_pass", + "fbsource//third-party/pypi/datasets:datasets", + "fbsource//third-party/pypi/librosa:librosa", + "fbsource//third-party/pypi/soundfile:soundfile", + "fbsource//third-party/pypi/torchmetrics:torchmetrics", + "fbsource//third-party/pypi/transformers:transformers", + ], +) + +python_binary( + name = "whisper", + main_module = "executorch.examples.qualcomm.oss_scripts.whisper.whisper", + deps = [ + ":whisper_lib", + ], +) diff --git a/examples/qualcomm/oss_scripts/whisper/targets.bzl b/examples/qualcomm/oss_scripts/whisper/targets.bzl new file mode 100644 index 00000000000..48f0174f392 --- /dev/null +++ b/examples/qualcomm/oss_scripts/whisper/targets.bzl @@ -0,0 +1,60 @@ +load( + "@fbsource//tools/build_defs:default_platform_defs.bzl", + "ANDROID", +) +load("@fbsource//xplat/executorch/build:runtime_wrapper.bzl", "get_oss_build_kwargs", "runtime") +load("@fbsource//xplat/executorch/backends/qualcomm/qnn_version.bzl", "get_qnn_library_version") + +def define_common_targets(): + runtime.cxx_library( + name = "runner_lib", + srcs = glob( + [ + "runner/*.cpp", + ], + ), + exported_headers = glob([ + "runner/*.h", + ]), + compiler_flags = [ + "-Wno-global-constructors", + "-Wunused-command-line-argument", + ], + deps = [ + "//executorch/extension/llm/runner:stats", + "//executorch/kernels/quantized:generated_lib", + "fbsource//third-party/qualcomm/qnn/qnn-{0}:api".format(get_qnn_library_version()), + ], + exported_deps = [ + "//executorch/extension/module:module", + "//executorch/extension/llm/sampler:sampler", + "//executorch/extension/tensor:tensor", + "//pytorch/tokenizers:hf_tokenizer", + "//executorch/extension/evalue_util:print_evalue", + "//executorch/backends/qualcomm/runtime:runtime", + ], + external_deps = [ + "gflags", + ], + platforms = [ANDROID], + **get_oss_build_kwargs() + ) + + runtime.cxx_binary( + name = "qnn_whisper_runner", + srcs = [ + "qnn_whisper_runner.cpp", + ], + compiler_flags = [ + "-Wno-global-constructors", + ], + deps = [ + ":runner_lib", + "//executorch/extension/threadpool:threadpool", + ], + external_deps = [ + "gflags", + ], + platforms = [ANDROID], + **get_oss_build_kwargs() + ) diff --git a/examples/qualcomm/oss_scripts/whisper/whisper.py b/examples/qualcomm/oss_scripts/whisper/whisper.py index a9f666e5f54..3eb1395ab0e 100644 --- a/examples/qualcomm/oss_scripts/whisper/whisper.py +++ b/examples/qualcomm/oss_scripts/whisper/whisper.py @@ -3,6 +3,10 @@ # # This source code is licensed under the BSD-style license found in the # LICENSE file in the root directory of this source tree. + +# TODO: reenable pyre after fixing the issues +# pyre-ignore-all-errors + import getpass import json import logging