Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Branch 144675800 #6895

Merged
merged 52 commits into from Jan 17, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
52 commits
Select commit Hold shift + click to select a range
c915f33
Update generated Python Op docs.
tensorflower-gardener Jan 13, 2017
202d00b
Task VariableV2 into account.
tensorflower-gardener Jan 13, 2017
04b3070
[XLA] Add a flag do_prefix to hlo_graph_dumper::DumpText()
tensorflower-gardener Jan 13, 2017
1e1e598
Change comment to use C++, not Python, syntax.
tensorflower-gardener Jan 13, 2017
19d41f0
Docs: Tweaks to the versioning guarantees before the 1.0 release.
asimshankar Jan 13, 2017
c94aece
Automated rollback of change 144270020
tensorflower-gardener Jan 13, 2017
b6671e4
Fix reference to now-deleted function field.
tensorflower-gardener Jan 13, 2017
16cc887
Make weight broadcasting more strict (in particular, catch the case w…
tensorflower-gardener Jan 13, 2017
29122ef
Stopgap removal of "features" input alternative, which fails with Spa…
davidsoergel Jan 13, 2017
9f97bba
[TF:XLA] Add support for specifying a device instance for randomized …
hawkinsp Jan 13, 2017
d414c79
Add control_dependencies parameter to ImportGraphDefOptions.
skye Jan 13, 2017
62d90be
Implement softplus_inverse op.
jvdillon Jan 13, 2017
f1a6dc1
Update generated Python Op docs.
tensorflower-gardener Jan 13, 2017
7c96ead
tfdbg: add Session.sess_str check to Session wrapper base class
caisq Jan 13, 2017
8f89336
Fix issues with shape inference during graph import.
petewarden Jan 13, 2017
1c51201
Fix SavedModel export when predictions is a single tensor and output_…
davidsoergel Jan 13, 2017
c4e3d4a
Enable customization of architecture dependent compiler optimizations…
martinwicke Jan 13, 2017
fb067ef
C API: Package rules for a C library and header files.
asimshankar Jan 13, 2017
a0ddcca
Implement Vector Student's T-distribution. This distribution is an Af…
jvdillon Jan 13, 2017
c847263
Enable record filtering while still allowing for downstream queuing t…
tensorflower-gardener Jan 13, 2017
8803dfa
Refactor KMeansClustering estimator to inherit from Estimator.
tensorflower-gardener Jan 13, 2017
705cc93
Do parallel_stack as a graph rewrite instead of python code.
tensorflower-gardener Jan 13, 2017
f6d87b8
Update ops-related pbtxt files.
tensorflower-gardener Jan 13, 2017
0d1008e
Update generated Python Op docs.
tensorflower-gardener Jan 13, 2017
0b7e66c
LinearOperatorScaledIdentity added to contrib/linalg/
langmore Jan 13, 2017
152f9fc
Fix some bugs in tf.Learn SavedModel APIs.
tensorflower-gardener Jan 13, 2017
3699dfe
Provide multiple implementations of RPC responses on the fetch path.
mrry Jan 13, 2017
a22f020
Update generated Python Op docs.
tensorflower-gardener Jan 13, 2017
b24a0b2
Makes the ops used by ParallelConcat internal.
tensorflower-gardener Jan 13, 2017
3b596e0
XLA: Drop dependency on unused internal C++ op lib.
tensorflower-gardener Jan 13, 2017
9438ace
Move Input/Output/etc. to tensorflow namespace from
tensorflower-gardener Jan 13, 2017
e4a235a
Internal change.
tensorflower-gardener Jan 14, 2017
edb10c6
internal only change
blakehechtman Jan 14, 2017
d06e669
Bug fix in SavedModel shim's named signature up-conversion for classi…
kirilg Jan 14, 2017
7ab67d8
Automated rollback of change 142694447
tensorflower-gardener Jan 14, 2017
8eb161e
Add support for passes that run post-partitioning to OptimizationRegi…
hawkinsp Jan 14, 2017
5ab7874
Fix breakage by recent changes in tf.summary.
tensorflower-gardener Jan 14, 2017
e720678
Default naming of scopes should continue, not reset, after jumps to r…
Jan 15, 2017
9654cf9
Add tf.tables_initializer as a replacement for tf.initialize_all_tabl…
tensorflower-gardener Jan 15, 2017
bbd9022
Update generated Python Op docs.
tensorflower-gardener Jan 15, 2017
a704573
Fix a breakage in python3 test
caisq Jan 15, 2017
6987e97
Adding nav entries for Layers tutorial, and making a few small format…
sandersk Jan 16, 2017
acdbd68
Create --config opt for compiling fully optimized binaries.
gunan Jan 16, 2017
44c5580
Updated bucket_ops to support different batch sizes per bucket.
tensorflower-gardener Jan 16, 2017
e1436d1
Update generated Python Op docs.
tensorflower-gardener Jan 16, 2017
1580d3b
tfdbg: Add GrpcDebugWrapperSession
caisq Jan 16, 2017
dbd7a2c
Update generated Python Op docs.
tensorflower-gardener Jan 16, 2017
26201f5
Fixed string formatting and valid task listing.
tensorflower-gardener Jan 16, 2017
cddb86f
Remove tf.cloud from public API until it's ready.
Jan 17, 2017
97c8933
Automated rollback of change 144470928
Jan 17, 2017
0b56eab
Use integer division to compute number of updates.
Jan 17, 2017
19ff874
Merge commit for internal changes
Jan 17, 2017
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
15 changes: 15 additions & 0 deletions configure
Expand Up @@ -49,6 +49,15 @@ while true; do
# Retry
done

## Set up architecture-dependent optimization flags.
if [ -z "$CC_OPT_FLAGS" ]; then
default_cc_opt_flags="-march=native"
read -p "Please specify optimization flags to use during compilation [Default is $default_cc_opt_flags]: " CC_OPT_FLAGS
if [ -z "$CC_OPT_FLAGS" ]; then
CC_OPT_FLAGS=$default_cc_opt_flags
fi
fi

if is_windows; then
TF_NEED_GCP=0
TF_NEED_HDFS=0
Expand Down Expand Up @@ -148,6 +157,12 @@ fi
# Invoke python_config and set up symlinks to python includes
./util/python/python_config.sh --setup "$PYTHON_BIN_PATH"

# Append CC optimization flags to bazel.rc
echo >> tools/bazel.rc
for opt in $CC_OPT_FLAGS; do
echo "build:opt --cxxopt=$opt --copt=$opt" >> tools/bazel.rc
done

# Run the gen_git_source to create links where bazel can track dependencies for
# git hash propagation
GEN_GIT_SOURCE=tensorflow/tools/git/gen_git_source.py
Expand Down
2 changes: 0 additions & 2 deletions tensorflow/cc/framework/ops.cc
Expand Up @@ -17,7 +17,6 @@ limitations under the License.
#include "tensorflow/core/lib/hash/hash.h"

namespace tensorflow {
namespace ops {

Operation::Operation(Node* n) : inputs_(GetInputs(n)), node_(n) {}

Expand Down Expand Up @@ -110,5 +109,4 @@ Input::Initializer::Initializer(
tensor = t;
}

} // namespace ops
} // namespace tensorflow
16 changes: 14 additions & 2 deletions tensorflow/cc/framework/ops.h
Expand Up @@ -25,7 +25,6 @@ limitations under the License.
#include "tensorflow/core/lib/strings/strcat.h"

namespace tensorflow {
namespace ops {

class Output;

Expand Down Expand Up @@ -193,6 +192,7 @@ class Input {
// * A scalar, or a multi-dimensional tensor specified as a recursive
// initializer list. This enables directly passing constants as
// inputs to op wrappers.
// * A Tensor object.
Input(const Output& o) : output_(o) {} // NOLINT(runtime/explicit)

template <typename T, typename = typename std::enable_if<
Expand Down Expand Up @@ -249,7 +249,7 @@ typedef std::vector<Output> OutputList;
class InputList {
public:
// Implicitly convert a list of outputs to a list of inputs. This is useful to
// write code such as tf.Concat(tf.Split(x, 4)).
// write code such as ops::Concat(ops::Split(x, 4)).
InputList(const OutputList& out) { // NOLINT(runtime/explicit)
for (auto const& x : out) {
inputs_.push_back(x);
Expand Down Expand Up @@ -284,7 +284,19 @@ class InputList {
std::vector<Input> inputs_;
};

// These symbols used to live in the ops namespace, so we temporarily
// declare some aliases there. TODO(josh11b): Delete this!
namespace ops {

using ::tensorflow::Input;
using ::tensorflow::InputList;
using ::tensorflow::Operation;
using ::tensorflow::Output;
using ::tensorflow::OutputHash;
using ::tensorflow::OutputList;

} // namespace ops

} // namespace tensorflow

#endif // THIRD_PARTY_TENSORFLOW_CC_FRAMEWORK_OPS_H_
6 changes: 2 additions & 4 deletions tensorflow/compiler/jit/encapsulate_subgraphs_pass.cc
Expand Up @@ -602,12 +602,10 @@ Status EncapsulateSubgraphsPass::Run(
std::unique_ptr<Graph>* subgraph, std::vector<int>* input_permutation,
std::vector<int>* output_permutation, NodeDef* node) {
// Optimize the subgraph.
Graph* g = subgraph->release();
OptimizeGraph(flr.get(), &g);
subgraph->reset(g);
OptimizeGraph(flr.get(), subgraph);

std::vector<bool> const_args(input_permutation->size());
TF_RETURN_IF_ERROR(BackwardsConstAnalysis(*g, &const_args));
TF_RETURN_IF_ERROR(BackwardsConstAnalysis(**subgraph, &const_args));

// Compute a permutation of the arguments such that the constant arguments
// are first.
Expand Down
37 changes: 24 additions & 13 deletions tensorflow/compiler/tests/randomized_tests.cc
Expand Up @@ -28,7 +28,7 @@ limitations under the License.
// Run tests, comparing the Tensorflow CPU operators with their XLA-compiled
// counterparts:
// randomized_tests \
// --tf_xla_test_use_jit=true --tf_xla_test_device=CPU \
// --tf_xla_test_use_jit=true --tf_xla_test_device=CPU:0 \
// --tf_xla_test_repetitions=20

// TODO(phawkins): add tests for:
Expand All @@ -50,6 +50,7 @@ limitations under the License.
#include "tensorflow/compiler/tf2xla/type_util.h"
#include "tensorflow/core/common_runtime/device.h"
#include "tensorflow/core/common_runtime/device_factory.h"
#include "tensorflow/core/common_runtime/device_mgr.h"
#include "tensorflow/core/framework/node_def_builder.h"
#include "tensorflow/core/framework/node_def_util.h"
#include "tensorflow/core/framework/op_kernel.h"
Expand All @@ -66,6 +67,7 @@ limitations under the License.
#include "tensorflow/core/public/session.h"
#include "tensorflow/core/public/session_options.h"
#include "tensorflow/core/util/command_line_flags.h"
#include "tensorflow/core/util/device_name_utils.h"

namespace tensorflow {
namespace {
Expand All @@ -76,9 +78,8 @@ int32 tf_xla_test_repetitions = 20;
string* tf_xla_test_device_ptr; // initial value set in main()
bool tf_xla_test_use_jit = true;

string DeviceTypeToDeviceName(DeviceType type) {
return strings::StrCat("/job:localhost/replica:0/task:0/device:", type.type(),
":0");
string LocalDeviceToFullDeviceName(const string& device) {
return strings::StrCat("/job:localhost/replica:0/task:0/device:", device);
}

constexpr std::array<DataType, 3> kAllXlaTypes = {
Expand Down Expand Up @@ -575,9 +576,14 @@ Status TensorsAreClose(const Tensor& a, const Tensor& b, double atol,

void OpTest::ExpectTfAndXlaOutputsAreClose(const OpTestBuilder& builder,
double atol, double rtol) {
string cpu_device = DeviceTypeToDeviceName(DEVICE_CPU);
DeviceType test_device_type(*tf_xla_test_device_ptr);
string test_device = DeviceTypeToDeviceName(test_device_type);
string cpu_device =
LocalDeviceToFullDeviceName(strings::StrCat(DEVICE_CPU, ":0"));
string test_device = LocalDeviceToFullDeviceName(*tf_xla_test_device_ptr);

DeviceNameUtils::ParsedName parsed_name;
ASSERT_TRUE(
DeviceNameUtils::ParseLocalName(*tf_xla_test_device_ptr, &parsed_name));
DeviceType test_device_type(parsed_name.type);
++num_tests_;

GraphDef graph;
Expand Down Expand Up @@ -2058,7 +2064,7 @@ TEST_F(OpTest, ZerosLike) {
} // namespace tensorflow

int main(int argc, char** argv) {
tensorflow::tf_xla_test_device_ptr = new tensorflow::string("GPU");
tensorflow::tf_xla_test_device_ptr = new tensorflow::string("GPU:0");
std::vector<tensorflow::Flag> flag_list = {
tensorflow::Flag(
"tf_xla_random_seed", &tensorflow::tf_xla_random_seed,
Expand All @@ -2085,13 +2091,18 @@ int main(int argc, char** argv) {
LOG(ERROR) << "Unknown argument " << argv[1] << "\n" << usage;
return 2;
}
// XLA devices register kernels at construction time; create and destroy all
// known devices to make sure the kernels are registered.
// XLA devices register kernels at construction time; create all known devices
// to make sure the kernels are registered.
std::vector<tensorflow::Device*> devices;
TF_CHECK_OK(tensorflow::DeviceFactory::AddDevices(
tensorflow::SessionOptions(), "", &devices));
for (tensorflow::Device* device : devices) {
delete device;
}
tensorflow::DeviceMgr device_mgr(devices);

tensorflow::Device* ignored;
TF_QCHECK_OK(
device_mgr.LookupDevice(*tensorflow::tf_xla_test_device_ptr, &ignored))
<< "Unknown test device (" << *tensorflow::tf_xla_test_device_ptr
<< "). Did you build in the right configuration (e.g., is CUDA enabled)?";

return RUN_ALL_TESTS();
}
1 change: 0 additions & 1 deletion tensorflow/compiler/tf2xla/BUILD
Expand Up @@ -97,7 +97,6 @@ cc_test(
"//tensorflow/cc:cc_ops",
"//tensorflow/cc:function_ops",
"//tensorflow/cc:ops",
"//tensorflow/cc:sendrecv_ops",
"//tensorflow/compiler/tf2xla/kernels:xla_ops",
"//tensorflow/compiler/xla:literal_util",
"//tensorflow/compiler/xla/client:client_library",
Expand Down
4 changes: 1 addition & 3 deletions tensorflow/compiler/tf2xla/xla_compiler.cc
Expand Up @@ -186,9 +186,7 @@ Status XlaCompiler::CompileFunctionBody(
// for devices other than CPU.
OptimizerOptions opts;
GraphOptimizer optimizer(opts);
Graph* g = graph.release();
OptimizeGraph(flr, &g);
graph.reset(g);
OptimizeGraph(flr, &graph);

if (VLOG_IS_ON(1)) {
dump_graph::DumpGraphToFile(
Expand Down
1 change: 0 additions & 1 deletion tensorflow/compiler/tf2xla/xla_compiler_test.cc
Expand Up @@ -16,7 +16,6 @@ limitations under the License.
#include "tensorflow/compiler/tf2xla/xla_compiler.h"
#include "tensorflow/cc/framework/ops.h"
#include "tensorflow/cc/ops/function_ops.h"
#include "tensorflow/cc/ops/sendrecv_ops.h"
#include "tensorflow/cc/ops/standard_ops.h"
#include "tensorflow/compiler/tf2xla/xla_compilation_device.h"
#include "tensorflow/compiler/xla/client/client_library.h"
Expand Down
26 changes: 7 additions & 19 deletions tensorflow/compiler/xla/service/algebraic_simplifier.cc
Expand Up @@ -51,18 +51,9 @@ bool IsLiteralWithValue(const HloInstruction* operand, int value) {

// Returns whether the given transpose produces a result which is bit-wise
// identical to its operand and thus may be replaced with a bitcast.
bool TransposeIsBitcast(
const HloInstruction* transpose,
const AlgebraicSimplifier::ValidBitcastCallback& valid_bitcast_callback) {
bool TransposeIsBitcast(const HloInstruction* transpose) {
CHECK_EQ(HloOpcode::kTranspose, transpose->opcode());
const HloInstruction* operand = transpose->operand(0);

// Can't insert bitcasts if the compiler used a memory layout which isn't
// compatible.
if (!valid_bitcast_callback(operand->shape(), transpose->shape())) {
return false;
}

return ShapeUtil::TransposeIsBitcast(operand->shape(), transpose->shape(),
transpose->dimensions());
}
Expand All @@ -80,11 +71,8 @@ bool ReshapeIsBitcast(
const HloInstruction* operand = reshape->operand(0);
// Can't insert bitcasts if the compiler used a memory layout which isn't
// compatible.
if (!valid_bitcast_callback(operand->shape(), reshape->shape())) {
return false;
}

return ShapeUtil::ReshapeIsBitcast(operand->shape(), reshape->shape());
return ShapeUtil::ReshapeIsBitcast(operand->shape(), reshape->shape()) &&
valid_bitcast_callback(operand->shape(), reshape->shape());
}
} // namespace

Expand Down Expand Up @@ -199,7 +187,7 @@ class AlgebraicSimplifierVisitor : public DfsHloVisitorWithDefault {
// Whether layout is considered during transformation.
bool is_layout_sensitive_;

// Callback used to determine if a bitcast is valid.
// Callback used to determine if a bitcast is possible.
AlgebraicSimplifier::ValidBitcastCallback valid_bitcast_callback_;
};

Expand Down Expand Up @@ -287,7 +275,8 @@ Status AlgebraicSimplifierVisitor::HandleDivide(HloInstruction* divide,
HloInstruction* rhs) {
// A/1 => A
VLOG(10) << "trying transform [A/1 => A]: " << divide->ToString();
if (IsLiteralWithValue(rhs, 1) && ReplaceInstructionIfSameShape(divide, lhs)) {
if (IsLiteralWithValue(rhs, 1) &&
ReplaceInstructionIfSameShape(divide, lhs)) {
return Status::OK();
}

Expand Down Expand Up @@ -717,8 +706,7 @@ Status AlgebraicSimplifierVisitor::HandleTranspose(HloInstruction* transpose) {
return Status::OK();
}

if (is_layout_sensitive_ &&
TransposeIsBitcast(transpose, valid_bitcast_callback_)) {
if (is_layout_sensitive_ && TransposeIsBitcast(transpose)) {
ReplaceWithBitcast(transpose);
return Status::OK();
}
Expand Down
8 changes: 5 additions & 3 deletions tensorflow/compiler/xla/service/algebraic_simplifier.h
Expand Up @@ -26,9 +26,11 @@ namespace xla {
// A pass which performs AlgebraicSimplications.
class AlgebraicSimplifier : public HloPass {
public:
// Given two shapes, determines if it is valid to bitcast between them.
// Precondition: the two shapes have layouts and have the same number of
// elements.
// Given two shapes, determines if it is valid to bitcast between them after
// considering platform dependent effects on layout like alignment
// restrictions.
// Precondition: the two shapes have layouts, the same number of
// elements and ShapeUtil::ReshapeIsBitcast returns true.
using ValidBitcastCallback = std::function<bool(const Shape&, const Shape&)>;

// If is_layout_sensitive is true, then the simplifier preserves layout during
Expand Down
6 changes: 4 additions & 2 deletions tensorflow/compiler/xla/service/hlo_graph_dumper.cc
Expand Up @@ -495,11 +495,13 @@ string DumpGraph(const HloComputation& computation, const string& label,
}

void DumpText(const HloModule& module, const string& label,
const string& directory_path) {
const string& directory_path, bool do_prefix) {
Env* env = Env::Default();
TF_CHECK_OK(env->RecursivelyCreateDir(directory_path));
string prefix = StrCat(env->NowMicros());
string path = JoinPath(directory_path, StrCat(prefix, "-", label, ".txt"));
string filename =
do_prefix ? StrCat(prefix, "-", label, ".txt") : StrCat(label, ".txt");
string path = JoinPath(directory_path, filename);
TF_CHECK_OK(WriteStringToFile(env, path, module.ToString()));
}

Expand Down
6 changes: 5 additions & 1 deletion tensorflow/compiler/xla/service/hlo_graph_dumper.h
Expand Up @@ -33,8 +33,12 @@ string DumpGraph(const HloComputation& computation, const string& label,

// Dumps the HloModule::ToString() as a file into the provided directory path
// suffixed with the provided label.
//
// If do_prefix is true, a timestamp will be prepended onto the label to
// construct a filename in the directory path; otherwise, the label is used
// as the filename directly.
void DumpText(const HloModule& module, const string& label,
const string& directory_path);
const string& directory_path, bool do_prefix = true);

// Abstract interface for classes that render DOT graphs.
class GraphRendererInterface {
Expand Down
11 changes: 10 additions & 1 deletion tensorflow/contrib/cmake/CMakeLists.txt
Expand Up @@ -27,6 +27,7 @@ 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)
option(tensorflow_OPTIMIZE_FOR_NATIVE_ARCH "Enable compiler optimizations for the native processor architecture (if available)" ON)

if (NOT WIN32)
# Threads: defines CMAKE_THREAD_LIBS_INIT and adds -pthread compile option
Expand Down Expand Up @@ -67,7 +68,15 @@ if(WIN32)
endif()

if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
set(CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS} "-fno-exceptions -std=c++11")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-exceptions -std=c++11")
endif()

if (tensorflow_OPTIMIZE_FOR_NATIVE_ARCH)
include(CheckCXXCompilerFlag)
CHECK_CXX_COMPILER_FLAG("-march=native" COMPILER_OPT_ARCH_NATIVE_SUPPORTED)
if (COMPILER_OPT_ARCH_NATIVE_SUPPORTED)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -march=native")
endif()
endif()

# External dependencies
Expand Down
17 changes: 17 additions & 0 deletions tensorflow/contrib/distributions/BUILD
Expand Up @@ -448,6 +448,23 @@ cuda_py_tests(
tags = ["nomsan"], # disable to avoid false positives from scipy.
)

cuda_py_tests(
name = "vector_student_t_test",
size = "medium",
srcs = ["python/kernel_tests/vector_student_t_test.py"],
additional_deps = [
":distributions_py",
":distributions_py_CYCLIC_DEPENDENCIES_THAT_NEED_TO_GO",
"//third_party/py/numpy",
"//tensorflow/python:array_ops",
"//tensorflow/python:client_testlib",
"//tensorflow/python:framework",
"//tensorflow/python:framework_for_generated_wrappers",
"//tensorflow/python:framework_test_lib",
"//tensorflow/python:platform_test",
],
)

cuda_py_tests(
name = "uniform_test",
size = "small",
Expand Down
6 changes: 6 additions & 0 deletions tensorflow/contrib/distributions/__init__.py
Expand Up @@ -93,6 +93,11 @@

@@kl
@@RegisterKL

## Utilities

@@softplus_inverse

"""
from __future__ import absolute_import
from __future__ import division
Expand All @@ -110,6 +115,7 @@
from tensorflow.contrib.distributions.python.ops.dirichlet_multinomial import *
from tensorflow.contrib.distributions.python.ops.distribution import *
from tensorflow.contrib.distributions.python.ops.distribution_util import matrix_diag_transform
from tensorflow.contrib.distributions.python.ops.distribution_util import softplus_inverse
from tensorflow.contrib.distributions.python.ops.exponential import *
from tensorflow.contrib.distributions.python.ops.gamma import *
from tensorflow.contrib.distributions.python.ops.inverse_gamma import *
Expand Down