Skip to content

Commit

Permalink
Merge changes from github.
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 155709893
  • Loading branch information
benoitsteiner authored and tensorflower-gardener committed May 11, 2017
1 parent 27c8920 commit ee112cf
Show file tree
Hide file tree
Showing 125 changed files with 2,306 additions and 687 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ node_modules
/.bazelrc
/.tf_configure.bazelrc
/bazel-*
/bazel_pip
/third_party/eigen3/mkl_include
/third_party/mkl/*
/tools/python_bin_path.sh
/tools/git/gen
/pip_test
Expand Down
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ TensorFlow coding style.
* Include unit tests when you contribute new features, as they help to
a) prove that your code works correctly, b) guard against future breaking
changes to lower the maintenance cost.
* Bug fixes also generally require unit tests, because the presense of bugs
* Bug fixes also generally require unit tests, because the presence of bugs
usually indicates insufficient test coverage.
* Keep API compatibility in mind when you change code in core TensorFlow,
e.g., code in [tensorflow/core](https://github.com/tensorflow/tensorflow/tree/master/tensorflow/core) and [tensorflow/python](https://github.com/tensorflow/tensorflow/tree/master/tensorflow/python).
Expand Down
99 changes: 64 additions & 35 deletions configure
Original file line number Diff line number Diff line change
Expand Up @@ -147,17 +147,17 @@ function setup_python {
# Set-up env variables used by python_configure.bzl
write_action_env_to_bazelrc "PYTHON_BIN_PATH" "$PYTHON_BIN_PATH"
write_action_env_to_bazelrc "PYTHON_LIB_PATH" "$PYTHON_LIB_PATH"
write_to_bazelrc "build --define PYTHON_BIN_PATH=$PYTHON_BIN_PATH"
write_to_bazelrc "build --define PYTHON_LIB_PATH=$PYTHON_LIB_PATH"
write_to_bazelrc "build --define PYTHON_BIN_PATH=\"$PYTHON_BIN_PATH\""
write_to_bazelrc "build --define PYTHON_LIB_PATH=\"$PYTHON_LIB_PATH\""
write_to_bazelrc "build --force_python=py$python_major_version"
write_to_bazelrc "build --host_force_python=py$python_major_version"
write_to_bazelrc "build --python${python_major_version}_path=$PYTHON_BIN_PATH"
write_to_bazelrc "build --python${python_major_version}_path=\"$PYTHON_BIN_PATH\""
write_to_bazelrc "test --force_python=py$python_major_version"
write_to_bazelrc "test --host_force_python=py$python_major_version"
write_to_bazelrc "test --define PYTHON_BIN_PATH=$PYTHON_BIN_PATH"
write_to_bazelrc "test --define PYTHON_LIB_PATH=$PYTHON_LIB_PATH"
write_to_bazelrc "run --define PYTHON_BIN_PATH=$PYTHON_BIN_PATH"
write_to_bazelrc "run --define PYTHON_LIB_PATH=$PYTHON_LIB_PATH"
write_to_bazelrc "test --define PYTHON_BIN_PATH=\"$PYTHON_BIN_PATH\""
write_to_bazelrc "test --define PYTHON_LIB_PATH=\"$PYTHON_LIB_PATH\""
write_to_bazelrc "run --define PYTHON_BIN_PATH=\"$PYTHON_BIN_PATH\""
write_to_bazelrc "run --define PYTHON_LIB_PATH=\"$PYTHON_LIB_PATH\""

# Write tools/python_bin_path.sh
echo "export PYTHON_BIN_PATH=\"$PYTHON_BIN_PATH\"" > tools/python_bin_path.sh
Expand All @@ -180,70 +180,99 @@ fi
setup_python

## Set up MKL related environment settings
if false; then # Disable building with MKL for now
while [ "$TF_NEED_MKL" == "" ]; do
while [ "$TF_NEED_MKL" == "" ]; do
fromuser=""
read -p "Do you wish to build TensorFlow with MKL support? [y/N] " INPUT
fromuser="1"
case $INPUT in
[Yy]* ) echo "MKL support will be enabled for TensorFlow"; TF_NEED_MKL=1;;
[Nn]* ) echo "No MKL support will be enabled for TensorFlow"; TF_NEED_MKL=0;;
"" ) echo "No MKL support will be enabled for TensorFlow"; TF_NEED_MKL=0;;
* ) echo "Invalid selection: " $INPUT;;
esac
done

OSNAME=`uname -s`

if [ "$TF_NEED_MKL" == "1" ]; then # TF_NEED_MKL
while [ "$TF_DOWNLOAD_MKL" == "" ]; do
fromuser=""
read -p "Do you wish to build TensorFlow with MKL support (experimental)? [y/N] " INPUT
read -p "Do you wish to download MKL LIB from the web? [Y/n] " INPUT
fromuser="1"
case $INPUT in
[Yy]* ) echo "MKL support (experimental) (will be enabled for TensorFlow"; TF_NEED_MKL=1;;
[Nn]* ) echo "No MKL support will be enabled for TensorFlow"; TF_NEED_MKL=0;;
"" ) echo "No MKL support will be enabled for TensorFlow"; TF_NEED_MKL=0;;
* ) echo "Invalid selection: " $INPUT;;
[Yy]* ) TF_DOWNLOAD_MKL=1;;
[Nn]* ) TF_DOWNLOAD_MKL=0;;
"" ) TF_DOWNLOAD_MKL=1;;
* ) echo "Invalid selection: " $INPUT; exit 1;;
esac
done

OSNAME=`uname -s`

if [ "$TF_NEED_MKL" == "1" ]; then # TF_NEED_MKL
if [[ "$TF_DOWNLOAD_MKL" == "1" ]]; then
DST=`dirname $0`
ARCHIVE_BASENAME=mklml_lnx_2017.0.2.20170209.tgz
GITHUB_RELEASE_TAG=v0.5
ARCHIVE_BASENAME=mklml_lnx_2018.0.20170425.tgz
GITHUB_RELEASE_TAG=v0.7
MKLURL="https://github.com/01org/mkl-dnn/releases/download/$GITHUB_RELEASE_TAG/$ARCHIVE_BASENAME"
if ! [ -e "$DST/third_party/mkl/$ARCHIVE_BASENAME" ]; then
wget --no-check-certificate -P $DST/third_party/mkl/ $MKLURL
if ! [ -e "${DST}/third_party/mkl/${ARCHIVE_BASENAME}" ]; then
curl -fSsL -o "${DST}/third_party/mkl/${ARCHIVE_BASENAME}" "${MKLURL}"
fi
tar -xzf $DST/third_party/mkl/$ARCHIVE_BASENAME -C $DST/third_party/mkl/
extracted_dir_name="${ARCHIVE_BASENAME%.*}"
MKL_INSTALL_PATH=$DST/third_party/mkl/$extracted_dir_name
MKL_INSTALL_PATH=`${PYTHON_BIN_PATH} -c "import os; print(os.path.realpath(os.path.expanduser('${MKL_INSTALL_PATH}')))"`

if [ "$OSNAME" == "Linux" ]; then
else
default_mkl_path=/opt/intel/mklml
fromuser=""
read -p "Please specify the location where MKL is installed. [Default is $default_mkl_path]: " MKL_INSTALL_PATH
fromuser="1"
if [ -z "$MKL_INSTALL_PATH" ]; then
MKL_INSTALL_PATH=$default_mkl_path
fi
# Result returned from "read" will be used unexpanded. That make "~" unuseable.
# Going through one more level of expansion to handle that.
MKL_INSTALL_PATH=`${PYTHON_BIN_PATH} -c "import os; print(os.path.realpath(os.path.expanduser('${MKL_INSTALL_PATH}')))"`
fi

if [ "$OSNAME" == "Linux" ]; then
# Full MKL configuration
MKL_RT_LIB_PATH="lib/intel64/libmkl_rt.so" #${TF_MKL_EXT}#TODO version?
MKL_RT_OMP_LIB_PATH="../compiler/lib/intel64/libiomp5.so" #TODO VERSION?

# MKL-ML configuration
MKL_ML_LIB_PATH="lib/libmklml_intel.so" #${TF_MKL_EXT}#TODO version?
MKL_ML_OMP_LIB_PATH="lib/libiomp5.so" #TODO VERSION?
elif [ "$OSNAME" == "Darwin" ]; then
elif [ "$OSNAME" == "Darwin" ]; then
echo "Darwin is unsupported yet";
exit 1
fi
fi

if [ -e "$MKL_INSTALL_PATH/${MKL_ML_LIB_PATH}" ]; then
if [ -e "$MKL_INSTALL_PATH/${MKL_ML_LIB_PATH}" ]; then
ln -sf $MKL_INSTALL_PATH/${MKL_ML_LIB_PATH} third_party/mkl/
ln -sf $MKL_INSTALL_PATH/${MKL_ML_OMP_LIB_PATH} third_party/mkl/
ln -sf $MKL_INSTALL_PATH/include third_party/mkl/
ln -sf $MKL_INSTALL_PATH/include third_party/eigen3/mkl_include
else
echo "ERROR: $MKL_INSTALL_PATH/${MKL_ML_LIB_PATH} does not exist";
exit 1
fi

if [ -z "$fromuser" ]; then
loc=$(locate -e libdl.so.2 | sed -n 1p)
ln -sf $loc third_party/mkl/libdl.so.2
elif [ -e "$MKL_INSTALL_PATH/${MKL_RT_LIB_PATH}" ]; then
ln -sf $MKL_INSTALL_PATH/${MKL_RT_LIB_PATH} third_party/mkl/
ln -sf $MKL_INSTALL_PATH/${MKL_RT_OMP_LIB_PATH} third_party/mkl/
ln -sf $MKL_INSTALL_PATH/include third_party/mkl/
ln -sf $MKL_INSTALL_PATH/include third_party/eigen3/mkl_include
loc=$(locate -e libdl.so.2 | sed -n 1p)
ln -sf $loc third_party/mkl/libdl.so.2
else
echo "ERROR: $MKL_INSTALL_PATH/${MKL_ML_LIB_PATH} nor $MKL_INSTALL_PATH/${MKL_RT_LIB_PATH} exists";
exit 1
fi
fi

cat > third_party/mkl/mkl.config <<EOF
# MKL_INSTALL_PATH refers to the location of MKL root folder. The MKL header and library
# files can be either in this directory, or under include/ and lib64/
MKL_INSTALL_PATH=$MKL_INSTALL_PATH
EOF

fi # TF_NEED_MKL
################## MKL
fi # Disable building with MKL for now
fi # TF_NEED_MKL
## End MKL setup

## Set up architecture-dependent optimization flags.
if [ -z "$CC_OPT_FLAGS" ]; then
Expand Down
5 changes: 3 additions & 2 deletions tensorflow/compiler/xla/service/allocation_tracker.cc
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,9 @@ GlobalDataHandle AllocationTracker::RegisterInternal(
auto& allocation = FindOrDie(handle_to_allocation_, handle);
int ref_count = allocation->ref_count();
CHECK_GT(ref_count, 0);
VLOG(2) << "ref_count: " << ref_count << " -> " << ref_count + 1;
allocation->increment_ref_count();
VLOG(2) << "ref_count: " << ref_count << " -> " <<
(ref_count + initial_ref_count);
allocation->increment_ref_count(initial_ref_count);
} else {
handle = next_handle_++;
VLOG(2) << "ref_count: " << initial_ref_count;
Expand Down
6 changes: 3 additions & 3 deletions tensorflow/compiler/xla/service/allocation_tracker.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,10 @@ class Allocation {
CHECK_GE(ref_count_, 0);
return ref_count_;
}
void increment_ref_count() {
void increment_ref_count(int inc) {
CHECK_GT(ref_count_, 0);
CHECK_LT(ref_count_, INT_MAX);
++ref_count_;
CHECK_LE(ref_count_, INT_MAX - inc);
ref_count_ += inc;
}
void decrement_ref_count() {
CHECK_GT(ref_count_, 0);
Expand Down
1 change: 1 addition & 0 deletions tensorflow/compiler/xla/service/cpu/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ cc_library(
name = "simple_orc_jit",
srcs = ["simple_orc_jit.cc"],
hdrs = ["simple_orc_jit.h"],
linkopts = ["-ldl"],
deps = [
":compiler_functor",
":cpu_runtime",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

#include <memory>
#include <vector>
#include <cmath>

#include "tensorflow/contrib/boosted_trees/lib/quantiles/weighted_quantiles_buffer.h"
#include "tensorflow/contrib/boosted_trees/lib/quantiles/weighted_quantiles_summary.h"
Expand Down
6 changes: 6 additions & 0 deletions tensorflow/contrib/cmake/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,12 @@ if (tensorflow_ENABLE_GPU)
endif()
endif()

# Find python executable
include(FindPythonInterp)
if(NOT ${PYTHONINTERP_FOUND})
message(FATAL_ERROR "CMake was unable to find a python interpreter.")
endif()

# Let's get to work!
include(tf_core_framework.cmake)
# NOTE: Disabled until issue #3996 is fixed.
Expand Down
1 change: 0 additions & 1 deletion tensorflow/contrib/cmake/tf_python.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@

# 1. Resolve the installed version of Python (for Python.h and python).
# TODO(mrry): Parameterize the build script to enable Python 3 building.
include(FindPythonInterp)
if(NOT PYTHON_INCLUDE_DIR)
set(PYTHON_NOT_FOUND false)
exec_program("${PYTHON_EXECUTABLE}"
Expand Down
7 changes: 7 additions & 0 deletions tensorflow/contrib/cmake/tf_shared_lib.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,13 @@ target_link_libraries(tensorflow PRIVATE
tf_protos_cc
)

# There is a bug in GCC 5 resulting in undefined reference to a __cpu_model function when
# linking to the tensorflow library. Adding the following libraries fixes it.
# See issue on github: https://github.com/tensorflow/tensorflow/issues/9593
if(CMAKE_COMPILER_IS_GNUCC AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 5.0)
target_link_libraries(tensorflow PRIVATE gcc_s gcc)
endif()

if(WIN32)
add_dependencies(tensorflow tensorflow_static)
endif(WIN32)
8 changes: 4 additions & 4 deletions tensorflow/contrib/cmake/tools/create_def_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
DUMPBIN = "dumpbin.exe"

# Exclude if matched
EXCLUDE_RE = re.compile(r"deleting destructor|::internal::")
EXCLUDE_RE = re.compile(r"RTTI|deleting destructor|::internal::")

# Include if matched before exclude
INCLUDEPRE_RE = re.compile(r"google::protobuf::internal::ExplicitlyConstructed|"
Expand Down Expand Up @@ -141,17 +141,17 @@ def main():
continue
if not INCLUDE_RE.search(line):
continue

if "deleting destructor" in line:
# Some of the symbols convered by INCLUDEPRE_RE export deleting
# destructor symbols, which is a bad idea.
# So we filter out such symbols here.
continue

if DATA_EXCLUDE_RE.search(line):
def_fp.write("\t" + decorated + "\n")
else:
def_fp.write("\t" + decorated + " DATA\n")
def_fp.write("\t" + decorated + " DATA\n")
taken.add(decorated)
exit_code = proc.wait()
if exit_code != 0:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ def _check_x(self, x):
"""Static check that the argument `x` is proper `shape`, `dtype`."""
# x is a typical argument e.g. to matmul or solve. In both cases, x should
# have the same type/shape since this is a square matrix. These checks are
# ususally not needed since we ususally have some tensor backing this
# usually not needed since we usually have some tensor backing this
# distribution, and the calls to tf.matmul do a shape/type check.
#
# Static checks only for efficiency, the identity should be fast.
Expand Down
2 changes: 1 addition & 1 deletion tensorflow/contrib/keras/python/keras/datasets/imdb.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def load_data(path='imdb.npz',
num_words: max number of words to include. Words are ranked
by how often they occur (in the training set) and only
the most frequent words are kept
skip_top: skip the top N most frequently occuring words
skip_top: skip the top N most frequently occurring words
(which may not be informative).
maxlen: truncate sequences after this length.
seed: random seed for sample shuffling.
Expand Down
2 changes: 1 addition & 1 deletion tensorflow/contrib/keras/python/keras/datasets/reuters.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def load_data(path='reuters.npz',
num_words: max number of words to include. Words are ranked
by how often they occur (in the training set) and only
the most frequent words are kept
skip_top: skip the top N most frequently occuring words
skip_top: skip the top N most frequently occurring words
(which may not be informative).
maxlen: truncate sequences after this length.
test_split: Fraction of the dataset to be used as test data.
Expand Down
2 changes: 1 addition & 1 deletion tensorflow/contrib/keras/python/keras/engine/topology.py
Original file line number Diff line number Diff line change
Expand Up @@ -649,7 +649,7 @@ def compute_mask(self, inputs, mask=None): # pylint: disable=unused-argument
'but was passed an input_mask: ' + str(mask))
# masking not explicitly supported: return None as mask
return None
# if masking is explictly supported, by default
# if masking is explicitly supported, by default
# carry over the input mask
return mask

Expand Down
2 changes: 1 addition & 1 deletion tensorflow/contrib/keras/python/keras/engine/training.py
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ def _check_array_lengths(inputs, targets, weights):


def _check_loss_and_target_compatibility(targets, loss_fns, output_shapes):
"""Does validation on the compatiblity of targets and loss functions.
"""Does validation on the compatibility of targets and loss functions.
This helps prevent users from using loss functions incorrectly.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ def call(self, inputs, training=None):

def normalize_inference():
if needs_broadcasting:
# In this case we must explictly broadcast all parameters.
# In this case we must explicitly broadcast all parameters.
broadcast_moving_mean = K.reshape(self.moving_mean, broadcast_shape)
broadcast_moving_variance = K.reshape(self.moving_variance,
broadcast_shape)
Expand Down
2 changes: 1 addition & 1 deletion tensorflow/contrib/keras/python/keras/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ def convert_custom_objects(obj):
obj: object, dict, or list.
Returns:
The same structure, where occurences
The same structure, where occurrences
of a custom object name have been replaced
with the custom object.
"""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ def skipgrams(sequence,
of word indices (integers). If using a `sampling_table`,
word indices are expected to match the rank
of the words in a reference dataset (e.g. 10 would encode
the 10-th most frequently occuring token).
the 10-th most frequently occurring token).
Note that index 0 is expected to be a non-word and will be skipped.
vocabulary_size: int. maximum possible word index + 1
window_size: int. actually half-window.
Expand Down
2 changes: 1 addition & 1 deletion tensorflow/contrib/labeled_tensor/python/ops/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -810,7 +810,7 @@ def axis_order_scope(axis_order=None):
Example usage:
with lt.axis_order_scope(['x', 'y', 'z']):
# result is guranteed to have the correct axis order
# result is guaranteed to have the correct axis order
result = w + b
You can nest scopes, in which case only the inner-most scope applies, e.g.,
Expand Down
4 changes: 2 additions & 2 deletions tensorflow/contrib/layers/python/layers/feature_column.py
Original file line number Diff line number Diff line change
Expand Up @@ -451,7 +451,7 @@ def _get_input_sparse_tensor(self, input_tensor):
return input_tensor

def is_compatible(self, other_column):
"""Check compatability of two sparse columns."""
"""Check compatibility of two sparse columns."""
if self.lookup_config and other_column.lookup_config:
return self.lookup_config == other_column.lookup_config
compatible = (self.length == other_column.length and
Expand Down Expand Up @@ -2129,7 +2129,7 @@ class _CrossedColumn(
"columns", "hash_bucket_size", "hash_key", "combiner",
"ckpt_to_load_from", "tensor_name_in_ckpt"
])):
"""Represents a cross transformation also known as conjuction or combination.
"""Represents a cross transformation also known as conjunction or combination.
Instances of this class are immutable. It crosses given `columns`. Crossed
column output will be hashed to hash_bucket_size.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1505,8 +1505,8 @@ def testEmbeddingColumnGradient(self):
expected_input_shape = [4, 3, embedding_dimension]
self.assertAllEqual(expected_input_shape, model_input.shape)

# `ids_tensor` consists of 7 instances of <empty>, 3 occurences of "b",
# 2 occurences of "c" and 1 instance of "a".
# `ids_tensor` consists of 7 instances of <empty>, 3 occurrences of "b",
# 2 occurrences of "c" and 1 instance of "a".
expected_gradient_values = sorted([0., 3., 2., 1.] * embedding_dimension)
actual_gradient_values = np.sort(gradients[0].values, axis=None)
self.assertAllClose(expected_gradient_values, actual_gradient_values)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ def testSharedEmbeddingColumn(self):
for i in range(len(b1_value)):
self.assertAllClose(b1_value[i], b2_value[i])

# Test the case when a shared_embedding_name is explictly specified.
# Test the case when a shared_embedding_name is explicitly specified.
d = fc.shared_embedding_columns(
[a1, a2],
dimension=4,
Expand Down
Loading

0 comments on commit ee112cf

Please sign in to comment.