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#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
20namespace tensorflow {
21
22Status 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
36Status 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
42Status 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