1 /* Copyright 2020 The TensorFlow Authors. All Rights Reserved.
2
3 Licensed under the Apache License, Version 2.0 (the "License");
4 you may not use this file except in compliance with the License.
5 You may obtain a copy of the License at
6
7 http://www.apache.org/licenses/LICENSE-2.0
8
9 Unless required by applicable law or agreed to in writing, software
10 distributed under the License is distributed on an "AS IS" BASIS,
11 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 See the License for the specific language governing permissions and
13 limitations under the License.
14 ==============================================================================*/
15
16 #include "tensorflow/compiler/xla/pjrt/distributed/distributed.h"
17
18 #include "grpcpp/grpcpp.h"
19 #include "tensorflow/compiler/xla/pjrt/distributed/client.h"
20 #include "tensorflow/compiler/xla/pjrt/distributed/service.h"
21
22 namespace xla {
23
24 StatusOr<std::unique_ptr<DistributedRuntimeService>>
GetDistributedRuntimeService(std::string address,const DistributedRuntimeServiceImpl::Options & options)25 GetDistributedRuntimeService(
26 std::string address,
27 const DistributedRuntimeServiceImpl::Options& options) {
28 auto credentials = ::grpc::InsecureServerCredentials();
29 return DistributedRuntimeService::Get(address, credentials, options);
30 }
31
GetDistributedRuntimeClient(std::string address,const DistributedRuntimeClient::Options & options)32 std::shared_ptr<DistributedRuntimeClient> GetDistributedRuntimeClient(
33 std::string address, const DistributedRuntimeClient::Options& options) {
34 std::shared_ptr<::grpc::ChannelCredentials> creds =
35 ::grpc::InsecureChannelCredentials();
36 std::shared_ptr<::grpc::Channel> channel =
37 ::grpc::CreateChannel(address, creds);
38 return absl::make_unique<DistributedRuntimeClient>(channel, options);
39 }
40
41 } // namespace xla
42