提交 cea9ef6f 编写于 作者: H horance 提交者: Vijay Vasudevan

Refactoring device name utils (#11797)

* remove duplicated code for full_name and legacy_name for DeviceNameUtils

* replace tabs

* Real->Device
上级 1f7c0f91
......@@ -85,28 +85,29 @@ static bool ConsumeNumber(StringPiece* in, int* val) {
}
}
/* static */
string DeviceNameUtils::FullName(const string& job, int replica, int task,
const string& type, int id) {
// Returns a fully qualified device name given the parameters.
static string DeviceName(const string& job, int replica, int task,
const string& device_prefix, const string& device_type,
int id) {
CHECK(IsJobName(job)) << job;
CHECK_LE(0, replica);
CHECK_LE(0, task);
CHECK(!type.empty());
CHECK(!device_type.empty());
CHECK_LE(0, id);
return strings::StrCat("/job:", job, "/replica:", replica, "/task:", task,
"/device:", type, ":", id);
device_prefix, device_type, ":", id);
}
/* static */
string DeviceNameUtils::FullName(const string& job, int replica, int task,
const string& type, int id) {
return DeviceName(job, replica, 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);
return DeviceName(job, replica, task, "/", str_util::Lowercase(type), id);
}
bool DeviceNameUtils::ParseFullName(StringPiece fullname, ParsedName* p) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册