Enable TFLite GPU delegate cmake build for normal Linux systems

Added Vulkan repo which is needed for delegates/gpu/api.h

$ mkdir tf-build; cd tf-build
$ cmake -DTFLITE_ENABLE_GPU=ON -DCMAKE_BUILD_TYPE=Release ../tensorflow/lite/
$ make all benchmark_model -j
$ ./benchmark_model --graph=mobilenet_v1_1.0_224.tflite --use_gpu=true

PiperOrigin-RevId: 336790174
Change-Id: Ia050b089502659b82baac2473d04f79d969ee445
This commit is contained in:
Terry Heo 2020-10-12 18:55:21 -07:00 committed by TensorFlower Gardener
parent 1da2ac286f
commit a892d4b8a4
3 changed files with 58 additions and 1 deletions

View File

@ -191,6 +191,7 @@ if(TFLITE_ENABLE_FLEX)
endif()
if(TFLITE_ENABLE_GPU)
find_package(opencl_headers REQUIRED)
find_package(vulkan_headers REQUIRED)
populate_tflite_source_vars(
"delegates/gpu/cl" TFLITE_DELEGATES_GPU_CL_SRCS
FILTER "(_test|gl_interop|egl_sync)\\.(cc|h)$"
@ -239,7 +240,7 @@ if(TFLITE_ENABLE_GPU)
${TFLITE_DELEGATES_GPU_COMMON_MEMORY_MANAGEMENT_SRCS}
${TFLITE_DELEGATES_GPU_COMMON_TRANSFORMATIONS_SRCS}
)
list(APPEND TFLITE_TARGET_PUBLIC_OPTIONS "-DCL_DELEGATE_NO_GL")
list(APPEND TFLITE_TARGET_PUBLIC_OPTIONS "-DCL_DELEGATE_NO_GL" "-DEGL_NO_X11")
list(APPEND TFLITE_TARGET_DEPENDENCIES
absl::any
absl::flat_hash_map

View File

@ -0,0 +1,16 @@
#
# Copyright 2020 The TensorFlow Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
include(vulkan_headers)

View File

@ -0,0 +1,40 @@
#
# Copyright 2020 The TensorFlow Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
if(TARGET vulkan_headers OR vulkan_headers_POPULATED)
return()
endif()
include(FetchContent)
OverridableFetchContent_Declare(
vulkan_headers
GIT_REPOSITORY https://github.com/KhronosGroup/Vulkan-Headers
# GIT_TAG must keep in sync with tensorflow/third_party/vulkan_headers/workspace.bzl
GIT_TAG 0e57fc1cfa56a203efe43e4dfb9b3c9e9b105593
GIT_PROGRESS TRUE
PREFIX "${CMAKE_BINARY_DIR}"
SOURCE_DIR "${CMAKE_BINARY_DIR}/vulkan_headers"
)
OverridableFetchContent_GetProperties(vulkan_headers)
if(NOT vulkan_headers)
OverridableFetchContent_Populate(vulkan_headers)
endif()
include_directories(
AFTER
"${vulkan_headers_SOURCE_DIR}/include"
)