From 6181ea14171515e8a16c20760202d7679fca8ff5 Mon Sep 17 00:00:00 2001 From: Jon Janzen Date: Thu, 23 Jul 2026 09:59:56 -0700 Subject: [PATCH] merge fbcode-only TARGETS rules into existing targets.bzl files (#21145) Summary: Pull Request resolved: https://github.com/pytorch/executorch/pull/21145 Chunk 7B of fbcode/executorch TARGETS->BUCK migration. 5 directories where both a TARGETS file (with extra fbcode-only rules) and a targets.bzl existed. For each: 1. Added the new fbcode-only loads from TARGETS to the top of targets.bzl (deduped against already-present loads). 2. Updated `def define_common_targets(...)` to accept `is_fbcode = False`. 3. Appended the fbcode-only TARGETS body at the end of the function inside an `if is_fbcode:` block so xplat continues to skip those rules. 4. Replaced TARGETS with a thin BUCK calling `define_common_targets(is_fbcode = is_fbcode())`. Directories migrated: - backends/cortex_m/test - examples/models/llama/fb - examples/qualcomm/oss_scripts/llama - examples/qualcomm/oss_scripts/whisper - kernels/fb/custom_ops Reviewed By: mzlee Differential Revision: D109082046 --- backends/cortex_m/test/BUCK | 3 +- backends/cortex_m/test/TARGETS | 30 -- backends/cortex_m/test/targets.bzl | 24 +- examples/qualcomm/oss_scripts/llama/BUCK | 5 +- examples/qualcomm/oss_scripts/llama/TARGETS | 280 ------------------ .../qualcomm/oss_scripts/llama/targets.bzl | 280 +++++++++++++++++- examples/qualcomm/oss_scripts/whisper/BUCK | 5 +- examples/qualcomm/oss_scripts/whisper/TARGETS | 47 --- .../qualcomm/oss_scripts/whisper/targets.bzl | 48 ++- 9 files changed, 352 insertions(+), 370 deletions(-) delete mode 100644 backends/cortex_m/test/TARGETS delete mode 100644 examples/qualcomm/oss_scripts/llama/TARGETS delete mode 100644 examples/qualcomm/oss_scripts/whisper/TARGETS diff --git a/backends/cortex_m/test/BUCK b/backends/cortex_m/test/BUCK index 5630c928299..09c672c0db9 100644 --- a/backends/cortex_m/test/BUCK +++ b/backends/cortex_m/test/BUCK @@ -4,8 +4,9 @@ # This source code is licensed under the BSD-style license found in the # LICENSE file in the root directory of this source tree. +load("@fbsource//tools/build_defs:fbsource_utils.bzl", "is_fbcode") load("targets.bzl", "define_common_targets") oncall("executorch") -define_common_targets() +define_common_targets(is_fbcode = is_fbcode()) diff --git a/backends/cortex_m/test/TARGETS b/backends/cortex_m/test/TARGETS deleted file mode 100644 index bb4b017c363..00000000000 --- a/backends/cortex_m/test/TARGETS +++ /dev/null @@ -1,30 +0,0 @@ -# Copyright (c) Meta Platforms, Inc. and affiliates. -# All rights reserved. -# Copyright 2026 Arm Limited and/or its affiliates. -# -# This source code is licensed under the BSD-style license found in the -# LICENSE file in the root directory of this source tree. - -load("@fbcode_macros//build_defs:python_unittest.bzl", "python_unittest") -load("@fbsource//xplat/executorch/build:runtime_wrapper.bzl", "runtime") -load("targets.bzl", "define_common_targets") - -oncall("executorch") -python_unittest( - name="test_replace_quant_nodes", - env={ - "TEST_RUNTIME_IS_NOT_OSS": "1" if not runtime.is_oss else "0", - }, - srcs=[ - "test_helpers_passes_utils.py", - "test_replace_quant_nodes.py", - ], - deps=[ - "//pytorch/ao:torchao", # @manual - "//caffe2:torch", - "//executorch/backends/cortex_m/passes:replace_quant_nodes_pass", - "//executorch/backends/cortex_m/ops:ops", - ], -) - -define_common_targets() diff --git a/backends/cortex_m/test/targets.bzl b/backends/cortex_m/test/targets.bzl index 49cd4579ad6..b639aaebed1 100644 --- a/backends/cortex_m/test/targets.bzl +++ b/backends/cortex_m/test/targets.bzl @@ -4,6 +4,7 @@ # This source code is licensed under the BSD-style license found in the # LICENSE file in the root directory of this source tree. +load("@fbcode_macros//build_defs:python_unittest.bzl", "python_unittest") load("@fbsource//xplat/executorch/build:runtime_wrapper.bzl", "runtime") load("@fbsource//tools/build_defs:platform_defs.bzl", "CXX") @@ -29,13 +30,24 @@ def define_operator_test_target(op): ] ) -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. - """ +def define_common_targets(is_fbcode = False): + """Defines targets that should be shared between fbcode and xplat.""" for op in OPERATORS: define_operator_test_target(op) + if is_fbcode: + python_unittest( + name = "test_replace_quant_nodes", + srcs = [ + "test_helpers_passes_utils.py", + "test_replace_quant_nodes.py", + ], + deps = [ + "//pytorch/ao:torchao", # @manual + "//caffe2:torch", + "//executorch/backends/cortex_m/passes:replace_quant_nodes_pass", + "//executorch/backends/cortex_m/ops:ops", + ], + ) + diff --git a/examples/qualcomm/oss_scripts/llama/BUCK b/examples/qualcomm/oss_scripts/llama/BUCK index 1e8cc179228..f559a6f1cfe 100644 --- a/examples/qualcomm/oss_scripts/llama/BUCK +++ b/examples/qualcomm/oss_scripts/llama/BUCK @@ -1,8 +1,9 @@ # Any targets that should be shared between fbcode and xplat must be defined in -# targets.bzl. This file can contain xplat-only targets. +# targets.bzl. +load("@fbsource//tools/build_defs:fbsource_utils.bzl", "is_fbcode") load(":targets.bzl", "define_common_targets") oncall("executorch") -define_common_targets() +define_common_targets(is_fbcode = is_fbcode()) diff --git a/examples/qualcomm/oss_scripts/llama/TARGETS b/examples/qualcomm/oss_scripts/llama/TARGETS deleted file mode 100644 index c00525d6fe7..00000000000 --- a/examples/qualcomm/oss_scripts/llama/TARGETS +++ /dev/null @@ -1,280 +0,0 @@ -load("@fbsource//xplat/executorch/build:runtime_wrapper.bzl", "runtime") -load("@fbsource//xplat/executorch/backends/qualcomm/qnn_version.bzl", "get_qnn_library_version") -load("@fbcode_macros//build_defs:python_binary.bzl", "python_binary") -load("@fbsource//xplat/executorch/build:runtime_wrapper.bzl", "runtime") - -oncall("executorch") - -runtime.python_library( - name = "static_llama", - srcs = [ - "model/__init__.py", - "model/apply_rope.py", - "model/embedding.py", - "model/feed_forward.py", - "model/layernorm.py", - "model/static_llama.py", - "model/vision_encoder.py", - ], - deps = [ - "//caffe2:torch", - "//executorch/examples/models/llama:transformer_modules", - "fbsource//third-party/pypi/transformers:transformers", - ], -) - -runtime.python_library( - name = "masking_utils", - srcs = [ - "masking_utils.py", - ], - deps = [ - "//caffe2:torch", - ], -) - -runtime.python_library( - name = "decoder_constants", - srcs = [ - "decoder_constants.py", - ], -) - -runtime.python_library( - name = "encoder", - srcs = [ - "encoder/__init__.py", - "encoder/encoder_config.py", - "encoder/encoder_quant_recipe.py", - ], - deps = [ - ":static_llama", - "//caffe2:torch", - ], -) - -runtime.python_library( - name = "static_llm_quant_recipe", - srcs = [ - "static_llm_quant_recipe.py", - ], - deps = [ - "//caffe2:torch", - "//executorch/backends/qualcomm/quantizer:quantizer", - "//pytorch/ao:torchao", - ], -) - -runtime.python_library( - name = "tokenizer", - srcs = [ - "tokenizer.py", - ], - deps = [ - ":decoder_constants", - ":static_llama", - "//caffe2:torch", - "fbsource//third-party/pypi/transformers:transformers", - ], -) - -runtime.python_library( - name = "utils", - srcs = [ - "utils.py", - ], - deps = [ - "//caffe2:torch", - "//executorch/exir:lib", - ], -) - -runtime.python_library( - name = "inference", - srcs = [ - "inference/__init__.py", - "inference/decoder.py", - "inference/encoder.py", - "inference/model.py", - ], - deps = [ - ":masking_utils", - "//caffe2:torch", - ], -) - -runtime.python_library( - name = "dataset", - srcs = [ - "dataset/__init__.py", - "dataset/builders.py", - "dataset/collators.py", - "dataset/config.py", - "dataset/datasets.py", - "dataset/loaders.py", - "dataset/preprocessors.py", - "dataset/schema.py", - ], - deps = [ - ":decoder_constants", - ":encoder", - ":masking_utils", - ":tokenizer", - "//caffe2:torch", - "//executorch/examples/models/llama:eval_library", - "fbsource//third-party/pypi/lm-eval:lm-eval", - "fbsource//third-party/pypi/transformers:transformers", - ], -) - -runtime.python_library( - name = "quantize", - srcs = [ - "quantize/__init__.py", - "quantize/ptq.py", - "quantize/strategy.py", - ], - deps = [ - ":decoder_constants", - ":inference", - ":utils", - "//caffe2:torch", - "//executorch/backends/qualcomm/_passes:passes", - ], -) - -runtime.python_library( - name = "mix_precision_analyzer", - srcs = [ - "mix_precision_analyzer.py", - ], - deps = [ - ":inference", - "//caffe2:torch", - "//executorch/backends/qualcomm/quantizer:quantizer", - "//executorch/devtools:lib", - "//executorch/exir:lib", - "//pytorch/ao:torchao", - ], -) - -runtime.python_library( - name = "evaluator", - srcs = [ - "evaluator/__init__.py", - "evaluator/device_evaluator.py", - "evaluator/lm_eval_adapter.py", - ], - deps = [ - ":dataset", - ":decoder_constants", - ":inference", - ":tokenizer", - ":utils", - "//caffe2:torch", - "//executorch/backends/qualcomm:export_utils", - "//executorch/examples/models/llama:eval_library", - "//pytorch/ao:torchao", - "fbsource//third-party/pypi/lm-eval:lm-eval", - ], -) - -runtime.python_library( - name = "wrappers", - srcs = [ - "wrappers/__init__.py", - "wrappers/attention_sink_wrappers.py", - "wrappers/base_component.py", - "wrappers/llm_wrappers.py", - ], - deps = [ - ":dataset", - ":decoder_constants", - ":encoder", - ":evaluator", - ":inference", - ":mix_precision_analyzer", - ":quantize", - ":static_llama", - ":static_llm_quant_recipe", - ":tokenizer", - "//caffe2:torch", - "//executorch/backends/qualcomm:export_utils", - "//executorch/backends/qualcomm/_passes:passes", - "//executorch/backends/qualcomm/quantizer:quantizer", - "//executorch/backends/qualcomm/utils:utils", - "//executorch/devtools/backend_debug:delegation_info", - "//executorch/examples/models/llama:hf_download", - "//executorch/examples/models/llama:source_transformation", - "//pytorch/ao:torchao", - "fbsource//third-party/pypi/transformers:transformers", - ], -) - -runtime.python_library( - name = "llama_lib", - srcs = ["__init__.py", "llama.py"], - deps = [ - ":dataset", - ":decoder_constants", - ":encoder", - ":evaluator", - ":masking_utils", - ":static_llm_quant_recipe", - ":tokenizer", - ":wrappers", - "//executorch/examples/models/llama:source_transformation", - "//caffe2:torch", - "//executorch/backends/qualcomm:export_utils", - "//executorch/backends/qualcomm/partition:partition", - "//executorch/backends/qualcomm/quantizer:quantizer", - "//executorch/devtools/backend_debug:delegation_info", - "//executorch/devtools:lib", - "//executorch/examples/models:models", - "//executorch/examples/models/codegen:codegen", - "//executorch/examples/models/gemma:gemma", - "//executorch/examples/models/gemma2:gemma2", - "//executorch/examples/models/glm:glm", - "//executorch/examples/models/granite:granite", - "//executorch/examples/models/internvl3:internvl3", - "//executorch/examples/models/smolvlm:smolvlm", - "//executorch/examples/models/llama:hf_download", - "//executorch/examples/qualcomm/oss_scripts/llama:range_setting_pt2e", - "//executorch/examples/qualcomm/oss_scripts/llama:static_llama", - "//executorch/extension/export_util:export_util", - "//executorch/extension/llm/export:export_lib", - "//executorch/extension/pybindings:aten_lib", - ], -) - -runtime.python_library( - name = "range_setting_pt2e", - srcs = [ - "range_setting_pt2e.py", - ], - deps = [ - "//caffe2:torch", - "//executorch/backends/qualcomm:export_utils", - ], -) - -python_binary( - name = "llama", - main_function = "executorch.examples.qualcomm.oss_scripts.llama.llama.main", - preload_deps = [ - "//executorch/extension/llm/custom_ops:model_sharding_py", - ], - deps = [ - ":llama_lib", - ], -) - -runtime.command_alias( - name = "llama_qnn", - env = { - "LD_LIBRARY_PATH": "$(location fbsource//third-party/qualcomm/qnn/qnn-{0}:qnn_offline_compile_libs)".format(get_qnn_library_version()), - # Place holder to pass the QNN_SDK_ROOT check in executorch/examples/qualcomm/utils.py - "QNN_SDK_ROOT": "", - }, - exe = ":llama", -) diff --git a/examples/qualcomm/oss_scripts/llama/targets.bzl b/examples/qualcomm/oss_scripts/llama/targets.bzl index 3769686c135..f39ffa09c5d 100644 --- a/examples/qualcomm/oss_scripts/llama/targets.bzl +++ b/examples/qualcomm/oss_scripts/llama/targets.bzl @@ -4,8 +4,10 @@ load( ) load("@fbsource//xplat/executorch/build:runtime_wrapper.bzl", "get_oss_build_kwargs", "runtime") load("@fbsource//xplat/executorch/backends/qualcomm/third-party:third_party_libs.bzl", "qnn_third_party_dep") +load("@fbsource//xplat/executorch/backends/qualcomm/qnn_version.bzl", "get_qnn_library_version") +load("@fbcode_macros//build_defs:python_binary.bzl", "python_binary") -def define_common_targets(): +def define_common_targets(is_fbcode = False): runtime.cxx_library( name = "runner_lib", srcs = glob( @@ -64,3 +66,279 @@ def define_common_targets(): platforms = [ANDROID], **get_oss_build_kwargs() ) + + + if is_fbcode: + runtime.python_library( + name = "static_llama", + srcs = [ + "model/__init__.py", + "model/apply_rope.py", + "model/embedding.py", + "model/feed_forward.py", + "model/layernorm.py", + "model/static_llama.py", + "model/vision_encoder.py", + ], + deps = [ + "//caffe2:torch", + "//executorch/examples/models/llama:transformer_modules", + "fbsource//third-party/pypi/transformers:transformers", + ], + ) + + runtime.python_library( + name = "masking_utils", + srcs = [ + "masking_utils.py", + ], + deps = [ + "//caffe2:torch", + ], + ) + + runtime.python_library( + name = "decoder_constants", + srcs = [ + "decoder_constants.py", + ], + ) + + runtime.python_library( + name = "encoder", + srcs = [ + "encoder/__init__.py", + "encoder/encoder_config.py", + "encoder/encoder_quant_recipe.py", + ], + deps = [ + ":static_llama", + "//caffe2:torch", + ], + ) + + runtime.python_library( + name = "static_llm_quant_recipe", + srcs = [ + "static_llm_quant_recipe.py", + ], + deps = [ + "//caffe2:torch", + "//executorch/backends/qualcomm/quantizer:quantizer", + "//pytorch/ao:torchao", + ], + ) + + runtime.python_library( + name = "tokenizer", + srcs = [ + "tokenizer.py", + ], + deps = [ + ":decoder_constants", + ":static_llama", + "//caffe2:torch", + "fbsource//third-party/pypi/transformers:transformers", + ], + ) + + runtime.python_library( + name = "utils", + srcs = [ + "utils.py", + ], + deps = [ + "//caffe2:torch", + "//executorch/exir:lib", + ], + ) + + runtime.python_library( + name = "inference", + srcs = [ + "inference/__init__.py", + "inference/decoder.py", + "inference/encoder.py", + "inference/model.py", + ], + deps = [ + ":masking_utils", + "//caffe2:torch", + ], + ) + + runtime.python_library( + name = "dataset", + srcs = [ + "dataset/__init__.py", + "dataset/builders.py", + "dataset/collators.py", + "dataset/config.py", + "dataset/datasets.py", + "dataset/loaders.py", + "dataset/preprocessors.py", + "dataset/schema.py", + ], + deps = [ + ":decoder_constants", + ":encoder", + ":masking_utils", + ":tokenizer", + "//caffe2:torch", + "//executorch/examples/models/llama:eval_library", + "fbsource//third-party/pypi/lm-eval:lm-eval", + "fbsource//third-party/pypi/transformers:transformers", + ], + ) + + runtime.python_library( + name = "quantize", + srcs = [ + "quantize/__init__.py", + "quantize/ptq.py", + "quantize/strategy.py", + ], + deps = [ + ":decoder_constants", + ":inference", + ":utils", + "//caffe2:torch", + "//executorch/backends/qualcomm/_passes:passes", + ], + ) + + runtime.python_library( + name = "mix_precision_analyzer", + srcs = [ + "mix_precision_analyzer.py", + ], + deps = [ + ":inference", + "//caffe2:torch", + "//executorch/backends/qualcomm/quantizer:quantizer", + "//executorch/devtools:lib", + "//executorch/exir:lib", + "//pytorch/ao:torchao", + ], + ) + + runtime.python_library( + name = "evaluator", + srcs = [ + "evaluator/__init__.py", + "evaluator/device_evaluator.py", + "evaluator/lm_eval_adapter.py", + ], + deps = [ + ":dataset", + ":decoder_constants", + ":inference", + ":tokenizer", + ":utils", + "//caffe2:torch", + "//executorch/backends/qualcomm:export_utils", + "//executorch/examples/models/llama:eval_library", + "//pytorch/ao:torchao", + "fbsource//third-party/pypi/lm-eval:lm-eval", + ], + ) + + runtime.python_library( + name = "wrappers", + srcs = [ + "wrappers/__init__.py", + "wrappers/attention_sink_wrappers.py", + "wrappers/base_component.py", + "wrappers/llm_wrappers.py", + ], + deps = [ + ":dataset", + ":decoder_constants", + ":encoder", + ":evaluator", + ":inference", + ":mix_precision_analyzer", + ":quantize", + ":static_llama", + ":static_llm_quant_recipe", + ":tokenizer", + "//caffe2:torch", + "//executorch/backends/qualcomm:export_utils", + "//executorch/backends/qualcomm/_passes:passes", + "//executorch/backends/qualcomm/quantizer:quantizer", + "//executorch/backends/qualcomm/utils:utils", + "//executorch/devtools/backend_debug:delegation_info", + "//executorch/examples/models/llama:hf_download", + "//executorch/examples/models/llama:source_transformation", + "//pytorch/ao:torchao", + "fbsource//third-party/pypi/transformers:transformers", + ], + ) + + runtime.python_library( + name = "llama_lib", + srcs = ["__init__.py", "llama.py"], + deps = [ + ":dataset", + ":decoder_constants", + ":encoder", + ":evaluator", + ":masking_utils", + ":static_llm_quant_recipe", + ":tokenizer", + ":wrappers", + "//executorch/examples/models/llama:source_transformation", + "//caffe2:torch", + "//executorch/backends/qualcomm:export_utils", + "//executorch/backends/qualcomm/partition:partition", + "//executorch/backends/qualcomm/quantizer:quantizer", + "//executorch/devtools/backend_debug:delegation_info", + "//executorch/devtools:lib", + "//executorch/examples/models:models", + "//executorch/examples/models/codegen:codegen", + "//executorch/examples/models/gemma:gemma", + "//executorch/examples/models/gemma2:gemma2", + "//executorch/examples/models/glm:glm", + "//executorch/examples/models/granite:granite", + "//executorch/examples/models/internvl3:internvl3", + "//executorch/examples/models/smolvlm:smolvlm", + "//executorch/examples/models/llama:hf_download", + "//executorch/examples/qualcomm/oss_scripts/llama:range_setting_pt2e", + "//executorch/examples/qualcomm/oss_scripts/llama:static_llama", + "//executorch/extension/export_util:export_util", + "//executorch/extension/llm/export:export_lib", + "//executorch/extension/pybindings:aten_lib", + ], + ) + + runtime.python_library( + name = "range_setting_pt2e", + srcs = [ + "range_setting_pt2e.py", + ], + deps = [ + "//caffe2:torch", + "//executorch/backends/qualcomm:export_utils", + ], + ) + + python_binary( + name = "llama", + main_function = "executorch.examples.qualcomm.oss_scripts.llama.llama.main", + preload_deps = [ + "//executorch/extension/llm/custom_ops:model_sharding_py", + ], + deps = [ + ":llama_lib", + ], + ) + + runtime.command_alias( + name = "llama_qnn", + env = { + "LD_LIBRARY_PATH": "$(location fbsource//third-party/qualcomm/qnn/qnn-{0}:qnn_offline_compile_libs)".format(get_qnn_library_version()), + # Place holder to pass the QNN_SDK_ROOT check in executorch/examples/qualcomm/utils.py + "QNN_SDK_ROOT": "", + }, + exe = ":llama", + ) diff --git a/examples/qualcomm/oss_scripts/whisper/BUCK b/examples/qualcomm/oss_scripts/whisper/BUCK index 1e8cc179228..f559a6f1cfe 100644 --- a/examples/qualcomm/oss_scripts/whisper/BUCK +++ b/examples/qualcomm/oss_scripts/whisper/BUCK @@ -1,8 +1,9 @@ # Any targets that should be shared between fbcode and xplat must be defined in -# targets.bzl. This file can contain xplat-only targets. +# targets.bzl. +load("@fbsource//tools/build_defs:fbsource_utils.bzl", "is_fbcode") load(":targets.bzl", "define_common_targets") oncall("executorch") -define_common_targets() +define_common_targets(is_fbcode = is_fbcode()) diff --git a/examples/qualcomm/oss_scripts/whisper/TARGETS b/examples/qualcomm/oss_scripts/whisper/TARGETS deleted file mode 100644 index e763a9e955b..00000000000 --- a/examples/qualcomm/oss_scripts/whisper/TARGETS +++ /dev/null @@ -1,47 +0,0 @@ -load("@fbsource//xplat/executorch/build:runtime_wrapper.bzl", "runtime") -load("@fbcode_macros//build_defs:python_binary.bzl", "python_binary") - -oncall("executorch") - -runtime.python_library( - name = "whisper_model_lib", - srcs = [ - "whisper_model.py", - ], - deps = [ - "//caffe2:torch", - "fbsource//third-party/pypi/transformers:transformers", - ], -) - -runtime.python_library( - name = "whisper_lib", - srcs = ["whisper.py"], - deps = [ - ":whisper_model_lib", - "//caffe2:torch", - "//executorch/backends/qualcomm:export_utils", - "//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 index cfed7f5d5dd..b2f9291dd64 100644 --- a/examples/qualcomm/oss_scripts/whisper/targets.bzl +++ b/examples/qualcomm/oss_scripts/whisper/targets.bzl @@ -4,8 +4,9 @@ load( ) load("@fbsource//xplat/executorch/build:runtime_wrapper.bzl", "get_oss_build_kwargs", "runtime") load("@fbsource//xplat/executorch/backends/qualcomm/third-party:third_party_libs.bzl", "qnn_third_party_dep") +load("@fbcode_macros//build_defs:python_binary.bzl", "python_binary") -def define_common_targets(): +def define_common_targets(is_fbcode = False): runtime.cxx_library( name = "runner_lib", srcs = glob( @@ -58,3 +59,48 @@ def define_common_targets(): platforms = [ANDROID], **get_oss_build_kwargs() ) + + + if is_fbcode: + runtime.python_library( + name = "whisper_model_lib", + srcs = [ + "whisper_model.py", + ], + deps = [ + "//caffe2:torch", + "fbsource//third-party/pypi/transformers:transformers", + ], + ) + + runtime.python_library( + name = "whisper_lib", + srcs = ["whisper.py"], + deps = [ + ":whisper_model_lib", + "//caffe2:torch", + "//executorch/backends/qualcomm:export_utils", + "//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", + ], + )