Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support --config=monolithic in tf.sysconfig.get_link_flags() #15139

Merged
merged 5 commits into from
Dec 15, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions tensorflow/core/public/version.h
Original file line number Diff line number Diff line change
Expand Up @@ -119,5 +119,7 @@ extern const char* tf_compiler_version();
extern const char* tf_git_version();
// Value of the _GLIBCXX_USE_CXX11_ABI flag, or 0 if it's not set.
extern const int tf_cxx11_abi_flag();
// Returns 1 if build is monolithic, or 0 otherwise.
extern const int tf_monolithic_build();

#endif // TENSORFLOW_CORE_PUBLIC_VERSION_H_
2 changes: 2 additions & 0 deletions tensorflow/python/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,7 @@
'GIT_VERSION',
'COMPILER_VERSION',
'CXX11_ABI_FLAG',
'MONOLITHIC_BUILD',
])

# Remove all extra symbols that don't have a docstring or are not explicitly
Expand All @@ -282,6 +283,7 @@
'__git_version__',
'__compiler_version__',
'__cxx11_abi_flag__',
'__monolithic_build__',
])

# Expose symbols minus dunders, unless they are whitelisted above.
Expand Down
3 changes: 3 additions & 0 deletions tensorflow/python/client/tf_session.i
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,9 @@ tensorflow::ImportNumpy();
// _GLIBCXX_USE_CXX11_ABI flag value
%constant const int __cxx11_abi_flag__ = tf_cxx11_abi_flag();

// Flag indicating whether the build is monolithic
%constant const int __monolithic_build__ = tf_monolithic_build();

// Release the Python GIL for the duration of most methods.
%exception {
Py_BEGIN_ALLOW_THREADS;
Expand Down
4 changes: 4 additions & 0 deletions tensorflow/python/framework/versions.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,13 @@
__git_version__ = pywrap_tensorflow.__git_version__
__compiler_version__ = pywrap_tensorflow.__compiler_version__
__cxx11_abi_flag__ = pywrap_tensorflow.__cxx11_abi_flag__
__monolithic_build__ = pywrap_tensorflow.__monolithic_build__

VERSION = __version__
GIT_VERSION = __git_version__
COMPILER_VERSION = __compiler_version__
CXX11_ABI_FLAG = __cxx11_abi_flag__
MONOLITHIC_BUILD = __monolithic_build__

GRAPH_DEF_VERSION = pywrap_tensorflow.GRAPH_DEF_VERSION
GRAPH_DEF_VERSION_MIN_CONSUMER = (
Expand All @@ -42,11 +44,13 @@
"__git_version__",
"__compiler_version__",
"__cxx11_abi_flag__",
"__monolithic_build__",
"COMPILER_VERSION",
"CXX11_ABI_FLAG",
"GIT_VERSION",
"GRAPH_DEF_VERSION",
"GRAPH_DEF_VERSION_MIN_CONSUMER",
"GRAPH_DEF_VERSION_MIN_PRODUCER",
"VERSION",
"MONOLITHIC_BUILD",
]
6 changes: 4 additions & 2 deletions tensorflow/python/platform/sysconfig.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import os.path as _os_path

from tensorflow.python.framework.versions import CXX11_ABI_FLAG as _CXX11_ABI_FLAG
from tensorflow.python.framework.versions import MONOLITHIC_BUILD as _MONOLITHIC_BUILD
from tensorflow.python.util.all_util import remove_undocumented


Expand Down Expand Up @@ -75,8 +76,9 @@ def get_link_flags():
The link flags.
"""
flags = []
flags.append('-L%s' % get_lib())
flags.append('-ltensorflow_framework')
if not _MONOLITHIC_BUILD:
flags.append('-L%s' % get_lib())
flags.append('-ltensorflow_framework')
return flags

_allowed_symbols = []
Expand Down
1 change: 1 addition & 0 deletions tensorflow/python/pywrap_tensorflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@
from tensorflow.python.pywrap_tensorflow_internal import __git_version__
from tensorflow.python.pywrap_tensorflow_internal import __compiler_version__
from tensorflow.python.pywrap_tensorflow_internal import __cxx11_abi_flag__
from tensorflow.python.pywrap_tensorflow_internal import __monolithic_build__

if _use_dlopen_global_flags:
pywrap_dlopen_global_flags.reset_dlopen_flags()
Expand Down
4 changes: 4 additions & 0 deletions tensorflow/tensorflow.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,10 @@ def tf_copts(android_optimization_level_override="-O2"):
+ if_mkl(["-DINTEL_MKL=1", "-DEIGEN_USE_VML", "-fopenmp",])
+ if_android_arm(["-mfpu=neon"])
+ if_linux_x86_64(["-msse3"])
+ select({
"//tensorflow:framework_shared_object": [],
"//conditions:default": ["-DTENSORFLOW_MONOLITHIC_BUILD"],
})
+ select({
clean_dep("//tensorflow:android"): android_copts,
clean_dep("//tensorflow:darwin"): [],
Expand Down
4 changes: 4 additions & 0 deletions tensorflow/tools/api/golden/tensorflow.pbtxt
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,10 @@ tf_module {
name: "LogMessage"
mtype: "<class \'google.protobuf.pyext.cpp_message.GeneratedProtocolMessageType\'>"
}
member {
name: "MONOLITHIC_BUILD"
mtype: "<type \'int\'>"
}
member {
name: "MetaGraphDef"
mtype: "<class \'google.protobuf.pyext.cpp_message.GeneratedProtocolMessageType\'>"
Expand Down
7 changes: 7 additions & 0 deletions tensorflow/tools/git/gen_git_source.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,13 @@ def write_version_info(filename, git_version):
return 0;
#endif
}
const int tf_monolithic_build() {
#ifdef TENSORFLOW_MONOLITHIC_BUILD
return 1;
#else
return 0;
#endif
}
""" % git_version
open(filename, "w").write(contents)

Expand Down
7 changes: 7 additions & 0 deletions tensorflow/tools/git/gen_git_source.sh
Original file line number Diff line number Diff line change
Expand Up @@ -36,5 +36,12 @@ const int tf_cxx11_abi_flag() {
return 0;
#endif
}
const int tf_monolithic_build() {
#ifdef TENSORFLOW_MONOLITHIC_BUILD
return 1;
#else
return 0;
#endif
}
EOF