Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/source/backends-overview.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ Backends are the bridge between your exported model and the hardware it runs on.
| [CUDA](backends/cuda/cuda-overview.md) | Linux/Windows | GPU | NVIDIA GPU acceleration |
| [Core ML](backends/coreml/coreml-overview.md) | iOS, macOS | NPU/GPU/CPU | Apple devices, high performance |
| [Metal Performance Shaders](backends/mps/mps-overview.md) | iOS, macOS | GPU | Apple GPU acceleration |
| [Vulkan](backends/vulkan/vulkan-overview.md) | Android | GPU | Android GPU acceleration |
| [Vulkan](backends/vulkan/vulkan-overview.md) | Android, Linux, Windows | GPU | Android devices (mature); Desktops (experimental) |
| [Qualcomm](backends-qualcomm) | Android | NPU | Qualcomm SoCs |
| [MediaTek](backends-mediatek) | Android | NPU | MediaTek SoCs |
| [Arm Ethos-U](backends/arm-ethos-u/arm-ethos-u-overview.md) | Embedded | NPU | Arm MCUs |
Expand Down
3 changes: 2 additions & 1 deletion docs/source/backends/vulkan/vulkan-overview.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
The ExecuTorch Vulkan (ET-VK) backend enables ExecuTorch models to execute on
GPUs via the cross-platform [Vulkan API](https://www.vulkan.org/). Although the
Vulkan API support is almost ubiquitous among modern GPUs, the ExecuTorch Vulkan
backend is currently developed with a specific focus for **Android GPUs**.
backend is developed with a focus on **Android GPUs**, and support for desktop
platforms is experimental.

## Features

Expand Down
39 changes: 39 additions & 0 deletions install_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
# LICENSE file in the root directory of this source tree.

import functools
import os
import platform
import re
import subprocess
Expand Down Expand Up @@ -56,6 +57,44 @@ def is_cuda_available() -> bool:
return False


def is_vulkan_available() -> bool:
"""
Check if the Vulkan shader compiler (glslc) is available on the system.

glslc is the only build-time dependency for the Vulkan backend; the Vulkan
loader itself is dlopen()ed at runtime via volk. Restricted to Linux and
Windows, the desktop GPU platforms the backend supports (macOS would require
MoltenVK).

glslc is looked up on PATH and, failing that, under $VULKAN_SDK/{bin,Bin} to
match the find_program() HINTS the build uses (see pybind.cmake and
ShaderLibrary.cmake): the Windows Vulkan SDK sets VULKAN_SDK but does not add
its bin directory to PATH, so a PATH-only probe would miss it there.

Returns:
True if glslc is available on a supported platform, False otherwise.
"""
if sys.platform not in ("linux", "win32"):
return False
candidates = ["glslc"]
vulkan_sdk = os.environ.get("VULKAN_SDK")
if vulkan_sdk:
glslc_name = "glslc.exe" if sys.platform == "win32" else "glslc"
candidates += [
os.path.join(vulkan_sdk, "bin", glslc_name),
os.path.join(vulkan_sdk, "Bin", glslc_name),
]
for glslc in candidates:
try:
subprocess.run(
[glslc, "--version"], capture_output=True, text=True, check=True
)
return True
except Exception:
continue
return False


@functools.lru_cache(maxsize=1)
def _get_cuda_version():
"""
Expand Down
21 changes: 21 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -889,6 +889,27 @@ def run(self): # noqa C901
):
cmake_configuration_args += ["-DEXECUTORCH_BUILD_CUDA=ON"]

# Auto-enable the Vulkan backend when its only build-time dependency,
# the glslc shader compiler, is available (mirrors the CUDA detection
# above). Unlike CUDA, the backend also needs third-party submodules
# that are not in the default checkout set, so gate on their presence
# too: an incidental glslc must not turn a working source build into a
# hard CMake failure. An explicit -DEXECUTORCH_BUILD_VULKAN=ON still
# flows through and surfaces the backend's own missing-submodule error.
vulkan_third_party = os.path.join(
os.path.dirname(os.path.abspath(__file__)),
"backends/vulkan/third-party/volk/volk.c",
)
if (
not minimal_build
and os.path.exists(vulkan_third_party)
and install_utils.is_vulkan_available()
and install_utils.is_cmake_option_on(
cmake_configuration_args, "EXECUTORCH_BUILD_VULKAN", default=True
)
):
cmake_configuration_args += ["-DEXECUTORCH_BUILD_VULKAN=ON"]

# Check if QNN SDK is available (via QNN_SDK_ROOT env var), and if so,
# enable building the Qualcomm backend by default.
qnn_sdk_root = os.environ.get("QNN_SDK_ROOT", "").strip()
Expand Down
Loading