diff options
author | 2017-07-26 22:11:20 -0700 | |
---|---|---|
committer | 2017-07-26 22:15:29 -0700 | |
commit | dd1f0cdddbfb3104e390026184474d4374f52642 (patch) | |
tree | 6bd1f58a74e4ba771f99e104ce874c0a98a51ffc /tensorflow/core/util/device_name_utils.cc | |
parent | 631a364cd1ddd822cf4b8712a5388d5ea39ecd7e (diff) |
Supports lookup devices by fullname either in the canonical form or the
legacy form. This makes DeviceSet behaves the same as DeviceMgr's
FindDevice method.
PiperOrigin-RevId: 163300346
Diffstat (limited to 'tensorflow/core/util/device_name_utils.cc')
-rw-r--r-- | tensorflow/core/util/device_name_utils.cc | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/tensorflow/core/util/device_name_utils.cc b/tensorflow/core/util/device_name_utils.cc index 1773ac00b7..ea25f90a64 100644 --- a/tensorflow/core/util/device_name_utils.cc +++ b/tensorflow/core/util/device_name_utils.cc @@ -387,4 +387,16 @@ bool DeviceNameUtils::SplitDeviceName(StringPiece name, string* task, return false; } +std::vector<string> DeviceNameUtils::GetNamesForDeviceMappings( + const ParsedName& pn) { + if (pn.has_job && pn.has_replica && pn.has_task && pn.has_type && pn.has_id) { + return { + DeviceNameUtils::FullName(pn.job, pn.replica, pn.task, pn.type, pn.id), + DeviceNameUtils::LegacyName(pn.job, pn.replica, pn.task, pn.type, + pn.id)}; + } else { + return {}; + } +} + } // namespace tensorflow |