Skip to content

Commit

Permalink
Merge pull request #5 from tensorflow/master
Browse files Browse the repository at this point in the history
Latest pull from tensorflow
  • Loading branch information
rajendraarora16 committed Jan 5, 2018
2 parents 1f1a251 + f99275a commit 84575be
Show file tree
Hide file tree
Showing 38 changed files with 392 additions and 129 deletions.
64 changes: 64 additions & 0 deletions RELEASE.md
@@ -1,3 +1,67 @@
# Release 1.5.0

## Breaking Changes
* Prebuilt binaries are now built against CUDA 9 and cuDNN 7.
* Our Linux binaries are built using ubuntu 16 containers, potentially
introducing glibc incompatibility issues with ubuntu 14.
* Starting from 1.6 release, our prebuilt binaries will use AVX instructions.
This may break TF on older CPUs.

## Major Features And Improvements
* [Eager execution](https://github.com/tensorflow/tensorflow/tree/r1.5/tensorflow/contrib/eager)
preview version is now available.
* [TensorFlow Lite](https://github.com/tensorflow/tensorflow/tree/r1.5/tensorflow/contrib/lite)
dev preview is now available.
* CUDA 9 and cuDNN 7 support.

## Bug Fixes and Other Changes
* `auto_correlation` added to `tf.contrib.distributions`.
* Add `DenseFlipout` probabilistic layer.
* Restandardize `DenseVariational` as simpler template for other probabilistic layers.
* Make `tf.contrib.distributions` QuadratureCompound classes support batch.
* `Stream::BlockHostUntilDone` now returns Status rather than bool.
* Customize request timeouts for the GCS filesystem.

## Thanks to our Contributors

This release contains contributions from many people at Google, as well as:

4d55397500, Abdullah Alrasheed, abenmao, Adam Salvail, Aditya Dhulipala, Ag Ramesh,
Akimasa Kimura, Alan Du, Alan Yee, Alexander, Amit Kushwaha, Amy, Andrei Costinescu,
Andrei Nigmatulin, Andrew Erlichson, Andrew Myers, Andrew Stepanov, Androbin, AngryPowman,
Anish Shah, Anton Daitche, Artsiom Chapialiou, asdf2014, Aseem Raj Baranwal, Ash Hall,
Bart Kiers, Batchu Venkat Vishal, ben, Ben Barsdell, Bill Piel, Carl Thomé, Catalin Voss,
Changming Sun, Chengzhi Chen, Chi Zeng, Chris Antaki, Chris Donahue, Chris Oelmueller,
Chris Tava, Clayne Robison, Codrut, Courtial Florian, Dalmo Cirne, Dan J, Darren Garvey,
David Kristoffersson, David Norman, David RöThlisberger, DavidNorman, Dhruv, DimanNe,
Dorokhov, Duncan Mac-Vicar P, EdwardDixon, EMCP, error.d, FAIJUL, Fan Xia,
Francois Xavier, Fred Reiss, Freedom" Koan-Sin Tan, Fritz Obermeyer, Gao, Xiang,
Guenther Schmuelling, Guo Yejun (郭叶军), Hans Gaiser, HectorSVC, Hyungsuk Yoon,
James Pruegsanusak, Jay Young, Jean Wanka, Jeff Carpenter, Jeremy Rutman, Jeroen BéDorf,
Jett Jones, Jimmy Jia, jinghuangintel, jinze1994, JKurland, Joel Hestness, joetoth,
John B Nelson, John Impallomeni, John Lawson, Jonas, Jonathan Dekhtiar, joshkyh, Jun Luan,
Jun Mei, Kai Sasaki, Karl Lessard, karl@kubx.ca, Kb Sriram, Kenichi Ueno, Kevin Slagle,
Kongsea, Lakshay Garg, lhlmgr, Lin Min, liu.guangcong, Loki Der Quaeler, Louie Helm,
lucasmoura, Luke Iwanski, Lyndon White, Mahmoud Abuzaina, Marcel Puyat, Mark Aaron Shirley,
Michele Colombo, MtDersvan, Namrata-Ibm, Nathan Luehr, Naurril, Nayana Thorat, Nicolas Lopez,
Niranjan Hasabnis, Nolan Liu, Nouce, Oliver Hennigh, osdamv, Patrik Erdes,
Patryk Chrabaszcz, Pavel Christof, Penghao Cen, postBG, Qingqing Cao, Qingying Chen, qjivy,
Raphael, Rasmi, raymondxyang, Renze Yu, resec, Roffel, Ruben Vereecken, Ryohei Kuroki,
sandipmgiri, Santiago Castro, Scott Kirkland, Sean Vig, Sebastian Raschka, Sebastian Weiss,
Sergey Kolesnikov, Sergii Khomenko, Shahid, Shivam Kotwalia, Stuart Berg, Sumit Gouthaman,
superzerg, Sven Mayer, tetris, Ti Zhou, Tiago Freitas Pereira, Tian Jin, Tomoaki Oiki,
Vaibhav Sood, vfdev, Vivek Rane, Vladimir Moskva, wangqr, Weber Xie, Will Frey,
Yan Facai (颜发才), yanivbl6, Yaroslav Bulatov, Yixing Lao, Yong Tang, youkaichao,
Yuan (Terry) Tang, Yue Zhang, Yuxin Wu, Ziming Dong, ZxYuan, 黄璞

We are also grateful to all who filed issues or helped resolve them, asked and
answered questions, and were part of inspiring discussions.

# Release 1.4.1

## Bug Fixes and Other Changes
* `LinearClassifier` fix for CloudML Engine.

# Release 1.4.0

## Major Features And Improvements
Expand Down
43 changes: 33 additions & 10 deletions configure.py
Expand Up @@ -302,6 +302,12 @@ def get_var(environ_cp,
Returns:
boolean value of the variable.
Raises:
UserInputError: if an environment variable is set, but it cannot be
interpreted as a boolean indicator, assume that the user has made a
scripting error, and will continue to provide invalid input.
Raise the error to avoid infinitely looping.
"""
if not question:
question = 'Do you wish to build TensorFlow with %s support?' % query_item
Expand All @@ -319,6 +325,23 @@ def get_var(environ_cp,
question += ' [y/N]: '

var = environ_cp.get(var_name)
if var is not None:
var_content = var.strip().lower()
true_strings = ('1', 't', 'true', 'y', 'yes')
false_strings = ('0', 'f', 'false', 'n', 'no')
if var_content in true_strings:
var = True
elif var_content in false_strings:
var = False
else:
raise UserInputError(
'Environment variable %s must be set as a boolean indicator.\n'
'The following are accepted as TRUE : %s.\n'
'The following are accepted as FALSE: %s.\n'
'Current value is %s.' % (
var_name, ', '.join(true_strings), ', '.join(false_strings),
var))

while var is None:
user_input_origin = get_input(question)
user_input = user_input_origin.strip().lower()
Expand Down Expand Up @@ -605,8 +628,9 @@ def prompt_loop_or_load_from_env(
Raises:
UserInputError: if a query has been attempted n_ask_attempts times without
success, assume that the user has made a scripting error, and will continue
to provide invalid input. Raise the error to avoid infinitely looping.
success, assume that the user has made a scripting error, and will
continue to provide invalid input. Raise the error to avoid infinitely
looping.
"""
default = environ_cp.get(var_name) or var_default
full_query = '%s [Default is %s]: ' % (
Expand Down Expand Up @@ -1099,16 +1123,15 @@ def toolkit_exists(toolkit_path):
computecpp_toolkit_path)

def set_trisycl_include_dir(environ_cp):
"""Set TRISYCL_INCLUDE_DIR"""
ask_trisycl_include_dir = ('Please specify the location of the triSYCL '
'include directory. (Use --config=sycl_trisycl '
'when building with Bazel) '
'[Default is %s]: '
) % (_DEFAULT_TRISYCL_INCLUDE_DIR)
"""Set TRISYCL_INCLUDE_DIR."""
ask_trisycl_include_dir = (
'Please specify the location of the triSYCL include directory. (Use '
'--config=sycl_trisycl when building with Bazel) '
'[Default is %s]: ') % _DEFAULT_TRISYCL_INCLUDE_DIR
while True:
trisycl_include_dir = get_from_env_or_user_or_default(
environ_cp, 'TRISYCL_INCLUDE_DIR', ask_trisycl_include_dir,
_DEFAULT_TRISYCL_INCLUDE_DIR)
environ_cp, 'TRISYCL_INCLUDE_DIR', ask_trisycl_include_dir,
_DEFAULT_TRISYCL_INCLUDE_DIR)
if os.path.exists(trisycl_include_dir):
break

Expand Down
18 changes: 18 additions & 0 deletions tensorflow/cc/gradients/math_grad.cc
Expand Up @@ -763,6 +763,24 @@ Status LgammaGrad(const Scope& scope, const Operation& op,
}
REGISTER_GRADIENT_OP("Lgamma", LgammaGrad);

Status SelectGrad(const Scope& scope, const Operation& op,
const std::vector<Output>& grad_inputs,
std::vector<Output>* grad_outputs) {
auto comparator = op.input(0);
auto x = op.input(1);
auto zeros = ZerosLike(scope, x);
auto grad = grad_inputs[0];

auto gx_1 = Where3(scope, comparator, grad, zeros);
auto gx_2 = Where3(scope, comparator, zeros, grad);

grad_outputs->push_back(NoGradient());
grad_outputs->push_back(gx_1);
grad_outputs->push_back(gx_2);
return scope.status();
}
REGISTER_GRADIENT_OP("Select", SelectGrad);

Status MinOrMaxGrad(const Scope& scope, const Operation& op,
const std::vector<Output>& grad_inputs,
std::vector<Output>* grad_outputs) {
Expand Down
12 changes: 12 additions & 0 deletions tensorflow/cc/gradients/math_grad_test.cc
Expand Up @@ -882,5 +882,17 @@ TEST_F(NaryGradTest, Prod) {
RunTest({x}, {x_shape}, {y}, {y_shape});
}

TEST_F(NaryGradTest, Select) {
TensorShape shape({3, 2});
auto x1 = Placeholder(scope_, DT_FLOAT, Placeholder::Shape(shape));
auto x2 = Placeholder(scope_, DT_FLOAT, Placeholder::Shape(shape));
// Use constant values to avoid instability when computing
Tensor c =
test::AsTensor<float>({-3.5f, 1.5f, -1.2f, 3.0f, -2.5f, 2.8f}, {3, 2});
auto zero = Cast(scope_, Const(scope_, 0.0), c.dtype());
auto y = Where3(scope_, Greater(scope_, c, zero), x1, x2);
RunTest({x1, x2}, {shape, shape}, {y}, {shape});
}

} // namespace
} // namespace tensorflow
Expand Up @@ -41,7 +41,7 @@ class LinearModel(tfe.Network):
For those familiar with TensorFlow graphs, notice the absence of
`tf.Session`. The `forward()` method here immediately executes and
returns output values. The `loss()` method immediately compares the
output of `forward()` with the target adn returns the MSE loss value.
output of `forward()` with the target and returns the MSE loss value.
The `fit()` performs gradient-descent training on the model's weights
and bias.
"""
Expand Down
2 changes: 1 addition & 1 deletion tensorflow/contrib/eager/python/examples/mnist/mnist.py
Expand Up @@ -40,7 +40,7 @@ class MNISTModel(tfe.Network):
"""MNIST Network.
Network structure is equivalent to:
https://github.com/tensorflow/tensorflow/blob/r1.4/tensorflow/examples/tutorials/mnist/mnist_deep.py
https://github.com/tensorflow/tensorflow/blob/r1.5/tensorflow/examples/tutorials/mnist/mnist_deep.py
and
https://github.com/tensorflow/models/blob/master/tutorials/image/mnist/convolutional.py
Expand Down
42 changes: 26 additions & 16 deletions tensorflow/contrib/libsvm/kernels/decode_libsvm_op.cc
Expand Up @@ -46,34 +46,44 @@ class DecodeLibsvmOp : public OpKernel {
std::vector<T> out_values;
std::vector<std::pair<int64, int64>> out_indices;
for (int i = 0; i < input_flat.size(); ++i) {
std::vector<string> entries =
str_util::Split(input_flat(i), " ", str_util::SkipEmpty());
OP_REQUIRES(ctx, !entries.empty(),
errors::InvalidArgument("No entries found for input[", i,
StringPiece line(input_flat(i));
str_util::RemoveWhitespaceContext(&line);

StringPiece piece;
OP_REQUIRES(ctx, str_util::ConsumeNonWhitespace(&line, &piece),
errors::InvalidArgument("No label found for input[", i,
"]: \"", input_flat(i), "\""));

Tlabel label_value;
OP_REQUIRES(
ctx, strings::SafeStringToNumeric<Tlabel>(entries[0], &label_value),
errors::InvalidArgument("Label format incorrect: ", entries[0]));
OP_REQUIRES(ctx,
strings::SafeStringToNumeric<Tlabel>(piece, &label_value),
errors::InvalidArgument("Label format incorrect: ", piece));
label(i) = label_value;
for (int j = 1; j < entries.size(); j++) {
std::vector<string> pair = str_util::Split(entries[j], ":");
OP_REQUIRES(
ctx, (pair.size() == 2),
errors::InvalidArgument("Invalid feature \"", entries[j], "\""));

str_util::RemoveLeadingWhitespace(&line);
while (str_util::ConsumeNonWhitespace(&line, &piece)) {
size_t p = piece.find(':');
OP_REQUIRES(ctx, (p != StringPiece::npos),
errors::InvalidArgument("Invalid feature \"", piece, "\""));

int64 feature_index;
OP_REQUIRES(
ctx, strings::safe_strto64(pair[0].c_str(), &feature_index),
errors::InvalidArgument("Feature format incorrect: ", entries[j]));
ctx, strings::safe_strto64(piece.substr(0, p), &feature_index),
errors::InvalidArgument("Feature format incorrect: ", piece));
OP_REQUIRES(ctx, (feature_index >= 0),
errors::InvalidArgument(
"Feature index should be >= 0, got ", feature_index));

T feature_value;
OP_REQUIRES(
ctx, strings::SafeStringToNumeric<T>(pair[1], &feature_value),
errors::InvalidArgument("Feature format incorrect: ", entries[j]));
ctx,
strings::SafeStringToNumeric<T>(piece.substr(p + 1),
&feature_value),
errors::InvalidArgument("Feature format incorrect: ", piece));
out_values.emplace_back(feature_value);
out_indices.emplace_back(std::pair<int64, int64>(i, feature_index));

str_util::RemoveLeadingWhitespace(&line);
}
}

Expand Down
8 changes: 8 additions & 0 deletions tensorflow/contrib/makefile/README.md
Expand Up @@ -262,6 +262,14 @@ to register ops and kernels.

#### Optimization

The `build_all_ios.sh` script can take optional command-line arguments to
selectively register only for the operators used in your graph.

```bash
tensorflow/contrib/makefile/build_all_ios.sh -a arm64 -g $HOME/graphs/inception/tensorflow_inception_graph.pb
```
Please note this is an aggresive optimization of the operators and the resulting library may not work with other graphs but will reduce the size of the final library.

The `compile_ios_tensorflow.sh` script can take optional command-line arguments.
The first argument will be passed as a C++ optimization flag and defaults to
debug mode. If you are concerned about performance or are working on a release
Expand Down
64 changes: 55 additions & 9 deletions tensorflow/contrib/makefile/build_all_ios.sh
Expand Up @@ -26,13 +26,16 @@ fi
usage() {
echo "Usage: $(basename "$0") [-a:T]"
echo "-a [build_arch] build only for specified arch x86_64 [default=all]"
echo "-g [graph] optimize and selectively register ops only for this graph"
echo "-T only build tensorflow (dont download other deps etc)"
exit 1
}

while getopts "a:T" opt_name; do
DEFAULT_ARCH="i386 x86_64 armv7 armv7s arm64"
while getopts "a:g:T" opt_name; do
case "$opt_name" in
a) BUILD_ARCH="${OPTARG}";;
g) OPTIMIZE_FOR_GRAPH="${OPTARG}";;
T) ONLY_MAKE_TENSORFLOW="true";;
*) usage;;
esac
Expand All @@ -42,7 +45,8 @@ shift $((OPTIND - 1))

# Make sure we're in the correct directory, at the root of the source tree.
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
cd ${SCRIPT_DIR}/../../../
TOP_SRCDIR="${SCRIPT_DIR}/../../../"
cd ${TOP_SRCDIR}

source "${SCRIPT_DIR}/build_helper.subr"
JOB_COUNT="${JOB_COUNT:-$(get_job_count)}"
Expand All @@ -56,6 +60,32 @@ if [[ -n MACOSX_DEPLOYMENT_TARGET ]]; then
export MACOSX_DEPLOYMENT_TARGET=$(sw_vers -productVersion)
fi

PRNT_SLCTV_BIN="${TOP_SRCDIR}bazel-bin/tensorflow/python/tools/print_selective_registration_header"

if [[ ! -z "${OPTIMIZE_FOR_GRAPH}" ]]; then
echo "Request to optimize for graph: ${OPTIMIZE_FOR_GRAPH}"
#Request to trim the OPs by selectively registering
if [ ! -f ${PRNT_SLCTV_BIN} ]; then
#Build bazel build tensorflow/python/tools:print_selective_registration_header
echo "${PRNT_SLCTV_BIN} not found. Trying to build it"
cd ${TOP_SRCDIR}
bazel build --copt="-DUSE_GEMM_FOR_CONV" tensorflow/python/tools:print_selective_registration_header
if [ ! -f ${PRNT_SLCTV_BIN} ]; then
echo "Building print_selective_registration_header failed"
echo "You may want to build TensorFlow with: "
echo "./configure"
echo "bazel build --copt="-DUSE_GEMM_FOR_CONV" tensorflow/python/tools:print_selective_registration_header"
echo "and then run this script again"
exit 1
fi
else
echo "${PRNT_SLCTV_BIN} found. Using it"
${PRNT_SLCTV_BIN} --graphs=${OPTIMIZE_FOR_GRAPH} > ${TOP_SRCDIR}/tensorflow/core/framework/ops_to_register.h

fi

fi

if [[ "${ONLY_MAKE_TENSORFLOW}" != "true" ]]; then
# Remove any old files first.
make -f tensorflow/contrib/makefile/Makefile clean
Expand All @@ -64,8 +94,13 @@ if [[ "${ONLY_MAKE_TENSORFLOW}" != "true" ]]; then
# Pull down the required versions of the frameworks we need.
tensorflow/contrib/makefile/download_dependencies.sh

# Compile protobuf for the target iOS device architectures.
tensorflow/contrib/makefile/compile_ios_protobuf.sh
if [[ -z "${BUILD_ARCH}" ]]; then
# Compile protobuf for the target iOS device architectures.
tensorflow/contrib/makefile/compile_ios_protobuf.sh -a ${DEFAULT_ARCH}
else
# Compile protobuf for the target iOS device architectures.
tensorflow/contrib/makefile/compile_ios_protobuf.sh -a ${BUILD_ARCH}
fi
fi

# Compile nsync for the target iOS device architectures.
Expand All @@ -80,13 +115,24 @@ else
fi
export HOST_NSYNC_LIB TARGET_NSYNC_LIB

if [[ -z "${BUILD_ARCH}" ]]; then
# build the ios tensorflow libraries.
tensorflow/contrib/makefile/compile_ios_tensorflow.sh -f "-O3" -h $HOST_NSYNC_LIB -n $TARGET_NSYNC_LIB
else
TF_CC_FLAGS="-O3"
TF_SCRIPT_FLAGS="-h ${HOST_NSYNC_LIB} -n ${TARGET_NSYNC_LIB}"

if [[ ! -z "${OPTIMIZE_FOR_GRAPH}" ]]; then
# arch specified so build just that
TF_CC_FLAGS="${TF_CC_FLAGS} -DANDROID_TYPES=__ANDROID_TYPES_FULL__ -DSELECTIVE_REGISTRATION -DSUPPORT_SELECTIVE_REGISTRATION"
# The Makefile checks the env var to decide which ANDROID_TYPES to build
export ANDROID_TYPES="-D__ANDROID_TYPES_FULL__"
fi

if [[ ! -z "${BUILD_ARCH}" ]]; then
# arch specified so build just that
tensorflow/contrib/makefile/compile_ios_tensorflow.sh -f "-O3" -a "${BUILD_ARCH}" -h $HOST_NSYNC_LIB -n $TARGET_NSYNC_LIB
TF_SCRIPT_FLAGS="${TF_SCRIPT_FLAGS} -a ${BUILD_ARCH}"
fi

# build the ios tensorflow libraries.
echo "Building TensorFlow with flags: ${TF_SCRIPT_FLAGS} -f ${TF_CC_FLAGS}"
tensorflow/contrib/makefile/compile_ios_tensorflow.sh ${TF_SCRIPT_FLAGS} -f "${TF_CC_FLAGS}"

# Creates a static universal library in
# tensorflow/contrib/makefile/gen/lib/libtensorflow-core.a
1 change: 0 additions & 1 deletion tensorflow/core/framework/numeric_types.h
Expand Up @@ -25,7 +25,6 @@ limitations under the License.
#include "third_party/eigen3/unsupported/Eigen/CXX11/FixedPoint"
// clang-format on

#include "tensorflow/core/platform/cpu_info.h"
#include "tensorflow/core/platform/types.h"

namespace tensorflow {
Expand Down

0 comments on commit 84575be

Please sign in to comment.