diff --git a/exir/dialects/edge/test/BUCK b/exir/dialects/edge/test/BUCK index 57d84ff1f8f..f559a6f1cfe 100644 --- a/exir/dialects/edge/test/BUCK +++ b/exir/dialects/edge/test/BUCK @@ -1,4 +1,9 @@ -# add this empty BUCK file to unblock landing. Without this, we get land error: -# "No build file at xplat/executorch/exir/dialects/edge/test/BUCK when resolving target fbsource//xplat/executorch/exir/dialects/edge/test:." +# Any targets that should be shared between fbcode and xplat must be defined in +# targets.bzl. + +load("@fbsource//tools/build_defs:fbsource_utils.bzl", "is_fbcode") +load(":targets.bzl", "define_common_targets") oncall("executorch") + +define_common_targets(is_fbcode = is_fbcode()) diff --git a/exir/dialects/edge/test/TARGETS b/exir/dialects/edge/test/TARGETS deleted file mode 100644 index 8a689b0dba6..00000000000 --- a/exir/dialects/edge/test/TARGETS +++ /dev/null @@ -1,32 +0,0 @@ -load("@fbcode_macros//build_defs:python_unittest.bzl", "python_unittest") - -oncall("executorch") - -python_unittest( - name = "test_edge_yaml", - srcs = [ - "test_edge_yaml.py", - ], - resources = { - "//executorch/exir/dialects/edge:edge_yaml": "edge.yaml", - }, - labels = ["long_running"], - deps = [ - "fbsource//third-party/pypi/expecttest:expecttest", # @manual - "//caffe2:torch", - "//executorch/exir/dialects/edge/dtype:lib", - "//executorch/exir/dialects/edge/spec:lib", - ], -) - -python_unittest( - name = "test_edge_ops", - srcs = [ - "test_edge_ops.py", - ], - deps = [ - "//caffe2:torch", - "//executorch/exir/dialects:lib", - "//executorch/exir/dialects/edge:lib", - ], -) diff --git a/exir/dialects/edge/test/targets.bzl b/exir/dialects/edge/test/targets.bzl new file mode 100644 index 00000000000..342bc504833 --- /dev/null +++ b/exir/dialects/edge/test/targets.bzl @@ -0,0 +1,34 @@ +load("@fbcode_macros//build_defs:python_unittest.bzl", "python_unittest") + +def define_common_targets(is_fbcode = False): + if not is_fbcode: + return + + python_unittest( + name = "test_edge_yaml", + srcs = [ + "test_edge_yaml.py", + ], + resources = { + "//executorch/exir/dialects/edge:edge_yaml": "edge.yaml", + }, + labels = ["long_running"], + deps = [ + "fbsource//third-party/pypi/expecttest:expecttest", # @manual + "//caffe2:torch", + "//executorch/exir/dialects/edge/dtype:lib", + "//executorch/exir/dialects/edge/spec:lib", + ], + ) + + python_unittest( + name = "test_edge_ops", + srcs = [ + "test_edge_ops.py", + ], + deps = [ + "//caffe2:torch", + "//executorch/exir/dialects:lib", + "//executorch/exir/dialects/edge:lib", + ], + ) diff --git a/exir/tests/BUCK b/exir/tests/BUCK index 213d4c228d1..f559a6f1cfe 100644 --- a/exir/tests/BUCK +++ b/exir/tests/BUCK @@ -1,4 +1,9 @@ -# add this empty BUCK file to unblock landing. Without this, we get land error: -# "No build file at xplat/executorch/exir/tests/BUCK when resolving target fbsource//xplat/executorch/exir/tests:." +# Any targets that should be shared between fbcode and xplat must be defined in +# targets.bzl. + +load("@fbsource//tools/build_defs:fbsource_utils.bzl", "is_fbcode") +load(":targets.bzl", "define_common_targets") oncall("executorch") + +define_common_targets(is_fbcode = is_fbcode()) diff --git a/exir/tests/TARGETS b/exir/tests/TARGETS deleted file mode 100644 index c5dac4841a4..00000000000 --- a/exir/tests/TARGETS +++ /dev/null @@ -1,519 +0,0 @@ -load("@fbcode_macros//build_defs:cpp_library.bzl", "cpp_library") -load("@fbsource//xplat/executorch/build:runtime_wrapper.bzl", "runtime") -load("@fbcode_macros//build_defs:python_unittest.bzl", "python_unittest") - -oncall("executorch") - -runtime.python_library( - name = "lib", - srcs = [ - "common.py", - ], - deps = [ - "//caffe2:torch", - "//executorch/exir:schema", - ], -) - -runtime.python_library( - name = "models", - srcs = [ - "models.py", - ], - deps = [ - "//caffe2:torch", - "//executorch/exir:lib", - "//executorch/exir:lowered_backend_module", - ], -) - -runtime.python_library( - name = "control_flow_models", - srcs = [ - "control_flow_models.py", - ], - deps = [ - "//caffe2:torch", - ], -) - -runtime.python_library( - name = "dynamic_shape_models", - srcs = [ - "dynamic_shape_models.py", - ], - deps = [ - "//caffe2:torch", - ], -) - -runtime.python_library( - name = "transformer", - srcs = [ - "transformer.py", - ], - deps = [ - "//caffe2:torch", - ], -) - -runtime.python_library( - name = "asr_joiner", - srcs = [ - "asr_joiner.py", - ], - deps = [ - "//caffe2:torch", - ], -) - - -python_unittest( - name = "serde", - srcs = [ - "test_serde.py", - ], - deps = [ - "//caffe2:torch", - "//executorch/exir:lib", - "//executorch/exir/backend:backend_api", - "//executorch/exir/backend/test:backend_with_compiler_demo", - "//executorch/exir/backend/test:op_partitioner_demo", - "//executorch/exir/serde:serialize", - "//executorch/backends/xnnpack/partition:xnnpack_partitioner", - ], -) - -python_unittest( - name = "joint_graph", - srcs = [ - "test_joint_graph.py", - ], - deps = [ - "//caffe2:torch", - "//executorch/exir:lib", - "//executorch/extension/pybindings:portable_lib", - ], -) - -python_unittest( - name = "error", - srcs = [ - "test_error.py", - ], - deps = [ - "//executorch/exir:error", - ], -) - -python_unittest( - name = "tensor", - srcs = [ - "test_tensor.py", - ], - deps = [ - "//caffe2:torch", - "//executorch/exir:schema", - "//executorch/exir:tensor", - ], -) - -python_unittest( - name = "reinplace_pass", - srcs = [ - "test_reinplace_pass.py", - ], - deps = [ - "//caffe2:torch", - "//executorch/exir:lib", - "//executorch/exir/passes:lib", - "//executorch/extension/pybindings:portable_lib", - ], -) - -cpp_library( - name = "test_lib", - srcs = [ - "test_lib.cpp", - ], - supports_python_dlopen = True, - deps = [ - "//caffe2:ATen-cpu", - "//caffe2:torch-cpp-cpu", # @manual - ], -) - -python_unittest( - name = "op_convert", - srcs = [ - "test_op_convert.py", - ], - preload_deps = [ - "//executorch/kernels/portable:custom_ops_generated_lib", - ":test_lib", # @manual - ], - deps = [ - "//caffe2:torch", - "//executorch/exir/operator:convert", - ], -) - -runtime.python_test( - name = "memory_planning", - srcs = [ - "test_memory_planning.py", - ], - preload_deps = [ - "//executorch/kernels/portable:custom_ops_generated_lib", - "//executorch/extension/llm/custom_ops:custom_ops_aot_lib", - ], - # Static listing does not support tests generated with parameterized - supports_static_listing = False, - deps = [ - "fbsource//third-party/pypi/parameterized:parameterized", - "//caffe2:torch", - "//executorch/exir:lib", - "//executorch/exir:memory_planning", - "//executorch/exir:pass_base", - "//executorch/exir:pass_manager", - "//executorch/exir/passes:lib", - "//executorch/exir/passes:sym_shape_eval_pass", - "//executorch/examples/models/llama:custom_kv_cache", - "//executorch/extension/llm/custom_ops:custom_ops_aot_py", - ], -) - -python_unittest( - name = "passes", - srcs = [ - "test_passes.py", - ], - preload_deps = [":test_lib"], - deps = [ - ":control_flow_models", - ":lib", - ":models", - "//caffe2:torch", - "//caffe2/functorch:functorch_src", - "//executorch/exir:graph_module", - "//executorch/exir:lib", - "//executorch/exir:memory", - "//executorch/exir:memory_planning", - "//executorch/exir:pass_base", - "//executorch/exir:schema", - "//executorch/exir:tensor", - "//executorch/exir/dialects:lib", - "//executorch/exir/dialects/edge:lib", - "//executorch/exir/emit:lib", - "//executorch/exir/passes:constant_prop_pass", - "//executorch/exir/passes:cse_pass", - "//executorch/exir/passes:debug_handle_generator_pass", - "//executorch/exir/passes:insert_write_back_for_buffers_pass", - "//executorch/exir/passes:lib", - "//executorch/exir/passes:memory_format_ops_pass", - "//executorch/exir/passes:normalize_view_copy_base_pass", - "//executorch/exir/passes:remove_graph_asserts_pass", - "//executorch/exir/passes:remove_mixed_type_operators", - "//executorch/exir/passes:replace_edge_with_backend_pass", - "//executorch/exir/passes:replace_view_copy_with_view_pass", - "//executorch/exir/passes:scalar_to_tensor_pass", - "//executorch/exir/passes:spec_prop_pass", - "//executorch/exir/passes:sym_to_tensor_pass", - "//executorch/exir/program:program", - "//executorch/extension/pybindings:portable_lib", # @manual - "//executorch/backends/xnnpack/partition:xnnpack_partitioner", - "//executorch/backends/xnnpack/quantizer:xnnpack_quantizer", - "//executorch/backends/xnnpack/quantizer:xnnpack_quantizer_utils", - ], -) - -python_unittest( - name = "pass_infra", - srcs = [ - "test_pass_infra.py", - ], - deps = [ - "//caffe2:torch", - "//executorch/exir:lib", - "//executorch/exir:pass_manager", - "//executorch/exir/passes:lib", - "//executorch/exir/passes:pass_registry", - ], -) - -python_unittest( - name = "common", - srcs = [ - "test_common.py", - ], - deps = [ - "//caffe2:torch", - "//executorch/exir:common", - "//executorch/exir:print_program", - ], -) - -python_unittest( - name = "verification", - srcs = [ - "test_verification.py", - ], - deps = [ - "//caffe2:torch", - "//executorch/exir:lib", - "//executorch/exir:schema", - "//executorch/exir/passes:const_prop_pass", - "//executorch/exir/verification:interpreter", - "//executorch/exir/verification:verifier", - ], -) - -python_unittest( - name = "delegate", - srcs = [ - "test_delegate.py", - ], - deps = [ - ":lib", - ":models", - "//caffe2:torch", - "//executorch/exir:lib", - "//executorch/exir:lowered_backend_module", - "//executorch/exir:schema", - "//executorch/exir/dialects:lib", - ], -) - -python_unittest( - name = "quant_fusion_pass", - srcs = [ - "test_quant_fusion_pass.py", - ], - preload_deps = [ - "//executorch/kernels/quantized:custom_ops_generated_lib", - ], - deps = [ - ":lib", - "//caffe2:torch", - "//executorch/exir:lib", - "//executorch/exir/passes:quant_fusion_pass", - "//pytorch/ao:torchao", - "//executorch/exir/passes:constant_prop_pass", - ], -) - -python_unittest( - name = "quantization", - srcs = [ - "test_quantization.py", - ], - preload_deps = [ - "//executorch/kernels/quantized:custom_ops_generated_lib", - ], - deps = [ - "fbsource//third-party/pypi/expecttest:expecttest", # @manual - "//caffe2:torch", - "//executorch/exir:lib", - "//executorch/exir/passes:quant_fusion_pass", - "//executorch/exir/passes:spec_prop_pass", - "//executorch/backends/xnnpack/quantizer:xnnpack_quantizer", - "//pytorch/vision:torchvision", - ], -) - - -python_unittest( - name = "dynamic_shape_propagation", - srcs = [ - "test_dynamic_shape_propagation.py", - ], - deps = [ - ":models", - "//caffe2:torch", - "//executorch/exir:lib", - "//executorch/exir/passes:lib", - ], -) - -python_unittest( - name = "arg_validator", - srcs = [ - "test_arg_validator.py", - ], - deps = [ - "//caffe2:torch", - "//executorch/exir:lib", - "//executorch/exir/dialects:lib", - "//executorch/exir/dialects/edge:lib", - "//executorch/exir/verification:verifier", - ], -) - -python_unittest( - name = "dim_order_utils", - srcs = [ - "test_dim_order_utils.py", - ], - deps = [ - "//caffe2:torch", - "//executorch/exir:dim_order_utils", - "//executorch/exir:lib", - ], -) - -python_unittest( - name = "test_memory_format_ops_pass_aten", - srcs = [ - "test_memory_format_ops_pass_aten.py", - ], - deps = [ - ":test_memory_format_ops_pass_utils", - "//caffe2:torch", - "//executorch/extension/pybindings:aten_lib", # @manual - "//pytorch/vision:torchvision", # @manual - ], -) - -python_unittest( - name = "test_memory_format_ops_pass", - srcs = [ - "test_memory_format_ops_pass.py", - ], - deps = [ - ":test_memory_format_ops_pass_utils", - "//caffe2:torch", - "//executorch/exir:dim_order_utils", - "//executorch/exir:lib", - "//executorch/exir:pass_base", - "//executorch/exir/dialects:lib", - "//executorch/exir/dialects/edge:lib", - "//executorch/extension/pybindings:portable_lib", # @manual - "//pytorch/vision:torchvision", # @manual - ], -) - -runtime.python_library( - name = "test_memory_format_ops_pass_utils", - srcs = [ - "test_memory_format_ops_pass_utils.py", - ], - deps = [ - "//caffe2:torch", - "//executorch/backends/xnnpack/partition:xnnpack_partitioner", - "//executorch/exir:dim_order_utils", - "//executorch/exir:lib", - "//executorch/exir/capture:config", - ], -) - -python_unittest( - name = "print_program", - srcs = [ - "test_print_program.py", - ], - deps = [ - "//caffe2:torch", - "//executorch/exir:lib", - "//executorch/exir:print_program", - ], -) - -python_unittest( - name = "test_remove_unused_parameters_pass", - srcs = [ - "test_remove_unused_parameters_pass.py", - ], - deps = [ - "//caffe2:torch", - "//executorch/backends/xnnpack:xnnpack_delegate", - "//executorch/exir:lib", - "//executorch/exir:memory", - "//executorch/exir/capture:config", - "//executorch/exir/passes:lib", - "//executorch/runtime:runtime", - ], -) - -python_unittest( - name = "test_remove_view_copy", - srcs = [ - "test_remove_view_copy.py", - ], - deps = [ - "//caffe2:torch", - "//executorch/exir:lib", - "//executorch/exir:memory", - "//executorch/exir/capture:config", - "//executorch/exir/passes:lib", - ], -) - -python_unittest( - name = "test_prune_empty_tensors", - srcs = [ - "test_prune_empty_tensors_pass.py", - ], - deps = [ - "//caffe2:torch", - "//executorch/exir:lib", - "//executorch/exir:memory", - "//executorch/exir/capture:config", - "//executorch/exir/passes:lib", - ], -) - -python_unittest( - name = "warnings", - srcs = [ - "test_warnings.py", - ], - deps = [ - "//executorch/exir:_warnings", - ], -) - -python_unittest( - name = "quantize_io_pass", - srcs = [ - "test_quantize_io_pass.py", - ], - deps = [ - "//caffe2:torch", - "//executorch/exir:lib", - "//executorch/exir/passes:quantize_io_pass", - "//executorch/backends/xnnpack/quantizer:xnnpack_quantizer", - ], -) - -python_unittest( - name = "propagate_device_pass", - srcs = [ - "test_propagate_device_pass.py", - ], - deps = [ - "//caffe2:torch", - "//executorch/exir:lib", - "//executorch/exir:schema", - "//executorch/exir:tensor", - "//executorch/exir/backend:backend_api", - "//executorch/exir/backend:compile_spec_schema", - "//executorch/exir/backend:partitioner", - "//executorch/exir/backend/canonical_partitioners:canonical_partitioner_lib", - "//executorch/exir/backend/test:backend_with_compiler_demo", - "//executorch/exir/backend/test:device_util", - "//executorch/exir/dialects:lib", - "//executorch/exir/passes:propagate_device_pass", - "//executorch/exir/passes:device_copy_ops_registry", - ], -) - -python_unittest( - name = "device_copy_ops", - srcs = [ - "test_device_copy_ops.py", - ], - deps = [ - "//caffe2:torch", - "//executorch/exir/passes:device_copy_ops_registry", - ], -) diff --git a/exir/tests/targets.bzl b/exir/tests/targets.bzl new file mode 100644 index 00000000000..1bfe6634b7f --- /dev/null +++ b/exir/tests/targets.bzl @@ -0,0 +1,521 @@ +load("@fbcode_macros//build_defs:cpp_library.bzl", "cpp_library") +load("@fbsource//xplat/executorch/build:runtime_wrapper.bzl", "runtime") +load("@fbcode_macros//build_defs:python_unittest.bzl", "python_unittest") + +def define_common_targets(is_fbcode = False): + if not is_fbcode: + return + + runtime.python_library( + name = "lib", + srcs = [ + "common.py", + ], + deps = [ + "//caffe2:torch", + "//executorch/exir:schema", + ], + ) + + runtime.python_library( + name = "models", + srcs = [ + "models.py", + ], + deps = [ + "//caffe2:torch", + "//executorch/exir:lib", + "//executorch/exir:lowered_backend_module", + ], + ) + + runtime.python_library( + name = "control_flow_models", + srcs = [ + "control_flow_models.py", + ], + deps = [ + "//caffe2:torch", + ], + ) + + runtime.python_library( + name = "dynamic_shape_models", + srcs = [ + "dynamic_shape_models.py", + ], + deps = [ + "//caffe2:torch", + ], + ) + + runtime.python_library( + name = "transformer", + srcs = [ + "transformer.py", + ], + deps = [ + "//caffe2:torch", + ], + ) + + runtime.python_library( + name = "asr_joiner", + srcs = [ + "asr_joiner.py", + ], + deps = [ + "//caffe2:torch", + ], + ) + + + python_unittest( + name = "serde", + srcs = [ + "test_serde.py", + ], + deps = [ + "//caffe2:torch", + "//executorch/exir:lib", + "//executorch/exir/backend:backend_api", + "//executorch/exir/backend/test:backend_with_compiler_demo", + "//executorch/exir/backend/test:op_partitioner_demo", + "//executorch/exir/serde:serialize", + "//executorch/backends/xnnpack/partition:xnnpack_partitioner", + ], + ) + + python_unittest( + name = "joint_graph", + srcs = [ + "test_joint_graph.py", + ], + deps = [ + "//caffe2:torch", + "//executorch/exir:lib", + "//executorch/extension/pybindings:portable_lib", + ], + ) + + python_unittest( + name = "error", + srcs = [ + "test_error.py", + ], + deps = [ + "//executorch/exir:error", + ], + ) + + python_unittest( + name = "tensor", + srcs = [ + "test_tensor.py", + ], + deps = [ + "//caffe2:torch", + "//executorch/exir:schema", + "//executorch/exir:tensor", + ], + ) + + python_unittest( + name = "reinplace_pass", + srcs = [ + "test_reinplace_pass.py", + ], + deps = [ + "//caffe2:torch", + "//executorch/exir:lib", + "//executorch/exir/passes:lib", + "//executorch/extension/pybindings:portable_lib", + ], + ) + + cpp_library( + name = "test_lib", + srcs = [ + "test_lib.cpp", + ], + supports_python_dlopen = True, + deps = [ + "//caffe2:ATen-cpu", + "//caffe2:torch-cpp-cpu", # @manual + ], + ) + + python_unittest( + name = "op_convert", + srcs = [ + "test_op_convert.py", + ], + preload_deps = [ + "//executorch/kernels/portable:custom_ops_generated_lib", + ":test_lib", # @manual + ], + deps = [ + "//caffe2:torch", + "//executorch/exir/operator:convert", + ], + ) + + runtime.python_test( + name = "memory_planning", + srcs = [ + "test_memory_planning.py", + ], + preload_deps = [ + "//executorch/kernels/portable:custom_ops_generated_lib", + "//executorch/extension/llm/custom_ops:custom_ops_aot_lib", + ], + # Static listing does not support tests generated with parameterized + supports_static_listing = False, + deps = [ + "fbsource//third-party/pypi/parameterized:parameterized", + "//caffe2:torch", + "//executorch/exir:lib", + "//executorch/exir:memory_planning", + "//executorch/exir:pass_base", + "//executorch/exir:pass_manager", + "//executorch/exir/passes:lib", + "//executorch/exir/passes:sym_shape_eval_pass", + "//executorch/examples/models/llama:custom_kv_cache", + "//executorch/extension/llm/custom_ops:custom_ops_aot_py", + ], + ) + + python_unittest( + name = "passes", + srcs = [ + "test_passes.py", + ], + preload_deps = [":test_lib"], + deps = [ + ":control_flow_models", + ":lib", + ":models", + "//caffe2:torch", + "//caffe2/functorch:functorch_src", + "//executorch/exir:graph_module", + "//executorch/exir:lib", + "//executorch/exir:memory", + "//executorch/exir:memory_planning", + "//executorch/exir:pass_base", + "//executorch/exir:schema", + "//executorch/exir:tensor", + "//executorch/exir/dialects:lib", + "//executorch/exir/dialects/edge:lib", + "//executorch/exir/emit:lib", + "//executorch/exir/passes:constant_prop_pass", + "//executorch/exir/passes:cse_pass", + "//executorch/exir/passes:debug_handle_generator_pass", + "//executorch/exir/passes:insert_write_back_for_buffers_pass", + "//executorch/exir/passes:lib", + "//executorch/exir/passes:memory_format_ops_pass", + "//executorch/exir/passes:normalize_view_copy_base_pass", + "//executorch/exir/passes:remove_graph_asserts_pass", + "//executorch/exir/passes:remove_mixed_type_operators", + "//executorch/exir/passes:replace_edge_with_backend_pass", + "//executorch/exir/passes:replace_view_copy_with_view_pass", + "//executorch/exir/passes:scalar_to_tensor_pass", + "//executorch/exir/passes:spec_prop_pass", + "//executorch/exir/passes:sym_to_tensor_pass", + "//executorch/exir/program:program", + "//executorch/extension/pybindings:portable_lib", # @manual + "//executorch/backends/xnnpack/partition:xnnpack_partitioner", + "//executorch/backends/xnnpack/quantizer:xnnpack_quantizer", + "//executorch/backends/xnnpack/quantizer:xnnpack_quantizer_utils", + ], + ) + + python_unittest( + name = "pass_infra", + srcs = [ + "test_pass_infra.py", + ], + deps = [ + "//caffe2:torch", + "//executorch/exir:lib", + "//executorch/exir:pass_manager", + "//executorch/exir/passes:lib", + "//executorch/exir/passes:pass_registry", + ], + ) + + python_unittest( + name = "common", + srcs = [ + "test_common.py", + ], + deps = [ + "//caffe2:torch", + "//executorch/exir:common", + "//executorch/exir:print_program", + ], + ) + + python_unittest( + name = "verification", + srcs = [ + "test_verification.py", + ], + deps = [ + "//caffe2:torch", + "//executorch/exir:lib", + "//executorch/exir:schema", + "//executorch/exir/passes:const_prop_pass", + "//executorch/exir/verification:interpreter", + "//executorch/exir/verification:verifier", + ], + ) + + python_unittest( + name = "delegate", + srcs = [ + "test_delegate.py", + ], + deps = [ + ":lib", + ":models", + "//caffe2:torch", + "//executorch/exir:lib", + "//executorch/exir:lowered_backend_module", + "//executorch/exir:schema", + "//executorch/exir/dialects:lib", + ], + ) + + python_unittest( + name = "quant_fusion_pass", + srcs = [ + "test_quant_fusion_pass.py", + ], + preload_deps = [ + "//executorch/kernels/quantized:custom_ops_generated_lib", + ], + deps = [ + ":lib", + "//caffe2:torch", + "//executorch/exir:lib", + "//executorch/exir/passes:quant_fusion_pass", + "//pytorch/ao:torchao", + "//executorch/exir/passes:constant_prop_pass", + ], + ) + + python_unittest( + name = "quantization", + srcs = [ + "test_quantization.py", + ], + preload_deps = [ + "//executorch/kernels/quantized:custom_ops_generated_lib", + ], + deps = [ + "fbsource//third-party/pypi/expecttest:expecttest", # @manual + "//caffe2:torch", + "//executorch/exir:lib", + "//executorch/exir/passes:quant_fusion_pass", + "//executorch/exir/passes:spec_prop_pass", + "//executorch/backends/xnnpack/quantizer:xnnpack_quantizer", + "//pytorch/vision:torchvision", + ], + ) + + + python_unittest( + name = "dynamic_shape_propagation", + srcs = [ + "test_dynamic_shape_propagation.py", + ], + deps = [ + ":models", + "//caffe2:torch", + "//executorch/exir:lib", + "//executorch/exir/passes:lib", + ], + ) + + python_unittest( + name = "arg_validator", + srcs = [ + "test_arg_validator.py", + ], + deps = [ + "//caffe2:torch", + "//executorch/exir:lib", + "//executorch/exir/dialects:lib", + "//executorch/exir/dialects/edge:lib", + "//executorch/exir/verification:verifier", + ], + ) + + python_unittest( + name = "dim_order_utils", + srcs = [ + "test_dim_order_utils.py", + ], + deps = [ + "//caffe2:torch", + "//executorch/exir:dim_order_utils", + "//executorch/exir:lib", + ], + ) + + python_unittest( + name = "test_memory_format_ops_pass_aten", + srcs = [ + "test_memory_format_ops_pass_aten.py", + ], + deps = [ + ":test_memory_format_ops_pass_utils", + "//caffe2:torch", + "//executorch/extension/pybindings:aten_lib", # @manual + "//pytorch/vision:torchvision", # @manual + ], + ) + + python_unittest( + name = "test_memory_format_ops_pass", + srcs = [ + "test_memory_format_ops_pass.py", + ], + deps = [ + ":test_memory_format_ops_pass_utils", + "//caffe2:torch", + "//executorch/exir:dim_order_utils", + "//executorch/exir:lib", + "//executorch/exir:pass_base", + "//executorch/exir/dialects:lib", + "//executorch/exir/dialects/edge:lib", + "//executorch/extension/pybindings:portable_lib", # @manual + "//pytorch/vision:torchvision", # @manual + ], + ) + + runtime.python_library( + name = "test_memory_format_ops_pass_utils", + srcs = [ + "test_memory_format_ops_pass_utils.py", + ], + deps = [ + "//caffe2:torch", + "//executorch/backends/xnnpack/partition:xnnpack_partitioner", + "//executorch/exir:dim_order_utils", + "//executorch/exir:lib", + "//executorch/exir/capture:config", + ], + ) + + python_unittest( + name = "print_program", + srcs = [ + "test_print_program.py", + ], + deps = [ + "//caffe2:torch", + "//executorch/exir:lib", + "//executorch/exir:print_program", + ], + ) + + python_unittest( + name = "test_remove_unused_parameters_pass", + srcs = [ + "test_remove_unused_parameters_pass.py", + ], + deps = [ + "//caffe2:torch", + "//executorch/backends/xnnpack:xnnpack_delegate", + "//executorch/exir:lib", + "//executorch/exir:memory", + "//executorch/exir/capture:config", + "//executorch/exir/passes:lib", + "//executorch/runtime:runtime", + ], + ) + + python_unittest( + name = "test_remove_view_copy", + srcs = [ + "test_remove_view_copy.py", + ], + deps = [ + "//caffe2:torch", + "//executorch/exir:lib", + "//executorch/exir:memory", + "//executorch/exir/capture:config", + "//executorch/exir/passes:lib", + ], + ) + + python_unittest( + name = "test_prune_empty_tensors", + srcs = [ + "test_prune_empty_tensors_pass.py", + ], + deps = [ + "//caffe2:torch", + "//executorch/exir:lib", + "//executorch/exir:memory", + "//executorch/exir/capture:config", + "//executorch/exir/passes:lib", + ], + ) + + python_unittest( + name = "warnings", + srcs = [ + "test_warnings.py", + ], + deps = [ + "//executorch/exir:_warnings", + ], + ) + + python_unittest( + name = "quantize_io_pass", + srcs = [ + "test_quantize_io_pass.py", + ], + deps = [ + "//caffe2:torch", + "//executorch/exir:lib", + "//executorch/exir/passes:quantize_io_pass", + "//executorch/backends/xnnpack/quantizer:xnnpack_quantizer", + ], + ) + + python_unittest( + name = "propagate_device_pass", + srcs = [ + "test_propagate_device_pass.py", + ], + deps = [ + "//caffe2:torch", + "//executorch/exir:lib", + "//executorch/exir:schema", + "//executorch/exir:tensor", + "//executorch/exir/backend:backend_api", + "//executorch/exir/backend:compile_spec_schema", + "//executorch/exir/backend:partitioner", + "//executorch/exir/backend/canonical_partitioners:canonical_partitioner_lib", + "//executorch/exir/backend/test:backend_with_compiler_demo", + "//executorch/exir/backend/test:device_util", + "//executorch/exir/dialects:lib", + "//executorch/exir/passes:propagate_device_pass", + "//executorch/exir/passes:device_copy_ops_registry", + ], + ) + + python_unittest( + name = "device_copy_ops", + srcs = [ + "test_device_copy_ops.py", + ], + deps = [ + "//caffe2:torch", + "//executorch/exir/passes:device_copy_ops_registry", + ], + ) diff --git a/test/end2end/BUCK b/test/end2end/BUCK index 28fbf0a0b35..f559a6f1cfe 100644 --- a/test/end2end/BUCK +++ b/test/end2end/BUCK @@ -1,5 +1,9 @@ -# @noautodeps -# add this empty BUCK file to unblock landing. Without this, we get land error like: -# "No build file at xplat/executorch/exir/BUCK when resolving target fbsource//xplat/executorch/exir:." +# Any targets that should be shared between fbcode and xplat must be defined in +# targets.bzl. + +load("@fbsource//tools/build_defs:fbsource_utils.bzl", "is_fbcode") +load(":targets.bzl", "define_common_targets") oncall("executorch") + +define_common_targets(is_fbcode = is_fbcode()) diff --git a/test/end2end/TARGETS b/test/end2end/TARGETS deleted file mode 100644 index e8c23edc500..00000000000 --- a/test/end2end/TARGETS +++ /dev/null @@ -1,95 +0,0 @@ -# @noautodeps - -load("@fbsource//xplat/executorch/build:runtime_wrapper.bzl", "runtime") -load("@fbcode_macros//build_defs:python_unittest.bzl", "python_unittest") - -oncall("executorch") - -runtime.python_library( - name = "exported_module", - srcs = [ - "exported_module.py", - ], - visibility = [ - "//executorch/...", - ], - deps = [ - "//caffe2:torch", - "//executorch/exir:dynamic_shape", - "//executorch/exir:lib", - "//executorch/exir:pass_manager", - "//executorch/exir/passes:lib", - ], -) - -runtime.python_library( - name = "register_scratch_meta_fns", - srcs = [ - "register_scratch_meta_fns.py", - ], - deps = [ - "//executorch/exir/operator:manip", - ], -) - -python_unittest( - name = "end2end_aten", - srcs = [ - "test_end2end.py", - ], - preload_deps = ["//executorch/kernels/portable:custom_ops_generated_lib"], - deps = [ - ":exported_module", - ":register_scratch_meta_fns", - "//caffe2:torch", - "//executorch/devtools:lib", - "//executorch/devtools/bundled_program:config", - "//executorch/devtools/bundled_program/serialize:lib", - "//executorch/exir:dynamic_shape", - "//executorch/exir:lib", - "//executorch/exir:memory", - "//executorch/exir:pass_manager", - "//executorch/exir:print_program", - "//executorch/exir:tensor", - "//executorch/exir/_serialize:lib", - "//executorch/exir/emit:lib", - "//executorch/exir/passes:lib", - "//executorch/exir/tests:control_flow_models", - "//executorch/exir/tests:dynamic_shape_models", - "//executorch/exir/tests:models", - "//executorch/exir/tests:transformer", - "//executorch/extension/pybindings:aten_lib", - "//executorch/extension/pytree:pybindings", - ], -) - -python_unittest( - name = "end2end", - srcs = [ - "test_end2end.py", - ], - preload_deps = ["//executorch/kernels/portable:custom_ops_generated_lib"], - deps = [ - ":exported_module", - ":register_scratch_meta_fns", - "//caffe2:torch", - "//executorch/devtools:lib", - "//executorch/devtools/bundled_program:config", - "//executorch/devtools/bundled_program/serialize:lib", - "//executorch/exir:dynamic_shape", - "//executorch/exir:lib", - "//executorch/exir:memory", - "//executorch/exir:pass_manager", - "//executorch/exir:print_program", - "//executorch/exir:tensor", - "//executorch/exir/_serialize:lib", - "//executorch/exir/emit:lib", - "//executorch/exir/passes:lib", - "//executorch/exir/tests:control_flow_models", - "//executorch/exir/tests:dynamic_shape_models", - "//executorch/exir/tests:models", - "//executorch/exir/tests:transformer", - "//executorch/extension/pybindings:portable_lib", - "//executorch/extension/pytree:pybindings", - ], -) diff --git a/test/end2end/targets.bzl b/test/end2end/targets.bzl new file mode 100644 index 00000000000..a2b82f180bd --- /dev/null +++ b/test/end2end/targets.bzl @@ -0,0 +1,99 @@ +load("@fbsource//xplat/executorch/build:runtime_wrapper.bzl", "runtime") +load("@fbcode_macros//build_defs:python_unittest.bzl", "python_unittest") + +def define_common_targets(is_fbcode = False): + if not is_fbcode: + return + + # @noautodeps + + + + runtime.python_library( + name = "exported_module", + srcs = [ + "exported_module.py", + ], + visibility = [ + "//executorch/...", + ], + deps = [ + "//caffe2:torch", + "//executorch/exir:dynamic_shape", + "//executorch/exir:lib", + "//executorch/exir:pass_manager", + "//executorch/exir/passes:lib", + ], + ) + + runtime.python_library( + name = "register_scratch_meta_fns", + srcs = [ + "register_scratch_meta_fns.py", + ], + deps = [ + "//executorch/exir/operator:manip", + ], + ) + + python_unittest( + name = "end2end_aten", + srcs = [ + "test_end2end.py", + ], + preload_deps = ["//executorch/kernels/portable:custom_ops_generated_lib"], + deps = [ + ":exported_module", + ":register_scratch_meta_fns", + "//caffe2:torch", + "//executorch/devtools:lib", + "//executorch/devtools/bundled_program:config", + "//executorch/devtools/bundled_program/serialize:lib", + "//executorch/exir:dynamic_shape", + "//executorch/exir:lib", + "//executorch/exir:memory", + "//executorch/exir:pass_manager", + "//executorch/exir:print_program", + "//executorch/exir:tensor", + "//executorch/exir/_serialize:lib", + "//executorch/exir/emit:lib", + "//executorch/exir/passes:lib", + "//executorch/exir/tests:control_flow_models", + "//executorch/exir/tests:dynamic_shape_models", + "//executorch/exir/tests:models", + "//executorch/exir/tests:transformer", + "//executorch/extension/pybindings:aten_lib", + "//executorch/extension/pytree:pybindings", + ], + ) + + python_unittest( + name = "end2end", + srcs = [ + "test_end2end.py", + ], + preload_deps = ["//executorch/kernels/portable:custom_ops_generated_lib"], + deps = [ + ":exported_module", + ":register_scratch_meta_fns", + "//caffe2:torch", + "//executorch/devtools:lib", + "//executorch/devtools/bundled_program:config", + "//executorch/devtools/bundled_program/serialize:lib", + "//executorch/exir:dynamic_shape", + "//executorch/exir:lib", + "//executorch/exir:memory", + "//executorch/exir:pass_manager", + "//executorch/exir:print_program", + "//executorch/exir:tensor", + "//executorch/exir/_serialize:lib", + "//executorch/exir/emit:lib", + "//executorch/exir/passes:lib", + "//executorch/exir/tests:control_flow_models", + "//executorch/exir/tests:dynamic_shape_models", + "//executorch/exir/tests:models", + "//executorch/exir/tests:transformer", + "//executorch/extension/pybindings:portable_lib", + "//executorch/extension/pytree:pybindings", + ], + )