Skip to content

Commit

Permalink
Merge changes from github.
Browse files Browse the repository at this point in the history
Change: 138675832
  • Loading branch information
benoitsteiner authored and tensorflower-gardener committed Nov 9, 2016
1 parent f0e9bd3 commit a771598
Show file tree
Hide file tree
Showing 110 changed files with 2,140 additions and 130 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ node_modules
/third_party/py/numpy/numpy_include
/tools/bazel.rc
/tools/python_bin_path.sh
/tools/git/gen
/util/python/python_include
/util/python/python_lib
/pip_test
Expand Down
105 changes: 104 additions & 1 deletion configure
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ if is_windows; then
TF_NEED_GCP=0
TF_NEED_HDFS=0
TF_NEED_CUDA=0
TF_NEED_OPENCL=0
fi

while [ "$TF_NEED_GCP" == "" ]; do
Expand Down Expand Up @@ -116,6 +117,17 @@ GEN_GIT_SOURCE=tensorflow/tools/git/gen_git_source.py
chmod a+x ${GEN_GIT_SOURCE}
"${PYTHON_BIN_PATH}" ${GEN_GIT_SOURCE} --configure "${SOURCE_BASE_DIR}"

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

## Set up Cuda-related environment settings

while [ "$TF_NEED_CUDA" == "" ]; do
Expand All @@ -129,12 +141,14 @@ while [ "$TF_NEED_CUDA" == "" ]; do
done

export TF_NEED_CUDA
if [ "$TF_NEED_CUDA" == "0" ]; then
export TF_NEED_SYCL
if [[ "$TF_NEED_CUDA" == "0" ]] && [[ "$TF_NEED_OPENCL" == "0" ]]; then
echo "Configuration finished"
bazel_clean_and_fetch
exit
fi

if [ "$TF_NEED_CUDA" == "1" ]; then
# Set up which gcc nvcc should use as the host compiler
while true; do
fromuser=""
Expand Down Expand Up @@ -336,6 +350,95 @@ EOF
TF_CUDA_COMPUTE_CAPABILITIES=""
done

# end of if "$TF_NEED_CUDA" == "1"
fi

# OpenCL configuration

if [ "$TF_NEED_OPENCL" == "1" ]; then

# Determine which C++ compiler should be used as the host compiler
while true; do
fromuser=""
if [ -z "$HOST_CXX_COMPILER" ]; then
default_cxx_host_compiler=$(which g++|| true)
read -p "Please specify which C++ compiler should be used as the host C++ compiler. [Default is $default_cxx_host_compiler]: " HOST_CXX_COMPILER
fromuser="1"
if [ -z "$HOST_CXX_COMPILER" ]; then
HOST_CXX_COMPILER=$default_cxx_host_compiler
fi
fi
if [ -e "$HOST_CXX_COMPILER" ]; then
export HOST_CXX_COMPILER
break
fi
echo "Invalid C++ compiler path. ${HOST_CXX_COMPILER} cannot be found" 1>&2
if [ -z "$fromuser" ]; then
exit 1
fi
HOST_CXX_COMPILER=""
# Retry
done

# Determine which C compiler should be used as the host compiler
while true; do
fromuser=""
if [ -z "$HOST_C_COMPILER" ]; then
default_c_host_compiler=$(which gcc|| true)
read -p "Please specify which C compiler should be used as the host C compiler. [Default is $default_c_host_compiler]: " HOST_C_COMPILER
fromuser="1"
if [ -z "$HOST_C_COMPILER" ]; then
HOST_C_COMPILER=$default_c_host_compiler
fi
fi
if [ -e "$HOST_C_COMPILER" ]; then
export HOST_C_COMPILER
break
fi
echo "Invalid C compiler path. ${HOST_C_COMPILER} cannot be found" 1>&2
if [ -z "$fromuser" ]; then
exit 1
fi
HOST_C_COMPILER=""
# Retry
done

while true; do
# Configure the OPENCL version to use.
TF_OPENCL_VERSION="1.2"

# Point to ComputeCpp root
if [ -z "$COMPUTECPP_TOOLKIT_PATH" ]; then
default_computecpp_toolkit_path=/usr/local/computecpp
read -p "Please specify the location where ComputeCpp $TF_OPENCL_VERSION is installed. Refer to README.md for more details. [Default is $default_computecpp_toolkit_path]: " COMPUTECPP_TOOLKIT_PATH
fromuser="1"
if [ -z "$COMPUTECPP_TOOLKIT_PATH" ]; then
COMPUTECPP_TOOLKIT_PATH=$default_computecpp_toolkit_path
fi
fi

if [ "$OSNAME" == "Linux" ]; then
SYCL_RT_LIB_PATH="lib/libComputeCpp.so"
fi

if [ -e "${COMPUTECPP_TOOLKIT_PATH}/${SYCL_RT_LIB_PATH}" ]; then
export COMPUTECPP_TOOLKIT_PATH
break
fi
echo "Invalid SYCL $TF_OPENCL_VERSION library path. ${COMPUTECPP_TOOLKIT_PATH}/${SYCL_RT_LIB_PATH} cannot be found"

if [ -z "$fromuser" ]; then
exit 1
fi
# Retry
TF_OPENCL_VERSION=""
COMPUTECPP_TOOLKIT_PATH=""
done

export TF_NEED_OPENCL
# end of if "$TF_NEED_OPENCL" == "1"
fi

bazel_clean_and_fetch

echo "Configuration finished"
5 changes: 3 additions & 2 deletions tensorflow/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,14 @@

# Bring in all of the public TensorFlow interface into this
# module.
# pylint: disable=wildcard-import

from __future__ import absolute_import
from __future__ import division
from __future__ import print_function

# pylint: disable=wildcard-import
from tensorflow.python import *

# pylint: enable=wildcard-import

# Lazily import the `tf.contrib` module. This avoids loading all of the
# dependencies of `tf.contrib` at `import tensorflow` time.
Expand Down
3 changes: 2 additions & 1 deletion tensorflow/contrib/bayesflow/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
from __future__ import division
from __future__ import print_function

# pylint: disable=unused-import,wildcard-import,line-too-long
# pylint: disable=unused-import,line-too-long
from tensorflow.contrib.bayesflow.python.ops import entropy
from tensorflow.contrib.bayesflow.python.ops import monte_carlo
from tensorflow.contrib.bayesflow.python.ops import special_math
Expand All @@ -29,3 +29,4 @@
from tensorflow.contrib.bayesflow.python.ops import stochastic_tensor
from tensorflow.contrib.bayesflow.python.ops import stochastic_variables
from tensorflow.contrib.bayesflow.python.ops import variational_inference
# pylint: enable=unused-import,line-too-long
10 changes: 8 additions & 2 deletions tensorflow/contrib/cmake/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ option(tensorflow_BUILD_CC_EXAMPLE "Build the C++ tutorial example" ON)
option(tensorflow_BUILD_PYTHON_BINDINGS "Build the Python bindings" ON)
option(tensorflow_BUILD_ALL_KERNELS "Build all OpKernels" ON)
option(tensorflow_BUILD_CONTRIB_KERNELS "Build OpKernels from tensorflow/contrib/..." ON)

option(tensorflow_BUILD_CC_TESTS "Build cc unit tests " OFF)
option(tensorflow_BUILD_PYTHON_TESTS "Build python unit tests " OFF)

#Threads: defines CMAKE_THREAD_LIBS_INIT and adds -pthread compile option for
# targets that link ${CMAKE_THREAD_LIBS_INIT}.
Expand Down Expand Up @@ -74,6 +75,9 @@ include(jsoncpp)
include(farmhash)
include(highwayhash)
include(protobuf)
if (tensorflow_BUILD_CC_TESTS)
include(googletest)
endif()

set(tensorflow_EXTERNAL_LIBRARIES
${zlib_STATIC_LIBRARIES}
Expand Down Expand Up @@ -194,7 +198,6 @@ include(tf_core_kernels.cmake)
if(tensorflow_ENABLE_GRPC_SUPPORT)
include(tf_core_distributed_runtime.cmake)
endif()

include(tf_cc_ops.cmake)
if(tensorflow_BUILD_CC_EXAMPLE)
include(tf_tutorials.cmake)
Expand All @@ -203,3 +206,6 @@ endif()
if(tensorflow_BUILD_PYTHON_BINDINGS)
include(tf_python.cmake)
endif()
if (tensorflow_BUILD_CC_TESTS OR tensorflow_BUILD_PYTHON_TESTS)
include(tf_tests.cmake)
endif()
21 changes: 18 additions & 3 deletions tensorflow/contrib/cmake/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,9 @@ Note: Windows support is in an **alpha** state, and we welcome your feedback.
on Windows, but have not yet committed to supporting that configuration.)

- The following Python APIs are not currently implemented:
* Loading custom op libraries via `tf.load_op_library()`.
* Loading custom op libraries via `tf.load_op_library()`. In order to use your
custom op, please put the source code under the tensorflow/core/user_ops
directory, and a shape function is required (not optional) for each op.
* Path manipulation functions (such as `tf.gfile.ListDirectory()`) are not
functional.

Expand All @@ -76,7 +78,6 @@ Note: Windows support is in an **alpha** state, and we welcome your feedback.
* `ImmutableConst`
* `Lgamma`
* `Polygamma`
* `SparseMatmul`
* `Zeta`

- Google Cloud Storage support is not currently implemented. The GCS library
Expand Down Expand Up @@ -195,7 +196,21 @@ Step-by-step Windows build
* `-Dtensorflow_ENABLE_GPU=(ON|OFF)`. Defaults to `OFF`. Include
GPU support. If GPU is enabled you need to install the CUDA 8.0 Toolkit and CUDNN 5.1.
CMake will expect the location of CUDNN in -DCUDNN_HOME=path_you_unziped_cudnn.


* `-Dtensorflow_BUILD_CC_TESTS=(ON|OFF)`. Defaults to `OFF`. This builds cc unit tests.
There are many of them and building will take a few hours.
After cmake, build and execute the tests with
```
MSBuild /p:Configuration=RelWithDebInfo ALL_BUILD.vcxproj
ctest -C RelWithDebInfo
```

* `-Dtensorflow_BUILD_PYTHON_TESTS=(ON|OFF)`. Defaults to `OFF`. This enables python kernel tests.
After building the python wheel, you need to install the new wheel before running the tests.
To execute the tests, use
```
ctest -C RelWithDebInfo
```

4. Invoke MSBuild to build TensorFlow.

Expand Down
29 changes: 29 additions & 0 deletions tensorflow/contrib/cmake/external/googletest.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
include (ExternalProject)

set(googletest_INCLUDE_DIRS ${CMAKE_CURRENT_BINARY_DIR}/googletest/src/googletest/googletest/include)
set(googletest_URL https://github.com/google/googletest.git)
set(googletest_BUILD ${CMAKE_CURRENT_BINARY_DIR}/googletest/)
set(googletest_TAG ec44c6c1675c25b9827aacd08c02433cccde7780)

if(WIN32)
set(googletest_STATIC_LIBRARIES
${CMAKE_CURRENT_BINARY_DIR}/googletest/src/googletest/googletest/${CMAKE_BUILD_TYPE}/gtest.lib)
else()
set(googletest_STATIC_LIBRARIES
${CMAKE_CURRENT_BINARY_DIR}/googletest/src/googletest/googletest/${CMAKE_BUILD_TYPE}/gtest.a)
endif()

ExternalProject_Add(googletest
PREFIX googletest
GIT_REPOSITORY ${googletest_URL}
GIT_TAG ${googletest_TAG}
DOWNLOAD_DIR "${DOWNLOAD_LOCATION}"
BUILD_IN_SOURCE 1
#PATCH_COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_SOURCE_DIR}/patches/grpc/CMakeLists.txt ${GRPC_BUILD}
INSTALL_COMMAND ""
CMAKE_CACHE_ARGS
-DCMAKE_BUILD_TYPE:STRING=${CMAKE_BUILD_TYPE}
-DBUILD_GMOCK:BOOL=OFF
-DBUILD_GTEST:BOOL=ON
-Dgtest_force_shared_crt:BOOL=ON
)
2 changes: 1 addition & 1 deletion tensorflow/contrib/cmake/external/zlib.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ set(ZLIB_TAG 50893291621658f355bc5b4d450a8d06a563053d)

if(WIN32)
set(zlib_STATIC_LIBRARIES
${CMAKE_CURRENT_BINARY_DIR}/zlib/install/lib/zlib.lib)
${CMAKE_CURRENT_BINARY_DIR}/zlib/install/lib/zlibstatic.lib)
else()
set(zlib_STATIC_LIBRARIES
${CMAKE_CURRENT_BINARY_DIR}/zlib/install/lib/libz.a)
Expand Down
1 change: 1 addition & 0 deletions tensorflow/contrib/cmake/tf_core_ops.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ set(tf_op_lib_names
"no_op"
"parsing_ops"
"random_ops"
"resource_variable_ops"
"script_ops"
"sdca_ops"
"sendrecv_ops"
Expand Down
1 change: 1 addition & 0 deletions tensorflow/contrib/cmake/tf_python.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,7 @@ GENERATE_PYTHON_OP_LIB("logging_ops")
GENERATE_PYTHON_OP_LIB("nn_ops")
GENERATE_PYTHON_OP_LIB("parsing_ops")
GENERATE_PYTHON_OP_LIB("random_ops")
GENERATE_PYTHON_OP_LIB("resource_variable_ops")
GENERATE_PYTHON_OP_LIB("script_ops")
GENERATE_PYTHON_OP_LIB("sdca_ops")
GENERATE_PYTHON_OP_LIB("state_ops")
Expand Down
Loading

0 comments on commit a771598

Please sign in to comment.