aboutsummaryrefslogtreecommitdiffhomepage
path: root/tensorflow/core/util/device_name_utils.cc
diff options
context:
space:
mode:
authorGravatar Brennan Saeta <saeta@google.com>2017-06-22 15:27:53 -0700
committerGravatar TensorFlower Gardener <gardener@tensorflow.org>2017-06-22 15:31:21 -0700
commited1d7fdb5225e2935f05b40c8ef3cfe7261cc37e (patch)
treebd93377249209ea78aabf98579ff7fac703da389 /tensorflow/core/util/device_name_utils.cc
parentf4945e74d6da0e816d992597e42de088e790df87 (diff)
Register devices under their legacy names
Because some higher level APIs continue to use the legacy name format, when using ClusterSpec propagation, we need to ensure that we register the devices under their legacy names as well as their canonical names. PiperOrigin-RevId: 159885777
Diffstat (limited to 'tensorflow/core/util/device_name_utils.cc')
-rw-r--r--tensorflow/core/util/device_name_utils.cc12
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 64aa0ac209..1773ac00b7 100644
--- a/tensorflow/core/util/device_name_utils.cc
+++ b/tensorflow/core/util/device_name_utils.cc
@@ -97,6 +97,18 @@ string DeviceNameUtils::FullName(const string& job, int replica, int task,
"/device:", type, ":", id);
}
+/* static */
+string DeviceNameUtils::LegacyName(const string& job, int replica, int task,
+ const string& type, int id) {
+ CHECK(IsJobName(job)) << job;
+ CHECK_LE(0, replica);
+ CHECK_LE(0, task);
+ CHECK(!type.empty());
+ CHECK_LE(0, id);
+ return strings::StrCat("/job:", job, "/replica:", replica, "/task:", task,
+ "/", str_util::Lowercase(type), ":", id);
+}
+
bool DeviceNameUtils::ParseFullName(StringPiece fullname, ParsedName* p) {
p->Clear();
if (fullname == "/") {