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 | #include "tensorflow/core/common_runtime/device_resolver_local.h" |
16 | |
17 | #include "tensorflow/core/common_runtime/device_mgr.h" |
18 | #include "tensorflow/core/platform/errors.h" |
19 | |
20 | namespace tensorflow { |
21 | |
22 | Status DeviceResolverLocal::GetDeviceAttributes(const string& device, |
23 | DeviceAttributes* attributes) { |
24 | Device* dev; |
25 | // LookupDevice returns InvalidArgument if the device is not found. |
26 | Status s = dev_mgr_->LookupDevice(device, &dev); |
27 | if (errors::IsInvalidArgument(s)) { |
28 | return errors::NotFound(device, " not found"); |
29 | } else if (!s.ok()) { |
30 | return s; |
31 | } |
32 | *attributes = dev->attributes(); |
33 | return OkStatus(); |
34 | } |
35 | |
36 | Status DeviceResolverLocal::GetAllDeviceAttributes( |
37 | const string& task, std::vector<DeviceAttributes>* attributes) { |
38 | return errors::Internal( |
39 | "GetTaskCached is not supposed to be called in local collectives"); |
40 | } |
41 | |
42 | Status DeviceResolverLocal::UpdateDeviceAttributes( |
43 | const std::vector<DeviceAttributes>& attributes) { |
44 | return errors::Internal( |
45 | "UpdateDeviceAttributes shouldn't be called with local collectives"); |
46 | } |
47 | |
48 | } // namespace tensorflow |
49 |