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",
srcs = ["gl_delegate.cc"],
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 = [
"@com_google_absl//absl/base:core_headers",
"@com_google_absl//absl/types:span",
@ -120,11 +109,6 @@ cc_binary(
linkopts = [
"-Wl,-soname=libtensorflowlite_gpu_gl.so",
] + select({
"//tensorflow:android": [
"-lEGL",
"-lGLESv3",
"-fvisibility=hidden",
],
"//tensorflow:windows": [],
"//conditions:default": [
"-fvisibility=hidden",
@ -136,7 +120,7 @@ cc_binary(
"nobuilder",
"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
@ -145,11 +129,6 @@ cc_binary(
linkopts = [
"-Wl,-soname=libtensorflowlite_gpu_delegate.so",
] + select({
"//tensorflow:android": [
"-lEGL",
"-lGLESv3",
"-fvisibility=hidden",
],
"//tensorflow:windows": [],
"//conditions:default": [
"-fvisibility=hidden",
@ -161,7 +140,7 @@ cc_binary(
"nobuilder",
"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
@ -221,18 +200,9 @@ cc_library(
name = "delegate",
srcs = ["delegate.cc"],
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 = [
"@com_google_absl//absl/memory",
"@com_google_absl//absl/types:span",
"//tensorflow/lite:kernel_api",
"//tensorflow/lite:minimal_logging",
"//tensorflow/lite/c:common",
@ -246,7 +216,5 @@ cc_library(
"//tensorflow/lite/delegates/gpu/common:status",
"//tensorflow/lite/delegates/gpu/gl:api2",
"//tensorflow/lite/kernels/internal:optimized_base",
"@com_google_absl//absl/memory",
"@com_google_absl//absl/types:span",
],
] + tflite_extra_gles_deps(),
)

View File

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

View File

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

View File

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

View File

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