diff --git a/backends/aoti/slim/factory/test/BUCK b/backends/aoti/slim/factory/test/BUCK new file mode 100644 index 00000000000..f559a6f1cfe --- /dev/null +++ b/backends/aoti/slim/factory/test/BUCK @@ -0,0 +1,9 @@ +# 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/backends/aoti/slim/factory/test/TARGETS b/backends/aoti/slim/factory/test/TARGETS deleted file mode 100644 index 77871de4469..00000000000 --- a/backends/aoti/slim/factory/test/TARGETS +++ /dev/null @@ -1,3 +0,0 @@ -load("targets.bzl", "define_common_targets") - -define_common_targets() diff --git a/backends/aoti/slim/factory/test/targets.bzl b/backends/aoti/slim/factory/test/targets.bzl index 7c0e218d233..2255e76a894 100644 --- a/backends/aoti/slim/factory/test/targets.bzl +++ b/backends/aoti/slim/factory/test/targets.bzl @@ -5,8 +5,15 @@ def get_backend_mode(): """Get the supported backend mode of slimtensor.""" return ["cuda", "cpu"] -def define_common_targets(): - """Define test targets for SlimTensor factory module.""" +def define_common_targets(is_fbcode = False): + """Define test targets for SlimTensor factory module. + + Uses fbcode-only kwargs (keep_gpu_sections, re_test_utils.remote_execution) + so we early-return outside fbcode to preserve pre-migration behavior + (this dir was originally TARGETS-only, never evaluated by xplat). + """ + if not is_fbcode: + return # GPU empty test with CUDA support for backend_mode in get_backend_mode(): diff --git a/backends/aoti/tests/BUCK b/backends/aoti/tests/BUCK new file mode 100644 index 00000000000..f559a6f1cfe --- /dev/null +++ b/backends/aoti/tests/BUCK @@ -0,0 +1,9 @@ +# 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/backends/aoti/tests/TARGETS b/backends/aoti/tests/TARGETS deleted file mode 100644 index f41c1bfb517..00000000000 --- a/backends/aoti/tests/TARGETS +++ /dev/null @@ -1,59 +0,0 @@ -load("@fbcode_macros//build_defs:cpp_unittest.bzl", "cpp_unittest") -load("@fbcode_macros//build_defs/lib:re_test_utils.bzl", "re_test_utils") - -oncall("executorch") - -cpp_unittest( - name = "test_resolve_blob_keys", - srcs = [ - "test_resolve_blob_keys.cpp", - ], - deps = [ - "//executorch/backends/aoti:delegate_handle", - "//executorch/runtime/core:core", - "//executorch/runtime/core:evalue", - ], -) - -cpp_unittest( - name = "test_common_shims", - srcs = [ - "test_common_shims.cpp", - ], - headers = [ - "utils.h", - ], - deps = [ - "//executorch/backends/aoti:common_shims", - "//executorch/extension/tensor:tensor", - "//executorch/runtime/core:core", - "//executorch/runtime/platform:platform", - "//executorch/runtime/core/exec_aten/testing_util:tensor_util", - "//executorch/runtime/core/exec_aten:lib", - "//executorch/extension/tensor:tensor", - ], -) - -cpp_unittest( - name = "test_common_shims_slim", - srcs = [ - "test_common_shims_slim.cpp", - ], - deps = [ - "//executorch/backends/aoti:common_shims_slim", - "//executorch/backends/aoti/slim/core:slimtensor", - "//executorch/backends/aoti/slim/factory:empty", - "//executorch/runtime/core:core", - "//executorch/runtime/platform:platform", - ], - external_deps = [ - ("cuda", None, "cuda-lazy"), - ], - preprocessor_flags = [ - "-DCUDA_AVAILABLE=1", - ], - keep_gpu_sections = True, - remote_execution = re_test_utils.remote_execution( - platform = "gpu-remote-execution", - ), -) diff --git a/backends/aoti/tests/targets.bzl b/backends/aoti/tests/targets.bzl new file mode 100644 index 00000000000..59bec93cfca --- /dev/null +++ b/backends/aoti/tests/targets.bzl @@ -0,0 +1,61 @@ +load("@fbcode_macros//build_defs:cpp_unittest.bzl", "cpp_unittest") +load("@fbcode_macros//build_defs/lib:re_test_utils.bzl", "re_test_utils") + +def define_common_targets(is_fbcode = False): + if not is_fbcode: + return + + cpp_unittest( + name = "test_resolve_blob_keys", + srcs = [ + "test_resolve_blob_keys.cpp", + ], + deps = [ + "//executorch/backends/aoti:delegate_handle", + "//executorch/runtime/core:core", + "//executorch/runtime/core:evalue", + ], + ) + + cpp_unittest( + name = "test_common_shims", + srcs = [ + "test_common_shims.cpp", + ], + headers = [ + "utils.h", + ], + deps = [ + "//executorch/backends/aoti:common_shims", + "//executorch/extension/tensor:tensor", + "//executorch/runtime/core:core", + "//executorch/runtime/platform:platform", + "//executorch/runtime/core/exec_aten/testing_util:tensor_util", + "//executorch/runtime/core/exec_aten:lib", + "//executorch/extension/tensor:tensor", + ], + ) + + cpp_unittest( + name = "test_common_shims_slim", + srcs = [ + "test_common_shims_slim.cpp", + ], + deps = [ + "//executorch/backends/aoti:common_shims_slim", + "//executorch/backends/aoti/slim/core:slimtensor", + "//executorch/backends/aoti/slim/factory:empty", + "//executorch/runtime/core:core", + "//executorch/runtime/platform:platform", + ], + external_deps = [ + ("cuda", None, "cuda-lazy"), + ], + preprocessor_flags = [ + "-DCUDA_AVAILABLE=1", + ], + keep_gpu_sections = True, + remote_execution = re_test_utils.remote_execution( + platform = "gpu-remote-execution", + ), + ) diff --git a/backends/apple/coreml/BUCK b/backends/apple/coreml/BUCK index 688ca64b990..f559a6f1cfe 100644 --- a/backends/apple/coreml/BUCK +++ b/backends/apple/coreml/BUCK @@ -1,184 +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:default_platform_defs.bzl", - "APPLE", -) -load("@fbsource//xplat/executorch/build:runtime_wrapper.bzl", "runtime") -load("@fbsource//xplat/executorch/runtime/core:targets.bzl", "build_sdk") +load("@fbsource//tools/build_defs:fbsource_utils.bzl", "is_fbcode") +load(":targets.bzl", "define_common_targets") oncall("executorch") -runtime.cxx_library( - name = "coreml", - srcs = [ - "runtime/delegate/ETCoreMLAsset.mm", - "runtime/delegate/ETCoreMLAssetManager.mm", - "runtime/delegate/ETCoreMLDefaultModelExecutor.mm", - "runtime/delegate/ETCoreMLLogging.mm", - "runtime/delegate/ETCoreMLModel.mm", - "runtime/delegate/ETCoreMLModelCache.mm", - "runtime/delegate/ETCoreMLModelCompiler.mm", - "runtime/delegate/ETCoreMLModelLoader.mm", - "runtime/delegate/ETCoreMLModelManager.mm", - "runtime/delegate/ETCoreMLStrings.mm", - "runtime/delegate/MLModel_Prewarm.mm", - "runtime/delegate/MLMultiArray_Copy.mm", - "runtime/delegate/asset.mm", - "runtime/delegate/backend_delegate.mm", - "runtime/delegate/coreml_backend_delegate.mm", - "runtime/delegate/multiarray.mm", - "runtime/delegate/executorch_operations.mm", - "runtime/delegate/serde_json.mm", - "runtime/inmemoryfs/inmemory_filesystem.cpp", - "runtime/inmemoryfs/inmemory_filesystem_utils.mm", - "runtime/inmemoryfs/memory_buffer.cpp", - "runtime/inmemoryfs/memory_stream.cpp", - "runtime/inmemoryfs/reversed_memory_stream.cpp", - "runtime/kvstore/database.cpp", - "runtime/kvstore/json_key_value_store.cpp", - "runtime/kvstore/key_value_store.cpp", - "runtime/kvstore/sqlite_error.cpp", - "runtime/kvstore/statement.cpp", - "runtime/util/json_util.cpp", - "runtime/util/objc_json_serde.mm", - ] + (glob([ - "runtime/sdk/*.mm", - ]) if build_sdk() else []), - headers = glob([ - "runtime/include/coreml_backend/delegate.h", - "runtime/kvstore/*.hpp", - "runtime/inmemoryfs/*.hpp", - "runtime/delegate/*.h", - "runtime/delegate/*.hpp", - "runtime/util/*.h", - "runtime/util/*.hpp", - ]) + (glob([ - "runtime/sdk/*.h", - ]) if build_sdk() else []), - compiler_flags = [ - "-fobjc-arc", - "-fno-exceptions", - "-fno-rtti", - "-Wno-null-character", - "-Wno-receiver-expr", - "-Wno-error", - ], - define_static_target = True, - header_namespace = "backends/apple/coreml", - exported_headers = ["runtime/delegate/executorch_operations.h", "runtime/include/coreml_backend/delegate.h"], - fbobjc_ios_target_sdk_version = "13.0", - fbobjc_frameworks = [ - "Accelerate", - "CoreML", - "Foundation", - ], - include_directories = [ - "runtime/include", - "runtime/kvstore", - "runtime/inmemoryfs", - "runtime/delegate", - "runtime/util", - ] + ([ - "runtime/sdk", - ] if build_sdk() else []), - fbobjc_libraries = [ - "libsqlite3", - ], - link_whole = True, - platforms = [APPLE], - visibility = ["PUBLIC"], - deps = [ - "//executorch/runtime/backend:backend_options", - "//executorch/runtime/backend:interface", - "//executorch/runtime/core:core", - "//executorch/runtime/kernel:kernel_includes", - ] + ([ - ":proto", - ] if build_sdk() else []), -) - -_PROTOS = [ - "ArrayFeatureExtractor", - "AudioFeaturePrint", - "BayesianProbitRegressor", - "CategoricalMapping", - "ClassConfidenceThresholding", - "CustomModel", - "DataStructures", - "DictVectorizer", - "FeatureTypes", - "FeatureVectorizer", - "Gazetteer", - "GLMClassifier", - "GLMRegressor", - "Identity", - "Imputer", - "ItemSimilarityRecommender", - "LinkedModel", - "MIL", - "Model", - "NearestNeighbors", - "NeuralNetwork", - "NonMaximumSuppression", - "Normalizer", - "OneHotEncoder", - "Parameters", - "Scaler", - "SoundAnalysisPreprocessing", - "SVM", - "TextClassifier", - "TreeEnsemble", - "VisionFeaturePrint", - "WordEmbedding", - "WordTagger", -] - -runtime.cxx_test( - name = "coreml_backend_options_test", - srcs = [ - "runtime/test/coreml_backend_options_test.cpp", - ], - deps = [ - ":coreml_backend_options", - "//executorch/runtime/backend:backend_options", - "//executorch/runtime/backend:backend_options_map", - "//executorch/runtime/core:core", - ], -) - -# Header-only library for CoreML backend options -runtime.cxx_library( - name = "coreml_backend_options", - exported_headers = [ - "runtime/include/coreml_backend/coreml_backend_options.h", - ], - header_namespace = "executorch/backends/apple/coreml", - visibility = ["PUBLIC"], - exported_deps = [ - "//executorch/runtime/backend:backend_options", - ], -) - -runtime.cxx_library( - name = "proto", - srcs = [ - "fbsource//third-party/pypi/coremltools:exported-cpp-protoc[{}.pb.cc]".format(name) - for name in _PROTOS - ], - exported_headers = { - "format/{}.pb.h".format(name): "fbsource//third-party/pypi/coremltools:exported-cpp-protoc[{}.pb.h]".format(name) - for name in _PROTOS - }, - header_namespace = "", - compiler_flags = [ - "-Wno-global-constructors", - ], - public_include_directories = [ - "", - ], - deps = [ - "//third-party/protobuf:fb-protobuf-lite", - ], -) +define_common_targets(is_fbcode = is_fbcode()) diff --git a/backends/apple/coreml/TARGETS b/backends/apple/coreml/TARGETS deleted file mode 100644 index 7574f90b742..00000000000 --- a/backends/apple/coreml/TARGETS +++ /dev/null @@ -1,161 +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/build:runtime_wrapper.bzl", "runtime") - -oncall("executorch") - -# TODO: this is a placeholder to support internal fbcode build. We should add the coreml backend target properly. -runtime.python_library( - name = "coreml", - visibility = ["PUBLIC"], -) - -runtime.python_library( - name = "backend", - srcs = glob([ - "compiler/*.py", - "logging.py", - ]), - visibility = ["PUBLIC"], - deps = [ - "fbsource//third-party/pypi/coremltools:coremltools", - ":executorchcoreml", - "//executorch/exir/backend:backend_details", - "//executorch/exir/backend:compile_spec_schema", - ], -) - -runtime.python_library( - name = "partitioner", - srcs = glob([ - "partition/*.py", - "logging.py", - ]), - visibility = ["PUBLIC"], - deps = [ - "fbsource//third-party/pypi/coremltools:coremltools", - ":backend", - "//caffe2:torch", - "//executorch/exir:lib", - "//executorch/exir/backend:compile_spec_schema", - "//executorch/exir/backend:partitioner", - "//executorch/exir/backend:utils", - ], -) - -runtime.python_library( - name = "quantizer", - srcs = glob([ - "quantizer/*.py", - ]), - visibility = ["PUBLIC"], -) - -runtime.python_library( - name = "coreml_recipes", - srcs = [ - "recipes/__init__.py", - "recipes/coreml_recipe_provider.py" - ], - visibility = ["PUBLIC"], - deps = [ - "fbsource//third-party/pypi/coremltools:coremltools", - ":coreml_recipe_types", - ":backend", - ":partitioner", - ":quantizer", - "//caffe2:torch", - "//executorch/exir:lib", - "//executorch/exir/backend:compile_spec_schema", - "//executorch/exir/backend:partitioner", - "//executorch/exir/backend:utils", - "//executorch/export:lib", - "//executorch/runtime:runtime", # @manual - ], -) - -runtime.python_library( - name = "coreml_recipe_types", - srcs = [ - "recipes/coreml_recipe_types.py", - ], - visibility = ["PUBLIC"], - deps = [ - "//executorch/export:recipe", - ], -) - -runtime.cxx_python_extension( - name = "executorchcoreml", - srcs = [ - "runtime/inmemoryfs/inmemory_filesystem.cpp", - "runtime/inmemoryfs/inmemory_filesystem_py.cpp", - "runtime/inmemoryfs/inmemory_filesystem_utils.cpp", - "runtime/inmemoryfs/memory_buffer.cpp", - "runtime/inmemoryfs/memory_stream.cpp", - "runtime/inmemoryfs/reversed_memory_stream.cpp", - "runtime/util/json_util.cpp", - ], - headers = glob([ - "runtime/inmemoryfs/**/*.hpp", - ]), - base_module = "executorch.backends.apple.coreml", - compiler_flags = [ - "-std=c++17", - ], - preprocessor_flags = [ - "-Iexecutorch/backends/apple/coreml/runtime/util", - ], - types = [ - "executorchcoreml.pyi", - ], - visibility = ["PUBLIC"], - deps = [ - "fbsource//third-party/nlohmann-json:nlohmann-json", - "fbsource//third-party/pybind11:pybind11", - ], -) - -runtime.python_test( - name = "test", - srcs = glob([ - "test/*.py", - ]), - deps = [ - "fbsource//third-party/pypi/coremltools:coremltools", - "fbsource//third-party/pypi/pytest:pytest", - ":partitioner", - ":quantizer", - ":coreml_recipes", - "//caffe2:torch", - "//pytorch/vision:torchvision", - "fbsource//third-party/pypi/scikit-learn:scikit-learn", - ], -) - -# Header-only library for CoreML backend options -runtime.cxx_library( - name = "coreml_backend_options", - exported_headers = [ - "runtime/include/coreml_backend/coreml_backend_options.h", - ], - header_namespace = "executorch/backends/apple/coreml", - visibility = ["PUBLIC"], - exported_deps = [ - "//executorch/runtime/backend:backend_options", - ], -) - -runtime.cxx_test( - name = "coreml_backend_options_test", - srcs = [ - "runtime/test/coreml_backend_options_test.cpp", - ], - deps = [ - ":coreml_backend_options", - "//executorch/runtime/backend:backend_options", - "//executorch/runtime/backend:backend_options_map", - "//executorch/runtime/core:core", - ], -) diff --git a/backends/apple/coreml/targets.bzl b/backends/apple/coreml/targets.bzl new file mode 100644 index 00000000000..311fce37fd5 --- /dev/null +++ b/backends/apple/coreml/targets.bzl @@ -0,0 +1,346 @@ +load("@fbsource//tools/build_defs:default_platform_defs.bzl", "APPLE") +load("@fbsource//xplat/executorch/build:runtime_wrapper.bzl", "runtime") +load("@fbsource//xplat/executorch/runtime/core:targets.bzl", "build_sdk") + +def define_common_targets(is_fbcode = False): + """Combined fbcode + xplat target definitions for backends/apple/coreml. + + Pre-migration this dir had a TARGETS file (fbcode-only Python rules) + and a BUCK file (xplat-only Apple platform cxx_library rules). The + branches below preserve that exact split. + """ + if is_fbcode: + # Any targets that should be shared between fbcode and xplat must be defined in + # targets.bzl. This file can contain fbcode-only targets. + + + + # TODO: this is a placeholder to support internal fbcode build. We should add the coreml backend target properly. + runtime.python_library( + name = "coreml", + visibility = ["PUBLIC"], + ) + + runtime.python_library( + name = "backend", + srcs = glob([ + "compiler/*.py", + "logging.py", + ]), + visibility = ["PUBLIC"], + deps = [ + "fbsource//third-party/pypi/coremltools:coremltools", + ":executorchcoreml", + "//executorch/exir/backend:backend_details", + "//executorch/exir/backend:compile_spec_schema", + ], + ) + + runtime.python_library( + name = "partitioner", + srcs = glob([ + "partition/*.py", + "logging.py", + ]), + visibility = ["PUBLIC"], + deps = [ + "fbsource//third-party/pypi/coremltools:coremltools", + ":backend", + "//caffe2:torch", + "//executorch/exir:lib", + "//executorch/exir/backend:compile_spec_schema", + "//executorch/exir/backend:partitioner", + "//executorch/exir/backend:utils", + ], + ) + + runtime.python_library( + name = "quantizer", + srcs = glob([ + "quantizer/*.py", + ]), + visibility = ["PUBLIC"], + ) + + runtime.python_library( + name = "coreml_recipes", + srcs = [ + "recipes/__init__.py", + "recipes/coreml_recipe_provider.py" + ], + visibility = ["PUBLIC"], + deps = [ + "fbsource//third-party/pypi/coremltools:coremltools", + ":coreml_recipe_types", + ":backend", + ":partitioner", + ":quantizer", + "//caffe2:torch", + "//executorch/exir:lib", + "//executorch/exir/backend:compile_spec_schema", + "//executorch/exir/backend:partitioner", + "//executorch/exir/backend:utils", + "//executorch/export:lib", + "//executorch/runtime:runtime", # @manual + ], + ) + + runtime.python_library( + name = "coreml_recipe_types", + srcs = [ + "recipes/coreml_recipe_types.py", + ], + visibility = ["PUBLIC"], + deps = [ + "//executorch/export:recipe", + ], + ) + + runtime.cxx_python_extension( + name = "executorchcoreml", + srcs = [ + "runtime/inmemoryfs/inmemory_filesystem.cpp", + "runtime/inmemoryfs/inmemory_filesystem_py.cpp", + "runtime/inmemoryfs/inmemory_filesystem_utils.cpp", + "runtime/inmemoryfs/memory_buffer.cpp", + "runtime/inmemoryfs/memory_stream.cpp", + "runtime/inmemoryfs/reversed_memory_stream.cpp", + "runtime/util/json_util.cpp", + ], + headers = glob([ + "runtime/inmemoryfs/**/*.hpp", + ]), + base_module = "executorch.backends.apple.coreml", + compiler_flags = [ + "-std=c++17", + ], + preprocessor_flags = [ + "-Iexecutorch/backends/apple/coreml/runtime/util", + ], + types = [ + "executorchcoreml.pyi", + ], + visibility = ["PUBLIC"], + deps = [ + "fbsource//third-party/nlohmann-json:nlohmann-json", + "fbsource//third-party/pybind11:pybind11", + ], + ) + + runtime.python_test( + name = "test", + srcs = glob([ + "test/*.py", + ]), + deps = [ + "fbsource//third-party/pypi/coremltools:coremltools", + "fbsource//third-party/pypi/pytest:pytest", + ":partitioner", + ":quantizer", + ":coreml_recipes", + "//caffe2:torch", + "//pytorch/vision:torchvision", + "fbsource//third-party/pypi/scikit-learn:scikit-learn", + ], + ) + + # Header-only library for CoreML backend options + runtime.cxx_library( + name = "coreml_backend_options", + exported_headers = [ + "runtime/include/coreml_backend/coreml_backend_options.h", + ], + header_namespace = "executorch/backends/apple/coreml", + visibility = ["PUBLIC"], + exported_deps = [ + "//executorch/runtime/backend:backend_options", + ], + ) + + runtime.cxx_test( + name = "coreml_backend_options_test", + srcs = [ + "runtime/test/coreml_backend_options_test.cpp", + ], + deps = [ + ":coreml_backend_options", + "//executorch/runtime/backend:backend_options", + "//executorch/runtime/backend:backend_options_map", + "//executorch/runtime/core:core", + ], + ) + else: + # xplat-only Apple platform cxx_library targets + + runtime.cxx_library( + name = "coreml", + srcs = [ + "runtime/delegate/ETCoreMLAsset.mm", + "runtime/delegate/ETCoreMLAssetManager.mm", + "runtime/delegate/ETCoreMLDefaultModelExecutor.mm", + "runtime/delegate/ETCoreMLLogging.mm", + "runtime/delegate/ETCoreMLModel.mm", + "runtime/delegate/ETCoreMLModelCache.mm", + "runtime/delegate/ETCoreMLModelCompiler.mm", + "runtime/delegate/ETCoreMLModelLoader.mm", + "runtime/delegate/ETCoreMLModelManager.mm", + "runtime/delegate/ETCoreMLStrings.mm", + "runtime/delegate/MLModel_Prewarm.mm", + "runtime/delegate/MLMultiArray_Copy.mm", + "runtime/delegate/asset.mm", + "runtime/delegate/backend_delegate.mm", + "runtime/delegate/coreml_backend_delegate.mm", + "runtime/delegate/multiarray.mm", + "runtime/delegate/executorch_operations.mm", + "runtime/delegate/serde_json.mm", + "runtime/inmemoryfs/inmemory_filesystem.cpp", + "runtime/inmemoryfs/inmemory_filesystem_utils.mm", + "runtime/inmemoryfs/memory_buffer.cpp", + "runtime/inmemoryfs/memory_stream.cpp", + "runtime/inmemoryfs/reversed_memory_stream.cpp", + "runtime/kvstore/database.cpp", + "runtime/kvstore/json_key_value_store.cpp", + "runtime/kvstore/key_value_store.cpp", + "runtime/kvstore/sqlite_error.cpp", + "runtime/kvstore/statement.cpp", + "runtime/util/json_util.cpp", + "runtime/util/objc_json_serde.mm", + ] + (glob([ + "runtime/sdk/*.mm", + ]) if build_sdk() else []), + headers = glob([ + "runtime/include/coreml_backend/delegate.h", + "runtime/kvstore/*.hpp", + "runtime/inmemoryfs/*.hpp", + "runtime/delegate/*.h", + "runtime/delegate/*.hpp", + "runtime/util/*.h", + "runtime/util/*.hpp", + ]) + (glob([ + "runtime/sdk/*.h", + ]) if build_sdk() else []), + compiler_flags = [ + "-fobjc-arc", + "-fno-exceptions", + "-fno-rtti", + "-Wno-null-character", + "-Wno-receiver-expr", + "-Wno-error", + ], + define_static_target = True, + header_namespace = "backends/apple/coreml", + exported_headers = ["runtime/delegate/executorch_operations.h", "runtime/include/coreml_backend/delegate.h"], + fbobjc_ios_target_sdk_version = "13.0", + fbobjc_frameworks = [ + "Accelerate", + "CoreML", + "Foundation", + ], + include_directories = [ + "runtime/include", + "runtime/kvstore", + "runtime/inmemoryfs", + "runtime/delegate", + "runtime/util", + ] + ([ + "runtime/sdk", + ] if build_sdk() else []), + fbobjc_libraries = [ + "libsqlite3", + ], + link_whole = True, + platforms = [APPLE], + visibility = ["PUBLIC"], + deps = [ + "//executorch/runtime/backend:backend_options", + "//executorch/runtime/backend:interface", + "//executorch/runtime/core:core", + "//executorch/runtime/kernel:kernel_includes", + ] + ([ + ":proto", + ] if build_sdk() else []), + ) + + _PROTOS = [ + "ArrayFeatureExtractor", + "AudioFeaturePrint", + "BayesianProbitRegressor", + "CategoricalMapping", + "ClassConfidenceThresholding", + "CustomModel", + "DataStructures", + "DictVectorizer", + "FeatureTypes", + "FeatureVectorizer", + "Gazetteer", + "GLMClassifier", + "GLMRegressor", + "Identity", + "Imputer", + "ItemSimilarityRecommender", + "LinkedModel", + "MIL", + "Model", + "NearestNeighbors", + "NeuralNetwork", + "NonMaximumSuppression", + "Normalizer", + "OneHotEncoder", + "Parameters", + "Scaler", + "SoundAnalysisPreprocessing", + "SVM", + "TextClassifier", + "TreeEnsemble", + "VisionFeaturePrint", + "WordEmbedding", + "WordTagger", + ] + + runtime.cxx_test( + name = "coreml_backend_options_test", + srcs = [ + "runtime/test/coreml_backend_options_test.cpp", + ], + deps = [ + ":coreml_backend_options", + "//executorch/runtime/backend:backend_options", + "//executorch/runtime/backend:backend_options_map", + "//executorch/runtime/core:core", + ], + ) + + # Header-only library for CoreML backend options + runtime.cxx_library( + name = "coreml_backend_options", + exported_headers = [ + "runtime/include/coreml_backend/coreml_backend_options.h", + ], + header_namespace = "executorch/backends/apple/coreml", + visibility = ["PUBLIC"], + exported_deps = [ + "//executorch/runtime/backend:backend_options", + ], + ) + + runtime.cxx_library( + name = "proto", + srcs = [ + "fbsource//third-party/pypi/coremltools:exported-cpp-protoc[{}.pb.cc]".format(name) + for name in _PROTOS + ], + exported_headers = { + "format/{}.pb.h".format(name): "fbsource//third-party/pypi/coremltools:exported-cpp-protoc[{}.pb.h]".format(name) + for name in _PROTOS + }, + header_namespace = "", + compiler_flags = [ + "-Wno-global-constructors", + ], + public_include_directories = [ + "", + ], + deps = [ + "//third-party/protobuf:fb-protobuf-lite", + ], + ) diff --git a/backends/cuda/runtime/BUCK b/backends/cuda/runtime/BUCK new file mode 100644 index 00000000000..f559a6f1cfe --- /dev/null +++ b/backends/cuda/runtime/BUCK @@ -0,0 +1,9 @@ +# 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/backends/cuda/runtime/TARGETS b/backends/cuda/runtime/TARGETS deleted file mode 100644 index 122560e98ec..00000000000 --- a/backends/cuda/runtime/TARGETS +++ /dev/null @@ -1,183 +0,0 @@ -load("@fbsource//xplat/executorch/build:runtime_wrapper.bzl", "runtime") -load("@fbcode_macros//build_defs:cpp_unittest.bzl", "cpp_unittest") -load("@fbcode_macros//build_defs/lib:re_test_utils.bzl", "re_test_utils") -load("//tools/build/buck:nvcc_flags.bzl", "get_nvcc_arch_args") - -oncall("executorch") - -runtime.cxx_library( - name = "cuda_platform", - srcs = [ - "platform/platform.cpp", - ], - headers = [ - "platform/platform.h", - ], - # @lint-ignore BUCKLINT: Avoid `link_whole=True` (https://fburl.com/avoid-link-whole) - link_whole = True, - supports_python_dlopen = True, - visibility = ["PUBLIC"], - deps = [ - "//executorch/runtime/core:core", - ], - nvcc_flags = get_nvcc_arch_args() + [ - "-_NVCC_HOST_COMPILER_FLAG_", - "gcc", - ], - external_deps = [ - ("cuda", None, "cuda-lazy"), - ], -) - -runtime.cxx_library( - name = "runtime_shims", - srcs = [ - "shims/cuda_guard.cpp", - "shims/int4mm.cu", - "shims/memory.cpp", - "shims/rand.cu", - "shims/sort.cu", - "shims/tensor_attribute.cpp", - ], - headers = [ - "shims/cuda_guard.h", - "shims/int4mm.cuh", - "shims/int4mm.h", - "shims/memory.h", - "shims/rand.h", - "shims/sort.h", - "shims/tensor_attribute.h", - "utils.h", - ], - # @lint-ignore BUCKLINT: Avoid `link_whole=True` (https://fburl.com/avoid-link-whole) - link_whole = True, - supports_python_dlopen = True, - # Constructor needed for backend registration. - compiler_flags = ["-Wno-global-constructors"], - preprocessor_flags = ["-DCUDA_AVAILABLE=1"], - visibility = ["PUBLIC"], - deps = [ - "//executorch/backends/aoti:aoti_common_slim", - "//executorch/backends/aoti/slim/core:slimtensor", - "//executorch/backends/aoti/slim/factory:empty", - "//executorch/backends/aoti/slim/factory:from_blob", - "//executorch/backends/aoti/slim/cuda:guard", - "//executorch/runtime/core:core", - "//executorch/runtime/core/exec_aten:lib", - "//executorch/runtime/core/exec_aten/util:tensor_util", - "//executorch/runtime/platform:platform", - ], - nvcc_flags = get_nvcc_arch_args() + [ - "-_NVCC_HOST_COMPILER_FLAG_", - "gcc", - ], - external_deps = [ - ("cuda", None, "cuda-lazy"), - ], -) - -runtime.cxx_library( - name = "cuda_allocator", - srcs = [ - "cuda_allocator.cpp", - ], - headers = [ - "cuda_allocator.h", - ], - # @lint-ignore BUCKLINT: Avoid `link_whole=True` (https://fburl.com/avoid-link-whole) - link_whole = True, - supports_python_dlopen = True, - visibility = ["PUBLIC"], - exported_deps = [ - "//executorch/runtime/core:device_allocator", - ], - deps = [ - "//executorch/extension/cuda:caller_stream", - "//executorch/runtime/platform:platform", - ], - nvcc_flags = get_nvcc_arch_args() + [ - "-_NVCC_HOST_COMPILER_FLAG_", - "gcc", - ], - external_deps = [ - ("cuda", None, "cuda-lazy"), - ], -) - -runtime.cxx_library( - name = "cuda_backend", - srcs = [ - "cuda_backend.cpp", - "cuda_mutable_state.cpp", - ], - headers = [ - "cuda_delegate_handle.h", - "cuda_mutable_state.h", - ], - # @lint-ignore BUCKLINT: Avoid `link_whole=True` (https://fburl.com/avoid-link-whole) - link_whole = True, - supports_python_dlopen = True, - # Constructor needed for backend registration. - compiler_flags = ["-Wno-global-constructors"], - preprocessor_flags = ["-DCUDA_AVAILABLE=1"], - visibility = ["PUBLIC"], - deps = [ - ":cuda_platform", - ":runtime_shims", - ":cuda_allocator", - ":cuda_platform", - "//executorch/backends/aoti:aoti_common_slim", - "//executorch/backends/aoti/slim/core:slimtensor", - "//executorch/backends/aoti/slim/factory:empty", - "//executorch/backends/aoti/slim/factory:from_blob", - "//executorch/backends/aoti/slim/factory:from_etensor", - "//executorch/extension/cuda:caller_stream", - "//executorch/extension/tensor:tensor", - "//executorch/runtime/backend:interface", - "//executorch/runtime/core/exec_aten/util:tensor_util", - ], - external_deps = [ - ("cuda", None, "cuda-lazy"), - ], -) - -cpp_unittest( - name = "test_cuda_mutable_state", - srcs = [ - "test/test_cuda_mutable_state.cpp", - ], - deps = [ - ":cuda_backend", - "//executorch/backends/aoti:aoti_common_slim", - "//executorch/backends/aoti/slim/core:slimtensor", - "//executorch/backends/aoti/slim/factory:from_blob", - "//executorch/runtime/core:core", - "//executorch/runtime/core:evalue", - "//executorch/runtime/platform:platform", - ], - external_deps = [ - ("cuda", None, "cuda-lazy"), - ], - preprocessor_flags = ["-DCUDA_AVAILABLE=1"], - keep_gpu_sections = True, - remote_execution = re_test_utils.remote_execution( - platform = "gpu-remote-execution", - ), -) - -cpp_unittest( - name = "test_cuda_allocator", - srcs = ["test/test_cuda_allocator.cpp"], - deps = [ - ":cuda_allocator", - "//executorch/extension/cuda:caller_stream", - "//executorch/runtime/core:core", - "//executorch/runtime/platform:platform", - ], - external_deps = [("cuda", None, "cuda-lazy")], - preprocessor_flags = ["-DCUDA_AVAILABLE=1"], - keep_gpu_sections = True, - remote_execution = re_test_utils.remote_execution( - platform = "gpu-remote-execution", - ), -) diff --git a/backends/cuda/runtime/shims/tests/BUCK b/backends/cuda/runtime/shims/tests/BUCK new file mode 100644 index 00000000000..f559a6f1cfe --- /dev/null +++ b/backends/cuda/runtime/shims/tests/BUCK @@ -0,0 +1,9 @@ +# 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/backends/cuda/runtime/shims/tests/TARGETS b/backends/cuda/runtime/shims/tests/TARGETS deleted file mode 100644 index 9ff3e83a8bd..00000000000 --- a/backends/cuda/runtime/shims/tests/TARGETS +++ /dev/null @@ -1,6 +0,0 @@ -load("@fbcode_macros//build_defs:cpp_unittest.bzl", "cpp_unittest") -load(":targets.bzl", "define_common_targets") - -oncall("executorch") - -define_common_targets() diff --git a/backends/cuda/runtime/shims/tests/targets.bzl b/backends/cuda/runtime/shims/tests/targets.bzl index a54c47e979d..62bc637c3a8 100644 --- a/backends/cuda/runtime/shims/tests/targets.bzl +++ b/backends/cuda/runtime/shims/tests/targets.bzl @@ -25,12 +25,16 @@ def cuda_shim_cpp_unittest(name): ), ) -def define_common_targets(): +def define_common_targets(is_fbcode = False): """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. + Uses fbcode-only macros (cpp_unittest, re_test_utils) and kwargs + (keep_gpu_sections), so we early-return outside fbcode to preserve + pre-migration behavior (this dir was originally TARGETS-only). """ + if not is_fbcode: + return + cuda_shim_cpp_unittest("aoti_torch_empty_strided") cuda_shim_cpp_unittest("aoti_torch_delete_tensor_object") cuda_shim_cpp_unittest("aoti_torch_create_tensor_from_blob_v2") diff --git a/backends/cuda/runtime/targets.bzl b/backends/cuda/runtime/targets.bzl new file mode 100644 index 00000000000..85b16c314b6 --- /dev/null +++ b/backends/cuda/runtime/targets.bzl @@ -0,0 +1,185 @@ +load("@fbsource//xplat/executorch/build:runtime_wrapper.bzl", "runtime") +load("@fbcode_macros//build_defs:cpp_unittest.bzl", "cpp_unittest") +load("@fbcode_macros//build_defs/lib:re_test_utils.bzl", "re_test_utils") +load("@fbcode//tools/build/buck:nvcc_flags.bzl", "get_nvcc_arch_args") + +def define_common_targets(is_fbcode = False): + if not is_fbcode: + return + + runtime.cxx_library( + name = "cuda_platform", + srcs = [ + "platform/platform.cpp", + ], + headers = [ + "platform/platform.h", + ], + # @lint-ignore BUCKLINT: Avoid `link_whole=True` (https://fburl.com/avoid-link-whole) + link_whole = True, + supports_python_dlopen = True, + visibility = ["PUBLIC"], + deps = [ + "//executorch/runtime/core:core", + ], + nvcc_flags = get_nvcc_arch_args() + [ + "-_NVCC_HOST_COMPILER_FLAG_", + "gcc", + ], + external_deps = [ + ("cuda", None, "cuda-lazy"), + ], + ) + + runtime.cxx_library( + name = "runtime_shims", + srcs = [ + "shims/cuda_guard.cpp", + "shims/int4mm.cu", + "shims/memory.cpp", + "shims/rand.cu", + "shims/sort.cu", + "shims/tensor_attribute.cpp", + ], + headers = [ + "shims/cuda_guard.h", + "shims/int4mm.cuh", + "shims/int4mm.h", + "shims/memory.h", + "shims/rand.h", + "shims/sort.h", + "shims/tensor_attribute.h", + "utils.h", + ], + # @lint-ignore BUCKLINT: Avoid `link_whole=True` (https://fburl.com/avoid-link-whole) + link_whole = True, + supports_python_dlopen = True, + # Constructor needed for backend registration. + compiler_flags = ["-Wno-global-constructors"], + preprocessor_flags = ["-DCUDA_AVAILABLE=1"], + visibility = ["PUBLIC"], + deps = [ + "//executorch/backends/aoti:aoti_common_slim", + "//executorch/backends/aoti/slim/core:slimtensor", + "//executorch/backends/aoti/slim/factory:empty", + "//executorch/backends/aoti/slim/factory:from_blob", + "//executorch/backends/aoti/slim/cuda:guard", + "//executorch/runtime/core:core", + "//executorch/runtime/core/exec_aten:lib", + "//executorch/runtime/core/exec_aten/util:tensor_util", + "//executorch/runtime/platform:platform", + ], + nvcc_flags = get_nvcc_arch_args() + [ + "-_NVCC_HOST_COMPILER_FLAG_", + "gcc", + ], + external_deps = [ + ("cuda", None, "cuda-lazy"), + ], + ) + + runtime.cxx_library( + name = "cuda_allocator", + srcs = [ + "cuda_allocator.cpp", + ], + headers = [ + "cuda_allocator.h", + ], + # @lint-ignore BUCKLINT: Avoid `link_whole=True` (https://fburl.com/avoid-link-whole) + link_whole = True, + supports_python_dlopen = True, + visibility = ["PUBLIC"], + exported_deps = [ + "//executorch/runtime/core:device_allocator", + ], + deps = [ + "//executorch/extension/cuda:caller_stream", + "//executorch/runtime/platform:platform", + ], + nvcc_flags = get_nvcc_arch_args() + [ + "-_NVCC_HOST_COMPILER_FLAG_", + "gcc", + ], + external_deps = [ + ("cuda", None, "cuda-lazy"), + ], + ) + + runtime.cxx_library( + name = "cuda_backend", + srcs = [ + "cuda_backend.cpp", + "cuda_mutable_state.cpp", + ], + headers = [ + "cuda_delegate_handle.h", + "cuda_mutable_state.h", + ], + # @lint-ignore BUCKLINT: Avoid `link_whole=True` (https://fburl.com/avoid-link-whole) + link_whole = True, + supports_python_dlopen = True, + # Constructor needed for backend registration. + compiler_flags = ["-Wno-global-constructors"], + preprocessor_flags = ["-DCUDA_AVAILABLE=1"], + visibility = ["PUBLIC"], + deps = [ + ":cuda_platform", + ":runtime_shims", + ":cuda_allocator", + ":cuda_platform", + "//executorch/backends/aoti:aoti_common_slim", + "//executorch/backends/aoti/slim/core:slimtensor", + "//executorch/backends/aoti/slim/factory:empty", + "//executorch/backends/aoti/slim/factory:from_blob", + "//executorch/backends/aoti/slim/factory:from_etensor", + "//executorch/extension/cuda:caller_stream", + "//executorch/extension/tensor:tensor", + "//executorch/runtime/backend:interface", + "//executorch/runtime/core/exec_aten/util:tensor_util", + ], + external_deps = [ + ("cuda", None, "cuda-lazy"), + ], + ) + + cpp_unittest( + name = "test_cuda_mutable_state", + srcs = [ + "test/test_cuda_mutable_state.cpp", + ], + deps = [ + ":cuda_backend", + "//executorch/backends/aoti:aoti_common_slim", + "//executorch/backends/aoti/slim/core:slimtensor", + "//executorch/backends/aoti/slim/factory:from_blob", + "//executorch/runtime/core:core", + "//executorch/runtime/core:evalue", + "//executorch/runtime/platform:platform", + ], + external_deps = [ + ("cuda", None, "cuda-lazy"), + ], + preprocessor_flags = ["-DCUDA_AVAILABLE=1"], + keep_gpu_sections = True, + remote_execution = re_test_utils.remote_execution( + platform = "gpu-remote-execution", + ), + ) + + cpp_unittest( + name = "test_cuda_allocator", + srcs = ["test/test_cuda_allocator.cpp"], + deps = [ + ":cuda_allocator", + "//executorch/extension/cuda:caller_stream", + "//executorch/runtime/core:core", + "//executorch/runtime/platform:platform", + ], + external_deps = [("cuda", None, "cuda-lazy")], + preprocessor_flags = ["-DCUDA_AVAILABLE=1"], + keep_gpu_sections = True, + remote_execution = re_test_utils.remote_execution( + platform = "gpu-remote-execution", + ), + ) diff --git a/backends/cuda/tests/BUCK b/backends/cuda/tests/BUCK new file mode 100644 index 00000000000..f559a6f1cfe --- /dev/null +++ b/backends/cuda/tests/BUCK @@ -0,0 +1,9 @@ +# 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/backends/cuda/tests/TARGETS b/backends/cuda/tests/TARGETS deleted file mode 100644 index 6d7ab3f9645..00000000000 --- a/backends/cuda/tests/TARGETS +++ /dev/null @@ -1,47 +0,0 @@ -load("@fbsource//xplat/executorch/build:runtime_wrapper.bzl", "runtime") -load("@fbcode_macros//build_defs:python_unittest.bzl", "python_unittest") -load("@fbcode_macros//build_defs:python_unittest_remote_gpu.bzl", "python_unittest_remote_gpu") -load("@fbcode_macros//build_defs/lib:re_test_utils.bzl", "re_test_utils") - -oncall("executorch") - -python_unittest_remote_gpu( - name = "test_cuda_export", - srcs = [ - "test_cuda_export.py", - ], - visibility = [ - "//executorch/...", - ], - deps = [ - "//caffe2:torch", - "//executorch/backends/cuda:cuda_backend", - "//executorch/backends/cuda:cuda_partitioner", - "//executorch/exir:lib", - "//executorch/exir/backend:backend_api", - "//executorch/exir/backend:compile_spec_schema", - "//executorch/examples/models/toy_model:toy_model", - ], - keep_gpu_sections = True, - remote_execution = re_test_utils.remote_execution( - platform = "gpu-remote-execution", - subplatform = "A100-exclusive", - ), -) - -python_unittest( - name = "test_cuda_partitioner", - srcs = [ - "test_cuda_partitioner.py", - ], - visibility = [ - "//executorch/...", - ], - deps = [ - "//caffe2:torch", - "//executorch/backends/cuda:cuda_partitioner", - "//executorch/backends/cuda:cuda_backend", - "//executorch/exir:lib", - "//executorch/exir/backend:compile_spec_schema", - ], -) diff --git a/backends/cuda/tests/targets.bzl b/backends/cuda/tests/targets.bzl new file mode 100644 index 00000000000..c1306595475 --- /dev/null +++ b/backends/cuda/tests/targets.bzl @@ -0,0 +1,49 @@ +load("@fbsource//xplat/executorch/build:runtime_wrapper.bzl", "runtime") +load("@fbcode_macros//build_defs:python_unittest.bzl", "python_unittest") +load("@fbcode_macros//build_defs:python_unittest_remote_gpu.bzl", "python_unittest_remote_gpu") +load("@fbcode_macros//build_defs/lib:re_test_utils.bzl", "re_test_utils") + +def define_common_targets(is_fbcode = False): + if not is_fbcode: + return + + python_unittest_remote_gpu( + name = "test_cuda_export", + srcs = [ + "test_cuda_export.py", + ], + visibility = [ + "//executorch/...", + ], + deps = [ + "//caffe2:torch", + "//executorch/backends/cuda:cuda_backend", + "//executorch/backends/cuda:cuda_partitioner", + "//executorch/exir:lib", + "//executorch/exir/backend:backend_api", + "//executorch/exir/backend:compile_spec_schema", + "//executorch/examples/models/toy_model:toy_model", + ], + keep_gpu_sections = True, + remote_execution = re_test_utils.remote_execution( + platform = "gpu-remote-execution", + subplatform = "A100-exclusive", + ), + ) + + python_unittest( + name = "test_cuda_partitioner", + srcs = [ + "test_cuda_partitioner.py", + ], + visibility = [ + "//executorch/...", + ], + deps = [ + "//caffe2:torch", + "//executorch/backends/cuda:cuda_partitioner", + "//executorch/backends/cuda:cuda_backend", + "//executorch/exir:lib", + "//executorch/exir/backend:compile_spec_schema", + ], + ) diff --git a/examples/models/llama/config/BUCK b/examples/models/llama/config/BUCK new file mode 100644 index 00000000000..f559a6f1cfe --- /dev/null +++ b/examples/models/llama/config/BUCK @@ -0,0 +1,9 @@ +# 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/examples/models/llama/config/TARGETS b/examples/models/llama/config/TARGETS deleted file mode 100644 index 2ba1b55a3dd..00000000000 --- a/examples/models/llama/config/TARGETS +++ /dev/null @@ -1,9 +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/build:runtime_wrapper.bzl", "runtime") -load(":targets.bzl", "define_common_targets") - -oncall("executorch") - -define_common_targets() diff --git a/examples/models/llama/config/targets.bzl b/examples/models/llama/config/targets.bzl index a72ffa6c8e0..6fd5edc92a0 100644 --- a/examples/models/llama/config/targets.bzl +++ b/examples/models/llama/config/targets.bzl @@ -1,7 +1,15 @@ load("@fbsource//xplat/executorch/build:runtime_wrapper.bzl", "runtime") load("@fbcode_macros//build_defs:python_unittest.bzl", "python_unittest") -def define_common_targets(): +def define_common_targets(is_fbcode = False): + """Defines targets that should be shared between fbcode and xplat. + + Uses fbcode-only python_unittest macro; gate on is_fbcode to preserve + pre-migration behavior (this dir was originally TARGETS-only). + """ + if not is_fbcode: + return + python_unittest( name = "test_llm_config", srcs = [ diff --git a/extension/pytree/test/BUCK b/extension/pytree/test/BUCK new file mode 100644 index 00000000000..f559a6f1cfe --- /dev/null +++ b/extension/pytree/test/BUCK @@ -0,0 +1,9 @@ +# 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/extension/pytree/test/TARGETS b/extension/pytree/test/TARGETS deleted file mode 100644 index e49e8cd2791..00000000000 --- a/extension/pytree/test/TARGETS +++ /dev/null @@ -1,23 +0,0 @@ -# @noautodeps -load("@fbcode_macros//build_defs:cpp_unittest.bzl", "cpp_unittest") -load("@fbcode_macros//build_defs:python_unittest.bzl", "python_unittest") - -oncall("executorch") - -cpp_unittest( - name = "pytree_test", - srcs = ["test_pytree.cpp"], - deps = ["//executorch/extension/pytree:pytree"], -) - -python_unittest( - name = "pybindings_test", - srcs = [ - "test.py", - ], - deps = [ - "//caffe2:torch", - "//executorch/extension/pytree:pybindings", - "//executorch/extension/pytree:pylib", - ], -) diff --git a/extension/pytree/test/targets.bzl b/extension/pytree/test/targets.bzl new file mode 100644 index 00000000000..c4cbe811e5a --- /dev/null +++ b/extension/pytree/test/targets.bzl @@ -0,0 +1,27 @@ +load("@fbcode_macros//build_defs:cpp_unittest.bzl", "cpp_unittest") +load("@fbcode_macros//build_defs:python_unittest.bzl", "python_unittest") + +def define_common_targets(is_fbcode = False): + if not is_fbcode: + return + + # @noautodeps + + + cpp_unittest( + name = "pytree_test", + srcs = ["test_pytree.cpp"], + deps = ["//executorch/extension/pytree:pytree"], + ) + + python_unittest( + name = "pybindings_test", + srcs = [ + "test.py", + ], + deps = [ + "//caffe2:torch", + "//executorch/extension/pytree:pybindings", + "//executorch/extension/pytree:pylib", + ], + )