1/* Copyright 2018 The TensorFlow Authors. All Rights Reserved.
2
3Licensed under the Apache License, Version 2.0 (the "License");
4you may not use this file except in compliance with the License.
5You may obtain a copy of the License at
6
7 http://www.apache.org/licenses/LICENSE-2.0
8
9Unless required by applicable law or agreed to in writing, software
10distributed under the License is distributed on an "AS IS" BASIS,
11WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12See the License for the specific language governing permissions and
13limitations under the License.
14==============================================================================*/
15#ifndef TENSORFLOW_CORE_DISTRIBUTED_RUNTIME_DEVICE_RESOLVER_DISTRIBUTED_H_
16#define TENSORFLOW_CORE_DISTRIBUTED_RUNTIME_DEVICE_RESOLVER_DISTRIBUTED_H_
17
18#include <string>
19#include <vector>
20
21#include "absl/container/flat_hash_map.h"
22#include "tensorflow/core/framework/collective.h"
23#include "tensorflow/core/framework/device_attributes.pb.h"
24#include "tensorflow/core/platform/status.h"
25
26namespace tensorflow {
27class DeviceMgr;
28class WorkerCacheInterface;
29
30class DeviceResolverDistributed : public DeviceResolverInterface {
31 public:
32 explicit DeviceResolverDistributed(const DeviceMgr* dev_mgr);
33
34 Status GetDeviceAttributes(const string& device,
35 DeviceAttributes* attributes) override;
36
37 Status GetAllDeviceAttributes(
38 const string& task, std::vector<DeviceAttributes>* attributes) override;
39
40 Status UpdateDeviceAttributes(
41 const std::vector<DeviceAttributes>& attributes) override;
42
43 protected:
44 const string task_name_;
45 mutex mu_;
46 absl::flat_hash_map<string, DeviceAttributes> attr_table_ TF_GUARDED_BY(mu_);
47};
48
49} // namespace tensorflow
50#endif // TENSORFLOW_CORE_DISTRIBUTED_RUNTIME_DEVICE_RESOLVER_DISTRIBUTED_H_
51