aboutsummaryrefslogtreecommitdiffhomepage
path: root/tensorflow/tools
diff options
context:
space:
mode:
authorGravatar Allen Lavoie <allenl@google.com>2017-09-21 11:29:45 -0700
committerGravatar TensorFlower Gardener <gardener@tensorflow.org>2017-09-21 11:33:40 -0700
commit5c7f9e316d8c7735308a217310350d416d7498cc (patch)
treea3457b97367fe6b1ed4ad47a4284cac88495ae16 /tensorflow/tools
parent054b88233bf6d6bc5b953fca50dbb01d108b2d18 (diff)
Remove RTLD_GLOBAL when loading pywrap_tensorflow
Splits out a shared object (//tensorflow/libtensorflow_framework.so) with core TensorFlow functionality but neither ops nor kernels. This object does include registries for ops, kernels, filesystems, etc. The expectation is that shared objects containing custom ops will have a runtime dependency on this framework shared object: TensorFlow will load the custom op shared object, and the custom op shared object will use the symbols from the framework shared object to register its ops/kernels/etc. rather than (as before this change) relying on those symbols being in the global symbol table. In this mode, TensorFlow artifacts (_pywrap_tensorflow.so for Python, libtensorflow.so for the C API; currently excluding Android artifacts) will depend on the framework shared object, which will be packaged with the Python pip package and other language distributions. This means that custom ops targeting the framework shared object will work in any language (C++, Java, Go; previously custom ops in these languages required custom Bazel builds). Adds a config option which reproduces the old behavior (--config=monolithic), which for Python means building a monolithic pywrap_tensorflow shared object and loading its symbols into the global symbol table (with RTLD_GLOBAL). As before, there will be no extra-Bazel custom op support for other languages when compiling in this mode. Does not change behavior on Windows; the cmake build is still monolithic. Requires using tf_cc_binary, tf_cc_test, and (rarely) tf_cc_shared_object rules to link in the framework shared object when adding new TensorFlow build rules. PiperOrigin-RevId: 169572746
Diffstat (limited to 'tensorflow/tools')
-rw-r--r--tensorflow/tools/benchmark/BUILD3
-rwxr-xr-xtensorflow/tools/ci_build/builds/test_user_ops.sh4
-rw-r--r--tensorflow/tools/graph_transforms/BUILD7
-rw-r--r--tensorflow/tools/lib_package/BUILD9
-rwxr-xr-xtensorflow/tools/lib_package/libtensorflow_test.sh5
-rw-r--r--tensorflow/tools/mlpbtxt/BUILD6
-rw-r--r--tensorflow/tools/pip_package/BUILD1
-rw-r--r--tensorflow/tools/proto_text/BUILD4
8 files changed, 29 insertions, 10 deletions
diff --git a/tensorflow/tools/benchmark/BUILD b/tensorflow/tools/benchmark/BUILD
index a2f0e15722..048035f2b1 100644
--- a/tensorflow/tools/benchmark/BUILD
+++ b/tensorflow/tools/benchmark/BUILD
@@ -9,6 +9,7 @@ load(
"//tensorflow:tensorflow.bzl",
"tf_copts",
"tf_cc_test",
+ "tf_cc_binary",
)
exports_files(["LICENSE"])
@@ -64,7 +65,7 @@ tf_cc_test(
# --crosstool_top=//external:android/crosstool \
# --cpu=armeabi-v7a \
# --host_crosstool_top=@bazel_tools//tools/cpp:toolchain
-cc_binary(
+tf_cc_binary(
name = "benchmark_model",
testonly = 1,
srcs = ["benchmark_model_main.cc"],
diff --git a/tensorflow/tools/ci_build/builds/test_user_ops.sh b/tensorflow/tools/ci_build/builds/test_user_ops.sh
index c3800cc256..479b1931ca 100755
--- a/tensorflow/tools/ci_build/builds/test_user_ops.sh
+++ b/tensorflow/tools/ci_build/builds/test_user_ops.sh
@@ -79,6 +79,8 @@ pushd "${TMP_DIR}"
# Obtain paths include and lib paths to the TensorFlow installation
TF_INC=$("${PYTHON_BIN_PATH}" \
-c 'import tensorflow as tf; print(tf.sysconfig.get_include())')
+TF_LIB=$("${PYTHON_BIN_PATH}" \
+ -c 'import tensorflow as tf; print(tf.sysconfig.get_lib())')
if [[ -z "${TF_INC}" ]]; then
die "FAILED to determine TensorFlow include path"
@@ -143,7 +145,7 @@ if [[ ${IS_GPU} == "0" ]]; then
"${GPP_BIN}" -std=c++11 ${EXTRA_GPP_FLAGS} \
-shared "${SRC_FILE}" -o "${USER_OP_SO}" \
- -fPIC ${TF_INCLUDE_PATH} || \
+ -fPIC ${TF_INCLUDE_PATH} -L "${TF_LIB}" -ltensorflow_framework || \
die "g++ compilation of ${SRC_FILE} FAILED"
else
diff --git a/tensorflow/tools/graph_transforms/BUILD b/tensorflow/tools/graph_transforms/BUILD
index f28b2b02ae..7975491a28 100644
--- a/tensorflow/tools/graph_transforms/BUILD
+++ b/tensorflow/tools/graph_transforms/BUILD
@@ -9,6 +9,7 @@ load(
"//tensorflow:tensorflow.bzl",
"if_not_windows",
"tf_copts",
+ "tf_cc_binary",
"tf_cc_test",
"tf_py_test",
)
@@ -218,7 +219,7 @@ cc_library(
],
)
-cc_binary(
+tf_cc_binary(
name = "transform_graph",
copts = tf_copts(),
linkstatic = 1,
@@ -264,7 +265,7 @@ cc_library(
],
)
-cc_binary(
+tf_cc_binary(
name = "summarize_graph",
copts = tf_copts(),
linkstatic = 1,
@@ -274,7 +275,7 @@ cc_binary(
],
)
-cc_binary(
+tf_cc_binary(
name = "compare_graphs",
srcs = ["compare_graphs.cc"],
copts = tf_copts(),
diff --git a/tensorflow/tools/lib_package/BUILD b/tensorflow/tools/lib_package/BUILD
index 494ddd2f5d..d522c9d395 100644
--- a/tensorflow/tools/lib_package/BUILD
+++ b/tensorflow/tools/lib_package/BUILD
@@ -42,6 +42,14 @@ pkg_tar(
# are resolved, otherwise these rules break when built
# with Python 3.
tags = ["manual"],
+ deps = [":common_deps"],
+)
+
+# Shared objects that all TensorFlow libraries depend on.
+pkg_tar(
+ name = "common_deps",
+ files = ["//tensorflow:libtensorflow_framework.so"],
+ tags = ["manual"],
)
pkg_tar(
@@ -66,6 +74,7 @@ pkg_tar(
# are resolved, otherwise these rules break when built
# with Python 3.
tags = ["manual"],
+ deps = [":common_deps"],
)
pkg_tar(
diff --git a/tensorflow/tools/lib_package/libtensorflow_test.sh b/tensorflow/tools/lib_package/libtensorflow_test.sh
index 7dfe8eefcc..f0294bc2bd 100755
--- a/tensorflow/tools/lib_package/libtensorflow_test.sh
+++ b/tensorflow/tools/lib_package/libtensorflow_test.sh
@@ -38,8 +38,9 @@ cd ${TEST_TMPDIR}
mkdir tensorflow
${TAR} -xzf ${TARFILE} -Ctensorflow
-# Compile the test .c file
-${CC} ${CFILE} -Itensorflow/include -Ltensorflow/lib -ltensorflow -oa.out
+# Compile the test .c file. Assumes with_framework_lib=True.
+${CC} ${CFILE} -Itensorflow/include -Ltensorflow/lib\
+ -ltensorflow_framework -ltensorflow -oa.out
# Execute it, with the shared library available.
# DYLD_LIBRARY_PATH is used on OS X, LD_LIBRARY_PATH on Linux.
diff --git a/tensorflow/tools/mlpbtxt/BUILD b/tensorflow/tools/mlpbtxt/BUILD
index fc63e9a0b7..f9f48c6500 100644
--- a/tensorflow/tools/mlpbtxt/BUILD
+++ b/tensorflow/tools/mlpbtxt/BUILD
@@ -6,12 +6,14 @@ package(default_visibility = ["//visibility:private"])
licenses(["notice"]) # Apache 2.0
+load("//tensorflow:tensorflow.bzl", "tf_cc_binary")
+
exports_files([
"LICENSE",
"placeholder.txt",
])
-cc_binary(
+tf_cc_binary(
name = "tomlpbtxt",
srcs = ["tomlpbtxt.cc"],
deps = [
@@ -21,7 +23,7 @@ cc_binary(
],
)
-cc_binary(
+tf_cc_binary(
name = "frommlpbtxt",
srcs = ["frommlpbtxt.cc"],
deps = [
diff --git a/tensorflow/tools/pip_package/BUILD b/tensorflow/tools/pip_package/BUILD
index 493d06a0d6..3c4e1b66bc 100644
--- a/tensorflow/tools/pip_package/BUILD
+++ b/tensorflow/tools/pip_package/BUILD
@@ -179,6 +179,7 @@ sh_binary(
"//tensorflow/python/eager:eager_pip",
"//tensorflow/python/saved_model:saved_model",
"//tensorflow/python/tools:tools_pip",
+ "//tensorflow/python:test_ops",
"//tensorflow/tools/dist_test/server:grpc_tensorflow_server",
],
}) + if_mkl(["//third_party/mkl:intel_binary_blob"]),
diff --git a/tensorflow/tools/proto_text/BUILD b/tensorflow/tools/proto_text/BUILD
index 3a60c8c958..ca62ee2fdf 100644
--- a/tensorflow/tools/proto_text/BUILD
+++ b/tensorflow/tools/proto_text/BUILD
@@ -20,6 +20,7 @@ exports_files([
load(
"//tensorflow:tensorflow.bzl",
"tf_generate_proto_text_sources",
+ "tf_cc_test",
)
# For platform specific build config
@@ -35,6 +36,7 @@ cc_binary(
deps = [
":gen_proto_text_functions_lib",
"//tensorflow/core:lib_proto_parsing",
+ "@protobuf_archive//:protobuf",
],
)
@@ -75,7 +77,7 @@ tf_generate_proto_text_sources(
srcs_relative_dir = "tensorflow/tools/proto_text/",
)
-cc_test(
+tf_cc_test(
name = "gen_proto_text_functions_lib_test",
size = "small",
srcs = [