From cd3c63bbad06b57f0e9773da42c39341bc31c1cc Mon Sep 17 00:00:00 2001 From: Jake Stevens Date: Tue, 3 Nov 2026 09:13:36 -0800 Subject: [PATCH] Enable Vulkan vision runners on Android (#24503) Summary: The Vulkan engine, its graph passes and the vision runner were only defined in fbcode, so the runner could not be built for Android. This defines them in xplat too. `backends/native/runtime/vulkan/targets.bzl` no longer returns early in xplat, `backends/native/runtime/vulkan/BUCK` defines the xplat `xplat_vulkan_runtime` next to the fbcode one, and `run_classification` and `run_classification_vulkan` are declared for both cells. The fbcode targets are unchanged. `vulkan_passes_test` needs neither a GPU nor SwiftShader, so it now also builds and runs in xplat. The xplat `run_classification` carries a CI label that builds it for Android arm64, which covers the Vulkan engine, its passes and ET-VK on Android. The new xplat targets use the default xplat platform set, which matches ET-VK's `get_platforms()`. Review fixes authored with Claude Code. Differential Revision: D129370846 --- backends/native/examples/vision/BUCK | 12 ++--- backends/native/runtime/vulkan/BUCK | 16 ++++++- backends/native/runtime/vulkan/targets.bzl | 6 +-- .../native/test/runtime/vulkan/targets.bzl | 44 +++++++++---------- 4 files changed, 43 insertions(+), 35 deletions(-) diff --git a/backends/native/examples/vision/BUCK b/backends/native/examples/vision/BUCK index 0d6fd98421d..7497e095c10 100644 --- a/backends/native/examples/vision/BUCK +++ b/backends/native/examples/vision/BUCK @@ -1,6 +1,6 @@ -load("@fbcode_macros//build_defs:build_file_migration.bzl", "fbcode_target") +load("@fbsource//tools/target_determinator/macros:ci.bzl", "ci") load("@fbsource//xplat/executorch/backends/native/runtime/engine:targets.bzl", "CPU_COMPAT") -load("@fbsource//xplat/executorch/build:runtime_wrapper.bzl", "runtime") +load("@fbsource//xplat/executorch/build:runtime_wrapper.bzl", "is_xplat", "runtime") oncall("executorch") @@ -42,8 +42,7 @@ runtime.cxx_binary( **CPU_COMPAT ) -fbcode_target( - _kind = runtime.cxx_binary, +runtime.cxx_binary( name = "run_classification", srcs = ["run_classification.cpp"], deps = [ @@ -51,11 +50,12 @@ fbcode_target( "//executorch/backends/native/runtime/vulkan:vulkan_engine", ], external_deps = ["gflags"], + # Android builds go through xplat. + labels = ci.labels(ci.linux(ci.mode("fbsource//arvr/mode/android/linux/opt"))) if is_xplat() else [], visibility = ["PUBLIC"], ) -fbcode_target( - _kind = runtime.command_alias, +runtime.command_alias( name = "run_classification_vulkan", exe = ":run_classification", visibility = ["PUBLIC"], diff --git a/backends/native/runtime/vulkan/BUCK b/backends/native/runtime/vulkan/BUCK index 5028d4ae24e..3a9f8349127 100644 --- a/backends/native/runtime/vulkan/BUCK +++ b/backends/native/runtime/vulkan/BUCK @@ -1,10 +1,12 @@ load("@fbcode_macros//build_defs:build_file_migration.bzl", "fbcode_target", "non_fbcode_target") +load("@fbsource//xplat/executorch/build:runtime_wrapper.bzl", "runtime") load(":targets.bzl", "define_common_targets") oncall("executorch") -# Link the host engine against ET-VK configured for the selected Vulkan device, -# exposing optional features such as integer dot product. +# Link the engine against ET-VK configured for the selected Vulkan device, +# exposing optional features such as integer dot product. fbcode links the +# xplat ET-VK targets directly. fbcode_target( _kind = native.cxx_library, name = "xplat_vulkan_runtime", @@ -15,6 +17,16 @@ fbcode_target( visibility = ["PUBLIC"], ) +non_fbcode_target( + _kind = runtime.cxx_library, + name = "xplat_vulkan_runtime", + exported_deps = [ + "//executorch/backends/vulkan:vulkan_compute_api", + "//executorch/backends/vulkan:vulkan_graph_runtime", + ], + visibility = ["PUBLIC"], +) + # Any targets that should be shared between fbcode and xplat must be defined in # targets.bzl. This file can contain cell-only targets. diff --git a/backends/native/runtime/vulkan/targets.bzl b/backends/native/runtime/vulkan/targets.bzl index b7a2c005071..5034644f8d0 100644 --- a/backends/native/runtime/vulkan/targets.bzl +++ b/backends/native/runtime/vulkan/targets.bzl @@ -1,4 +1,4 @@ -load("@fbsource//xplat/executorch/build:runtime_wrapper.bzl", "is_xplat", "runtime") +load("@fbsource//xplat/executorch/build:runtime_wrapper.bzl", "runtime") def define_common_targets(): runtime.cxx_library( @@ -10,10 +10,6 @@ def define_common_targets(): visibility = ["//executorch/backends/native/..."], ) - # Host-only for now; Android integration is not wired up. - if is_xplat(): - return - runtime.cxx_library( name = "vulkan_passes", srcs = [ diff --git a/backends/native/test/runtime/vulkan/targets.bzl b/backends/native/test/runtime/vulkan/targets.bzl index 0add4242c86..afb7902c023 100644 --- a/backends/native/test/runtime/vulkan/targets.bzl +++ b/backends/native/test/runtime/vulkan/targets.bzl @@ -9,6 +9,28 @@ def define_common_targets(): ], ) + runtime.cxx_test( + name = "vulkan_passes_test", + srcs = [ + "test_fuse_quantized_embedding.cpp", + "test_fuse_quantized_linear.cpp", + "test_insert_prepack.cpp", + "test_lower_hf_attention.cpp", + "test_lower_rms_norm.cpp", + "test_materialize_view_copies.cpp", + ], + deps = [ + "//executorch/backends/native/runtime/vulkan:vulkan_passes", + "//executorch/backends/native/runtime/graph:argument", + "//executorch/backends/native/runtime/graph:graph", + "//executorch/backends/native/runtime/graph:graph_utils", + "//executorch/backends/native/runtime/graph:node", + "//executorch/backends/native/runtime/graph:scalar_type", + "//executorch/backends/native/runtime/graph:value", + "//executorch/backends/native/runtime/graph:tensor_meta", + ], + ) + if is_xplat(): return @@ -48,25 +70,3 @@ def define_common_targets(): "fbsource//third-party/swiftshader/lib/linux-x64:libvk_swiftshader_fbcode", ], ) - - runtime.cxx_test( - name = "vulkan_passes_test", - srcs = [ - "test_fuse_quantized_embedding.cpp", - "test_fuse_quantized_linear.cpp", - "test_insert_prepack.cpp", - "test_lower_hf_attention.cpp", - "test_lower_rms_norm.cpp", - "test_materialize_view_copies.cpp", - ], - deps = [ - "//executorch/backends/native/runtime/vulkan:vulkan_passes", - "//executorch/backends/native/runtime/graph:argument", - "//executorch/backends/native/runtime/graph:graph", - "//executorch/backends/native/runtime/graph:graph_utils", - "//executorch/backends/native/runtime/graph:node", - "//executorch/backends/native/runtime/graph:scalar_type", - "//executorch/backends/native/runtime/graph:value", - "//executorch/backends/native/runtime/graph:tensor_meta", - ], - )