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

Method ListDevices

tensorflow/core/distributed_runtime/rpc/grpc_session.cc:363–398  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

361}
362
363Status GrpcSession::ListDevices(std::vector<DeviceAttributes>* response) {
364 ListDevicesRequest req;
365 {
366 mutex_lock l(mu_);
367 req.set_session_handle(handle_);
368 }
369 if (req.session_handle().empty()) {
370 LOG(WARNING) << "GrpcSession::ListDevices will initialize the session with "
371 "an empty graph and other defaults because the session has "
372 "not yet been created.";
373 GraphDef graph_def;
374 TF_RETURN_IF_ERROR(Create(graph_def));
375 {
376 mutex_lock l(mu_);
377 req.set_session_handle(handle_);
378 }
379 }
380 ListDevicesResponse resp;
381 CallOptions call_options;
382 call_options.SetTimeout(options_.config.operation_timeout_in_ms());
383 Status s = master_->ListDevices(&call_options, &req, &resp);
384 if (!s.ok()) {
385 LOG(ERROR) << "Could not list devices: " << s;
386 return s;
387 }
388
389 response->clear();
390 response->reserve(resp.local_device_size() + resp.remote_device_size());
391 for (const auto& device_attr : resp.local_device()) {
392 response->emplace_back(device_attr);
393 }
394 for (const auto& device_attr : resp.remote_device()) {
395 response->emplace_back(device_attr);
396 }
397 return Status::OK();
398}
399
400void GrpcSession::SetRemoteMaster(std::unique_ptr<MasterInterface> master) {
401 master_ = std::move(master);

Callers 5

EagerServiceImplTestMethod · 0.45
InitMethod · 0.45
TESTFunction · 0.45
MakeTestClusterMethod · 0.45
ListDevicesHandlerMethod · 0.45

Calls 9

set_session_handleMethod · 0.80
session_handleMethod · 0.80
SetTimeoutMethod · 0.80
CreateFunction · 0.50
emptyMethod · 0.45
okMethod · 0.45
clearMethod · 0.45
reserveMethod · 0.45
emplace_backMethod · 0.45

Tested by 3

EagerServiceImplTestMethod · 0.36
TESTFunction · 0.36
MakeTestClusterMethod · 0.36