Always include the local worker in the list of filtered targets.
authorDerek Murray <mrry@google.com>
Fri, 20 Apr 2018 03:00:21 +0000 (20:00 -0700)
committerTensorFlower Gardener <gardener@tensorflow.org>
Fri, 20 Apr 2018 03:03:04 +0000 (20:03 -0700)
It is currently legal to specify a device filter that doesn't include the local worker.
In that case, the MasterSession includes all local devices regardless of the filter.
This change extends this behavior to the list of filtered workers, which will be crucial for backwards compatibility when we enable CreateWorkerSession for all MasterSessions, because we need to call CreateWorkerSession on all potential workers.

PiperOrigin-RevId: 193613313

tensorflow/core/distributed_runtime/master.cc

index 288656e..e60386f 100644 (file)
@@ -167,13 +167,16 @@ class DeviceFinder {
     }
     // Enumerates all known workers' target. A target name is a
     // prefix of a device name. E.g., /job:mnist/replica:0/task:10.
+    CHECK_GT(env_->local_devices.size(), 0) << "No local devices provided.";
+    const string& local_device_name = env_->local_devices[0]->name();
     std::vector<string> workers;
     worker_cache->ListWorkers(&workers);
     if (filters_.empty()) {
       std::swap(workers, targets_);
     } else {
       for (const string& name : workers) {
-        if (MatchFilters(name)) {
+        if (MatchFilters(name) ||
+            DeviceNameUtils::IsSameAddressSpace(name, local_device_name)) {
           targets_.push_back(name);
         }
       }