Take device locality into account during prioritization.
After this CL, if multiple devices with identical device type are viable for a placement of an op, the local device (if available) will be selected. (Prior to this change, the device whose job name comes first alphabetically would be selected.) PiperOrigin-RevId: 312716604 Change-Id: I484c00cf0d34acc23c32ab8dd1cc5c394d32f0f3
This commit is contained in:
parent
eaa710abca
commit
37ab9c3bfc
@ -116,12 +116,15 @@ void DeviceSet::SortPrioritizedDeviceVector(PrioritizedDeviceVector* vector) {
|
||||
if (a_type_name != b_type_name) {
|
||||
auto a_priority = DeviceFactory::DevicePriority(a_type_name);
|
||||
auto b_priority = DeviceFactory::DevicePriority(b_type_name);
|
||||
// First sort by prioritized device type (higher is preferred) and
|
||||
// then by device name (lexicographically).
|
||||
if (a_priority != b_priority) {
|
||||
return a_priority > b_priority;
|
||||
}
|
||||
}
|
||||
|
||||
if (a.first->IsLocal() != b.first->IsLocal()) {
|
||||
return a.first->IsLocal();
|
||||
}
|
||||
|
||||
return StringPiece(a.first->name()) < StringPiece(b.first->name());
|
||||
};
|
||||
std::sort(vector->begin(), vector->end(), device_sort);
|
||||
|
@ -90,8 +90,8 @@ class DeviceSet {
|
||||
//
|
||||
// After a call to this function, the argument vector will be sorted by
|
||||
// explicit priority (the second element in the `std::pair<DeviceType,
|
||||
// int32>`), then by `DeviceTypeOrder` of the device type, and lastly
|
||||
// by device name.
|
||||
// int32>`), then by `DeviceTypeOrder` of the device type, then by device
|
||||
// locality, and lastly by device name.
|
||||
static void SortPrioritizedDeviceVector(PrioritizedDeviceVector* vector);
|
||||
|
||||
// Sorts a PrioritizedDeviceTypeVector according to types and explicit
|
||||
|
Loading…
Reference in New Issue
Block a user