From ce37a0a3d0cbe8389e4a25eba24e248ef41bfeaa Mon Sep 17 00:00:00 2001 From: lucylq Date: Mon, 19 May 2025 16:42:34 -0700 Subject: [PATCH] Dtype selective build: fail if not xplat, if portable/optimized not in kernel_deps https://github.com/pytorch/executorch/pull/10985 Try to make user error harder for dtype selective build. Emit warning for now, as too many failures when set to failure :( For example: ``` buck2 build //xplat/sgr/resources/tests/handwriting:pkg buck2 build fbsource//xplat/sgr/resources/mwa:main_pkg_libAndroid Differential Revision: [D75027794](https://our.internmc.facebook.com/intern/diff/D75027794/) [ghstack-poisoned] --- shim_et/xplat/executorch/codegen/codegen.bzl | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/shim_et/xplat/executorch/codegen/codegen.bzl b/shim_et/xplat/executorch/codegen/codegen.bzl index f4996b6aaf7..ceb987a1a78 100644 --- a/shim_et/xplat/executorch/codegen/codegen.bzl +++ b/shim_et/xplat/executorch/codegen/codegen.bzl @@ -641,6 +641,26 @@ def executorch_generated_lib( if not aten_mode and not functions_yaml_target and not custom_ops_yaml_target: fail("At least one of functions_yaml_target, custom_ops_yaml_target needs to be provided") + if dtype_selective_build: + if not is_xplat(): + warning(""" + !!WARNING!! Dtype_selective_build is only available in xplat. + Proceeding without dtype selective build for lib: {}.""".format(name)) + + # Dtype selective build is enabled on portable and optimized kernel libraries. + if (not "//executorch/kernels/portable:operators" in kernel_deps) and (not "//executorch/kernels/optimized:optimized_operators" in kernel_deps): + warning(""" + !!WARNING!! Dtype_selective_build is enabled but kernel_deps does not contain portable or optimized dependencies. + Please add one of these to kernel_deps in `executorch_generated_lib`: + //executorch/kernels/portable:operators + //executorch/kernels/optimized:optimized_operators + This will tell the build system to rebuild portable/optimized with dtype selective build enabled. + For examples, see: //executorch/examples/selective_build/targets.bzl + Currently, kernel_deps contains {}. + + Proceeding without dtype selective build. + """.format(kernel_deps)) + aten_suffix = "_aten" if aten_mode else "" # merge functions.yaml with fallback yaml