diff --git a/docs/TARGETS b/docs/BUCK similarity index 88% rename from docs/TARGETS rename to docs/BUCK index a0281b8b782..490d3471fb3 100644 --- a/docs/TARGETS +++ b/docs/BUCK @@ -1,9 +1,10 @@ +load("@fbcode_macros//build_defs:build_file_migration.bzl", "fbcode_target", "non_fbcode_target") load("@fbcode_macros//build_defs:native_rules.bzl", "buck_filegroup", "buck_sh_test") load("@fbcode_macros//build_defs:python_binary.bzl", "python_binary") oncall("executorch") -python_binary( +fbcode_target(_kind = python_binary, name = "sphinx", main_module = "sphinx.cmd.build", par_style = "xar", @@ -30,12 +31,12 @@ python_binary( ], ) -buck_filegroup( +fbcode_target(_kind = buck_filegroup, name = "source", srcs = glob(["source/**/*"]), ) -buck_sh_test( +fbcode_target(_kind = buck_sh_test, name = "doctest", args = [ "-M", diff --git a/examples/apple/coreml/llama/TARGETS b/examples/apple/coreml/llama/BUCK similarity index 87% rename from examples/apple/coreml/llama/TARGETS rename to examples/apple/coreml/llama/BUCK index eedb88774e0..c012e260eb0 100644 --- a/examples/apple/coreml/llama/TARGETS +++ b/examples/apple/coreml/llama/BUCK @@ -1,9 +1,10 @@ +load("@fbcode_macros//build_defs:build_file_migration.bzl", "fbcode_target", "non_fbcode_target") # Any targets that should be shared between fbcode and xplat must be defined in # targets.bzl. This file can contain fbcode-only targets. load("@fbsource//xplat/executorch/build:runtime_wrapper.bzl", "runtime") -runtime.python_library( +fbcode_target(_kind = runtime.python_library, name = "llama_transformer", srcs = [ "llama_transformer.py", @@ -17,7 +18,7 @@ runtime.python_library( ], ) -runtime.python_library( +fbcode_target(_kind = runtime.python_library, name = "utils", srcs = [ "utils.py", @@ -30,7 +31,7 @@ runtime.python_library( ], ) -runtime.python_binary( +fbcode_target(_kind = runtime.python_binary, name = "export", srcs = [ "export.py", diff --git a/examples/apple/coreml/scripts/TARGETS b/examples/apple/coreml/scripts/BUCK similarity index 82% rename from examples/apple/coreml/scripts/TARGETS rename to examples/apple/coreml/scripts/BUCK index c47af5235f7..01f1d588ecd 100644 --- a/examples/apple/coreml/scripts/TARGETS +++ b/examples/apple/coreml/scripts/BUCK @@ -1,8 +1,9 @@ +load("@fbcode_macros//build_defs:build_file_migration.bzl", "fbcode_target", "non_fbcode_target") # Any targets that should be shared between fbcode and xplat must be defined in # targets.bzl. This file can contain fbcode-only targets. load("@fbcode_macros//build_defs:python_binary.bzl", "python_binary") -python_binary( +fbcode_target(_kind = python_binary, name = "export", srcs = [ "export.py", diff --git a/examples/apple/mps/executor_runner/BUCK b/examples/apple/mps/executor_runner/BUCK index 5fe34f9aa41..1d1d40e1384 100644 --- a/examples/apple/mps/executor_runner/BUCK +++ b/examples/apple/mps/executor_runner/BUCK @@ -1,3 +1,5 @@ +load("@fbcode_macros//build_defs:build_file_migration.bzl", "fbcode_target", "non_fbcode_target") +oncall("executorch") # # Copyright (c) 2023 Apple Inc. All rights reserved. # Provided subject to the LICENSE file in the top level directory. @@ -8,6 +10,20 @@ load(":targets.bzl", "define_common_targets") -oncall("executorch") -define_common_targets() +non_fbcode_target(_kind = define_common_targets,) + +# !!!! fbcode/executorch/examples/apple/mps/executor_runner/TARGETS was merged into this file, see https://fburl.com/workplace/xl8l9yuo for more info !!!! + +# +# Copyright (c) 2023 Apple Inc. All rights reserved. +# Provided subject to the LICENSE file in the top level directory. +# + +# Any targets that should be shared between fbcode and xplat must be defined in +# targets.bzl. This file can contain fbcode-only targets. + +load(":targets.bzl", "define_common_targets") + + +fbcode_target(_kind = define_common_targets,) diff --git a/examples/apple/mps/executor_runner/TARGETS b/examples/apple/mps/executor_runner/TARGETS deleted file mode 100644 index 3926187e5e5..00000000000 --- a/examples/apple/mps/executor_runner/TARGETS +++ /dev/null @@ -1,13 +0,0 @@ -# -# Copyright (c) 2023 Apple Inc. All rights reserved. -# Provided subject to the LICENSE file in the top level directory. -# - -# Any targets that should be shared between fbcode and xplat must be defined in -# targets.bzl. This file can contain fbcode-only targets. - -load(":targets.bzl", "define_common_targets") - -oncall("executorch") - -define_common_targets() diff --git a/examples/devtools/example_runner/BUCK b/examples/devtools/example_runner/BUCK index 1e8cc179228..3410c24b710 100644 --- a/examples/devtools/example_runner/BUCK +++ b/examples/devtools/example_runner/BUCK @@ -1,8 +1,19 @@ +load("@fbcode_macros//build_defs:build_file_migration.bzl", "fbcode_target", "non_fbcode_target") +oncall("executorch") # 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() +non_fbcode_target(_kind = define_common_targets,) + +# !!!! fbcode/executorch/examples/devtools/example_runner/TARGETS was merged into this file, see https://fburl.com/workplace/xl8l9yuo for more info !!!! + +# Any targets that should be shared between fbcode and xplat must be defined in +# targets.bzl. This file can contain fbcode-only targets. + +load(":targets.bzl", "define_common_targets") + + +fbcode_target(_kind = define_common_targets,) diff --git a/examples/devtools/example_runner/TARGETS b/examples/devtools/example_runner/TARGETS deleted file mode 100644 index 2341af9282f..00000000000 --- a/examples/devtools/example_runner/TARGETS +++ /dev/null @@ -1,8 +0,0 @@ -# Any targets that should be shared between fbcode and xplat must be defined in -# targets.bzl. This file can contain fbcode-only targets. - -load(":targets.bzl", "define_common_targets") - -oncall("executorch") - -define_common_targets() diff --git a/examples/devtools/scripts/BUCK b/examples/devtools/scripts/BUCK new file mode 100644 index 00000000000..720ba137733 --- /dev/null +++ b/examples/devtools/scripts/BUCK @@ -0,0 +1,30 @@ +load("@fbcode_macros//build_defs:build_file_migration.bzl", "fbcode_target", "non_fbcode_target") +load("@fbsource//xplat/executorch/build:runtime_wrapper.bzl", "runtime") + +oncall("executorch") + +fbcode_target(_kind = runtime.python_binary, + name = "export_bundled_program", + main_function = ".export_bundled_program.main", + main_src = "export_bundled_program.py", + deps = [ + "//caffe2:torch", + "//executorch/devtools:lib", + "//executorch/devtools/bundled_program:config", + "//executorch/devtools/bundled_program/serialize:lib", + "//executorch/examples/models:models", + "//executorch/extension/export_util:export_util", + ], +) + +fbcode_target(_kind = runtime.python_binary, + name = "gen_sample_etrecord", + srcs = ["gen_sample_etrecord.py"], + main_function = "executorch.examples.devtools.scripts.gen_sample_etrecord.main", + deps = [ + "//executorch/devtools:lib", + "//executorch/devtools/etrecord:etrecord", + "//executorch/examples/models:models", + "//executorch/exir:lib", + ], +) diff --git a/examples/llm_pte_finetuning/TARGETS b/examples/llm_pte_finetuning/BUCK similarity index 90% rename from examples/llm_pte_finetuning/TARGETS rename to examples/llm_pte_finetuning/BUCK index 1acb7adee49..0b3d97ba3bc 100644 --- a/examples/llm_pte_finetuning/TARGETS +++ b/examples/llm_pte_finetuning/BUCK @@ -1,9 +1,10 @@ +load("@fbcode_macros//build_defs:build_file_migration.bzl", "fbcode_target", "non_fbcode_target") load("@fbcode_macros//build_defs:python_binary.bzl", "python_binary") load("@fbsource//xplat/executorch/build:runtime_wrapper.bzl", "runtime") oncall("papaya_oncall") -runtime.python_library( +fbcode_target(_kind = runtime.python_library, name = "model_loading_lib", srcs = [ "model_loading_lib.py", @@ -20,7 +21,7 @@ runtime.python_library( ], ) -runtime.python_library( +fbcode_target(_kind = runtime.python_library, name = "training_lib", srcs = [ "training_lib.py", @@ -36,7 +37,7 @@ runtime.python_library( ], ) -python_binary( +fbcode_target(_kind = python_binary, name = "runner", srcs = [ "runner.py", @@ -53,7 +54,7 @@ python_binary( ], ) -python_binary( +fbcode_target(_kind = python_binary, name = "model_exporter", srcs = [ "model_exporter.py", diff --git a/examples/models/BUCK b/examples/models/BUCK new file mode 100644 index 00000000000..94cc88360bf --- /dev/null +++ b/examples/models/BUCK @@ -0,0 +1,53 @@ +load("@fbcode_macros//build_defs:build_file_migration.bzl", "fbcode_target", "non_fbcode_target") +load("@fbcode_macros//build_defs:python_library.bzl", "python_library") + +oncall("executorch") + +fbcode_target(_kind = python_library, + name = "models", + srcs = [ + "__init__.py", + "model_factory.py", + ], + deps = [ + "//caffe2:torch", + "//executorch/examples/models:model_base", # @manual + "//executorch/examples/models/deeplab_v3:dl3_model", # @manual + "//executorch/examples/models/edsr:edsr_model", # @manual + "//executorch/examples/models/emformer_rnnt:emformer_rnnt_model", # @manual + "//executorch/examples/models/inception_v3:ic3_model", # @manual + "//executorch/examples/models/inception_v4:ic4_model", # @manual + "//executorch/examples/models/llama:llama2_model", # @manual + "//executorch/examples/models/mobilebert:mobilebert_model", # @manual + "//executorch/examples/models/mobilenet_v2:mv2_model", # @manual + "//executorch/examples/models/mobilenet_v3:mv3_model", # @manual + "//executorch/examples/models/resnet:resnet_model", # @manual + "//executorch/examples/models/torchvision_vit:vit_model", # @manual + "//executorch/examples/models/toy_model:toy_model", # @manual + "//executorch/examples/models/wav2letter:w2l_model", # @manual + "//executorch/examples/models/llama3_2_vision:multimodal_lib", # @manual + "//executorch/examples/models/gemma3:gemma3", # @manual + "//executorch/examples/models/qwen2_5:qwen2_5", # @manual + "//executorch/examples/models/qwen3:qwen3", # @manual + "//executorch/examples/models/phi_4_mini:phi_4_mini", # @manual + "//executorch/examples/models/smollm2:smollm2", # @manual + "//executorch/examples/models/smollm3:smollm3", # @manual + ], +) + +fbcode_target(_kind = python_library, + name = "checkpoint", + srcs = [ + "checkpoint.py", + ], +) + +fbcode_target(_kind = python_library, + name = "model_base", + srcs = [ + "model_base.py", + ], + deps = [ + "//caffe2:torch", + ], +) diff --git a/examples/models/deeplab_v3/BUCK b/examples/models/deeplab_v3/BUCK new file mode 100644 index 00000000000..d6d8f56b73f --- /dev/null +++ b/examples/models/deeplab_v3/BUCK @@ -0,0 +1,17 @@ +load("@fbcode_macros//build_defs:build_file_migration.bzl", "fbcode_target", "non_fbcode_target") +load("@fbcode_macros//build_defs:python_library.bzl", "python_library") + +oncall("executorch") + +fbcode_target(_kind = python_library, + name = "dl3_model", + srcs = [ + "__init__.py", + "model.py", + ], + deps = [ + "//caffe2:torch", + "//executorch/examples/models:model_base", + "//pytorch/vision:torchvision", # @manual + ], +) diff --git a/examples/models/edsr/BUCK b/examples/models/edsr/BUCK new file mode 100644 index 00000000000..3c959fad6f6 --- /dev/null +++ b/examples/models/edsr/BUCK @@ -0,0 +1,17 @@ +load("@fbcode_macros//build_defs:build_file_migration.bzl", "fbcode_target", "non_fbcode_target") +load("@fbcode_macros//build_defs:python_library.bzl", "python_library") + +oncall("executorch") + +fbcode_target(_kind = python_library, + name = "edsr_model", + srcs = [ + "__init__.py", + "model.py", + ], + deps = [ + "fbsource//third-party/pypi/torchsr:torchsr", # @manual + "//caffe2:torch", + "//executorch/examples/models:model_base", + ], +) diff --git a/examples/models/emformer_rnnt/BUCK b/examples/models/emformer_rnnt/BUCK new file mode 100644 index 00000000000..cce83e8de96 --- /dev/null +++ b/examples/models/emformer_rnnt/BUCK @@ -0,0 +1,17 @@ +load("@fbcode_macros//build_defs:build_file_migration.bzl", "fbcode_target", "non_fbcode_target") +load("@fbcode_macros//build_defs:python_library.bzl", "python_library") + +oncall("executorch") + +fbcode_target(_kind = python_library, + name = "emformer_rnnt_model", + srcs = [ + "__init__.py", + "model.py", + ], + deps = [ + "//caffe2:torch", + "//executorch/examples/models:model_base", + "//pytorch/audio/src:torchaudio_core", + ], +) diff --git a/examples/models/gemma3/BUCK b/examples/models/gemma3/BUCK new file mode 100644 index 00000000000..a4e190dfafe --- /dev/null +++ b/examples/models/gemma3/BUCK @@ -0,0 +1,25 @@ +load("@fbcode_macros//build_defs:build_file_migration.bzl", "fbcode_target", "non_fbcode_target") +load("@fbsource//xplat/executorch/build:runtime_wrapper.bzl", "runtime") +load("@fbcode_macros//build_defs:python_library.bzl", "python_library") + +oncall("executorch") + +fbcode_target(_kind = runtime.python_library, + name = "gemma3", + srcs = [ + "__init__.py", + "convert_weights.py", + ], + _is_external_target = True, + base_module = "executorch.examples.models.gemma3", + resources = { + "config/1b_config.json": "config/1b_config.json", + }, + deps = [ + "//caffe2:torch", + "//executorch/examples/models:model_base", + "//executorch/examples/models/llama:llama2_model", + "fbcode//pytorch/torchtune:lib", + ], + visibility = ["PUBLIC"], +) diff --git a/examples/models/inception_v3/BUCK b/examples/models/inception_v3/BUCK new file mode 100644 index 00000000000..74ad3cbeda8 --- /dev/null +++ b/examples/models/inception_v3/BUCK @@ -0,0 +1,17 @@ +load("@fbcode_macros//build_defs:build_file_migration.bzl", "fbcode_target", "non_fbcode_target") +load("@fbcode_macros//build_defs:python_library.bzl", "python_library") + +oncall("executorch") + +fbcode_target(_kind = python_library, + name = "ic3_model", + srcs = [ + "__init__.py", + "model.py", + ], + deps = [ + "//caffe2:torch", + "//executorch/examples/models:model_base", + "//pytorch/vision:torchvision", # @manual + ], +) diff --git a/examples/models/inception_v4/BUCK b/examples/models/inception_v4/BUCK new file mode 100644 index 00000000000..5a0a3d4097f --- /dev/null +++ b/examples/models/inception_v4/BUCK @@ -0,0 +1,17 @@ +load("@fbcode_macros//build_defs:build_file_migration.bzl", "fbcode_target", "non_fbcode_target") +load("@fbcode_macros//build_defs:python_library.bzl", "python_library") + +oncall("executorch") + +fbcode_target(_kind = python_library, + name = "ic4_model", + srcs = [ + "__init__.py", + "model.py", + ], + deps = [ + "fbsource//third-party/pypi/timm:timm", + "//caffe2:torch", + "//executorch/examples/models:model_base", + ], +) diff --git a/examples/models/lfm2/BUCK b/examples/models/lfm2/BUCK new file mode 100644 index 00000000000..e435e3b5537 --- /dev/null +++ b/examples/models/lfm2/BUCK @@ -0,0 +1,24 @@ +load("@fbcode_macros//build_defs:build_file_migration.bzl", "fbcode_target", "non_fbcode_target") +# Any targets that should be shared between fbcode and xplat must be defined in +# targets.bzl. This file can contain fbcode-only targets. + +load("@fbsource//xplat/executorch/build:runtime_wrapper.bzl", "runtime") + +oncall("executorch") + +fbcode_target(_kind = runtime.python_library, + name = "lfm2", + srcs = [ + "__init__.py", + "short_conv.py", + "convert_weights.py", + ], + base_module = "executorch.examples.models.lfm2", + visibility = ["PUBLIC"], + deps = [ + "//caffe2:torch", + "//executorch/examples/models/llama:transformer_modules", + "fbcode//pytorch/torchtune:lib", + "fbsource//third-party/pypi/safetensors:safetensors", + ], +)