diff options
author | A. Unique TensorFlower <gardener@tensorflow.org> | 2016-09-17 20:20:33 -0800 |
---|---|---|
committer | TensorFlower Gardener <gardener@tensorflow.org> | 2016-09-17 21:32:49 -0700 |
commit | c05dbaefe82ed1f1141ecc7edad530402e77acc5 (patch) | |
tree | daa911b5c34b8abe1a26accb316ed00025f071ad | |
parent | 9814f5efc297692ef04309d94eb582d19bf2aef0 (diff) |
TensorCoding: Always use meta_ when parsing the RawMessage,
even in the case of a non-CPU resident value, because
meta_ may later be used to test for a dead Tensor.
Change: 133500231
-rw-r--r-- | tensorflow/core/distributed_runtime/tensor_coding.cc | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/tensorflow/core/distributed_runtime/tensor_coding.cc b/tensorflow/core/distributed_runtime/tensor_coding.cc index 49507dc823..b26970b606 100644 --- a/tensorflow/core/distributed_runtime/tensor_coding.cc +++ b/tensorflow/core/distributed_runtime/tensor_coding.cc @@ -79,11 +79,18 @@ Status TensorResponse::ParseFrom(Source* source) { input.SetTotalBytesLimit(INT_MAX, INT_MAX); // Unlimited // Pre-parse into local storage, then delegate to device. - RecvTensorResponse proto; - if (!proto.ParseFromCodedStream(&input) || !input.ConsumedEntireMessage()) { + if (!meta_.ParseFromCodedStream(&input) || !input.ConsumedEntireMessage()) { return errors::InvalidArgument("Cannot parse tensor from response"); } - return device_->MakeTensorFromProto(proto.tensor(), alloc_attrs_, &tensor_); + Status s = + device_->MakeTensorFromProto(meta_.tensor(), alloc_attrs_, &tensor_); + // Reduce memory usage for big tensors. + { + TensorProto empty; + meta_.mutable_tensor()->Swap(&empty); + } + meta_.clear_tensor(); + return s; } if (already_used_) { ClearTensor(); |