aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar A. Unique TensorFlower <gardener@tensorflow.org>2017-12-02 15:20:25 -0800
committerGravatar TensorFlower Gardener <gardener@tensorflow.org>2017-12-02 15:23:52 -0800
commit04e93d09455b1fd849ca0706d7b6825a11a45c5c (patch)
tree7d770dc04d120e0668747d2e653d3bd90643d757
parent7d82dbb42744a21ff05924e973e57a68465f3347 (diff)
Fix a bug in CreateItem of FunctionLibraryRuntimeImpl.
PiperOrigin-RevId: 177710771
-rw-r--r--tensorflow/core/common_runtime/function.cc23
1 files changed, 11 insertions, 12 deletions
diff --git a/tensorflow/core/common_runtime/function.cc b/tensorflow/core/common_runtime/function.cc
index 4c87c922c2..3328125dc9 100644
--- a/tensorflow/core/common_runtime/function.cc
+++ b/tensorflow/core/common_runtime/function.cc
@@ -552,8 +552,16 @@ Status FunctionLibraryRuntimeImpl::CreateItem(Handle handle, Item** item) {
Executor* exec;
TF_RETURN_IF_ERROR(NewLocalExecutor(params, g.release(), &exec));
- (*item)->graph = graph;
- (*item)->exec = exec;
+ {
+ // Guard item since it is already inserted in items_.
+ mutex_lock l(mu_);
+ if ((*item)->exec) {
+ delete exec;
+ } else {
+ (*item)->graph = graph;
+ (*item)->exec = exec;
+ }
+ }
return Status::OK();
}
@@ -572,16 +580,7 @@ Status FunctionLibraryRuntimeImpl::GetOrCreateItem(Handle handle, Item** item) {
}
// NOTE: We need to call CreateItem out of mu_ because creating an
// executor needs to call CreateKernel.
- TF_RETURN_IF_ERROR(CreateItem(handle, item));
-
- {
- mutex_lock l(mu_);
- if (items_[local_handle] == nullptr) {
- // Insert *item in items_.
- items_.insert({local_handle, *item});
- }
- }
- return Status::OK();
+ return CreateItem(handle, item);
}
void FunctionLibraryRuntimeImpl::RunRemote(const Options& opts, Handle handle,