diff --git a/backends/apple/mps/targets.bzl b/backends/apple/mps/targets.bzl index 74d79448362..99c97d2b318 100644 --- a/backends/apple/mps/targets.bzl +++ b/backends/apple/mps/targets.bzl @@ -3,6 +3,7 @@ # Provided subject to the LICENSE file in the top level directory. # +load("@fbsource//xplat/executorch/build:build_variables.bzl", "MPS_BACKEND_BUCK_SRCS") load("@fbsource//xplat/executorch/build:runtime_wrapper.bzl", "runtime") def define_common_targets(is_xplat = False, platforms = []): @@ -37,10 +38,7 @@ def define_common_targets(is_xplat = False, platforms = []): "runtime/*.h", "runtime/operations/*.h", ]), - "srcs": native.glob([ - "runtime/*.mm", - "runtime/operations/*.mm", - ]), + "srcs": MPS_BACKEND_BUCK_SRCS, "visibility": [ "//executorch/backends/apple/...", "//executorch/examples/...", diff --git a/backends/xnnpack/targets.bzl b/backends/xnnpack/targets.bzl index aee5104b17a..0eab89a00f9 100644 --- a/backends/xnnpack/targets.bzl +++ b/backends/xnnpack/targets.bzl @@ -1,4 +1,5 @@ load("@fbsource//xplat/executorch/backends/xnnpack/third-party:third_party_libs.bzl", "third_party_dep") +load("@fbsource//xplat/executorch/build:build_variables.bzl", "XNNPACK_BACKEND_BUCK_SRCS") load("@fbsource//xplat/executorch/build:runtime_wrapper.bzl", "get_aten_mode_options", "runtime") def _get_preprocessor_flags(): @@ -37,10 +38,7 @@ def define_common_targets(): aten_suffix = "_aten" if aten_mode else "" runtime.cxx_library( name = "xnnpack_backend" + aten_suffix, - srcs = native.glob([ - "runtime/*.cpp", - "runtime/profiling/*.cpp", - ]), + srcs = XNNPACK_BACKEND_BUCK_SRCS, headers = native.glob([ "runtime/*.h", "runtime/profiling/*.h", diff --git a/extension/threadpool/targets.bzl b/extension/threadpool/targets.bzl index 5e7cf2c7dae..6ef55c42434 100644 --- a/extension/threadpool/targets.bzl +++ b/extension/threadpool/targets.bzl @@ -1,4 +1,5 @@ load("@fbsource//xplat/executorch/backends/xnnpack/third-party:third_party_libs.bzl", "third_party_dep") +load("@fbsource//xplat/executorch/build:build_variables.bzl", "THREADPOOL_SRCS") load("@fbsource//xplat/executorch/build:runtime_wrapper.bzl", "runtime") def define_common_targets(): @@ -8,11 +9,9 @@ def define_common_targets(): TARGETS and BUCK files that call this function. """ - _THREADPOOL_SRCS = [ - "thread_parallel.cpp", - "threadpool.cpp", - "threadpool_guard.cpp", - ] + (["fb/threadpool_use_n_threads.cpp"] if not runtime.is_oss else []) + _THREADPOOL_SRCS = THREADPOOL_SRCS + ( + ["fb/threadpool_use_n_threads.cpp"] if not runtime.is_oss else [] + ) _THREADPOOL_HEADERS = [ "threadpool.h", diff --git a/kernels/portable/cpu/pattern/targets.bzl b/kernels/portable/cpu/pattern/targets.bzl index 9d6f1a6885d..636c5d2127b 100644 --- a/kernels/portable/cpu/pattern/targets.bzl +++ b/kernels/portable/cpu/pattern/targets.bzl @@ -1,3 +1,4 @@ +load("@fbsource//xplat/executorch/build:build_variables.bzl", "PATTERN_SRCS") load("@fbsource//xplat/executorch/build:runtime_wrapper.bzl", "runtime") def define_common_targets(): @@ -49,11 +50,7 @@ def define_common_targets(): runtime.cxx_library( name = "pattern", - srcs = [ - "unary_ufunc_realhbbf16_to_bool.cpp", - "unary_ufunc_realhbbf16_to_floathbf16.cpp", - "unary_ufunc_realhbf16.cpp", - ], + srcs = PATTERN_SRCS, exported_headers = [ "pattern.h", ], diff --git a/runtime/executor/targets.bzl b/runtime/executor/targets.bzl index ec0fb19ff96..103ea299c34 100644 --- a/runtime/executor/targets.bzl +++ b/runtime/executor/targets.bzl @@ -1,3 +1,4 @@ +load("@fbsource//xplat/executorch/build:build_variables.bzl", "PROGRAM_NO_PRIM_OPS_SRCS") load("@fbsource//xplat/executorch/build:runtime_wrapper.bzl", "get_aten_mode_options", "runtime") def _program_preprocessor_flags(): @@ -93,11 +94,7 @@ def define_common_targets(): runtime.cxx_library( name = "program_no_prim_ops" + aten_suffix, - srcs = [ - "method.cpp", - "method_meta.cpp", - "program.cpp", - "tensor_parser_exec_aten.cpp", + srcs = PROGRAM_NO_PRIM_OPS_SRCS + [ "tensor_parser{}.cpp".format(aten_suffix if aten_mode else "_portable"), ], headers = [ diff --git a/runtime/platform/targets.bzl b/runtime/platform/targets.bzl index eecac8ae5db..457deed531e 100644 --- a/runtime/platform/targets.bzl +++ b/runtime/platform/targets.bzl @@ -1,3 +1,4 @@ +load("@fbsource//xplat/executorch/build:build_variables.bzl", "PLATFORM_SRCS") load("@fbsource//xplat/executorch/build:runtime_wrapper.bzl", "runtime") load(":log.bzl", "get_et_logging_flags") @@ -73,13 +74,7 @@ def define_common_targets(): "runtime.h", "compat_unistd.h", ], - srcs = [ - "abort.cpp", - "log.cpp", - "platform.cpp", - "profiler.cpp", - "runtime.cpp", - ], + srcs = PLATFORM_SRCS, exported_preprocessor_flags = get_profiling_flags() + get_et_logging_flags(), exported_deps = [ "//executorch/runtime/platform:pal_interface", diff --git a/shim_et/xplat/executorch/build/build_variables.bzl b/shim_et/xplat/executorch/build/build_variables.bzl index e78cc08ef27..73e500bf21d 100644 --- a/shim_et/xplat/executorch/build/build_variables.bzl +++ b/shim_et/xplat/executorch/build/build_variables.bzl @@ -32,7 +32,22 @@ EXECUTORCH_SRCS = [ "kernels/prim_ops/register_prim_ops.cpp", ] -EXECUTORCH_CORE_SRCS = [ +PROGRAM_NO_PRIM_OPS_SRCS = [ + "method.cpp", + "method_meta.cpp", + "program.cpp", + "tensor_parser_exec_aten.cpp", +] + +PLATFORM_SRCS = [ + "abort.cpp", + "log.cpp", + "platform.cpp", + "profiler.cpp", + "runtime.cpp", +] + +EXECUTORCH_CORE_SRCS = sorted([ "runtime/backend/interface.cpp", "runtime/core/evalue.cpp", "runtime/core/exec_aten/util/tensor_shape_to_c_string.cpp", @@ -40,19 +55,16 @@ EXECUTORCH_CORE_SRCS = [ "runtime/core/portable_type/tensor_impl.cpp", "runtime/core/tag.cpp", "runtime/core/tensor_layout.cpp", - "runtime/executor/method.cpp", - "runtime/executor/method_meta.cpp", - "runtime/executor/program.cpp", - "runtime/executor/pte_data_map.cpp", - "runtime/executor/tensor_parser_exec_aten.cpp", "runtime/executor/tensor_parser_portable.cpp", + "runtime/executor/pte_data_map.cpp", "runtime/kernel/operator_registry.cpp", - "runtime/platform/abort.cpp", - "runtime/platform/log.cpp", - "runtime/platform/platform.cpp", - "runtime/platform/profiler.cpp", - "runtime/platform/runtime.cpp", "schema/extended_header.cpp", +] + ["runtime/executor/" + x for x in PROGRAM_NO_PRIM_OPS_SRCS] + ["runtime/platform/" + x for x in PLATFORM_SRCS]) + +PATTERN_SRCS = [ + "unary_ufunc_realhbbf16_to_bool.cpp", + "unary_ufunc_realhbbf16_to_floathbf16.cpp", + "unary_ufunc_realhbf16.cpp", ] PORTABLE_KERNELS_SRCS = [ @@ -221,10 +233,7 @@ PORTABLE_KERNELS_SRCS = [ "kernels/portable/cpu/op_view_copy.cpp", "kernels/portable/cpu/op_where.cpp", "kernels/portable/cpu/op_zeros.cpp", - "kernels/portable/cpu/pattern/unary_ufunc_realhbbf16_to_bool.cpp", - "kernels/portable/cpu/pattern/unary_ufunc_realhbbf16_to_floathbf16.cpp", - "kernels/portable/cpu/pattern/unary_ufunc_realhbf16.cpp", -] +] + ["kernels/portable/cpu/pattern/" + x for x in PATTERN_SRCS] KERNELS_UTIL_ALL_DEPS_SRCS = [ "kernels/portable/cpu/util/activation_ops_util.cpp", @@ -354,12 +363,14 @@ EXTENSION_TENSOR_SRCS = [ "extension/tensor/tensor_ptr_maker.cpp", ] -EXTENSION_THREADPOOL_SRCS = [ - "extension/threadpool/thread_parallel.cpp", - "extension/threadpool/threadpool.cpp", - "extension/threadpool/threadpool_guard.cpp", +THREADPOOL_SRCS = [ + "thread_parallel.cpp", + "threadpool.cpp", + "threadpool_guard.cpp", ] +EXTENSION_THREADPOOL_SRCS = ["extension/threadpool/" + x for x in THREADPOOL_SRCS] + EXTENSION_TRAINING_SRCS = [ "extension/data_loader/file_data_loader.cpp", "extension/data_loader/mmap_data_loader.cpp", @@ -426,32 +437,34 @@ MPS_EXECUTOR_RUNNER_SRCS = [ "extension/data_loader/file_data_loader.cpp", ] -MPS_BACKEND_SRCS = [ - "backends/apple/mps/runtime/MPSBackend.mm", - "backends/apple/mps/runtime/MPSCompiler.mm", - "backends/apple/mps/runtime/MPSDelegateHeader.mm", - "backends/apple/mps/runtime/MPSDevice.mm", - "backends/apple/mps/runtime/MPSExecutor.mm", - "backends/apple/mps/runtime/MPSGraphBuilder.mm", - "backends/apple/mps/runtime/MPSStream.mm", - "backends/apple/mps/runtime/operations/ActivationOps.mm", - "backends/apple/mps/runtime/operations/BinaryOps.mm", - "backends/apple/mps/runtime/operations/ClampOps.mm", - "backends/apple/mps/runtime/operations/ConstantOps.mm", - "backends/apple/mps/runtime/operations/ConvolutionOps.mm", - "backends/apple/mps/runtime/operations/IndexingOps.mm", - "backends/apple/mps/runtime/operations/LinearAlgebra.mm", - "backends/apple/mps/runtime/operations/NormalizationOps.mm", - "backends/apple/mps/runtime/operations/OperationUtils.mm", - "backends/apple/mps/runtime/operations/PadOps.mm", - "backends/apple/mps/runtime/operations/PoolingOps.mm", - "backends/apple/mps/runtime/operations/QuantDequant.mm", - "backends/apple/mps/runtime/operations/RangeOps.mm", - "backends/apple/mps/runtime/operations/ReduceOps.mm", - "backends/apple/mps/runtime/operations/ShapeOps.mm", - "backends/apple/mps/runtime/operations/UnaryOps.mm", +MPS_BACKEND_BUCK_SRCS = [ + "runtime/MPSBackend.mm", + "runtime/MPSCompiler.mm", + "runtime/MPSDelegateHeader.mm", + "runtime/MPSDevice.mm", + "runtime/MPSExecutor.mm", + "runtime/MPSGraphBuilder.mm", + "runtime/MPSStream.mm", + "runtime/operations/ActivationOps.mm", + "runtime/operations/BinaryOps.mm", + "runtime/operations/ClampOps.mm", + "runtime/operations/ConstantOps.mm", + "runtime/operations/ConvolutionOps.mm", + "runtime/operations/IndexingOps.mm", + "runtime/operations/LinearAlgebra.mm", + "runtime/operations/NormalizationOps.mm", + "runtime/operations/OperationUtils.mm", + "runtime/operations/PadOps.mm", + "runtime/operations/PoolingOps.mm", + "runtime/operations/QuantDequant.mm", + "runtime/operations/RangeOps.mm", + "runtime/operations/ReduceOps.mm", + "runtime/operations/ShapeOps.mm", + "runtime/operations/UnaryOps.mm", ] +MPS_BACKEND_SRCS = ["backends/apple/mps/" + x for x in MPS_BACKEND_BUCK_SRCS] + MPS_SCHEMA_SRCS = [ "backends/apple/mps/serialization/schema.fbs", ] @@ -461,15 +474,17 @@ XNN_EXECUTOR_RUNNER_SRCS = [ "extension/data_loader/file_data_loader.cpp", ] -XNNPACK_BACKEND_SRCS = [ - "backends/xnnpack/runtime/XNNCompiler.cpp", - "backends/xnnpack/runtime/XNNExecutor.cpp", - "backends/xnnpack/runtime/XNNHeader.cpp", - "backends/xnnpack/runtime/XNNPACKBackend.cpp", - "backends/xnnpack/runtime/XNNWeightsCache.cpp", - "backends/xnnpack/runtime/profiling/XNNProfiler.cpp", +XNNPACK_BACKEND_BUCK_SRCS = [ + "runtime/XNNCompiler.cpp", + "runtime/XNNExecutor.cpp", + "runtime/XNNHeader.cpp", + "runtime/XNNPACKBackend.cpp", + "runtime/XNNWeightsCache.cpp", + "runtime/profiling/XNNProfiler.cpp", ] +XNNPACK_BACKEND_SRCS = ["backends/xnnpack/" + x for x in XNNPACK_BACKEND_BUCK_SRCS] + XNNPACK_SCHEMA_SRCS = [ "backends/xnnpack/serialization/runtime_schema.fbs", ]