Skip to content

Commit 829a2bd

Browse files
SS-JIAfacebook-github-bot
authored andcommitted
Set up Vulkan executor_runner (#2239)
Summary: Pull Request resolved: #2239 imported-using-ghimport Test Plan: Imported from OSS Reviewed By: kirklandsign Differential Revision: D54512106 Pulled By: SS-JIA fbshipit-source-id: 3a52d2051b62c4dc9bcf1d252b9636fcae182fe4
1 parent 6c9880c commit 829a2bd

File tree

3 files changed

+43
-2
lines changed

3 files changed

+43
-2
lines changed

backends/vulkan/CMakeLists.txt

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,9 @@ if(NOT FLATC_EXECUTABLE)
3232
set(FLATC_EXECUTABLE flatc)
3333
endif()
3434

35+
# Include this file to access target_link_options_shared_lib
36+
include(${EXECUTORCH_ROOT}/build/Utils.cmake)
37+
3538
# ATen Vulkan Libs
3639

3740
set(PYTORCH_PATH ${EXECUTORCH_ROOT}/third-party/pytorch)
@@ -92,6 +95,29 @@ target_link_libraries(vulkan_backend PRIVATE executorch)
9295

9396
target_compile_options(vulkan_backend PRIVATE ${VULKAN_CXX_FLAGS})
9497

98+
# This is required to ensure that vulkan_backend gets linked with
99+
# --whole-archive since backends are registered via static variables that would
100+
# otherwise be discarded
101+
target_link_options_shared_lib(vulkan_backend)
102+
103+
# Executor Runner
104+
105+
if(NOT CMAKE_TOOLCHAIN_FILE MATCHES ".*iOS\.cmake$")
106+
set(VULKAN_RUNNER_SRCS ${_executor_runner__srcs})
107+
list(TRANSFORM VULKAN_RUNNER_SRCS PREPEND "${EXECUTORCH_ROOT}/")
108+
add_executable(vulkan_executor_runner ${VULKAN_RUNNER_SRCS})
109+
target_link_libraries(vulkan_executor_runner ${_executor_runner_libs})
110+
target_link_libraries(vulkan_executor_runner vulkan_schema)
111+
target_link_libraries(vulkan_executor_runner vulkan_backend)
112+
target_compile_options(vulkan_executor_runner PUBLIC ${VULKAN_CXX_FLAGS})
113+
114+
add_library(vulkan_executor_runner_lib STATIC ${VULKAN_RUNNER_SRCS})
115+
target_link_libraries(vulkan_executor_runner_lib ${_executor_runner_libs})
116+
target_link_libraries(vulkan_executor_runner_lib vulkan_schema)
117+
target_link_libraries(vulkan_executor_runner_lib vulkan_backend)
118+
target_compile_options(vulkan_executor_runner_lib PUBLIC ${VULKAN_CXX_FLAGS})
119+
endif()
120+
95121
# Test targets
96122

97123
if(EXECUTORCH_BUILD_GTESTS)

backends/vulkan/__init__.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# Copyright (c) Meta Platforms, Inc. and affiliates.
2+
# All rights reserved.
3+
#
4+
# This source code is licensed under the BSD-style license found in the
5+
# LICENSE file in the root directory of this source tree.
6+
7+
from .partitioner.vulkan_partitioner import VulkanPartitioner
8+
9+
from .vulkan_preprocess import VulkanBackend
10+
11+
__all__ = [
12+
"VulkanPartitioner",
13+
"VulkanBackend",
14+
]

backends/vulkan/serialization/vulkan_graph_serialize.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
from typing import ClassVar, List
1414

1515
# pyre-ignore[21]: Could not find module `executorch.exir._serialize._bindings`.
16-
import executorch.exir._serialize._bindings as bindings # @manual=//executorch/exir/_serialize:_bindings
1716
import pkg_resources
1817
import torch
1918

@@ -23,6 +22,8 @@
2322
)
2423
from executorch.exir._serialize._dataclass import _DataclassEncoder
2524

25+
from executorch.exir._serialize._flatbuffer import _flatc_compile
26+
2627

2728
def convert_to_flatbuffer(vk_graph: VkGraph) -> bytes:
2829
vk_graph_json = json.dumps(vk_graph, cls=_DataclassEncoder)
@@ -35,7 +36,7 @@ def convert_to_flatbuffer(vk_graph: VkGraph) -> bytes:
3536
with open(json_path, "wb") as json_file:
3637
json_file.write(vk_graph_json.encode("ascii"))
3738
# pyre-ignore
38-
bindings.flatc_compile(d, schema_path, json_path)
39+
_flatc_compile(d, schema_path, json_path)
3940
output_path = os.path.join(d, "schema.bin")
4041
with open(output_path, "rb") as output_file:
4142
return output_file.read()

0 commit comments

Comments
 (0)