diff --git a/.ci/scripts/unittest-buck2.sh b/.ci/scripts/unittest-buck2.sh index f748be62ac1..340f7438f02 100755 --- a/.ci/scripts/unittest-buck2.sh +++ b/.ci/scripts/unittest-buck2.sh @@ -9,7 +9,11 @@ set -eux # TODO: expand this to //... # TODO: can't query cadence & vulkan backends # TODO: can't query //kernels/prim_ops because of non-buckified stuff in OSS. -buck2 query "//backends/apple/... + //backends/example/... + \ +# TODO: Make //backends/arm tests use runtime wrapper so we can just query //backends/arm/... +buck2 query "//backends/apple/... + //backends/arm: + //backends/arm/debug/... + \ +//backends/arm/operator_support/... + //backends/arm/operators/... + \ +//backends/arm/_passes/... + //backends/arm/runtime/... + //backends/arm/tosa/... \ ++ //backends/example/... + \ //backends/mediatek/... + //backends/transforms/... + \ //backends/xnnpack/... + //configurations/... + //extension/flat_tensor: + \ //extension/llm/runner: + //kernels/aten/... + //kernels/optimized/... + \ diff --git a/backends/arm/TARGETS b/backends/arm/TARGETS index 35b16f819e5..0d947d63903 100644 --- a/backends/arm/TARGETS +++ b/backends/arm/TARGETS @@ -14,7 +14,8 @@ runtime.python_library( "ethosu/partitioner.py" ], deps = [ - ":arm_partitioner", + ":arm_vela", + "//executorch/backends/arm/tosa:arm_partitioner", ] ) runtime.python_library( @@ -25,7 +26,7 @@ runtime.python_library( "vgf/partitioner.py" ], deps = [ - ":arm_partitioner", + "//executorch/backends/arm/tosa:arm_partitioner", ] ) runtime.python_library( @@ -50,21 +51,6 @@ runtime.python_library( "//executorch/exir:lib", ], ) -runtime.python_library( - name = "arm_partitioner", - srcs = [ - "tosa/backend.py", - "tosa/partitioner.py", - ], - deps = [ - ":arm_backend", - ":constants", - "//executorch/backends/arm/debug:schema", - "//executorch/backends/arm/operator_support:operator_support", - "//executorch/backends/arm/_passes:passes", - "//executorch/exir:lib", - ], -) runtime.python_library( name = "arm_backend", srcs = [ @@ -77,7 +63,6 @@ runtime.python_library( "fbsource//third-party/tosa_tools/v1.00/serialization_lib/python/serializer:serializer", "fbsource//third-party/tosa_tools/v0.80/serialization_lib/python/tosa:tosa", "fbsource//third-party/tosa_tools/v1.00/serialization_lib/python/tosa:tosa", - ":arm_vela", ":process_node", "//executorch/backends/arm/operators:lib", "//executorch/backends/arm/operators:node_visitor", diff --git a/backends/arm/tosa/TARGETS b/backends/arm/tosa/TARGETS index b1df4f37c53..18868054259 100644 --- a/backends/arm/tosa/TARGETS +++ b/backends/arm/tosa/TARGETS @@ -59,3 +59,20 @@ runtime.python_library( ":specification", ], ) + +runtime.python_library( + name = "arm_partitioner", + srcs = [ + "backend.py", + "partitioner.py", + ], + deps = [ + "//executorch/backends/arm:arm_backend", + "//executorch/backends/arm:constants", + "//executorch/backends/arm:process_node", + "//executorch/backends/arm/debug:schema", + "//executorch/backends/arm/operator_support:operator_support", + "//executorch/backends/arm/_passes:passes", + "//executorch/exir:lib", + ], +) diff --git a/backends/cadence/aot/TARGETS b/backends/cadence/aot/TARGETS index 0c39fd3d38e..27f9c00f4ac 100644 --- a/backends/cadence/aot/TARGETS +++ b/backends/cadence/aot/TARGETS @@ -12,7 +12,6 @@ load( "CXX", ) load("@fbsource//xplat/executorch/codegen:codegen.bzl", "executorch_generated_lib") -load("@fbcode_macros//build_defs:cpp_python_extension.bzl", "cpp_python_extension") oncall("odai_jarvis") diff --git a/codegen/tools/targets.bzl b/codegen/tools/targets.bzl index 39de8fcb482..acea3370e7d 100644 --- a/codegen/tools/targets.bzl +++ b/codegen/tools/targets.bzl @@ -17,10 +17,10 @@ def define_common_targets(is_fbcode = False): ], deps = [ "//executorch/codegen:gen_lib", - ] + select({ + ] + ([] if runtime.is_oss else select({ "DEFAULT": [], - "ovr_config//os:linux": [] if runtime.is_oss else ["//executorch/codegen/tools:selective_build"], # TODO(larryliu0820) :selective_build doesn't build in OSS yet - }), + "ovr_config//os:linux": ["//executorch/codegen/tools:selective_build"], # TODO(larryliu0820) :selective_build doesn't build in OSS yet + })), ) runtime.python_binary( diff --git a/devtools/TARGETS b/devtools/TARGETS index 2236702fbc7..d384e15fd4a 100644 --- a/devtools/TARGETS +++ b/devtools/TARGETS @@ -5,6 +5,7 @@ oncall("executorch") runtime.python_library( name = "lib", srcs = ["__init__.py"], + visibility = ["//executorch/...", "@EXECUTORCH_CLIENTS"] deps = [ "//executorch/devtools/bundled_program:core", "//executorch/devtools/etrecord:etrecord", diff --git a/exir/TARGETS b/exir/TARGETS index 853d5e199ba..557a61a0e4a 100644 --- a/exir/TARGETS +++ b/exir/TARGETS @@ -7,6 +7,7 @@ runtime.python_library( srcs = [ "tracer.py", ], + visibility = ["//executorch/...", "@EXECUTORCH_CLIENTS"] deps = [ "fbsource//third-party/pypi/typing-extensions:typing-extensions", ":common", @@ -46,6 +47,7 @@ runtime.python_library( srcs = [ "scalar_type.py", ], + visibility = ["//executorch/...", "@EXECUTORCH_CLIENTS"] ) runtime.python_library( @@ -53,6 +55,7 @@ runtime.python_library( srcs = [ "schema.py", ], + visibility = ["//executorch/...", "@EXECUTORCH_CLIENTS"] deps = [ ":scalar_type", "//executorch/exir/backend:compile_spec_schema", @@ -71,6 +74,7 @@ runtime.python_library( srcs = [ "tensor.py", ], + visibility = ["//executorch/...", "@EXECUTORCH_CLIENTS"] deps = [ ":error", ":schema", @@ -84,6 +88,7 @@ runtime.python_library( srcs = [ "memory.py", ], + visibility = ["//executorch/...", "@EXECUTORCH_CLIENTS"] deps = [ "fbsource//third-party/pypi/typing-extensions:typing-extensions", ":tensor", @@ -111,6 +116,7 @@ runtime.python_library( "delegate.py", "delegate.pyi", ], + visibility = ["//executorch/...", "@EXECUTORCH_CLIENTS"] deps = [ "//caffe2:torch", ], @@ -140,6 +146,7 @@ runtime.python_library( srcs = [ "__init__.py", ], + visibility = ["//executorch/...", "@EXECUTORCH_CLIENTS"] deps = [ ":tracer", "//caffe2:torch", @@ -155,6 +162,7 @@ runtime.python_library( srcs = [ "memory_planning.py", ], + visibility = ["//executorch/...", "@EXECUTORCH_CLIENTS"] deps = [ ":control_flow", ":delegate", @@ -213,6 +221,7 @@ runtime.python_library( srcs = [ "print_program.py", ], + visibility = ["//executorch/...", "@EXECUTORCH_CLIENTS"] deps = [ ":error", ":schema", @@ -225,6 +234,7 @@ runtime.python_library( srcs = [ "dynamic_shape.py", ], + visibility = ["//executorch/...", "@EXECUTORCH_CLIENTS"] ) runtime.python_library( @@ -232,6 +242,7 @@ runtime.python_library( srcs = [ "pass_base.py", ], + visibility = ["//executorch/...", "@EXECUTORCH_CLIENTS"] deps = [ ":delegate", ":error", @@ -246,6 +257,7 @@ runtime.python_library( srcs = [ "pass_manager.py", ], + visibility = ["//executorch/...", "@EXECUTORCH_CLIENTS"] deps = [ "fbsource//third-party/pypi/typing-extensions:typing-extensions", ":error", diff --git a/exir/_serialize/TARGETS b/exir/_serialize/TARGETS index 6671bf00334..83a2d4957ce 100644 --- a/exir/_serialize/TARGETS +++ b/exir/_serialize/TARGETS @@ -1,11 +1,10 @@ -load("@fbcode_macros//build_defs:cpp_python_extension.bzl", "cpp_python_extension") 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. -cpp_python_extension( +runtime.cxx_python_extension( name = "_bindings", srcs = [ "bindings.cpp", diff --git a/exir/dialects/TARGETS b/exir/dialects/TARGETS index 39f0a9d0f1b..d1c3af732ca 100644 --- a/exir/dialects/TARGETS +++ b/exir/dialects/TARGETS @@ -10,6 +10,7 @@ runtime.python_library( resources = { "//executorch/exir/dialects/edge:edge_yaml": "edge.yaml", }, + visibility = ["//executorch/...", "@EXECUTORCH_CLIENTS"] deps = [ "//caffe2:torch", "//caffe2/torchgen:torchgen", diff --git a/exir/dialects/edge/TARGETS b/exir/dialects/edge/TARGETS index 4fcf1948b5f..62768ebd72d 100644 --- a/exir/dialects/edge/TARGETS +++ b/exir/dialects/edge/TARGETS @@ -11,6 +11,7 @@ runtime.python_library( resources = { ":edge_yaml": "edge.yaml", }, + visibility = ["//executorch/...", "@EXECUTORCH_CLIENTS"] deps = [ "fbsource//third-party/pypi/ruamel-yaml:ruamel-yaml", "fbsource//third-party/pypi/setuptools:setuptools", diff --git a/exir/passes/TARGETS b/exir/passes/TARGETS index 45e505cdc7d..b0edb46bfb2 100644 --- a/exir/passes/TARGETS +++ b/exir/passes/TARGETS @@ -7,6 +7,7 @@ runtime.python_library( srcs = [ "__init__.py", ], + visibility = ["//executorch/...", "@EXECUTORCH_CLIENTS"] deps = [ ":const_prop_pass", ":debug_handle_generator_pass", @@ -105,6 +106,7 @@ runtime.python_library( srcs = [ "const_prop_pass.py", ], + visibility = ["//executorch/...", "@EXECUTORCH_CLIENTS"] deps = [ "//caffe2:torch", "//executorch/exir:pass_base", @@ -117,6 +119,7 @@ runtime.python_library( srcs = [ "scalar_to_tensor_pass.py", ], + visibility = ["//executorch/...", "@EXECUTORCH_CLIENTS"] deps = [ "//caffe2:torch", "//executorch/exir:pass_base", @@ -128,6 +131,7 @@ runtime.python_library( srcs = [ "constant_prop_pass.py", ], + visibility = ["//executorch/...", "@EXECUTORCH_CLIENTS"] deps = [ "//caffe2:torch", "//executorch/exir/dialects:lib", @@ -142,6 +146,7 @@ runtime.python_library( srcs = [ "remove_graph_asserts_pass.py", ], + visibility = ["//executorch/...", "@EXECUTORCH_CLIENTS"] deps = [ "//caffe2:torch", ], @@ -164,6 +169,7 @@ runtime.python_library( "_quant_patterns_and_replacements.py", "quant_fusion_pass.py", ], + visibility = ["//executorch/...", "@EXECUTORCH_CLIENTS"] deps = [ ":replace_aten_with_edge_pass", "//caffe2:torch", @@ -179,6 +185,7 @@ runtime.python_library( srcs = [ "quantize_io_pass.py", ], + visibility = ["//executorch/...", "@EXECUTORCH_CLIENTS"] deps = [ "fbsource//third-party/pypi/numpy:numpy", "//caffe2:torch", @@ -232,6 +239,7 @@ runtime.python_library( srcs = [ "remove_mixed_type_operators.py", ], + visibility = ["//executorch/...", "@EXECUTORCH_CLIENTS"] deps = [ "//caffe2:torch", "//executorch/exir:pass_base", @@ -243,6 +251,7 @@ runtime.python_library( srcs = [ "spec_prop_pass.py", ], + visibility = ["//executorch/...", "@EXECUTORCH_CLIENTS"] deps = [ "//caffe2:torch", "//executorch/exir:delegate", @@ -256,6 +265,7 @@ runtime.python_library( srcs = [ "init_mutable_pass.py", ], + visibility = ["//executorch/...", "@EXECUTORCH_CLIENTS"] deps = [ "//executorch/exir:delegate", ], @@ -266,6 +276,7 @@ runtime.python_library( srcs = [ "sym_shape_eval_pass.py", ], + visibility = ["//executorch/...", "@EXECUTORCH_CLIENTS"] deps = [ "//caffe2:torch", "//executorch/exir:_warnings", @@ -340,6 +351,7 @@ runtime.python_library( srcs = [ "debug_handle_generator_pass.py", ], + visibility = ["//executorch/...", "@EXECUTORCH_CLIENTS"] deps = [ "//caffe2:torch", "//executorch/exir:debug_handle_utils", diff --git a/exir/tests/TARGETS b/exir/tests/TARGETS index 855793d53a5..2f5f36d88c8 100644 --- a/exir/tests/TARGETS +++ b/exir/tests/TARGETS @@ -20,6 +20,7 @@ runtime.python_library( srcs = [ "models.py", ], + visibility = ["//executorch/...", "@EXECUTORCH_CLIENTS"] deps = [ "//caffe2:torch", "//executorch/exir:lib", diff --git a/exir/verification/TARGETS b/exir/verification/TARGETS index 8362d87a238..19ccf197258 100644 --- a/exir/verification/TARGETS +++ b/exir/verification/TARGETS @@ -1,10 +1,9 @@ -load("@fbcode_macros//build_defs:cpp_python_extension.bzl", "cpp_python_extension") load("@fbsource//xplat/executorch/build:runtime_wrapper.bzl", "runtime") load("@fbcode_macros//build_defs:python_unittest.bzl", "python_unittest") oncall("executorch") -cpp_python_extension( +runtime.cxx_python_extension( name = "bindings", srcs = [ "bindings.cpp", @@ -48,6 +47,7 @@ runtime.python_library( "arg_validator.py", "verifier.py", ], + visibility = ["//executorch/...", "@EXECUTORCH_CLIENTS"] deps = [ "//caffe2:torch", "//executorch/exir:error", diff --git a/extension/pytree/TARGETS b/extension/pytree/TARGETS index 32eea9b3bdb..c240e69c2f1 100644 --- a/extension/pytree/TARGETS +++ b/extension/pytree/TARGETS @@ -1,7 +1,6 @@ # 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:cpp_python_extension.bzl", "cpp_python_extension") load("@fbsource//xplat/executorch/build:runtime_wrapper.bzl", "runtime") load(":targets.bzl", "define_common_targets") @@ -9,7 +8,7 @@ oncall("executorch") define_common_targets() -cpp_python_extension( +runtime.cxx_python_extension( name = "pybindings", srcs = [ "pybindings.cpp", @@ -21,7 +20,7 @@ cpp_python_extension( ], ) -cpp_python_extension( +runtime.cxx_python_extension( name = "pybindings_debug", srcs = [ "pybindings.cpp", @@ -39,6 +38,7 @@ runtime.python_library( "__init__.py", ], base_module = "executorch.extension.pytree", + visibility = ["//executorch/...", "@EXECUTORCH_CLIENTS"] deps = [ ":pybindings", "//caffe2:torch", diff --git a/extension/training/TARGETS b/extension/training/TARGETS index eeed302c339..f7e3ce0b827 100644 --- a/extension/training/TARGETS +++ b/extension/training/TARGETS @@ -13,6 +13,7 @@ runtime.python_library( srcs = [ "__init__.py", ], + visibility = ["//executorch/...", "@EXECUTORCH_CLIENTS"] deps = [ "//executorch/extension/training/pybindings:_training_lib", "//executorch/extension/training/pybindings:_training_module", diff --git a/shim_et/xplat/executorch/build/runtime_wrapper.bzl b/shim_et/xplat/executorch/build/runtime_wrapper.bzl index bbf4a0fe789..46101ab36db 100644 --- a/shim_et/xplat/executorch/build/runtime_wrapper.bzl +++ b/shim_et/xplat/executorch/build/runtime_wrapper.bzl @@ -290,6 +290,7 @@ def _cxx_test(*args, **kwargs): def _cxx_python_extension(*args, **kwargs): _patch_kwargs_common(kwargs) + _remove_caffe2_deps(kwargs) kwargs["srcs"] = _patch_executorch_references(kwargs["srcs"]) if "types" in kwargs: kwargs["types"] = _patch_executorch_references(kwargs["types"]) @@ -324,8 +325,19 @@ def _genrule(*args, **kwargs): kwargs["name"] += "_static" env.genrule(*args, **kwargs) +def _remove_caffe2_deps(kwargs): + if not env.is_oss: + return + # We don't have Buckified PyTorch in OSS. At least let buck query work. + MISSING_BUCK_DIRS = ("//caffe2", "//pytorch", "fbsource//third-party") + for dep_type in ('deps', 'exported_deps'): + if dep_type not in kwargs: + continue + kwargs[dep_type] = [x for x in kwargs[dep_type] if not any([x.startswith(y) for y in MISSING_BUCK_DIRS])] + def _python_library(*args, **kwargs): _patch_kwargs_common(kwargs) + _remove_caffe2_deps(kwargs) env.python_library(*args, **kwargs) def _python_binary(*args, **kwargs):