Allow partially-specified resource edge colocation as long as device specifications don't have information which conflicts
Mainly I'm targeting the resource edge checking in core/common_runtime/colocation_graph.cc PiperOrigin-RevId: 288938069 Change-Id: I448e967d043d4e267e394051bf609d835f9dde0c
This commit is contained in:
parent
10b22bf930
commit
62bc37e41e
@ -279,6 +279,27 @@ bool DeviceNameUtils::IsSpecification(const ParsedName& less_specific,
|
||||
return true;
|
||||
}
|
||||
|
||||
/* static */
|
||||
bool DeviceNameUtils::AreCompatibleDevNames(const ParsedName& a,
|
||||
const ParsedName& b) {
|
||||
if (a.has_job && b.has_job && (a.job != b.job)) {
|
||||
return false;
|
||||
}
|
||||
if (a.has_replica && b.has_replica && (a.replica != b.replica)) {
|
||||
return false;
|
||||
}
|
||||
if (a.has_task && b.has_task && (a.task != b.task)) {
|
||||
return false;
|
||||
}
|
||||
if (a.has_type && b.has_type && (a.type != b.type)) {
|
||||
return false;
|
||||
}
|
||||
if (a.has_id && b.has_id && (a.id != b.id)) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void DeviceNameUtils::EnsureSpecification(ParsedName* more_specific,
|
||||
const ParsedName& less_specific) {
|
||||
if (less_specific.has_job) {
|
||||
|
@ -128,12 +128,9 @@ class DeviceNameUtils {
|
||||
static bool IsCompleteSpecification(const ParsedName& pattern,
|
||||
const ParsedName& name);
|
||||
|
||||
// True iff there exists any possible complete device name that is
|
||||
// a specification of both "a" and "b".
|
||||
static inline bool AreCompatibleDevNames(const ParsedName& a,
|
||||
const ParsedName& b) {
|
||||
return IsSpecification(a, b) || IsSpecification(b, a);
|
||||
}
|
||||
// True iff there exists any possible device name that is a specification of
|
||||
// both "a" and "b".
|
||||
static bool AreCompatibleDevNames(const ParsedName& a, const ParsedName& b);
|
||||
|
||||
// Merges the device specifications in "*target" and "other", and
|
||||
// stores the result in "*target". Returns OK if "*target" and
|
||||
|
@ -277,6 +277,19 @@ TEST(DeviceNameUtilsTest, Basic) {
|
||||
/*explicitDevice=*/true));
|
||||
}
|
||||
}
|
||||
{
|
||||
DeviceNameUtils::ParsedName x, y;
|
||||
DeviceNameUtils::ParseFullName("/job:work/replica:1/task:3/device:GPU:*",
|
||||
&x);
|
||||
DeviceNameUtils::ParseFullName("/device:CPU:*", &y);
|
||||
EXPECT_FALSE(DeviceNameUtils::AreCompatibleDevNames(x, y));
|
||||
}
|
||||
{
|
||||
DeviceNameUtils::ParsedName x, y;
|
||||
DeviceNameUtils::ParseFullName("/job:work/replica:1/task:3", &x);
|
||||
DeviceNameUtils::ParseFullName("/device:CPU:*", &y);
|
||||
EXPECT_TRUE(DeviceNameUtils::AreCompatibleDevNames(x, y));
|
||||
}
|
||||
}
|
||||
|
||||
static bool IsCSHelper(StringPiece pattern, StringPiece actual) {
|
||||
|
Loading…
Reference in New Issue
Block a user