aboutsummaryrefslogtreecommitdiffhomepage
path: root/tensorflow/core/util/device_name_utils.h
diff options
context:
space:
mode:
authorGravatar Rohan Jain <rohanj@google.com>2017-10-02 14:58:39 -0700
committerGravatar TensorFlower Gardener <gardener@tensorflow.org>2017-10-02 15:05:25 -0700
commitdd94edb18cb7bf00156a4213bbdb77a3a79790d5 (patch)
tree73b235af9a97c7be2755e21f2b96f49a58ce08e4 /tensorflow/core/util/device_name_utils.h
parenta470779865883706dc2db1dcd8bd386527e1df03 (diff)
Standardizing device names to the newer /device:<type>:<index> format by making all the device factories produce the new device names.
The python API would still support the legacy /<type>:<index> format so the C++ layer would accept both legacy and standardized names but the C++ layer would produce only new device names now. PiperOrigin-RevId: 170758313
Diffstat (limited to 'tensorflow/core/util/device_name_utils.h')
-rw-r--r--tensorflow/core/util/device_name_utils.h16
1 files changed, 12 insertions, 4 deletions
diff --git a/tensorflow/core/util/device_name_utils.h b/tensorflow/core/util/device_name_utils.h
index 740aa13fa7..0ae28df997 100644
--- a/tensorflow/core/util/device_name_utils.h
+++ b/tensorflow/core/util/device_name_utils.h
@@ -48,9 +48,6 @@ class DeviceNameUtils {
// Returns a fully qualified device name given the parameters.
static string FullName(const string& job, int replica, int task,
const string& type, int id);
- // Returns a fully qualified device name given the parameters in legacy style.
- static string LegacyName(const string& job, int replica, int task,
- const string& type, int id);
struct ParsedName {
void Clear() {
@@ -91,6 +88,11 @@ class DeviceNameUtils {
// Parses "fullname" into "*parsed". Returns true iff succeeds.
static bool ParseFullName(StringPiece fullname, ParsedName* parsed);
+ // Canonicalizes "fullname". Accepts both legacy, newer and local versions of
+ // the device spec. Returns the newer version of the device spec. If we were
+ // unable to interpret / parse "fullname" returns "".
+ static string CanonicalizeDeviceName(StringPiece fullname);
+
// Returns true if "name" specifies any non-trivial constraint on the device.
static bool HasSomeDetails(const ParsedName& name) {
return name.has_job || name.has_replica || name.has_task || name.has_type ||
@@ -155,8 +157,14 @@ class DeviceNameUtils {
// Returns canonical and legacy full names for the given parsed
// device name 'pn'. The returned string names are often useful to
- // lookup devices from a mapping.
+ // look up devices from a mapping.
static std::vector<string> GetNamesForDeviceMappings(const ParsedName& pn);
+
+ // Returns canonical and legacy local names for the given parsed device name
+ // 'pn'. The returned string names are often useful to look up devices from a
+ // mapping.
+ static std::vector<string> GetLocalNamesForDeviceMappings(
+ const ParsedName& pn);
};
} // namespace tensorflow