Skip to content

Commit 866dbd3

Browse files
[executorch][native-vk] Expose Vulkan device features and stage Half outputs as Float (pytorch#23464)
This PR was created by the merge bot to help merge the original PR into the main branch. ghstack PR number: pytorch#23429 by @digantdesai ^ Please use this as the source of truth for the PR details, comments, and reviews ghstack PR base: https://github.com/pytorch/executorch/tree/gh/digantdesai/124/base ghstack PR head: https://github.com/pytorch/executorch/tree/gh/digantdesai/124/head Merge bot PR base: https://github.com/pytorch/executorch/tree/gh/digantdesai/123/orig Merge bot PR head: https://github.com/pytorch/executorch/tree/gh/digantdesai/124/orig Differential Revision: [D119601879](https://our.internmc.facebook.com/intern/diff/D119601879/) @diff-train-skip-merge cc @SS-JIA @manuelcandales @digantdesai @cbilgin --------- Co-authored-by: Digant Desai <digantdesai@meta.com>
1 parent 56594e4 commit 866dbd3

4 files changed

Lines changed: 21 additions & 7 deletions

File tree

‎backends/native/examples/vision/BUCK‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,7 @@ load("@fbsource//xplat/executorch/build:runtime_wrapper.bzl", "runtime")
44
oncall("executorch")
55

66
# Run an exported .ptn on the Vulkan engine and check the logits against the
7-
# eager reference. Host-runnable on SwiftShader through the engine's transitive
8-
# ET-VK dependency.
7+
# eager reference. Runs on the host's system Vulkan device.
98
fbcode_target(
109
_kind = runtime.cxx_binary,
1110
name = "run_classification",

‎backends/native/runtime/vulkan/BUCK‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,18 @@ load(":targets.bzl", "define_common_targets")
33

44
oncall("executorch")
55

6+
# Link the host engine against ET-VK configured for the selected Vulkan device,
7+
# exposing optional features such as integer dot product.
8+
fbcode_target(
9+
_kind = native.cxx_library,
10+
name = "xplat_vulkan_runtime",
11+
exported_deps = [
12+
"@fbsource//xplat/executorch/backends/vulkan:vulkan_compute_api",
13+
"@fbsource//xplat/executorch/backends/vulkan:vulkan_graph_runtime",
14+
],
15+
visibility = ["PUBLIC"],
16+
)
17+
618
# Any targets that should be shared between fbcode and xplat must be defined in
719
# targets.bzl. This file can contain cell-only targets.
820

‎backends/native/runtime/vulkan/VulkanEngineExecutable.cpp‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1424,7 +1424,12 @@ class VulkanEngineExecutable final : public EngineExecutable {
14241424
graph_->set_output_tensor(output, false);
14251425
output_staging_.push_back(kNoOutputStaging);
14261426
} else {
1427-
output_staging_.push_back(graph_->set_output_tensor(output));
1427+
const ScalarType output_type = meta_of(outputs_[i]).dtype;
1428+
const vkapi::ScalarType staging_type = output_type == ScalarType::Half
1429+
? vkapi::kFloat
1430+
: to_vk_dtype(device_dtype(output_type));
1431+
output_staging_.push_back(
1432+
graph_->set_output_tensor(output, staging_type));
14281433
}
14291434
}
14301435

‎backends/native/runtime/vulkan/targets.bzl‎

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -69,10 +69,8 @@ def define_common_targets():
6969
"//executorch/runtime/core:core",
7070
":vulkan_passes",
7171
# ET-VK: ComputeGraph + operator registry + shaders (link_whole, so
72-
# the static op registrations survive), and the Vulkan API layer
73-
# (Runtime / Adapter / Context; SwiftShader on a headless host).
74-
"//executorch/backends/vulkan:vulkan_graph_runtime",
75-
"//executorch/backends/vulkan:vulkan_compute_api",
72+
# the static op registrations survive), and the Vulkan API layer.
73+
":xplat_vulkan_runtime",
7674
],
7775
visibility = ["PUBLIC"],
7876
)

0 commit comments

Comments
 (0)