From 3db3f1f83a562587cc207106258751d089c48ae4 Mon Sep 17 00:00:00 2001 From: Loo Rong Jie Date: Wed, 4 Jul 2018 13:18:02 +0800 Subject: [MSVC] Disable C++ exceptions --- tensorflow/tensorflow.bzl | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'tensorflow/tensorflow.bzl') diff --git a/tensorflow/tensorflow.bzl b/tensorflow/tensorflow.bzl index e4632c4811..c3bd854940 100644 --- a/tensorflow/tensorflow.bzl +++ b/tensorflow/tensorflow.bzl @@ -180,9 +180,12 @@ def get_win_copts(is_external=False): "/DEIGEN_AVOID_STL_ARRAY", "/Iexternal/gemmlowp", "/wd4018", # -Wno-sign-compare - "/U_HAS_EXCEPTIONS", - "/D_HAS_EXCEPTIONS=1", - "/EHsc", # -fno-exceptions + # Bazel's CROSSTOOL currently pass /EHsc to enable exception by + # default. We can't pass /EHs-c- to disable exception, otherwise + # we will get a waterfall of flag conflict warnings. Wait for + # Bazel to fix this. + # "/D_HAS_EXCEPTIONS=0", + # "/EHs-c-", "/DNOGDI", ] if is_external: -- cgit v1.2.3 From 86ad3363e18f7df3f86f30150f7b13d389c459e5 Mon Sep 17 00:00:00 2001 From: Loo Rong Jie Date: Wed, 4 Jul 2018 19:32:20 +0800 Subject: Suppress /wd4577 'noexcept with no exception handling mode' warning --- tensorflow/contrib/cmake/CMakeLists.txt | 2 ++ tensorflow/tensorflow.bzl | 1 + 2 files changed, 3 insertions(+) (limited to 'tensorflow/tensorflow.bzl') diff --git a/tensorflow/contrib/cmake/CMakeLists.txt b/tensorflow/contrib/cmake/CMakeLists.txt index 693393c1e7..708618dcb0 100644 --- a/tensorflow/contrib/cmake/CMakeLists.txt +++ b/tensorflow/contrib/cmake/CMakeLists.txt @@ -177,6 +177,8 @@ if(WIN32) string(REPLACE "/EHsc" "/EHs-c-" ${flag} "${${flag}}") endforeach() add_definitions(/D_HAS_EXCEPTIONS=0) + # Suppress 'noexcept used with no exception handling mode specified' warning + add_compile_options(/wd4577) # Try to avoid flaky failures due to failed generation of generate.stamp files. set(CMAKE_SUPPRESS_REGENERATION ON) diff --git a/tensorflow/tensorflow.bzl b/tensorflow/tensorflow.bzl index c3bd854940..46d554a19d 100644 --- a/tensorflow/tensorflow.bzl +++ b/tensorflow/tensorflow.bzl @@ -186,6 +186,7 @@ def get_win_copts(is_external=False): # Bazel to fix this. # "/D_HAS_EXCEPTIONS=0", # "/EHs-c-", + "/wd4577", "/DNOGDI", ] if is_external: -- cgit v1.2.3 From 64117da0c36f0697467ce6d56a7be6837da24d2f Mon Sep 17 00:00:00 2001 From: Mahmoud Abuzaina Date: Thu, 5 Jul 2018 13:56:22 -0700 Subject: Fixing AVX performance issue --- tensorflow/tensorflow.bzl | 5 +++++ third_party/mkl_dnn/BUILD | 8 ++++++++ third_party/mkl_dnn/mkldnn.BUILD | 29 ++++++++++++++++++++++++++++- tools/bazel.rc | 4 ++++ 4 files changed, 45 insertions(+), 1 deletion(-) (limited to 'tensorflow/tensorflow.bzl') diff --git a/tensorflow/tensorflow.bzl b/tensorflow/tensorflow.bzl index e4632c4811..3e3fbeb8f8 100644 --- a/tensorflow/tensorflow.bzl +++ b/tensorflow/tensorflow.bzl @@ -24,6 +24,10 @@ load( "if_mkl", "if_mkl_lnx_x64" ) +load( + "//third_party/mkl_dnn:build_defs.bzl", + "if_mkl_open_source_only", +) def register_extension_info(**kwargs): pass @@ -214,6 +218,7 @@ def tf_copts(android_optimization_level_override="-O2", is_external=False): + if_cuda(["-DGOOGLE_CUDA=1"]) + if_tensorrt(["-DGOOGLE_TENSORRT=1"]) + if_mkl(["-DINTEL_MKL=1", "-DEIGEN_USE_VML"]) + + if_mkl_open_source_only(["-DDO_NOT_USE_ML"]) + if_mkl_lnx_x64(["-fopenmp"]) + if_android_arm(["-mfpu=neon"]) + if_linux_x86_64(["-msse3"]) diff --git a/third_party/mkl_dnn/BUILD b/third_party/mkl_dnn/BUILD index 5b01f6e3e4..17a0074abe 100644 --- a/third_party/mkl_dnn/BUILD +++ b/third_party/mkl_dnn/BUILD @@ -1 +1,9 @@ licenses(["notice"]) + +config_setting( + name = "using_mkl_dnn_only", + values = { + "define": "using_mkl_dnn_only=true", + }, + visibility = ["//visibility:public"], +) diff --git a/third_party/mkl_dnn/mkldnn.BUILD b/third_party/mkl_dnn/mkldnn.BUILD index 68f24aabae..57d2e1292b 100644 --- a/third_party/mkl_dnn/mkldnn.BUILD +++ b/third_party/mkl_dnn/mkldnn.BUILD @@ -1,5 +1,10 @@ exports_files(["LICENSE"]) +load( + "@org_tensorflow//third_party/mkl_dnn:build_defs.bzl", + "if_mkl_open_source_only", +) + config_setting( name = "clang_linux_x86_64", values = { @@ -15,7 +20,14 @@ cc_library( "src/cpu/*.cpp", ]), hdrs = glob(["include/*"]), - copts = ["-fexceptions"] + select({ + copts = [ + "-fexceptions", + "-DUSE_MKL", + "-DUSE_CBLAS", + ] + if_mkl_open_source_only([ + "-UUSE_MKL", + "-UUSE_CBLAS", + ]) + select({ "@org_tensorflow//tensorflow:linux_x86_64": [ "-fopenmp", # only works with gcc ], @@ -33,4 +45,19 @@ cc_library( ], nocopts = "-fno-exceptions", visibility = ["//visibility:public"], + deps = select({ + "@org_tensorflow//tensorflow:linux_x86_64": [ + "@mkl_linux//:mkl_headers", + "@mkl_linux//:mkl_libs_linux", + ], + "@org_tensorflow//tensorflow:darwin": [ + "@mkl_darwin//:mkl_headers", + "@mkl_darwin//:mkl_libs_darwin", + ], + "@org_tensorflow//tensorflow:windows": [ + "@mkl_windows//:mkl_headers", + "@mkl_windows//:mkl_libs_windows", + ], + "//conditions:default": [], + }), ) diff --git a/tools/bazel.rc b/tools/bazel.rc index 1c1e6afb65..b3a9e6f0ef 100644 --- a/tools/bazel.rc +++ b/tools/bazel.rc @@ -27,6 +27,10 @@ build --define framework_shared_object=true build:mkl --define=using_mkl=true build:mkl -c opt +# This config option is used to enable MKL-DNN open source library only, +# without depending on MKL binary version. +build:mkl_open_source_only --define=using_mkl_dnn_only=true + build:download_clang --crosstool_top=@local_config_download_clang//:toolchain build:download_clang --define=using_clang=true -- cgit v1.2.3 From 41b93403ac8148bd880c749165c40840ddb95b44 Mon Sep 17 00:00:00 2001 From: "A. Unique TensorFlower" Date: Fri, 20 Jul 2018 11:26:39 -0700 Subject: Create a config option to not link LGPL PiperOrigin-RevId: 205427089 --- tensorflow/BUILD | 8 ++++++++ tensorflow/tensorflow.bzl | 8 ++++++++ 2 files changed, 16 insertions(+) (limited to 'tensorflow/tensorflow.bzl') diff --git a/tensorflow/BUILD b/tensorflow/BUILD index 518c2b0489..388ca3f293 100644 --- a/tensorflow/BUILD +++ b/tensorflow/BUILD @@ -24,6 +24,14 @@ load( "gen_api_init_files", # @unused ) +# Config setting used when building for products +# which requires restricted licenses to be avoided. +config_setting( + name = "no_lgpl_deps", + values = {"define": "__TENSORFLOW_NO_LGPL_DEPS__=1"}, + visibility = ["//visibility:public"], +) + # Config setting for determining if we are building for Android. config_setting( name = "android", diff --git a/tensorflow/tensorflow.bzl b/tensorflow/tensorflow.bzl index 955b53f691..954940642b 100644 --- a/tensorflow/tensorflow.bzl +++ b/tensorflow/tensorflow.bzl @@ -137,6 +137,14 @@ def if_not_mobile(a): "//conditions:default": a, }) +# Config setting selector used when building for products +# which requires restricted licenses to be avoided. +def if_not_lgpl_restricted(a): + _ = (a,) + return select({ + "//conditions:default": [], + }) + def if_not_windows(a): return select({ clean_dep("//tensorflow:windows"): [], -- cgit v1.2.3 From 0cc0166a97f95499f0af673f3004d6bb748dc7e4 Mon Sep 17 00:00:00 2001 From: Allen Lavoie Date: Fri, 20 Jul 2018 16:34:46 -0700 Subject: Relax dependency checking for custom op libraries These checks were necessary when we used RTLD_GLOBAL to expose TF symbols to custom ops, since :framework and :lib pulled in implementations. They're now header-only. Ideally we'd switch the checks to framework_internal_impl and lib_internal_impl, but that would require visibility for those rules (thus making it more likely they'd get included in silly places). So this change disables the check for dynamic builds, on the theory that accidentally relying on implementation rules is much more difficult than it was with a static build. Should allow tf_custom_op_libraries to depend on GPU kernels (which depend on core:gpu_lib which depends on :framework). PiperOrigin-RevId: 205472434 --- tensorflow/tensorflow.bzl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tensorflow/tensorflow.bzl') diff --git a/tensorflow/tensorflow.bzl b/tensorflow/tensorflow.bzl index 954940642b..26970c8cb0 100644 --- a/tensorflow/tensorflow.bzl +++ b/tensorflow/tensorflow.bzl @@ -1359,7 +1359,7 @@ def tf_custom_op_library(name, srcs=[], gpu_srcs=[], deps=[], linkopts=[]): name=name, srcs=srcs, deps=deps + if_cuda(cuda_deps), - data=[name + "_check_deps"], + data=if_static([name + "_check_deps"]), copts=tf_copts(is_external=True), features = ["windows_export_all_symbols"], linkopts=linkopts + select({ -- cgit v1.2.3 From f8bbd3ceb7e86b7595ba74a9a03cfc7c1be252a8 Mon Sep 17 00:00:00 2001 From: "A. Unique TensorFlower" Date: Tue, 24 Jul 2018 09:38:26 -0700 Subject: A subsequent improvement to the creation of a config option to not link LGPL, including fix for the Android/Apple version of code (C++ macros-es fix) PiperOrigin-RevId: 205842327 --- tensorflow/tensorflow.bzl | 1 + 1 file changed, 1 insertion(+) (limited to 'tensorflow/tensorflow.bzl') diff --git a/tensorflow/tensorflow.bzl b/tensorflow/tensorflow.bzl index 26970c8cb0..340d3f393c 100644 --- a/tensorflow/tensorflow.bzl +++ b/tensorflow/tensorflow.bzl @@ -244,6 +244,7 @@ def tf_copts(android_optimization_level_override="-O2", is_external=False): clean_dep("//tensorflow:windows"): get_win_copts(is_external), clean_dep("//tensorflow:windows_msvc"): get_win_copts(is_external), clean_dep("//tensorflow:ios"): ["-std=c++11"], + clean_dep("//tensorflow:no_lgpl_deps"): ["-D__TENSORFLOW_NO_LGPL_DEPS__", "-pthread"], "//conditions:default": ["-pthread"] })) -- cgit v1.2.3