Fully enabled absl and removed TENSORFLOW_USE_ABSL define (as absl is now always available).

Previously, absl was not enabled for mobile or for makefile-based builds.

PiperOrigin-RevId: 209648505
This commit is contained in:
A. Unique TensorFlower 2018-08-21 13:21:13 -07:00 committed by TensorFlower Gardener
parent 7cc6abab4e
commit 75adfa5ca1
4 changed files with 31 additions and 11 deletions

View File

@ -90,6 +90,7 @@ HOST_INCLUDES := \
-I$(MAKEFILE_DIR)/downloads/nsync/public \
-I$(MAKEFILE_DIR)/downloads/fft2d \
-I$(MAKEFILE_DIR)/downloads/double_conversion \
-I$(MAKEFILE_DIR)/downloads/absl \
-I$(HOST_GENDIR)
ifeq ($(HAS_GEN_HOST_PROTOC),true)
HOST_INCLUDES += -I$(MAKEFILE_DIR)/gen/protobuf-host/include
@ -116,6 +117,21 @@ ifeq ($(HOST_OS),PI)
HOST_LIBS += -ldl -lpthread
endif
# Abseil sources.
ABSL_CC_ALL_SRCS := \
$(wildcard tensorflow/contrib/makefile/downloads/absl/absl/*/*.cc) \
$(wildcard tensorflow/contrib/makefile/downloads/absl/absl/*/*/*.cc) \
$(wildcard tensorflow/contrib/makefile/downloads/absl/absl/*/*/*/*.cc) \
$(wildcard tensorflow/contrib/makefile/downloads/absl/absl/*/*/*/*/*.cc)
ABSL_CC_EXCLUDE_SRCS := \
$(wildcard tensorflow/contrib/makefile/downloads/absl/absl/*/*test*.cc) \
$(wildcard tensorflow/contrib/makefile/downloads/absl/absl/*/*/*test*.cc) \
$(wildcard tensorflow/contrib/makefile/downloads/absl/absl/*/*/*/*test*.cc) \
$(wildcard tensorflow/contrib/makefile/downloads/absl/absl/*/*/*/*/*test*.cc) \
tensorflow/contrib/makefile/downloads/absl/absl/synchronization/internal/mutex_nonprod.cc
ABSL_CC_SRCS := $(filter-out $(ABSL_CC_EXCLUDE_SRCS), $(ABSL_CC_ALL_SRCS))
# proto_text is a tool that converts protobufs into a form we can use more
# compactly within TensorFlow. It's a bit like protoc, but is designed to
@ -125,7 +141,9 @@ endif
PROTO_TEXT := $(HOST_BINDIR)proto_text
# The list of dependencies is derived from the Bazel build file by running
# the gen_file_lists.sh script on a system with a working Bazel setup.
PROTO_TEXT_CC_FILES := $(shell cat $(MAKEFILE_DIR)/proto_text_cc_files.txt)
PROTO_TEXT_CC_FILES := \
$(ABSL_CC_SRCS) \
$(shell cat $(MAKEFILE_DIR)/proto_text_cc_files.txt)
PROTO_TEXT_PB_CC_LIST := \
$(shell cat $(MAKEFILE_DIR)/proto_text_pb_cc_files.txt) \
$(wildcard tensorflow/contrib/makefile/downloads/double_conversion/double-conversion/*.cc)
@ -175,6 +193,7 @@ INCLUDES := \
-I$(MAKEFILE_DIR)/downloads/nsync/public \
-I$(MAKEFILE_DIR)/downloads/fft2d \
-I$(MAKEFILE_DIR)/downloads/double_conversion \
-I$(MAKEFILE_DIR)/downloads/absl \
-I$(PROTOGENDIR) \
-I$(PBTGENDIR)
ifeq ($(HAS_GEN_HOST_PROTOC),true)
@ -236,7 +255,6 @@ ifeq ($(TARGET),PI)
endif
# Set up Android building
# LINT.IfChange
ifeq ($(TARGET),ANDROID)
# Override NDK_ROOT on the command line with your own NDK location, e.g.
# make -f tensorflow/contrib/makefile/Makefile TARGET=ANDROID \
@ -331,6 +349,7 @@ $(MARCH_OPTION) \
-I$(MAKEFILE_DIR)/downloads/nsync/public \
-I$(MAKEFILE_DIR)/downloads/fft2d \
-I$(MAKEFILE_DIR)/downloads/double_conversion \
-I$(MAKEFILE_DIR)/downloads/absl \
-I$(MAKEFILE_DIR)/gen/protobuf_android/$(ANDROID_ARCH)/include \
-I$(PROTOGENDIR) \
-I$(PBTGENDIR)
@ -446,7 +465,6 @@ $(MARCH_OPTION) \
DEPDIR := $(DEPDIR)android_$(ANDROID_ARCH)/
endif # ifeq ($(BUILD_FOR_TEGRA),1)
endif # ANDROID
# LINT.ThenChange(//tensorflow/contrib/android/cmake/CMakeLists.txt)
# Settings for iOS.
ifeq ($(TARGET),IOS)
@ -596,6 +614,7 @@ BENCHMARK_NAME := $(BINDIR)benchmark
# gen_file_lists.sh script.
CORE_CC_ALL_SRCS := \
$(ABSL_CC_SRCS) \
$(wildcard tensorflow/core/*.cc) \
$(wildcard tensorflow/core/common_runtime/*.cc) \
$(wildcard tensorflow/core/framework/*.cc) \

View File

@ -1572,6 +1572,7 @@ cc_library(
],
visibility = ["//visibility:public"],
deps = [
":mobile_additional_lib_deps",
":protos_all_cc_impl",
":stats_calculator_portable",
"//third_party/eigen3",
@ -1582,6 +1583,11 @@ cc_library(
alwayslink = 1,
)
cc_library(
name = "mobile_additional_lib_deps",
deps = tf_additional_lib_deps(),
)
# Native library support for iOS applications.
#
# bazel build --config=ios_x86_64 \
@ -1613,6 +1619,7 @@ cc_library(
copts = tf_copts() + ["-Os"] + ["-std=c++11"],
visibility = ["//visibility:public"],
deps = [
":mobile_additional_lib_deps",
":protos_all_cc_impl",
":stats_calculator_portable",
"//third_party/eigen3",

View File

@ -619,11 +619,11 @@ def tf_additional_lib_defines():
"//tensorflow:with_jemalloc_linux_x86_64": ["TENSORFLOW_USE_JEMALLOC"],
"//tensorflow:with_jemalloc_linux_ppc64le": ["TENSORFLOW_USE_JEMALLOC"],
"//conditions:default": [],
}) + if_not_mobile(["TENSORFLOW_USE_ABSL"])
})
def tf_additional_lib_deps():
"""Additional dependencies needed to build TF libraries."""
return if_not_mobile(["@com_google_absl//absl/base:base"]) + if_static(
return ["@com_google_absl//absl/base:base"] + if_static(
["@nsync//:nsync_cpp"],
["@nsync//:nsync_headers"],
) + select({

View File

@ -17,9 +17,7 @@ limitations under the License.
#include "jemalloc/jemalloc.h"
#endif
#ifdef TENSORFLOW_USE_ABSL
#include "absl/base/internal/sysinfo.h"
#endif
#include "tensorflow/core/platform/cpu_info.h"
#include "tensorflow/core/platform/logging.h"
@ -194,11 +192,7 @@ bool Snappy_Uncompress(const char* input, size_t length, char* output) {
string Demangle(const char* mangled) { return mangled; }
double NominalCPUFrequency() {
#ifdef TENSORFLOW_USE_ABSL
return absl::base_internal::NominalCPUFrequency();
#else
return 1.0;
#endif
}
int64 AvailableRam() {