mirror of
https://github.com/saymrwulf/pytorch.git
synced 2026-05-14 20:57:59 +00:00
Provide CMake option to enable Vulkan API. (#46503)
Summary: Pull Request resolved: https://github.com/pytorch/pytorch/pull/46503 Test Plan: Imported from OSS Reviewed By: IvanKobzarev Differential Revision: D24379144 Pulled By: AshkanAliabadi fbshipit-source-id: 8d8c57f96bbac2a44615828a3474c912704f3a85
This commit is contained in:
parent
3e041b503f
commit
6cd8b5e9a7
16 changed files with 59 additions and 4 deletions
|
|
@ -203,6 +203,7 @@ cmake_dependent_option(
|
|||
USE_VALGRIND "Use Valgrind. Only available on Linux." ON
|
||||
"LINUX" OFF)
|
||||
option(USE_VULKAN "Use Vulkan GPU backend" OFF)
|
||||
option(USE_VULKAN_API "Use Vulkan GPU backend v2" OFF)
|
||||
option(USE_VULKAN_WRAPPER "Use Vulkan wrapper" ON)
|
||||
option(USE_VULKAN_SHADERC_RUNTIME "Use Vulkan Shader compilation runtime(Needs shaderc lib)" OFF)
|
||||
option(USE_VULKAN_RELAXED_PRECISION "Use Vulkan relaxed precision(mediump)" OFF)
|
||||
|
|
@ -536,6 +537,10 @@ if(USE_VULKAN)
|
|||
string(APPEND CMAKE_CXX_FLAGS " -DUSE_VULKAN")
|
||||
endif()
|
||||
|
||||
if(USE_VULKAN_API)
|
||||
string(APPEND CMAKE_CXX_FLAGS " -DUSE_VULKAN_API")
|
||||
endif()
|
||||
|
||||
if(USE_VULKAN_WRAPPER)
|
||||
string(APPEND CMAKE_CXX_FLAGS " -DUSE_VULKAN_WRAPPER")
|
||||
endif()
|
||||
|
|
|
|||
|
|
@ -65,7 +65,8 @@ file(GLOB native_cpp "native/*.cpp")
|
|||
file(GLOB native_mkl_cpp "native/mkl/*.cpp")
|
||||
file(GLOB native_mkldnn_cpp "native/mkldnn/*.cpp")
|
||||
file(GLOB vulkan_cpp "vulkan/*.cpp")
|
||||
file(GLOB native_vulkan_cpp "native/vulkan/api/*.cpp" "native/vulkan/*.cpp")
|
||||
file(GLOB native_vulkan_cpp "native/vulkan/*.cpp")
|
||||
file(GLOB native_vulkan_api_cpp "native/vulkan/api/*.cpp" "native/vulkan/ops/*.cpp")
|
||||
|
||||
# Metal
|
||||
file(GLOB metal_h "metal/*.h")
|
||||
|
|
@ -124,6 +125,9 @@ if(AT_MKLDNN_ENABLED)
|
|||
endif()
|
||||
if(USE_VULKAN)
|
||||
set(all_cpu_cpp ${all_cpu_cpp} ${vulkan_cpp} ${native_vulkan_cpp} ${vulkan_generated_cpp})
|
||||
if(USE_VULKAN_API)
|
||||
set(all_cpu_cpp ${all_cpu_cpp} ${native_vulkan_api_cpp})
|
||||
endif()
|
||||
else()
|
||||
set(all_cpu_cpp ${all_cpu_cpp} ${vulkan_cpp})
|
||||
endif()
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
#pragma once
|
||||
|
||||
#ifdef USE_VULKAN_API
|
||||
|
||||
#include <ATen/native/vulkan/api/Common.h>
|
||||
#include <ATen/native/vulkan/api/Runtime.h>
|
||||
|
||||
|
|
@ -34,3 +36,5 @@ struct Adapter final {
|
|||
} // namespace vulkan
|
||||
} // namespace native
|
||||
} // namespace at
|
||||
|
||||
#endif /* USE_VULKAN_API */
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
#pragma once
|
||||
|
||||
#ifdef USE_VULKAN_API
|
||||
|
||||
#include <ATen/native/vulkan/api/Common.h>
|
||||
|
||||
#ifdef DEBUG
|
||||
|
|
@ -24,3 +26,5 @@
|
|||
#ifdef __clang__
|
||||
#pragma clang diagnostic pop
|
||||
#endif /* __clang__ */
|
||||
|
||||
#endif /* USE_VULKAN_API */
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
#pragma once
|
||||
|
||||
#ifdef USE_VULKAN_API
|
||||
|
||||
#include <ATen/native/vulkan/api/Common.h>
|
||||
|
||||
namespace at {
|
||||
|
|
@ -86,3 +88,5 @@ inline void Cache<Factory>::purge() {
|
|||
} // namespace vulkan
|
||||
} // namespace native
|
||||
} // namespace at
|
||||
|
||||
#endif /* USE_VULKAN_API */
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
#pragma once
|
||||
|
||||
#ifdef USE_VULKAN_API
|
||||
|
||||
#include <ATen/native/vulkan/api/Common.h>
|
||||
#include <ATen/native/vulkan/api/Descriptor.h>
|
||||
#include <ATen/native/vulkan/api/Pipeline.h>
|
||||
|
|
@ -93,3 +95,5 @@ inline Command::Buffer& Command::Buffer::operator=(Buffer&& buffer) {
|
|||
} // namespace vulkan
|
||||
} // namespace native
|
||||
} // namespace at
|
||||
|
||||
#endif /* USE_VULKAN_API */
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
#pragma once
|
||||
|
||||
#ifdef USE_VULKAN_API
|
||||
|
||||
#include <ATen/ATen.h>
|
||||
|
||||
#ifdef USE_VULKAN_SHADERC_RUNTIME
|
||||
|
|
@ -181,3 +183,5 @@ inline void Handle<Type, Deleter>::reset(Type payload) {
|
|||
} // namespace vulkan
|
||||
} // namespace native
|
||||
} // namespace at
|
||||
|
||||
#endif /* USE_VULKAN_API */
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
#pragma once
|
||||
|
||||
#ifdef USE_VULKAN_API
|
||||
|
||||
#include <ATen/native/vulkan/api/Common.h>
|
||||
#include <ATen/native/vulkan/api/Adapter.h>
|
||||
#include <ATen/native/vulkan/api/Command.h>
|
||||
|
|
@ -177,3 +179,5 @@ inline void Context::dispatch(
|
|||
} // namespace vulkan
|
||||
} // namespace native
|
||||
} // namespace at
|
||||
|
||||
#endif /* USE_VULKAN_API */
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
#pragma once
|
||||
|
||||
#ifdef USE_VULKAN_API
|
||||
|
||||
#include <ATen/native/vulkan/api/Common.h>
|
||||
#include <ATen/native/vulkan/api/Resource.h>
|
||||
#include <ATen/native/vulkan/api/Shader.h>
|
||||
|
|
@ -154,3 +156,5 @@ inline Descriptor::Set& Descriptor::Set::operator=(Set&& set) {
|
|||
} // namespace vulkan
|
||||
} // namespace native
|
||||
} // namespace at
|
||||
|
||||
#endif /* USE_VULKAN_API */
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
#pragma once
|
||||
|
||||
#ifdef USE_VULKAN_API
|
||||
|
||||
#include <ATen/native/vulkan/api/Common.h>
|
||||
#include <ATen/native/vulkan/api/Cache.h>
|
||||
#include <ATen/native/vulkan/api/Resource.h>
|
||||
|
|
@ -218,3 +220,5 @@ inline void Pipeline::Cache::purge() {
|
|||
} // namespace vulkan
|
||||
} // namespace native
|
||||
} // namespace at
|
||||
|
||||
#endif /* USE_VULKAN_API */
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
#pragma once
|
||||
|
||||
#ifdef USE_VULKAN_API
|
||||
|
||||
#include <ATen/native/vulkan/api/Common.h>
|
||||
#include <ATen/native/vulkan/api/Allocator.h>
|
||||
#include <ATen/native/vulkan/api/Cache.h>
|
||||
|
|
@ -375,3 +377,5 @@ inline VkFence Resource::Fence::handle(const bool add_to_waitlist) const {
|
|||
} // namespace vulkan
|
||||
} // namespace native
|
||||
} // namespace at
|
||||
|
||||
#endif /* USE_VULKAN_API */
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ namespace api {
|
|||
namespace {
|
||||
|
||||
struct Configuration final {
|
||||
#ifndef DEBUG
|
||||
#ifdef DEBUG
|
||||
static constexpr Runtime::Type kRuntime = Runtime::Type::Debug;
|
||||
#else
|
||||
static constexpr Runtime::Type kRuntime = Runtime::Type::Release;
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
#pragma once
|
||||
|
||||
#ifdef USE_VULKAN_API
|
||||
|
||||
#include <ATen/native/vulkan/api/Common.h>
|
||||
|
||||
namespace at {
|
||||
|
|
@ -61,3 +63,5 @@ Runtime* runtime();
|
|||
} // namespace vulkan
|
||||
} // namespace native
|
||||
} // namespace at
|
||||
|
||||
#endif /* USE_VULKAN_API */
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
#pragma once
|
||||
|
||||
#ifdef USE_VULKAN_API
|
||||
|
||||
#include <ATen/native/vulkan/api/Common.h>
|
||||
#include <ATen/native/vulkan/api/Cache.h>
|
||||
#include <c10/util/hash.h>
|
||||
|
|
@ -293,3 +295,5 @@ inline bool operator==(
|
|||
(_1.stageFlags == _2.stageFlags) &&
|
||||
(_1.pImmutableSamplers == _2.pImmutableSamplers);
|
||||
}
|
||||
|
||||
#endif /* USE_VULKAN_API */
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
#pragma once
|
||||
|
||||
#ifdef USE_VULKAN_API
|
||||
|
||||
#include <ATen/native/vulkan/api/Common.h>
|
||||
|
||||
#include <ATen/native/vulkan/api/Adapter.h>
|
||||
|
|
@ -10,3 +12,5 @@
|
|||
#include <ATen/native/vulkan/api/Resource.h>
|
||||
#include <ATen/native/vulkan/api/Runtime.h>
|
||||
#include <ATen/native/vulkan/api/Shader.h>
|
||||
|
||||
#endif /* USE_VULKAN_API */
|
||||
|
|
|
|||
|
|
@ -2,8 +2,6 @@
|
|||
|
||||
#ifdef USE_VULKAN_API
|
||||
|
||||
#include <ATen/native/vulkan/api/api.h>
|
||||
|
||||
namespace {
|
||||
|
||||
} // namespace
|
||||
|
|
|
|||
Loading…
Reference in a new issue