1 | /* Copyright 2018 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 | #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 | |
26 | namespace tensorflow { |
27 | class DeviceMgr; |
28 | class WorkerCacheInterface; |
29 | |
30 | class 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 |