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/mediatek/runtime/BUCK b/backends/mediatek/runtime/BUCK index d395eb07786..e6d6432f28d 100644 --- a/backends/mediatek/runtime/BUCK +++ b/backends/mediatek/runtime/BUCK @@ -5,11 +5,13 @@ load( "@fbsource//tools/build_defs:default_platform_defs.bzl", "ANDROID", ) +load("@fbcode_macros//build_defs:build_file_migration.bzl", "non_fbcode_target") load("@fbsource//xplat/executorch/build:runtime_wrapper.bzl", "runtime") oncall("executorch") -runtime.cxx_library( +non_fbcode_target( + _kind = runtime.cxx_library, name = "neuron_backend", srcs = [ "NeuronBackend.cpp", diff --git a/backends/mediatek/runtime/TARGETS b/backends/mediatek/runtime/TARGETS deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/backends/vulkan/test/BUCK b/backends/vulkan/test/BUCK index 7a73d7bad65..f559a6f1cfe 100644 --- a/backends/vulkan/test/BUCK +++ b/backends/vulkan/test/BUCK @@ -1,14 +1,9 @@ -load("@fbsource//tools/build_defs:fb_native_wrapper.bzl", "fb_native") -load(":compute_api_tests.bzl", "define_compute_api_test_targets") +# Any targets that should be shared between fbcode and xplat must be defined in +# targets.bzl. -fb_native.filegroup( - name = "test_shaders", - srcs = glob([ - "glsl/*", - ]), - visibility = [ - "PUBLIC", - ], -) +load("@fbsource//tools/build_defs:fbsource_utils.bzl", "is_fbcode") +load(":targets.bzl", "define_common_targets") -define_compute_api_test_targets() +oncall("executorch") + +define_common_targets(is_fbcode = is_fbcode()) diff --git a/backends/vulkan/test/TARGETS b/backends/vulkan/test/TARGETS deleted file mode 100644 index 196c41d3ec3..00000000000 --- a/backends/vulkan/test/TARGETS +++ /dev/null @@ -1,116 +0,0 @@ -load("@fbcode_macros//build_defs:python_unittest.bzl", "python_unittest") -load("@fbsource//xplat/executorch/build:runtime_wrapper.bzl", "runtime") - -oncall("executorch") - -python_unittest( - name = "test_vulkan_delegate", - srcs = [ - "test_vulkan_delegate.py", - ], - preload_deps = [ - "fbsource//third-party/swiftshader/lib/linux-x64:libvk_swiftshader_fbcode", - "//executorch/backends/vulkan:vulkan_backend_lib", - "//executorch/kernels/portable:custom_ops_generated_lib", - ], - deps = [ - ":test_utils", - "//caffe2:torch", - "//executorch/backends/transforms:convert_dtype_pass", - "//executorch/backends/vulkan:vulkan_preprocess", - "//executorch/backends/vulkan/partitioner:vulkan_partitioner", - "//executorch/exir:lib", - "//executorch/extension/pybindings:portable_lib", # @manual - "//executorch/extension/pytree:pylib", - "//executorch/kernels/portable:custom_ops_generated_lib", - ], -) - -python_unittest( - name = "test_vulkan_passes", - srcs = [ - "test_vulkan_passes.py", - ], - deps = [ - "//caffe2:torch", - "//executorch/backends/vulkan/_passes:vulkan_passes", - "//executorch/backends/vulkan:vulkan_preprocess", - "//executorch/backends/xnnpack/quantizer:xnnpack_quantizer", - "//pytorch/ao:torchao", # @manual - ] -) - -python_unittest( - name = "test_vulkan_delegate_header", - srcs = [ - "test_vulkan_delegate_header.py", - ], - deps = [ - "//executorch/backends/vulkan:vulkan_preprocess", - ], -) - -python_unittest( - name = "test_vulkan_compile_options", - srcs = [ - "test_vulkan_compile_options.py", - ], - deps = [ - "//caffe2:torch", - "//executorch/backends/vulkan:vulkan_preprocess", - "//executorch/backends/vulkan/partitioner:vulkan_partitioner", - "//executorch/exir/_serialize:lib", - "//executorch/exir:lib", - ], -) - -python_unittest( - name = "test_serialization", - srcs = [ - "test_serialization.py", - ], - deps = [ - "//caffe2:torch", - "//executorch/backends/vulkan:vulkan_preprocess", - ], -) - -python_unittest( - name = "test_vulkan_tensor_repr", - srcs = [ - "test_vulkan_tensor_repr.py", - ], - deps = [ - "//caffe2:torch", - "//executorch/backends/vulkan:vulkan_preprocess", - ], -) - -runtime.python_library( - name = "tester", - srcs = ["tester.py"], - deps = [ - "//executorch/backends/vulkan/partitioner:vulkan_partitioner", - "//executorch/backends/vulkan:vulkan_preprocess", - ] -) - -runtime.python_library( - name = "test_utils", - srcs = [ - "utils.py", - ], - deps = [ - "//caffe2:torch", - "//executorch/backends/vulkan:vulkan_preprocess", - "//executorch/backends/vulkan/partitioner:vulkan_partitioner", - "//executorch/backends/xnnpack:xnnpack_preprocess", - "//executorch/backends/xnnpack/quantizer:xnnpack_quantizer", - "//executorch/backends/xnnpack/partition:xnnpack_partitioner", - "//executorch/devtools:lib", - "//executorch/devtools/bundled_program/serialize:lib", - "//executorch/exir:lib", - "//executorch/extension/pybindings:portable_lib", # @manual - "//executorch/extension/pytree:pylib", - ], -) diff --git a/backends/vulkan/test/targets.bzl b/backends/vulkan/test/targets.bzl new file mode 100644 index 00000000000..fe13759243b --- /dev/null +++ b/backends/vulkan/test/targets.bzl @@ -0,0 +1,131 @@ +load("@fbsource//tools/build_defs:fb_native_wrapper.bzl", "fb_native") +load(":compute_api_tests.bzl", "define_compute_api_test_targets") +load("@fbcode_macros//build_defs:python_unittest.bzl", "python_unittest") +load("@fbsource//xplat/executorch/build:runtime_wrapper.bzl", "runtime") + +def define_common_targets(is_fbcode = False): + """Combined fbcode + xplat targets for backends/vulkan/test.""" + if is_fbcode: + python_unittest( + name = "test_vulkan_delegate", + srcs = [ + "test_vulkan_delegate.py", + ], + preload_deps = [ + "fbsource//third-party/swiftshader/lib/linux-x64:libvk_swiftshader_fbcode", + "//executorch/backends/vulkan:vulkan_backend_lib", + "//executorch/kernels/portable:custom_ops_generated_lib", + ], + deps = [ + ":test_utils", + "//caffe2:torch", + "//executorch/backends/transforms:convert_dtype_pass", + "//executorch/backends/vulkan:vulkan_preprocess", + "//executorch/backends/vulkan/partitioner:vulkan_partitioner", + "//executorch/exir:lib", + "//executorch/extension/pybindings:portable_lib", # @manual + "//executorch/extension/pytree:pylib", + "//executorch/kernels/portable:custom_ops_generated_lib", + ], + ) + + python_unittest( + name = "test_vulkan_passes", + srcs = [ + "test_vulkan_passes.py", + ], + deps = [ + "//caffe2:torch", + "//executorch/backends/vulkan/_passes:vulkan_passes", + "//executorch/backends/vulkan:vulkan_preprocess", + "//executorch/backends/xnnpack/quantizer:xnnpack_quantizer", + "//pytorch/ao:torchao", # @manual + ] + ) + + python_unittest( + name = "test_vulkan_delegate_header", + srcs = [ + "test_vulkan_delegate_header.py", + ], + deps = [ + "//executorch/backends/vulkan:vulkan_preprocess", + ], + ) + + python_unittest( + name = "test_vulkan_compile_options", + srcs = [ + "test_vulkan_compile_options.py", + ], + deps = [ + "//caffe2:torch", + "//executorch/backends/vulkan:vulkan_preprocess", + "//executorch/backends/vulkan/partitioner:vulkan_partitioner", + "//executorch/exir/_serialize:lib", + "//executorch/exir:lib", + ], + ) + + python_unittest( + name = "test_serialization", + srcs = [ + "test_serialization.py", + ], + deps = [ + "//caffe2:torch", + "//executorch/backends/vulkan:vulkan_preprocess", + ], + ) + + python_unittest( + name = "test_vulkan_tensor_repr", + srcs = [ + "test_vulkan_tensor_repr.py", + ], + deps = [ + "//caffe2:torch", + "//executorch/backends/vulkan:vulkan_preprocess", + ], + ) + + runtime.python_library( + name = "tester", + srcs = ["tester.py"], + deps = [ + "//executorch/backends/vulkan/partitioner:vulkan_partitioner", + "//executorch/backends/vulkan:vulkan_preprocess", + ] + ) + + runtime.python_library( + name = "test_utils", + srcs = [ + "utils.py", + ], + deps = [ + "//caffe2:torch", + "//executorch/backends/vulkan:vulkan_preprocess", + "//executorch/backends/vulkan/partitioner:vulkan_partitioner", + "//executorch/backends/xnnpack:xnnpack_preprocess", + "//executorch/backends/xnnpack/quantizer:xnnpack_quantizer", + "//executorch/backends/xnnpack/partition:xnnpack_partitioner", + "//executorch/devtools:lib", + "//executorch/devtools/bundled_program/serialize:lib", + "//executorch/exir:lib", + "//executorch/extension/pybindings:portable_lib", # @manual + "//executorch/extension/pytree:pylib", + ], + ) + else: + fb_native.filegroup( + name = "test_shaders", + srcs = glob([ + "glsl/*", + ]), + visibility = [ + "PUBLIC", + ], + ) + + define_compute_api_test_targets() diff --git a/backends/vulkan/tools/gpuinfo/BUCK b/backends/vulkan/tools/gpuinfo/BUCK index 7477875096e..f559a6f1cfe 100644 --- a/backends/vulkan/tools/gpuinfo/BUCK +++ b/backends/vulkan/tools/gpuinfo/BUCK @@ -1,58 +1,9 @@ -load("@fbcode_macros//build_defs:native_rules.bzl", "buck_filegroup") -load("@fbsource//tools/build_defs:fb_xplat_cxx_binary.bzl", "fb_xplat_cxx_binary") -load( - "@fbsource//tools/build_defs:platform_defs.bzl", - "ANDROID", -) -load( - "@fbsource//xplat/executorch/backends/vulkan:targets.bzl", - "vulkan_spv_shader_lib", -) +# Any targets that should be shared between fbcode and xplat must be defined in +# targets.bzl. -oncall("executorch") - -buck_filegroup( - name = "gpuinfo_shaders", - srcs = glob([ - "glsl/*", - ]), - visibility = [ - "PUBLIC", - ], -) +load("@fbsource//tools/build_defs:fbsource_utils.bzl", "is_fbcode") +load(":targets.bzl", "define_common_targets") -vulkan_spv_shader_lib( - name = "gpuinfo_shader_lib", - spv_filegroups = { - ":gpuinfo_shaders": "glsl", - }, -) +oncall("executorch") -fb_xplat_cxx_binary( - name = "vulkan_gpuinfo", - srcs = glob([ - "**/*.cpp", - ]), - headers = glob([ - "**/*.h", - ]), - compiler_flags = select({ - "DEFAULT": [ - "-Wno-header-hygiene", - ], - "ovr_config//compiler:cl": [], - }), - header_namespace = "/include", - include_directories = ["/include"], - platforms = ANDROID, - raw_headers = glob([ - "**/*.h", - ]), - deps = [ - ":gpuinfo_shader_lib", - "//arvr/third-party/opencl:headers", - "//arvr/third-party/opencl:runtime", - "//xplat/executorch/backends/vulkan:vulkan_graph_runtime", - "//xplat/folly:json", - ], -) +define_common_targets(is_fbcode = is_fbcode()) diff --git a/backends/vulkan/tools/gpuinfo/TARGETS b/backends/vulkan/tools/gpuinfo/TARGETS deleted file mode 100644 index 10e3acb4b8c..00000000000 --- a/backends/vulkan/tools/gpuinfo/TARGETS +++ /dev/null @@ -1,50 +0,0 @@ -load("@fbcode_macros//build_defs:native_rules.bzl", "buck_filegroup") -load("@fbsource//tools/build_defs:fb_xplat_cxx_binary.bzl", "fb_xplat_cxx_binary") -load( - "@fbsource//tools/build_defs:platform_defs.bzl", - "ANDROID", -) -load( - "@fbsource//xplat/executorch/backends/vulkan:targets.bzl", - "vulkan_spv_shader_lib", -) - -oncall("executorch") - -buck_filegroup( - name = "gpuinfo_shaders", - srcs = glob([ - "glsl/*", - ]), - visibility = [ - "PUBLIC", - ], -) - -vulkan_spv_shader_lib( - name = "gpuinfo_shader_lib", - is_fbcode = True, - spv_filegroups = { - ":gpuinfo_shaders": "glsl", - }, -) - -fb_xplat_cxx_binary( - name = "vulkan_gpuinfo", - srcs = glob([ - "**/*.cpp", - ]), - headers = glob([ - "**/*.h", - ]), - header_namespace = "/include", - include_directories = ["/include"], - platforms = ANDROID, - raw_headers = glob([ - "**/*.h", - ]), - deps = [ - ":gpuinfo_shader_lib", - "//executorch/backends/vulkan:vulkan_graph_runtime", - ], -) diff --git a/backends/vulkan/tools/gpuinfo/targets.bzl b/backends/vulkan/tools/gpuinfo/targets.bzl new file mode 100644 index 00000000000..2bc9b3f1d04 --- /dev/null +++ b/backends/vulkan/tools/gpuinfo/targets.bzl @@ -0,0 +1,74 @@ +load("@fbcode_macros//build_defs:native_rules.bzl", "buck_filegroup") +load("@fbsource//tools/build_defs:fb_xplat_cxx_binary.bzl", "fb_xplat_cxx_binary") +load("@fbsource//tools/build_defs:platform_defs.bzl", "ANDROID") +load("@fbsource//xplat/executorch/backends/vulkan:targets.bzl", "vulkan_spv_shader_lib") + +def define_common_targets(is_fbcode = False): + """Combined fbcode + xplat targets for backends/vulkan/tools/gpuinfo.""" + buck_filegroup( + name = "gpuinfo_shaders", + srcs = native.glob([ + "glsl/*", + ]), + visibility = [ + "PUBLIC", + ], + ) + + vulkan_spv_shader_lib( + name = "gpuinfo_shader_lib", + is_fbcode = is_fbcode, + spv_filegroups = { + ":gpuinfo_shaders": "glsl", + }, + ) + + if is_fbcode: + fb_xplat_cxx_binary( + name = "vulkan_gpuinfo", + srcs = native.glob([ + "**/*.cpp", + ]), + headers = native.glob([ + "**/*.h", + ]), + header_namespace = "/include", + include_directories = ["/include"], + platforms = ANDROID, + raw_headers = native.glob([ + "**/*.h", + ]), + deps = [ + ":gpuinfo_shader_lib", + "//executorch/backends/vulkan:vulkan_graph_runtime", + ], + ) + else: + fb_xplat_cxx_binary( + name = "vulkan_gpuinfo", + srcs = native.glob([ + "**/*.cpp", + ]), + headers = native.glob([ + "**/*.h", + ]), + compiler_flags = select({ + "DEFAULT": [ + "-Wno-header-hygiene", + ], + "ovr_config//compiler:cl": [], + }), + header_namespace = "/include", + include_directories = ["/include"], + platforms = ANDROID, + raw_headers = native.glob([ + "**/*.h", + ]), + deps = [ + ":gpuinfo_shader_lib", + "//arvr/third-party/opencl:headers", + "//arvr/third-party/opencl:runtime", + "//xplat/executorch/backends/vulkan:vulkan_graph_runtime", + "//xplat/folly:json", + ], + ) diff --git a/examples/llm_server/python/TARGETS b/examples/llm_server/python/BUCK similarity index 85% rename from examples/llm_server/python/TARGETS rename to examples/llm_server/python/BUCK index 38009c9d1c7..ff592f51a4d 100644 --- a/examples/llm_server/python/TARGETS +++ b/examples/llm_server/python/BUCK @@ -1,8 +1,9 @@ load("@fbsource//xplat/executorch/build:runtime_wrapper.bzl", "runtime") +load("@fbcode_macros//build_defs:build_file_migration.bzl", "fbcode_target") oncall("executorch") -runtime.python_library( +fbcode_target(_kind = runtime.python_library, name = "lib", srcs = [ "__init__.py", diff --git a/examples/models/gemma4_31b/BUCK b/examples/models/gemma4_31b/BUCK new file mode 100644 index 00000000000..de00a718b95 --- /dev/null +++ b/examples/models/gemma4_31b/BUCK @@ -0,0 +1,40 @@ +load("@fbsource//xplat/executorch/build:runtime_wrapper.bzl", "runtime") +load("@fbcode_macros//build_defs:build_file_migration.bzl", "fbcode_target") + +oncall("executorch") + +fbcode_target(_kind = runtime.python_library, + name = "quant", + srcs = [ + "cuda_packers.py", + "quant/quantize.py", + "quant/recipe.py", + ], + base_module = "executorch.examples.models.gemma4_31b", + visibility = ["PUBLIC"], + deps = [ + "//caffe2:torch", + "//executorch/backends/cuda:coalesced_int4_tensor", + "//executorch/backends/cuda:dp4a_planar_int5_tensor", + "//executorch/backends/cuda:dp4a_planar_int6_tensor", + "//executorch/extension/llm/export:gguf", + "//executorch/extension/llm/export:int4", + "//executorch/extension/llm/export:quant", + "//pytorch/ao:torchao", + "fbsource//third-party/pypi/safetensors:safetensors", + ], +) + +fbcode_target(_kind = runtime.python_library, + name = "quantize_and_save", + srcs = ["quantize_and_save.py"], + base_module = "executorch.examples.models.gemma4_31b", + visibility = ["PUBLIC"], + deps = [ + "//caffe2:torch", + "//executorch/extension/llm/export:load", + "//executorch/extension/llm/export:quant", + "//pytorch/ao:torchao", + "fbsource//third-party/pypi/safetensors:safetensors", + ], +) diff --git a/runtime/test/BUCK b/runtime/test/BUCK new file mode 100644 index 00000000000..f559a6f1cfe --- /dev/null +++ b/runtime/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/runtime/test/TARGETS b/runtime/test/TARGETS deleted file mode 100644 index 3c1acb9c534..00000000000 --- a/runtime/test/TARGETS +++ /dev/null @@ -1,34 +0,0 @@ -load("@fbsource//xplat/executorch/build:runtime_wrapper.bzl", "runtime") - -oncall("executorch") - -runtime.python_test( - name = "test_runtime", - srcs = ["test_runtime.py"], - deps = [ - "//executorch/extension/pybindings/test:make_test", - "//executorch/runtime:runtime", - "//executorch/devtools/etdump:serialize", - ], -) - -runtime.python_test( - name = "test_runtime_etdump_gen", - srcs = ["test_runtime_etdump_gen.py"], - deps = [ - "//executorch/extension/pybindings/test:make_test", - "//executorch/runtime:runtime", - "//executorch/devtools/etdump:serialize", - ], -) - -runtime.python_test( - name = "test_runtime_xnnpack", - srcs = ["test_runtime_xnnpack.py"], - deps = [ - "//caffe2:torch", - "//executorch/backends/xnnpack/partition:xnnpack_partitioner", - "//executorch/exir:lib", - "//executorch/runtime:runtime", - ], -) diff --git a/runtime/test/targets.bzl b/runtime/test/targets.bzl new file mode 100644 index 00000000000..74309a59e01 --- /dev/null +++ b/runtime/test/targets.bzl @@ -0,0 +1,36 @@ +load("@fbsource//xplat/executorch/build:runtime_wrapper.bzl", "runtime") + +def define_common_targets(is_fbcode = False): + if not is_fbcode: + return + + runtime.python_test( + name = "test_runtime", + srcs = ["test_runtime.py"], + deps = [ + "//executorch/extension/pybindings/test:make_test", + "//executorch/runtime:runtime", + "//executorch/devtools/etdump:serialize", + ], + ) + + runtime.python_test( + name = "test_runtime_etdump_gen", + srcs = ["test_runtime_etdump_gen.py"], + deps = [ + "//executorch/extension/pybindings/test:make_test", + "//executorch/runtime:runtime", + "//executorch/devtools/etdump:serialize", + ], + ) + + runtime.python_test( + name = "test_runtime_xnnpack", + srcs = ["test_runtime_xnnpack.py"], + deps = [ + "//caffe2:torch", + "//executorch/backends/xnnpack/partition:xnnpack_partitioner", + "//executorch/exir:lib", + "//executorch/runtime:runtime", + ], + )