GPU delegate: Add Android to tflite_extra_gles_deps, instead of manually linking against system libraries for EGL and GLESv3.

PiperOrigin-RevId: 312846221
Change-Id: I2179e81d026144c092573a254099838605b8648b
This commit is contained in:
Robert David 2020-05-22 11:51:36 -07:00 committed by TensorFlower Gardener
parent 227024b31a
commit c2aa840a2e
5 changed files with 17 additions and 80 deletions

View File

@ -29,17 +29,6 @@ cc_library(
name = "gl_delegate", name = "gl_delegate",
srcs = ["gl_delegate.cc"], srcs = ["gl_delegate.cc"],
hdrs = ["gl_delegate.h"], hdrs = ["gl_delegate.h"],
linkopts = select({
"//tensorflow:android": [
"-lEGL",
# We don't need to link libGLESv3, because if it exists,
# it is a symlink to libGLESv2.
# See Compatibility Definition Document:
# https://source.android.com/compatibility/10/android-10-cdd#7_1_4_1_opengl_es
"-lGLESv2",
],
"//conditions:default": [],
}),
deps = [ deps = [
"@com_google_absl//absl/base:core_headers", "@com_google_absl//absl/base:core_headers",
"@com_google_absl//absl/types:span", "@com_google_absl//absl/types:span",
@ -120,11 +109,6 @@ cc_binary(
linkopts = [ linkopts = [
"-Wl,-soname=libtensorflowlite_gpu_gl.so", "-Wl,-soname=libtensorflowlite_gpu_gl.so",
] + select({ ] + select({
"//tensorflow:android": [
"-lEGL",
"-lGLESv3",
"-fvisibility=hidden",
],
"//tensorflow:windows": [], "//tensorflow:windows": [],
"//conditions:default": [ "//conditions:default": [
"-fvisibility=hidden", "-fvisibility=hidden",
@ -136,7 +120,7 @@ cc_binary(
"nobuilder", "nobuilder",
"notap", "notap",
], ],
deps = [":gl_delegate"], deps = [":gl_delegate"] + tflite_extra_gles_deps(),
) )
# build -c opt --config android_arm64 --copt -Os --copt -DTFLITE_GPU_BINARY_RELEASE --copt --linkopt -s --strip always :libtensorflowlite_gpu_delegate.so # build -c opt --config android_arm64 --copt -Os --copt -DTFLITE_GPU_BINARY_RELEASE --copt --linkopt -s --strip always :libtensorflowlite_gpu_delegate.so
@ -145,11 +129,6 @@ cc_binary(
linkopts = [ linkopts = [
"-Wl,-soname=libtensorflowlite_gpu_delegate.so", "-Wl,-soname=libtensorflowlite_gpu_delegate.so",
] + select({ ] + select({
"//tensorflow:android": [
"-lEGL",
"-lGLESv3",
"-fvisibility=hidden",
],
"//tensorflow:windows": [], "//tensorflow:windows": [],
"//conditions:default": [ "//conditions:default": [
"-fvisibility=hidden", "-fvisibility=hidden",
@ -161,7 +140,7 @@ cc_binary(
"nobuilder", "nobuilder",
"notap", "notap",
], ],
deps = [":delegate"], deps = [":delegate"] + tflite_extra_gles_deps(),
) )
# bazel build -c opt --cpu ios_arm64 --copt -Os --copt -DTFLITE_GPU_BINARY_RELEASE --copt -fvisibility=hidden --linkopt -s --strip always --cxxopt=-std=c++14 :libtensorflowlite_gpu_metal --apple_platform_type=ios # bazel build -c opt --cpu ios_arm64 --copt -Os --copt -DTFLITE_GPU_BINARY_RELEASE --copt -fvisibility=hidden --linkopt -s --strip always --cxxopt=-std=c++14 :libtensorflowlite_gpu_metal --apple_platform_type=ios
@ -221,18 +200,9 @@ cc_library(
name = "delegate", name = "delegate",
srcs = ["delegate.cc"], srcs = ["delegate.cc"],
hdrs = ["delegate.h"], hdrs = ["delegate.h"],
linkopts = select({
"//tensorflow:android": [
"-lEGL",
# We don't need to link libGLESv3, because if it exists,
# it is a symlink to libGLESv2.
# See Compatibility Definition Document:
# https://source.android.com/compatibility/10/android-10-cdd#7_1_4_1_opengl_es
"-lGLESv2",
],
"//conditions:default": [],
}),
deps = [ deps = [
"@com_google_absl//absl/memory",
"@com_google_absl//absl/types:span",
"//tensorflow/lite:kernel_api", "//tensorflow/lite:kernel_api",
"//tensorflow/lite:minimal_logging", "//tensorflow/lite:minimal_logging",
"//tensorflow/lite/c:common", "//tensorflow/lite/c:common",
@ -246,7 +216,5 @@ cc_library(
"//tensorflow/lite/delegates/gpu/common:status", "//tensorflow/lite/delegates/gpu/common:status",
"//tensorflow/lite/delegates/gpu/gl:api2", "//tensorflow/lite/delegates/gpu/gl:api2",
"//tensorflow/lite/kernels/internal:optimized_base", "//tensorflow/lite/kernels/internal:optimized_base",
"@com_google_absl//absl/memory", ] + tflite_extra_gles_deps(),
"@com_google_absl//absl/types:span",
],
) )

View File

@ -1,8 +1,6 @@
load("@flatbuffers//:build_defs.bzl", "flatbuffer_cc_library") load("@flatbuffers//:build_defs.bzl", "flatbuffer_cc_library")
load( load("//tensorflow/core/platform:build_config_root.bzl", "tf_gpu_tests_tags")
"//tensorflow/core/platform:build_config_root.bzl", load("//tensorflow/lite:special_rules.bzl", "tflite_extra_gles_deps")
"tf_gpu_tests_tags",
)
package( package(
default_visibility = ["//visibility:public"], default_visibility = ["//visibility:public"],
@ -267,17 +265,11 @@ cc_library(
name = "gpu_api_delegate", name = "gpu_api_delegate",
srcs = ["gpu_api_delegate.cc"], srcs = ["gpu_api_delegate.cc"],
hdrs = ["gpu_api_delegate.h"], hdrs = ["gpu_api_delegate.h"],
linkopts = select({
"//tensorflow:android": [
"-lEGL",
"-lGLESv3",
],
"//conditions:default": [],
}),
deps = [ deps = [
":api", ":api",
":opencl_wrapper", ":opencl_wrapper",
":tensor_type_util", ":tensor_type_util",
"@com_google_absl//absl/types:span",
"//tensorflow/lite:kernel_api", "//tensorflow/lite:kernel_api",
"//tensorflow/lite/c:common", "//tensorflow/lite/c:common",
"//tensorflow/lite/delegates/gpu:api", "//tensorflow/lite/delegates/gpu:api",
@ -287,8 +279,7 @@ cc_library(
"//tensorflow/lite/delegates/gpu/common:model_transformer", "//tensorflow/lite/delegates/gpu/common:model_transformer",
"//tensorflow/lite/delegates/gpu/common:status", "//tensorflow/lite/delegates/gpu/common:status",
"//tensorflow/lite/delegates/gpu/common/transformations:general_transformations", "//tensorflow/lite/delegates/gpu/common/transformations:general_transformations",
"@com_google_absl//absl/types:span", ] + tflite_extra_gles_deps(),
],
) )
cc_library( cc_library(

View File

@ -35,10 +35,6 @@ cc_library(
cc_test( cc_test(
name = "opengl_test", name = "opengl_test",
srcs = ["opengl_test.cc"], srcs = ["opengl_test.cc"],
linkopts = [
"-lEGL",
"-lGLESv3",
],
tags = tf_gpu_tests_tags() + [ tags = tf_gpu_tests_tags() + [
"local", "local",
"nobuilder", "nobuilder",

View File

@ -1,8 +1,5 @@
load("//tensorflow/lite:special_rules.bzl", "tflite_portable_test_suite_combined") load("//tensorflow/lite:special_rules.bzl", "tflite_extra_gles_deps", "tflite_portable_test_suite_combined")
load( load("//tensorflow/core/platform:build_config_root.bzl", "tf_gpu_tests_tags")
"//tensorflow/core/platform:build_config_root.bzl",
"tf_gpu_tests_tags",
)
package( package(
default_visibility = ["//visibility:public"], default_visibility = ["//visibility:public"],
@ -32,10 +29,6 @@ cc_test(
name = "converter_test", name = "converter_test",
size = "small", size = "small",
srcs = ["converter_test.cc"], srcs = ["converter_test.cc"],
linkopts = [
"-lEGL",
"-lGLESv3",
],
tags = tf_gpu_tests_tags() + [ tags = tf_gpu_tests_tags() + [
"local", "local",
"nobuilder", "nobuilder",
@ -44,15 +37,15 @@ cc_test(
], ],
deps = [ deps = [
":converter", ":converter",
"@com_google_googletest//:gtest_main",
"@com_google_absl//absl/types:span",
"//tensorflow/lite/delegates/gpu/common:convert", "//tensorflow/lite/delegates/gpu/common:convert",
"//tensorflow/lite/delegates/gpu/common:shape", "//tensorflow/lite/delegates/gpu/common:shape",
"//tensorflow/lite/delegates/gpu/common:status", "//tensorflow/lite/delegates/gpu/common:status",
"//tensorflow/lite/delegates/gpu/gl:egl_environment", "//tensorflow/lite/delegates/gpu/gl:egl_environment",
"//tensorflow/lite/delegates/gpu/gl:gl_buffer", "//tensorflow/lite/delegates/gpu/gl:gl_buffer",
"//tensorflow/lite/delegates/gpu/gl:portable", "//tensorflow/lite/delegates/gpu/gl:portable",
"@com_google_absl//absl/types:span", ] + tflite_extra_gles_deps(),
"@com_google_googletest//:gtest_main",
],
) )
cc_library( cc_library(
@ -655,11 +648,9 @@ cc_library(
testonly = 1, testonly = 1,
srcs = ["test_util.cc"], srcs = ["test_util.cc"],
hdrs = ["test_util.h"], hdrs = ["test_util.h"],
linkopts = [
"-lEGL",
"-lGLESv3",
],
deps = [ deps = [
"@com_google_googletest//:gtest",
"@com_google_googletest//:gtest_main",
"//tensorflow/lite/delegates/gpu/common:model", "//tensorflow/lite/delegates/gpu/common:model",
"//tensorflow/lite/delegates/gpu/common:operations", "//tensorflow/lite/delegates/gpu/common:operations",
"//tensorflow/lite/delegates/gpu/common:status", "//tensorflow/lite/delegates/gpu/common:status",
@ -673,9 +664,7 @@ cc_library(
"//tensorflow/lite/delegates/gpu/gl:request_gpu_info", "//tensorflow/lite/delegates/gpu/gl:request_gpu_info",
"//tensorflow/lite/delegates/gpu/gl:runtime_options", "//tensorflow/lite/delegates/gpu/gl:runtime_options",
"//tensorflow/lite/delegates/gpu/gl/workgroups:default_calculator", "//tensorflow/lite/delegates/gpu/gl/workgroups:default_calculator",
"@com_google_googletest//:gtest", ] + tflite_extra_gles_deps(),
"@com_google_googletest//:gtest_main",
],
) )
cc_library( cc_library(

View File

@ -13,13 +13,6 @@ cc_library(
name = "native", name = "native",
srcs = ["gpu_delegate_jni.cc"], srcs = ["gpu_delegate_jni.cc"],
copts = tflite_copts(), copts = tflite_copts(),
linkopts = select({
"//tensorflow:android": [
"-lGLESv3",
"-lEGL",
],
"//conditions:default": [],
}),
tags = [ tags = [
"manual", "manual",
"notap", "notap",