From aa2d886dbbb0f72aa34230d52a4d4f3ce92dafff Mon Sep 17 00:00:00 2001 From: TARGETS Exterminator Date: Thu, 29 Jan 2026 20:35:14 -0800 Subject: [PATCH] Rename build files from TARGETS to BUCK (group ID: -4334518691985813592) (#17046) Summary: Pull Request resolved: https://github.com/pytorch/executorch/pull/17046 Reviewed By: bigfootjon Differential Revision: D91837938 --- exir/BUCK | 303 ++++++++++++++++++++++++- exir/TARGETS | 298 ------------------------ exir/_serialize/{TARGETS => BUCK} | 5 +- exir/_serialize/test/{TARGETS => BUCK} | 11 +- exir/backend/BUCK | 104 ++++++++- exir/backend/TARGETS | 97 -------- 6 files changed, 413 insertions(+), 405 deletions(-) delete mode 100644 exir/TARGETS rename exir/_serialize/{TARGETS => BUCK} (89%) rename exir/_serialize/test/{TARGETS => BUCK} (78%) delete mode 100644 exir/backend/TARGETS diff --git a/exir/BUCK b/exir/BUCK index 51846daef65..f00b3f1c787 100644 --- a/exir/BUCK +++ b/exir/BUCK @@ -1,4 +1,305 @@ +load("@fbcode_macros//build_defs:build_file_migration.bzl", "fbcode_target", "non_fbcode_target") +oncall("executorch") # add this empty BUCK file to unblock landing. Without this, we get land error: # "No build file at xplat/executorch/exir/BUCK when resolving target fbsource//xplat/executorch/exir:." -oncall("executorch") + +# !!!! fbcode/executorch/exir/TARGETS was merged into this file, see https://fburl.com/workplace/xl8l9yuo for more info !!!! + +load("@fbsource//xplat/executorch/build:runtime_wrapper.bzl", "runtime") + + +fbcode_target(_kind = runtime.python_library, + name = "tracer", + srcs = [ + "tracer.py", + ], + deps = [ + "fbsource//third-party/pypi/typing-extensions:typing-extensions", + ":common", + ":error", + ":graph_module", + ":types", + "//caffe2:torch", + "//executorch/exir/operator:convert", + "//executorch/exir/operator:util", + "//executorch/extension/pytree:pylib", + ], +) + +fbcode_target(_kind = runtime.python_library, + name = "graph", + srcs = [ + "graph.py", + ], + deps = [ + ":tensor", + "//caffe2:torch", + ], +) + +fbcode_target(_kind = runtime.python_library, + name = "graph_module", + srcs = [ + "graph_module.py", + ], + deps = [ + "//caffe2:torch", + ], +) + +fbcode_target(_kind = runtime.python_library, + name = "scalar_type", + srcs = [ + "scalar_type.py", + ], +) + +fbcode_target(_kind = runtime.python_library, + name = "schema", + srcs = [ + "schema.py", + ], + deps = [ + ":scalar_type", + "//executorch/exir/backend:compile_spec_schema", + ], +) + +fbcode_target(_kind = runtime.python_library, + name = "version", + srcs = [ + "version.py", + ], +) + +fbcode_target(_kind = runtime.python_library, + name = "tensor", + srcs = [ + "tensor.py", + ], + deps = [ + ":error", + ":schema", + "//caffe2:torch", + "//executorch/exir:sym_util", + ], +) + +fbcode_target(_kind = runtime.python_library, + name = "tensor_layout", + srcs = [ + "tensor_layout.py", + ], + deps = [ + ":scalar_type", + ":tensor", + ] +) + +fbcode_target(_kind = runtime.python_library, + name = "memory", + srcs = [ + "memory.py", + ], + deps = [ + "fbsource//third-party/pypi/typing-extensions:typing-extensions", + ":tensor", + "//caffe2:torch", + "//executorch/exir:sym_util", + ], +) + +fbcode_target(_kind = runtime.python_library, + name = "control_flow", + srcs = [ + "control_flow.py", + ], + deps = [ + ":error", + ":tracer", + ":wrap", + "//caffe2:torch", + ], +) + +fbcode_target(_kind = runtime.python_library, + name = "delegate", + srcs = [ + "delegate.py", + "delegate.pyi", + ], + deps = [ + "//caffe2:torch", + ], +) + +fbcode_target(_kind = runtime.python_library, + name = "lowered_backend_module", + srcs = [ + "lowered_backend_module.py", + ], + deps = [ + ":delegate", + ":graph_module", + ":schema", + ":tracer", + "//caffe2:torch", + "//executorch/exir/_serialize:lib", + "//executorch/exir/backend:compile_spec_schema", + "//executorch/exir/emit:lib", + "//executorch/exir/passes:memory_planning_pass", + "//executorch/exir/passes:spec_prop_pass", + ], +) + +fbcode_target(_kind = runtime.python_library, + name = "lib", + srcs = [ + "__init__.py", + ], + deps = [ + ":tracer", + "//caffe2:torch", + "//executorch/exir/capture:lib", + "//executorch/exir/emit:lib", + "//executorch/exir/program:lib", + "//executorch/exir/serde:serialize", + ], +) + +fbcode_target(_kind = runtime.python_library, + name = "memory_planning", + srcs = [ + "memory_planning.py", + ], + deps = [ + ":control_flow", + ":delegate", + ":error", + ":memory", + ":schema", + ":tensor", + "//caffe2:torch", + "//executorch/exir/operator:convert", + ], +) + +fbcode_target(_kind = runtime.python_library, + name = "common", + srcs = [ + "common.py", + ], + deps = [ + "//caffe2:torch", + ], +) + +fbcode_target(_kind = runtime.python_library, + name = "error", + srcs = [ + "error.py", + ], + deps = [], +) + +fbcode_target(_kind = runtime.python_library, + name = "types", + srcs = [ + "types.py", + ], + deps = [ + "fbsource//third-party/pypi/typing-extensions:typing-extensions", + ":tensor", + ], +) + +fbcode_target(_kind = runtime.python_library, + name = "wrap", + srcs = [ + "wrap.py", + ], + deps = [ + ":tracer", + "//caffe2:torch", + "//caffe2/functorch:functorch", # @manual + ], +) + +fbcode_target(_kind = runtime.python_library, + name = "print_program", + srcs = [ + "print_program.py", + ], + deps = [ + ":error", + ":schema", + "//caffe2:torch", + ], +) + +fbcode_target(_kind = runtime.python_library, + name = "dynamic_shape", + srcs = [ + "dynamic_shape.py", + ], +) + +fbcode_target(_kind = runtime.python_library, + name = "pass_base", + srcs = [ + "pass_base.py", + ], + deps = [ + ":delegate", + ":error", + ":memory", + "//caffe2:torch", + "//executorch/exir/dialects/edge:lib", + ], +) + +fbcode_target(_kind = runtime.python_library, + name = "pass_manager", + srcs = [ + "pass_manager.py", + ], + deps = [ + "fbsource//third-party/pypi/typing-extensions:typing-extensions", + ":error", + "//caffe2:torch", + ], +) + +fbcode_target(_kind = runtime.python_library, + name = "sym_util", + srcs = ["sym_util.py"], + deps = [ + "fbsource//third-party/pypi/sympy:sympy", + "//caffe2:torch", + ], +) + +fbcode_target(_kind = runtime.python_library, + name = "dim_order_utils", + srcs = ["dim_order_utils.py"], + deps = [ + "//caffe2:torch", + ], +) + +fbcode_target(_kind = runtime.python_library, + name = "_warnings", + srcs = ["_warnings.py"], + deps = [ + "fbsource//third-party/pypi/typing-extensions:typing-extensions", + ], +) + +fbcode_target(_kind = runtime.python_library, + name = "debug_handle_utils", + srcs = ["debug_handle_utils.py"], + deps = [ + "//caffe2:torch", + ], +) diff --git a/exir/TARGETS b/exir/TARGETS deleted file mode 100644 index 58cfa3735de..00000000000 --- a/exir/TARGETS +++ /dev/null @@ -1,298 +0,0 @@ -load("@fbsource//xplat/executorch/build:runtime_wrapper.bzl", "runtime") - -oncall("executorch") - -runtime.python_library( - name = "tracer", - srcs = [ - "tracer.py", - ], - deps = [ - "fbsource//third-party/pypi/typing-extensions:typing-extensions", - ":common", - ":error", - ":graph_module", - ":types", - "//caffe2:torch", - "//executorch/exir/operator:convert", - "//executorch/exir/operator:util", - "//executorch/extension/pytree:pylib", - ], -) - -runtime.python_library( - name = "graph", - srcs = [ - "graph.py", - ], - deps = [ - ":tensor", - "//caffe2:torch", - ], -) - -runtime.python_library( - name = "graph_module", - srcs = [ - "graph_module.py", - ], - deps = [ - "//caffe2:torch", - ], -) - -runtime.python_library( - name = "scalar_type", - srcs = [ - "scalar_type.py", - ], -) - -runtime.python_library( - name = "schema", - srcs = [ - "schema.py", - ], - deps = [ - ":scalar_type", - "//executorch/exir/backend:compile_spec_schema", - ], -) - -runtime.python_library( - name = "version", - srcs = [ - "version.py", - ], -) - -runtime.python_library( - name = "tensor", - srcs = [ - "tensor.py", - ], - deps = [ - ":error", - ":schema", - "//caffe2:torch", - "//executorch/exir:sym_util", - ], -) - -runtime.python_library( - name = "tensor_layout", - srcs = [ - "tensor_layout.py", - ], - deps = [ - ":scalar_type", - ":tensor", - ] -) - -runtime.python_library( - name = "memory", - srcs = [ - "memory.py", - ], - deps = [ - "fbsource//third-party/pypi/typing-extensions:typing-extensions", - ":tensor", - "//caffe2:torch", - "//executorch/exir:sym_util", - ], -) - -runtime.python_library( - name = "control_flow", - srcs = [ - "control_flow.py", - ], - deps = [ - ":error", - ":tracer", - ":wrap", - "//caffe2:torch", - ], -) - -runtime.python_library( - name = "delegate", - srcs = [ - "delegate.py", - "delegate.pyi", - ], - deps = [ - "//caffe2:torch", - ], -) - -runtime.python_library( - name = "lowered_backend_module", - srcs = [ - "lowered_backend_module.py", - ], - deps = [ - ":delegate", - ":graph_module", - ":schema", - ":tracer", - "//caffe2:torch", - "//executorch/exir/_serialize:lib", - "//executorch/exir/backend:compile_spec_schema", - "//executorch/exir/emit:lib", - "//executorch/exir/passes:memory_planning_pass", - "//executorch/exir/passes:spec_prop_pass", - ], -) - -runtime.python_library( - name = "lib", - srcs = [ - "__init__.py", - ], - deps = [ - ":tracer", - "//caffe2:torch", - "//executorch/exir/capture:lib", - "//executorch/exir/emit:lib", - "//executorch/exir/program:lib", - "//executorch/exir/serde:serialize", - ], -) - -runtime.python_library( - name = "memory_planning", - srcs = [ - "memory_planning.py", - ], - deps = [ - ":control_flow", - ":delegate", - ":error", - ":memory", - ":schema", - ":tensor", - "//caffe2:torch", - "//executorch/exir/operator:convert", - ], -) - -runtime.python_library( - name = "common", - srcs = [ - "common.py", - ], - deps = [ - "//caffe2:torch", - ], -) - -runtime.python_library( - name = "error", - srcs = [ - "error.py", - ], - deps = [], -) - -runtime.python_library( - name = "types", - srcs = [ - "types.py", - ], - deps = [ - "fbsource//third-party/pypi/typing-extensions:typing-extensions", - ":tensor", - ], -) - -runtime.python_library( - name = "wrap", - srcs = [ - "wrap.py", - ], - deps = [ - ":tracer", - "//caffe2:torch", - "//caffe2/functorch:functorch", # @manual - ], -) - -runtime.python_library( - name = "print_program", - srcs = [ - "print_program.py", - ], - deps = [ - ":error", - ":schema", - "//caffe2:torch", - ], -) - -runtime.python_library( - name = "dynamic_shape", - srcs = [ - "dynamic_shape.py", - ], -) - -runtime.python_library( - name = "pass_base", - srcs = [ - "pass_base.py", - ], - deps = [ - ":delegate", - ":error", - ":memory", - "//caffe2:torch", - "//executorch/exir/dialects/edge:lib", - ], -) - -runtime.python_library( - name = "pass_manager", - srcs = [ - "pass_manager.py", - ], - deps = [ - "fbsource//third-party/pypi/typing-extensions:typing-extensions", - ":error", - "//caffe2:torch", - ], -) - -runtime.python_library( - name = "sym_util", - srcs = ["sym_util.py"], - deps = [ - "fbsource//third-party/pypi/sympy:sympy", - "//caffe2:torch", - ], -) - -runtime.python_library( - name = "dim_order_utils", - srcs = ["dim_order_utils.py"], - deps = [ - "//caffe2:torch", - ], -) - -runtime.python_library( - name = "_warnings", - srcs = ["_warnings.py"], - deps = [ - "fbsource//third-party/pypi/typing-extensions:typing-extensions", - ], -) - -runtime.python_library( - name = "debug_handle_utils", - srcs = ["debug_handle_utils.py"], - deps = [ - "//caffe2:torch", - ], -) diff --git a/exir/_serialize/TARGETS b/exir/_serialize/BUCK similarity index 89% rename from exir/_serialize/TARGETS rename to exir/_serialize/BUCK index 7208befb51e..be09c1756b3 100644 --- a/exir/_serialize/TARGETS +++ b/exir/_serialize/BUCK @@ -1,10 +1,11 @@ +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") # TODO(T157145817): Update other flatbuffer serializers to use flatc like # _flatbuffer.py does, and remove this. -runtime.cxx_python_extension( +fbcode_target(_kind = runtime.cxx_python_extension, name = "_bindings", srcs = [ "bindings.cpp", @@ -23,7 +24,7 @@ runtime.cxx_python_extension( # Use runtime.python_library instead of the one defined in python_library.bzl, # so we can have access to EXECUTORCH_CLIENTS list. -runtime.python_library( +fbcode_target(_kind = runtime.python_library, name = "lib", srcs = [ "__init__.py", diff --git a/exir/_serialize/test/TARGETS b/exir/_serialize/test/BUCK similarity index 78% rename from exir/_serialize/test/TARGETS rename to exir/_serialize/test/BUCK index 483d8bb31d0..c70a3629cd1 100644 --- a/exir/_serialize/test/TARGETS +++ b/exir/_serialize/test/BUCK @@ -1,8 +1,9 @@ +load("@fbcode_macros//build_defs:build_file_migration.bzl", "fbcode_target", "non_fbcode_target") load("@fbcode_macros//build_defs:python_unittest.bzl", "python_unittest") oncall("executorch") -python_unittest( +fbcode_target(_kind = python_unittest, name = "test_program", srcs = [ "test_program.py", @@ -14,7 +15,7 @@ python_unittest( ], ) -python_unittest( +fbcode_target(_kind = python_unittest, name = "test_flatbuffer", srcs = [ "test_flatbuffer.py", @@ -24,7 +25,7 @@ python_unittest( ], ) -python_unittest( +fbcode_target(_kind = python_unittest, name = "test_cord", srcs = [ "test_cord.py", @@ -34,7 +35,7 @@ python_unittest( ], ) -python_unittest( +fbcode_target(_kind = python_unittest, name = "test_named_data_store", srcs = [ "test_named_data_store.py", @@ -44,7 +45,7 @@ python_unittest( ], ) -python_unittest( +fbcode_target(_kind = python_unittest, name = "test_serialize", srcs = [ "test_serialize.py", diff --git a/exir/backend/BUCK b/exir/backend/BUCK index 1e8cc179228..bb54371ef63 100644 --- a/exir/backend/BUCK +++ b/exir/backend/BUCK @@ -1,8 +1,108 @@ +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/exir/backend/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("@fbsource//xplat/executorch/backends:backends.bzl", "get_all_cpu_aot_and_backend_targets") +load("@fbsource//xplat/executorch/build:runtime_wrapper.bzl", "runtime") +load(":targets.bzl", "define_common_targets") + + +fbcode_target(_kind = define_common_targets,) + +# Use runtime.python_library instead of the one defined in python_library.bzl, +# so we can have access to EXECUTORCH_CLIENTS list. +fbcode_target(_kind = runtime.python_library, + name = "backend_api", + srcs = [ + "backend_api.py", + ], + visibility = ["PUBLIC"], + deps = [ + ":backend_details", + ":compile_spec_schema", + "//caffe2:torch", + "//executorch/exir/backend:utils", + "//executorch/exir/backend/canonical_partitioners:duplicate_constant_node_pass", + ], +) + +fbcode_target(_kind = runtime.python_library, + name = "compile_spec_schema", + srcs = [ + "compile_spec_schema.py", + ], + visibility = ["PUBLIC"], +) + +fbcode_target(_kind = runtime.python_library, + name = "operator_support", + srcs = [ + "operator_support.py", + ], + visibility = ["PUBLIC"], +) + +fbcode_target(_kind = runtime.python_library, + name = "partitioner", + srcs = [ + "partitioner.py", + ], + visibility = ["PUBLIC"], + deps = [ + ":compile_spec_schema", + "//caffe2:torch", + ], +) + +fbcode_target(_kind = runtime.python_library, + name = "backend_details", + srcs = [ + "backend_details.py", + ], + visibility = ["PUBLIC"], + deps = [ + ":compile_spec_schema", + ":partitioner", + "//caffe2:torch", + "//executorch/exir:delegate", + "//executorch/exir:graph_module", + ], +) + +# backend_lib includes all ahead of time apis and supported backends, +# it's supposed to be only used on server side and not for production on device. +fbcode_target(_kind = runtime.python_library, + name = "backend_lib", + visibility = ["PUBLIC"], + deps = [ + ":backend_api", + ":backend_details", + ":utils", + "//executorch/exir/backend/canonical_partitioners:canonical_partitioner_lib", + ] + get_all_cpu_aot_and_backend_targets(), +) + +fbcode_target(_kind = runtime.python_library, + name = "utils", + srcs = [ + "utils.py", + ], + visibility = ["PUBLIC"], + deps = [ + "fbsource//third-party/pypi/pandas:pandas", + "//caffe2:torch", + "//executorch/exir:lowered_backend_module", + "//executorch/exir/backend/canonical_partitioners:duplicate_constant_node_pass", + ], +) diff --git a/exir/backend/TARGETS b/exir/backend/TARGETS deleted file mode 100644 index fa33fa96428..00000000000 --- a/exir/backend/TARGETS +++ /dev/null @@ -1,97 +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("@fbsource//xplat/executorch/backends:backends.bzl", "get_all_cpu_aot_and_backend_targets") -load("@fbsource//xplat/executorch/build:runtime_wrapper.bzl", "runtime") -load(":targets.bzl", "define_common_targets") - -oncall("executorch") - -define_common_targets() - -# Use runtime.python_library instead of the one defined in python_library.bzl, -# so we can have access to EXECUTORCH_CLIENTS list. -runtime.python_library( - name = "backend_api", - srcs = [ - "backend_api.py", - ], - visibility = ["PUBLIC"], - deps = [ - ":backend_details", - ":compile_spec_schema", - "//caffe2:torch", - "//executorch/exir/backend:utils", - "//executorch/exir/backend/canonical_partitioners:duplicate_constant_node_pass", - ], -) - -runtime.python_library( - name = "compile_spec_schema", - srcs = [ - "compile_spec_schema.py", - ], - visibility = ["PUBLIC"], -) - -runtime.python_library( - name = "operator_support", - srcs = [ - "operator_support.py", - ], - visibility = ["PUBLIC"], -) - -runtime.python_library( - name = "partitioner", - srcs = [ - "partitioner.py", - ], - visibility = ["PUBLIC"], - deps = [ - ":compile_spec_schema", - "//caffe2:torch", - ], -) - -runtime.python_library( - name = "backend_details", - srcs = [ - "backend_details.py", - ], - visibility = ["PUBLIC"], - deps = [ - ":compile_spec_schema", - ":partitioner", - "//caffe2:torch", - "//executorch/exir:delegate", - "//executorch/exir:graph_module", - ], -) - -# backend_lib includes all ahead of time apis and supported backends, -# it's supposed to be only used on server side and not for production on device. -runtime.python_library( - name = "backend_lib", - visibility = ["PUBLIC"], - deps = [ - ":backend_api", - ":backend_details", - ":utils", - "//executorch/exir/backend/canonical_partitioners:canonical_partitioner_lib", - ] + get_all_cpu_aot_and_backend_targets(), -) - -runtime.python_library( - name = "utils", - srcs = [ - "utils.py", - ], - visibility = ["PUBLIC"], - deps = [ - "fbsource//third-party/pypi/pandas:pandas", - "//caffe2:torch", - "//executorch/exir:lowered_backend_module", - "//executorch/exir/backend/canonical_partitioners:duplicate_constant_node_pass", - ], -)