File tree Expand file tree Collapse file tree 1 file changed +8
-1
lines changed
xla/service/memory_space_assignment Expand file tree Collapse file tree 1 file changed +8
-1
lines changed Original file line number Diff line number Diff line change @@ -3514,10 +3514,17 @@ void MsaAlgorithm::FinalizeAllocations(
35143514 }
35153515 }
35163516 }
3517+ // The colocation_map is a hash table using a pointer as a key. Process its
3518+ // values in some sorted order to get deterministic results.
3519+ std::vector<std::pair<const AliasedOffset*, std::vector<Allocation*>>>
3520+ sorted_colocations (colocation_map.begin (), colocation_map.end ());
3521+ absl::c_sort (sorted_colocations, [](const auto & a, const auto & b) {
3522+ return a.first ->offset < b.first ->offset ;
3523+ });
35173524 // The allocations that have the same AliasedOffset need to be colocated.
35183525 // Export these to repack_allocation_blocks_ so that we can repack them to
35193526 // reduce fragmentation.
3520- for (auto & colocation : colocation_map ) {
3527+ for (auto & colocation : sorted_colocations ) {
35213528 std::vector<AllocationBlock*> colocations;
35223529 for (Allocation* colocated_allocation : colocation.second ) {
35233530 repack_allocation_blocks_.push_back (MakeRepackAllocationBlock (
You can’t perform that action at this time.
0 commit comments