Pulling Rendezvous initialization out of TFE_Context constructor.
authorAlexandre Passos <apassos@google.com>
Fri, 9 Mar 2018 02:12:54 +0000 (18:12 -0800)
committerTensorFlower Gardener <gardener@tensorflow.org>
Fri, 9 Mar 2018 02:17:31 +0000 (18:17 -0800)
PiperOrigin-RevId: 188423386

tensorflow/c/eager/c_api.cc
tensorflow/c/eager/c_api_internal.h

index dfe2089..6793bb5 100644 (file)
@@ -105,8 +105,11 @@ TFE_Context* TFE_NewContext(const TFE_ContextOptions* opts, TF_Status* status) {
   if (!status->status.ok()) {
     return nullptr;
   }
-  return new TFE_Context(*opts, std::unique_ptr<tensorflow::DeviceMgr>(
-                                    new tensorflow::DeviceMgr(devices)));
+  std::unique_ptr<tensorflow::DeviceMgr> device_mgr(
+      new tensorflow::DeviceMgr(devices));
+  tensorflow::Rendezvous* r =
+      new tensorflow::IntraProcessRendezvous(device_mgr.get());
+  return new TFE_Context(*opts, std::move(device_mgr), r);
 }
 
 void TFE_DeleteContext(TFE_Context* ctx, TF_Status* status) {
index f701f34..5bbfd57 100644 (file)
@@ -48,14 +48,14 @@ TFE_ContextDevicePlacementPolicy PlacementPolicy(
 
 struct TFE_Context {
   explicit TFE_Context(const TFE_ContextOptions& opts,
-                       std::unique_ptr<tensorflow::DeviceMgr> device_mgr)
+                       std::unique_ptr<tensorflow::DeviceMgr> device_mgr,
+                       tensorflow::Rendezvous* rendezvous)
       : soft_placement(
             opts.session_options.options.config.allow_soft_placement()),
         policy(PlacementPolicy(soft_placement, opts.policy)),
         device_manager(std::move(device_mgr)),
         devices(device_manager->ListDevices()),
-        rendezvous(
-            new tensorflow::IntraProcessRendezvous(device_manager.get())),
+        rendezvous(rendezvous),
         pflr(new tensorflow::ProcessFunctionLibraryRuntime(
             device_manager.get(), opts.session_options.options.env,
             TF_GRAPH_DEF_VERSION, &func_lib_def, {})),