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 186777369 #17226

Merged
merged 30 commits into from
Feb 23, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
83a35a8
[XLA] Enable F16 convolution test for CPU.
bixia1 Feb 22, 2018
30310e4
Enable int64 outfeed.
jpienaar Feb 22, 2018
963b9be
Adds support for identifying dilated convolution emulation.
tensorflower-gardener Feb 22, 2018
cb7e196
Internal change.
fdxmw Feb 22, 2018
dce9a49
Merge changes from github.
yifeif Feb 22, 2018
6006f46
[tf.data] Handle a function-raised OutOfRange error correctly in Para…
mrry Feb 22, 2018
848c53f
Implement the logic to parse TensorProto (the tensor value for input …
tensorflower-gardener Feb 22, 2018
c50e351
Add a regression test for virtual_scheduler.
yacoder Feb 23, 2018
810ddac
New Mutex operations for a distributed-happy and Function-less Critic…
ebrevdo Feb 23, 2018
9114005
Add integration tests for remote build execution.
tensorflower-gardener Feb 23, 2018
cdb0dd6
Add to disabled tests the date they were last ran and failed.
bixia1 Feb 23, 2018
db0db83
[XLA] Enable most xla/tests for interpreter.
kayzhu Feb 23, 2018
d4bf5b2
Internal change.
tensorflower-gardener Feb 23, 2018
2985919
Support degenerate strided slicing under XLA.
iganichev Feb 23, 2018
1ae8533
Clarify ownership story of TfLiteIntArray* nodes_to_replace
aselle Feb 23, 2018
f68f5e4
Go: Update generated wrapper functions for TensorFlow ops.
tensorflower-gardener Feb 23, 2018
33b6cc7
LSTM support: Quantized types, quantization params for 16-bit unfused…
tensorflower-gardener Feb 23, 2018
8722aee
Moved LIBXSMM convolutions to a separate --define flag so that they a…
tensorflower-gardener Feb 23, 2018
57ee22d
Turn on strip_default_attrs by default during custom export.
tensorflower-gardener Feb 23, 2018
8852be3
Fix fix Defun logic when returning a value captured from an outer scope.
mrry Feb 23, 2018
491fb62
Add cost estimator tests for the BiasAdd, ReLU, and Conv2D operations.
tensorflower-gardener Feb 23, 2018
0f18c8e
[XLA] Add SliceInDim to the local Python XLA client.
tensorflower-gardener Feb 23, 2018
917a4ac
Update ops-related pbtxt files.
tensorflower-gardener Feb 23, 2018
1dcd464
Pass 'mode' argument to input_fn if appropriate in TPUEstimator.
tensorflower-gardener Feb 23, 2018
befd823
Enable constant propagation across Switch(x,x) by rewriting the two o…
tensorflower-gardener Feb 23, 2018
bff1648
Unify metropolis_hastings interface with HMC kernel.
dustinvtran Feb 23, 2018
1acc02f
Let variables initialized from checkpoints answer ".initialized_value…
tensorflower-gardener Feb 23, 2018
cef8364
Allow setting of OpMetadata for Send HLOs.
tensorflower-gardener Feb 23, 2018
0f6f85e
Merge commit for internal changes
yifeif Feb 23, 2018
db8c7e9
Remove repeated defination due to auto-merge.
yifeif Feb 23, 2018
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
5 changes: 3 additions & 2 deletions configure.py
Original file line number Diff line number Diff line change
Expand Up @@ -1067,7 +1067,7 @@ def is_compatible(tensorrt_lib, cuda_ver, cudnn_ver):
break

# Reset and Retry
if len(possible_files):
if possible_files:
print('TensorRT libraries found in one the following directories',
'are not compatible with selected cuda and cudnn installations')
print(trt_install_path)
Expand All @@ -1076,7 +1076,8 @@ def is_compatible(tensorrt_lib, cuda_ver, cudnn_ver):
if search_result:
print(libnvinfer_path_from_ldconfig)
else:
print('Invalid path to TensorRT. None of the following files can be found:')
print(
'Invalid path to TensorRT. None of the following files can be found:')
print(trt_install_path)
print(os.path.join(trt_install_path, 'lib'))
print(os.path.join(trt_install_path, 'lib64'))
Expand Down
29 changes: 29 additions & 0 deletions tensorflow/compiler/tests/slice_ops_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

from tensorflow.compiler.tests.xla_test import XLATestCase
from tensorflow.python.framework import dtypes
from tensorflow.python.framework import tensor_shape
from tensorflow.python.ops import array_ops
from tensorflow.python.platform import googletest

Expand Down Expand Up @@ -137,6 +138,34 @@ def test1DNegativeStride(self):

self.assertAllEqual([6, 4], result)

def test2DDegenerate(self):
for dtype in self.numeric_types:
with self.test_session():
i = array_ops.placeholder(dtype, shape=[2, 3])
with self.test_scope():
o = array_ops.strided_slice(i, [-1, 0], [0, 3])
params = {
i: [[0, 1, 2],
[3, 4, 5]]
}
result = o.eval(feed_dict=params)

self.assertEqual(tensor_shape.TensorShape((0, 3)), result.shape)

def test2DDegenerateNegativeStride(self):
for dtype in self.numeric_types:
with self.test_session():
i = array_ops.placeholder(dtype, shape=[2, 3])
with self.test_scope():
o = array_ops.strided_slice(i, [0, 0], [-1, 3], [-1, 1])
params = {
i: [[0, 1, 2],
[3, 4, 5]]
}
result = o.eval(feed_dict=params)

self.assertEqual(tensor_shape.TensorShape((0, 3)), result.shape)

def test3D(self):
for dtype in self.numeric_types:
with self.test_session():
Expand Down
5 changes: 3 additions & 2 deletions tensorflow/compiler/tf2xla/kernels/strided_slice_op.cc
Original file line number Diff line number Diff line change
Expand Up @@ -77,13 +77,14 @@ class StridedSliceOp : public XlaOpKernel {
for (int i = 0; i < begin.size(); ++i) {
if (strides[i] > 0) {
slice_begin.push_back(begin[i]);
slice_end.push_back(end[i]);
slice_end.push_back(std::max(end[i], begin[i]));
slice_strides.push_back(strides[i]);
} else {
// Negative stride: swap begin and end, add 1 because the interval
// is semi-open, and mark the dimension to be reversed.
slice_begin.push_back(input_shape.dim_size(i) - begin[i] - 1);
slice_end.push_back(input_shape.dim_size(i) - end[i] - 1);
slice_end.push_back(std::max(input_shape.dim_size(i) - end[i] - 1,
input_shape.dim_size(i) - begin[i] - 1));
slice_strides.push_back(-strides[i]);
dimensions_to_reverse.push_back(i);
}
Expand Down
5 changes: 2 additions & 3 deletions tensorflow/compiler/xla/client/computation_builder.h
Original file line number Diff line number Diff line change
Expand Up @@ -198,9 +198,8 @@ class ComputationBuilder {
tensorflow::gtl::ArraySlice<int64> new_sizes);

// Enqueues an operation onto the computation that collapses the operand, from
// minor to major order, then reshapes it into the shape with the given
// dimension sizes, also from major to minor. Conceptually, this is a limited
// form of "shape casting".
// first to last dimension (C order), then reshapes it to the given dimension
// sizes. Conceptually, this is a limited form of "shape casting".
ComputationDataHandle Reshape(const ComputationDataHandle& operand,
tensorflow::gtl::ArraySlice<int64> new_sizes);

Expand Down
6 changes: 6 additions & 0 deletions tensorflow/compiler/xla/python/local_computation_builder.cc
Original file line number Diff line number Diff line change
Expand Up @@ -368,6 +368,12 @@ ComputationDataHandle LocalComputationBuilder::Slice(
return builder_.Slice(operand, start_indices, limit_indices, strides);
}

ComputationDataHandle LocalComputationBuilder::SliceInDim(
const ComputationDataHandle& operand, int64 start_index, int64 limit_index,
int64 stride, int64 dimno) {
return builder_.SliceInDim(operand, start_index, limit_index, stride, dimno);
}

ComputationDataHandle LocalComputationBuilder::DynamicSlice(
const ComputationDataHandle& operand,
const ComputationDataHandle& start_indices,
Expand Down
4 changes: 4 additions & 0 deletions tensorflow/compiler/xla/python/local_computation_builder.h
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,10 @@ class LocalComputationBuilder {
tensorflow::gtl::ArraySlice<int64> limit_indices,
tensorflow::gtl::ArraySlice<int64> strides);

ComputationDataHandle SliceInDim(const ComputationDataHandle& operand,
int64 start_index, int64 limit_index,
int64 stride, int64 dimno);

ComputationDataHandle DynamicSlice(
const ComputationDataHandle& operand,
const ComputationDataHandle& start_indices,
Expand Down
1 change: 1 addition & 0 deletions tensorflow/compiler/xla/python/local_computation_builder.i
Original file line number Diff line number Diff line change
Expand Up @@ -886,6 +886,7 @@ tensorflow::ImportNumpy();
%unignore xla::swig::LocalComputationBuilder::Collapse;
%unignore xla::swig::LocalComputationBuilder::CrossReplicaSum;
%unignore xla::swig::LocalComputationBuilder::Slice;
%unignore xla::swig::LocalComputationBuilder::SliceInDim;
%unignore xla::swig::LocalComputationBuilder::DynamicSlice;
%unignore xla::swig::LocalComputationBuilder::DynamicUpdateSlice;
%unignore xla::swig::LocalComputationBuilder::ConcatInDim;
Expand Down
39 changes: 34 additions & 5 deletions tensorflow/compiler/xla/python/xla_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -656,7 +656,7 @@ def Pad(self, operand, padding_value, padding_config):
representing the configuration of the padding operation.

Returns:
A ComputationDataHandle representing the added pad op.
A ComputationDataHandle representing the added Pad op.
"""
if not isinstance(padding_config, xla_data_pb2.PaddingConfig):
padding_config = GetPaddingConfigFromTriples(padding_config)
Expand All @@ -666,7 +666,20 @@ def Pad(self, operand, padding_value, padding_config):
padding_config))

def Reshape(self, operand, dimensions, new_sizes):
"""Reshape op."""
"""Enqueues a reshape op onto the computation.

Args:
operand: ComputationDataHandle representing the array to be reshaped.
dimensions: sequence of integers encoding the order in which dimensions
are collapsed or None, in which case dimensions are flattened in order.
new_sizes: sequence of integers encoding the new dimension sizes (shape).

Returns:
A ComputationDataHandle representing the added Reshape op.
"""
if dimensions is None:
ndim = len(self.GetShape(operand).dimensions())
dimensions = tuple(range(ndim))
return _wrap_data_handle(
self._client.Reshape(
_unwrap_data_handle(operand), dimensions, new_sizes))
Expand Down Expand Up @@ -772,11 +785,27 @@ def Slice(self, operand, start_indices, limit_indices, strides=None):
strides = [1] * len(start_indices)
return _wrap_data_handle(
self._client.Slice(
_unwrap_data_handle(operand),
start_indices,
limit_indices,
_unwrap_data_handle(operand), start_indices, limit_indices,
strides))

def SliceInDim(self, operand, start_index, limit_index, stride, dimno):
"""Enqueues a slice-in-dimension operation onto the computation.

Args:
operand: ComputationDataHandle for the N dimensional array to be sliced.
start_index: an integer containing the start index of the slice.
limit_index: an integer containing the end index of the slice.
stride: an integer containing the stride size for the slice.
dimno: an integer indicating the dimension along which to slice.

Returns:
A ComputationDataHandle representing the added Slice op.
"""
return _wrap_data_handle(
self._client.SliceInDim(
_unwrap_data_handle(operand), start_index, limit_index, stride,
dimno))

def DynamicSlice(self, operand, start_indices, slice_sizes):
"""Enqueues a slice op with dynamic start indices onto the computation.

Expand Down
17 changes: 17 additions & 0 deletions tensorflow/compiler/xla/python/xla_client_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -762,6 +762,23 @@ def testSlice(self):
[3, 2])
self._ExecuteAndCompareExact(c, expected=[[4, 5], [7, 8]])

def testSliceInDim(self):
c = self._NewComputation()
c.SliceInDim(
c.Constant(NumpyArrayS32([[1, 2, 3], [4, 5, 6], [7, 8, 9]])),
start_index=1,
limit_index=2,
stride=1,
dimno=1)
self._ExecuteAndCompareExact(c, expected=[[2], [5], [8]])
c.SliceInDim(
c.Constant(NumpyArrayS32([[1, 2, 3], [4, 5, 6], [7, 8, 9]])),
start_index=0,
limit_index=3,
stride=2,
dimno=0)
self._ExecuteAndCompareExact(c, expected=[[1, 2, 3], [7, 8, 9]])

def testDynamicSlice(self):
c = self._NewComputation()
c.DynamicSlice(
Expand Down
6 changes: 6 additions & 0 deletions tensorflow/compiler/xla/service/hlo_instruction.h
Original file line number Diff line number Diff line change
Expand Up @@ -824,6 +824,12 @@ class HloInstruction {
// Precondition: opcode() == HloOpcode::kSend or HloOpcode::kRecv
int64 channel_id() const { return channel_id_; }

// Returns the channel name associated with the instruction. The name is
// used to identify host Send/Recv operations.
//
// Precondition: opcode() == HloOpcode::kHostCompute
string channel_name() const { return channel_name_; }

// Returns feature_index field associated with the instruction. The index
// represents the index of the feature dimension.
//
Expand Down
12 changes: 12 additions & 0 deletions tensorflow/compiler/xla/service/hlo_module_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,15 @@ class HloModuleConfig {
bool hlo_profiling_enabled() const { return hlo_profiling_enabled_; }
void enable_hlo_profiling(bool enabled) { hlo_profiling_enabled_ = enabled; }

// Sets/returns whether this is a "host module". Host modules are used to
// record the data- and control-flow dependencies of host side computation
// that communicates with compiled code. They are used for analysis and
// scheduling purposes, but no code is generated.
bool is_host_module() const { return is_host_module_; }
void set_is_host_module(bool is_host_module) {
is_host_module_ = is_host_module;
}

// Sets/returns the module seed set during execution.
void set_seed(uint64 seed) { seed_ = seed; }
uint64 seed() const { return seed_; }
Expand Down Expand Up @@ -104,6 +113,9 @@ class HloModuleConfig {
// Whether to enable HLO-level profiling.
bool hlo_profiling_enabled_ = false;

// Whether this is a 'host module'.
bool is_host_module_ = false;

// Module/graph-level seed handle.
uint64 seed_ = 0;

Expand Down
6 changes: 5 additions & 1 deletion tensorflow/compiler/xla/service/hlo_sharding.cc
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,10 @@ Status HloSharding::ValidateTuple(const Shape& shape, int64 num_devices) const {
// shape tree.
ShapeTree<HloSharding> shape_tree = GetAsShapeTree(shape);
for (const auto& index_to_sharding : shape_tree.leaves()) {
if (index_to_sharding.first.empty()) {
// An empty tuple has a ShapeTree with a single leaf at the empty index.
continue;
}
Status status = index_to_sharding.second.ValidateNonTuple(
ShapeUtil::GetSubshape(shape, index_to_sharding.first), num_devices);
if (!status.ok()) {
Expand Down Expand Up @@ -222,7 +226,7 @@ Status HloSharding::ValidateNonTuple(const Shape& shape,
Status status = Status::OK();
std::set<int64> seen_cores;
tile_assignment_.Each(
[&](tensorflow::gtl::ArraySlice<int64> indices, uint32 core) {
[&](tensorflow::gtl::ArraySlice<int64> indices, int32 core) {
// Don't overwrite a bad status, so we report the first error.
if (status.ok()) {
if (core >= num_devices) {
Expand Down
6 changes: 4 additions & 2 deletions tensorflow/compiler/xla/service/service.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1556,8 +1556,10 @@ tensorflow::Status Service::Op(const OpRequest* arg, OpResponse* result) {
case OpRequest::kSendRequest: {
TF_RETURN_IF_ERROR(
channel_tracker_.RegisterSend(arg->send_request().channel_handle()));
TF_RETURN_IF_ERROR(computation->AddSendInstruction(arg->send_request()));
return tensorflow::Status::OK();
// Send does not return a value, but we need a handle to be able to
// set OpMetadata and OpSharding (device assignment).
handle_status = computation->AddSendInstruction(arg->send_request());
break;
}
case OpRequest::kRecvRequest: {
TF_RETURN_IF_ERROR(
Expand Down
5 changes: 3 additions & 2 deletions tensorflow/compiler/xla/service/user_computation.cc
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,8 @@ StatusOr<ComputationDataHandle> UserComputation::AddParameterInstruction(
return handle;
}

Status UserComputation::AddSendInstruction(const SendRequest& send_request) {
StatusOr<ComputationDataHandle> UserComputation::AddSendInstruction(
const SendRequest& send_request) {
tensorflow::mutex_lock lock(mutex_);

// Check if the operand of the instruction is valid.
Expand All @@ -244,7 +245,7 @@ Status UserComputation::AddSendInstruction(const SendRequest& send_request) {
VLOG(1) << "AddSendInstruction (" << GetVersionedHandleInternal()
<< "), data handle " << handle.handle() << ": "
<< send_request.ShortDebugString();
return Status::OK();
return handle;
}

StatusOr<ComputationDataHandle> UserComputation::AddRecvInstruction(
Expand Down
3 changes: 2 additions & 1 deletion tensorflow/compiler/xla/service/user_computation.h
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,8 @@ class UserComputation {
const UserComputation& false_computation);

// Enqueues a Send instruction onto this user computation.
Status AddSendInstruction(const SendRequest& send_request);
StatusOr<ComputationDataHandle> AddSendInstruction(
const SendRequest& send_request);

// Enqueues a Recv instruction onto this user computation.
StatusOr<ComputationDataHandle> AddRecvInstruction(
Expand Down