Internal cleanup.
authorA. Unique TensorFlower <gardener@tensorflow.org>
Fri, 16 Mar 2018 01:22:09 +0000 (18:22 -0700)
committerTensorFlower Gardener <gardener@tensorflow.org>
Fri, 16 Mar 2018 01:26:04 +0000 (18:26 -0700)
PiperOrigin-RevId: 189278596

tensorflow/c/eager/c_api.cc

index 0811bd3..455bc19 100644 (file)
@@ -1213,8 +1213,11 @@ TFE_TensorHandle* TFE_TensorHandleCopyToDevice(TFE_TensorHandle* h,
     // Note that `h` may not be currently ready. However execution order will
     // make sure that `h` is ready before the copy is actually done.
     CopyToDeviceNode* node = new CopyToDeviceNode(h, dstd, ctx);
+    TFE_TensorHandle* output = node->dst();
+    // Note that calling Add makes `node` accessible by the TFE_Executor thread.
+    // So further accesses need to be thread-safe.
     ctx->executor.Add(node);
-    return node->dst();
+    return output;
   } else {
     TFE_TensorHandle* output = nullptr;
     status->status = TensorHandleCopyToDevice(h, ctx, dstd, &output);