MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / GetAllRemoteDevices

Function GetAllRemoteDevices

tensorflow/c/eager/c_api.cc:99–130  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

97
98#if !defined(IS_MOBILE_PLATFORM)
99tensorflow::Status GetAllRemoteDevices(
100 const std::vector<string>& remote_workers,
101 tensorflow::WorkerCacheInterface* worker_cache,
102 std::unique_ptr<tensorflow::DeviceMgr>* device_mgr) {
103 std::vector<std::unique_ptr<tensorflow::Device>> remote_devices;
104 tensorflow::Status status;
105 // TODO(nareshmodi) do this in parallel instead of serially.
106 for (const string& remote_worker : remote_workers) {
107 tensorflow::Notification n;
108 tensorflow::NewRemoteDevices(
109 tensorflow::Env::Default(), worker_cache, remote_worker,
110 [&status, &n, &remote_devices](
111 const tensorflow::Status& s,
112 std::vector<tensorflow::Device*>* devices) {
113 status = s;
114 if (s.ok()) {
115 for (tensorflow::Device* d : *devices) {
116 remote_devices.emplace_back(d);
117 }
118 }
119 n.Notify();
120 });
121 n.WaitForNotification();
122 }
123 std::unique_ptr<tensorflow::DeviceMgr> remote_device_mgr(
124 new tensorflow::DeviceMgr(std::move(remote_devices)));
125
126 TF_RETURN_IF_ERROR(status);
127
128 *device_mgr = std::move(remote_device_mgr);
129 return tensorflow::Status::OK();
130}
131
132tensorflow::Status CreateRemoteContexts(
133 const std::vector<string>& remote_workers, tensorflow::uint64 context_id,

Callers 1

Calls 6

NewRemoteDevicesFunction · 0.85
DefaultFunction · 0.85
okMethod · 0.45
emplace_backMethod · 0.45
NotifyMethod · 0.45
WaitForNotificationMethod · 0.45

Tested by

no test coverage detected