Skip to content

Commit

Permalink
Release the TensorHandle lock when waiting for OpIdAndOutputNum.
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 559621835
  • Loading branch information
rjpower authored and tensorflower-gardener committed Aug 24, 2023
1 parent e46b690 commit 5d18993
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions tensorflow/core/common_runtime/eager/tensor_handle.cc
Original file line number Diff line number Diff line change
Expand Up @@ -712,16 +712,22 @@ Status TensorHandle::RemoteAddress(const Device* d, const bool wait_until_ready,
DVLOG(3) << "RemoteAddress on TensorHandle: " << this << " device: " << d
<< " " << d->name();

const tensorflow::RemoteTensorHandleData* remote_data = nullptr;

// Waiting on a different device handle.
if (d != device_) {
tf_shared_lock l(mu_);
auto mirror = remote_mirrors_.find(d->name());
if (mirror != remote_mirrors_.end()) {
return mirror->second.OpIdAndOutputNum(wait_until_ready, op_id,
output_num);
remote_data = &mirror->second;
} else {
return errors::FailedPrecondition(
"Could not find remote mirror for specified device");
}
}

return errors::FailedPrecondition(
"Could not find remote mirror for specified device");
if (remote_data != nullptr) {
return remote_data->OpIdAndOutputNum(wait_until_ready, op_id, output_num);
}

if (Type() != REMOTE) {
Expand Down

0 comments on commit 5d18993

Please sign in to comment.