Add Vulkan memory objects to TfLite GPU API.
PiperOrigin-RevId: 288871910 Change-Id: I0e2598db746bc2b57724cacc8840684e44fb1730
This commit is contained in:
parent
2ffb2fbed3
commit
25a06bc503
|
@ -204,6 +204,7 @@ cc_library(
|
|||
"@com_google_absl//absl/types:span",
|
||||
"@com_google_absl//absl/types:variant",
|
||||
"@opencl_headers",
|
||||
"@vulkan_headers//:vulkan_headers_no_prototypes",
|
||||
],
|
||||
)
|
||||
|
||||
|
|
|
@ -44,6 +44,7 @@ limitations under the License.
|
|||
#include "tensorflow/lite/delegates/gpu/common/status.h"
|
||||
#include "tensorflow/lite/delegates/gpu/common/util.h"
|
||||
#include "tensorflow/lite/delegates/gpu/gl/portable_gl31.h"
|
||||
#include <vulkan/vulkan.h>
|
||||
|
||||
namespace tflite {
|
||||
namespace gpu {
|
||||
|
@ -103,6 +104,13 @@ struct OpenClTexture {
|
|||
// TODO(akulik): should it specify texture format?
|
||||
};
|
||||
|
||||
struct VulkanMemory {
|
||||
VulkanMemory() = default;
|
||||
explicit VulkanMemory(VkDeviceMemory new_memory) : memory(new_memory) {}
|
||||
|
||||
VkDeviceMemory memory;
|
||||
};
|
||||
|
||||
struct CpuMemory {
|
||||
CpuMemory() = default;
|
||||
CpuMemory(void* new_data, size_t new_size_bytes)
|
||||
|
|
|
@ -38,6 +38,7 @@ load("//third_party/pasta:workspace.bzl", pasta = "repo")
|
|||
load("//third_party/psimd:workspace.bzl", psimd = "repo")
|
||||
load("//third_party/pthreadpool:workspace.bzl", pthreadpool = "repo")
|
||||
load("//third_party/sobol_data:workspace.bzl", sobol_data = "repo")
|
||||
load("//third_party/vulkan_headers:workspace.bzl", vulkan_headers = "repo")
|
||||
|
||||
def initialize_third_party():
|
||||
""" Load third party repositories. See above load() statements. """
|
||||
|
@ -59,6 +60,7 @@ def initialize_third_party():
|
|||
psimd()
|
||||
pthreadpool()
|
||||
sobol_data()
|
||||
vulkan_headers()
|
||||
|
||||
# Sanitize a dependency so that it works correctly from code that includes
|
||||
# TensorFlow as a submodule.
|
||||
|
|
|
@ -0,0 +1,56 @@
|
|||
package(default_visibility = ["//visibility:public"])
|
||||
|
||||
licenses(["notice"])
|
||||
|
||||
exports_files(["LICENSE"])
|
||||
|
||||
VULKAN_HDRS = [
|
||||
"include/vulkan/vk_platform.h",
|
||||
"include/vulkan/vk_sdk_platform.h",
|
||||
"include/vulkan/vulkan.h",
|
||||
"include/vulkan/vulkan_core.h",
|
||||
]
|
||||
|
||||
VULKAN_TEXTUAL_HDRS = [
|
||||
"include/vulkan/vulkan_android.h",
|
||||
"include/vulkan/vulkan_fuchsia.h",
|
||||
"include/vulkan/vulkan_ggp.h",
|
||||
"include/vulkan/vulkan_ios.h",
|
||||
"include/vulkan/vulkan_macos.h",
|
||||
"include/vulkan/vulkan_metal.h",
|
||||
"include/vulkan/vulkan_vi.h",
|
||||
"include/vulkan/vulkan_wayland.h",
|
||||
"include/vulkan/vulkan_win32.h",
|
||||
"include/vulkan/vulkan_xcb.h",
|
||||
"include/vulkan/vulkan_xlib.h",
|
||||
"include/vulkan/vulkan_xlib_xrandr.h",
|
||||
]
|
||||
|
||||
# The main vulkan public headers for applications. This excludes headers
|
||||
# designed for ICDs and layers.
|
||||
cc_library(
|
||||
name = "vulkan_headers",
|
||||
hdrs = VULKAN_HDRS,
|
||||
includes = ["include"],
|
||||
textual_hdrs = VULKAN_TEXTUAL_HDRS,
|
||||
)
|
||||
|
||||
# Like :vulkan_headers but defining VK_NO_PROTOTYPES to disable the
|
||||
# inclusion of C function prototypes. Useful if dynamically loading
|
||||
# all symbols via dlopen/etc.
|
||||
cc_library(
|
||||
name = "vulkan_headers_no_prototypes",
|
||||
hdrs = VULKAN_HDRS,
|
||||
defines = ["VK_NO_PROTOTYPES"],
|
||||
includes = ["include"],
|
||||
textual_hdrs = VULKAN_TEXTUAL_HDRS,
|
||||
)
|
||||
|
||||
# Provides a C++-ish interface to Vulkan.
|
||||
cc_library(
|
||||
name = "vulkan_hpp",
|
||||
hdrs = ["include/vulkan/vulkan.hpp"],
|
||||
defines = ["VULKAN_HPP_NO_EXCEPTIONS"],
|
||||
includes = ["include"],
|
||||
deps = [":vulkan_headers"],
|
||||
)
|
|
@ -0,0 +1,15 @@
|
|||
"""Loads Vulkan-Headers, used by TF Lite."""
|
||||
|
||||
load("//third_party:repo.bzl", "third_party_http_archive")
|
||||
|
||||
def repo():
|
||||
third_party_http_archive(
|
||||
name = "vulkan_headers",
|
||||
strip_prefix = "Vulkan-Headers-0e57fc1cfa56a203efe43e4dfb9b3c9e9b105593",
|
||||
sha256 = "096c4bff0957e9d6777b47d01c63e99ad9cf9d57e52be688a661b2473f8e52cb",
|
||||
urls = [
|
||||
"https://mirror.bazel.build/github.com/KhronosGroup/Vulkan-Headers/archive/0e57fc1cfa56a203efe43e4dfb9b3c9e9b105593.tar.gz",
|
||||
"https://github.com/KhronosGroup/Vulkan-Headers/archive/0e57fc1cfa56a203efe43e4dfb9b3c9e9b105593.tar.gz",
|
||||
],
|
||||
build_file = "//third_party/vulkan_headers:BUILD.bazel",
|
||||
)
|
Loading…
Reference in New Issue