From db4a4387e0d210fca0bde6bd5466540cd5f414e1 Mon Sep 17 00:00:00 2001 From: Scott Wolchok Date: Thu, 13 Mar 2025 15:02:06 -0700 Subject: [PATCH] Update [ghstack-poisoned] --- .ci/scripts/unittest-buck2.sh | 4 +++- examples/selective_build/targets.bzl | 15 +++++++++++++++ kernels/portable/cpu/pattern/targets.bzl | 6 ++++-- kernels/portable/cpu/util/targets.bzl | 2 +- shim_et/xplat/executorch/codegen/codegen.bzl | 2 +- 5 files changed, 24 insertions(+), 5 deletions(-) diff --git a/.ci/scripts/unittest-buck2.sh b/.ci/scripts/unittest-buck2.sh index 59b8ac6ccd2..5e3f149b6c0 100755 --- a/.ci/scripts/unittest-buck2.sh +++ b/.ci/scripts/unittest-buck2.sh @@ -24,6 +24,8 @@ BUILDABLE_KERNELS_PRIM_OPS_TARGETS=$(buck2 query //kernels/prim_ops/... | grep - # TODO: expand the covered scope of Buck targets. # //runtime/kernel/... is failing because //third-party:torchgen_files's shell script can't find python on PATH. # //runtime/test/... requires Python torch, which we don't have in our OSS buck setup. -buck2 test $BUILDABLE_OPTIMIZED_OPS //kernels/portable/... \ +buck2 test \ + //examples/selective_build:select_all_dtype_selective_lib_portable_lib \ + $BUILDABLE_OPTIMIZED_OPS //kernels/portable/... \ $BUILDABLE_KERNELS_PRIM_OPS_TARGETS //runtime/backend/... //runtime/core/... \ //runtime/executor: //runtime/kernel/... //runtime/platform/... diff --git a/examples/selective_build/targets.bzl b/examples/selective_build/targets.bzl index 276ee3afe41..07fd89c3797 100644 --- a/examples/selective_build/targets.bzl +++ b/examples/selective_build/targets.bzl @@ -25,6 +25,21 @@ def define_common_targets(): ], ) + executorch_generated_lib( + name = "select_all_dtype_selective_lib", + functions_yaml_target = "//executorch/kernels/portable:functions.yaml", + kernel_deps = [ + "//executorch/kernels/portable:operators", + ], + # Setting dtype_selective_build without using list or dict selection isn't a + # typical use case; we just do it here so that we can test that our mechanism + # for getting buck deps right for dtype_selective_build is working. + dtype_selective_build = True, + deps = [ + ":select_all_ops", + ], + ) + # Select a list of operators: defined in `ops` et_operator_library( name = "select_ops_in_list", diff --git a/kernels/portable/cpu/pattern/targets.bzl b/kernels/portable/cpu/pattern/targets.bzl index 1de3035776e..16a85a750eb 100644 --- a/kernels/portable/cpu/pattern/targets.bzl +++ b/kernels/portable/cpu/pattern/targets.bzl @@ -11,7 +11,7 @@ def define_common_targets(): # build, where the portable ops are built from source and linked with :all_deps runtime.cxx_library( name = "all_deps", - deps = [ + exported_deps = [ "//executorch/kernels/portable/cpu/pattern:pattern", "//executorch/kernels/portable/cpu/pattern:bitwise_op", "//executorch/kernels/portable/cpu/pattern:comparison_op", @@ -54,6 +54,9 @@ def define_common_targets(): "unary_ufunc_realhbbf16_to_floathbf16.cpp", "unary_ufunc_realh.cpp", ], + exported_deps = [ + "//executorch/runtime/kernel:kernel_includes", + ], exported_headers = [ "pattern.h", ], @@ -61,7 +64,6 @@ def define_common_targets(): deps = [ "//executorch/kernels/portable/cpu/util:broadcast_util", "//executorch/kernels/portable/cpu/util:functional_util", - "//executorch/runtime/kernel:kernel_includes", ], visibility = ["//executorch/kernels/portable/cpu/...", "//executorch/kernels/optimized/cpu/..."], ) diff --git a/kernels/portable/cpu/util/targets.bzl b/kernels/portable/cpu/util/targets.bzl index 95fd1734d8e..85f781b1482 100644 --- a/kernels/portable/cpu/util/targets.bzl +++ b/kernels/portable/cpu/util/targets.bzl @@ -11,7 +11,7 @@ def define_common_targets(): # build, where the portable ops are built from source and linked with :all_deps runtime.cxx_library( name = "all_deps", - deps = [ + exported_deps = [ "//executorch/kernels/portable/cpu/util:functional_util", "//executorch/kernels/portable/cpu/util:broadcast_util", "//executorch/kernels/portable/cpu/util:kernel_ops_util", diff --git a/shim_et/xplat/executorch/codegen/codegen.bzl b/shim_et/xplat/executorch/codegen/codegen.bzl index a6d6d59e0c2..b988e01e631 100644 --- a/shim_et/xplat/executorch/codegen/codegen.bzl +++ b/shim_et/xplat/executorch/codegen/codegen.bzl @@ -631,7 +631,7 @@ def executorch_generated_lib( ) portable_lib = [] - if dtype_selective_build and is_xplat() and "//executorch/kernels/portable:operators" in kernel_deps: + if dtype_selective_build and (is_xplat() or runtime.is_oss) and "//executorch/kernels/portable:operators" in kernel_deps: # Remove portable from kernel_deps as we're building it from source. kernel_deps.remove("//executorch/kernels/portable:operators")