static */
| 43 | |
| 44 | /* static */ |
| 45 | Status GrpcSession::Create(const SessionOptions& options, |
| 46 | std::unique_ptr<GrpcSession>* out_session) { |
| 47 | std::unique_ptr<GrpcSession> session(new GrpcSession(options)); |
| 48 | std::unique_ptr<MasterInterface> master; |
| 49 | // For testing, we enable the client to disable the use of the local |
| 50 | // master registry, so that the RPC stack is exercised. |
| 51 | if (!options.config.rpc_options().use_rpc_for_inprocess_master()) { |
| 52 | master = LocalMaster::Lookup(options.target); |
| 53 | } |
| 54 | if (!master) { |
| 55 | SharedGrpcChannelPtr master_channel; |
| 56 | TF_RETURN_IF_ERROR( |
| 57 | NewHostPortGrpcChannel(options.target.substr(kSchemePrefixLength), |
| 58 | &options.config.rpc_options(), &master_channel)); |
| 59 | master.reset(NewGrpcMaster(master_channel)); |
| 60 | } |
| 61 | session->SetRemoteMaster(std::move(master)); |
| 62 | *out_session = std::move(session); |
| 63 | return Status::OK(); |
| 64 | } |
| 65 | |
| 66 | namespace { |
| 67 | // Re-encodes constant represented in tensor proto into |