Skip to content

Commit 7d33b17

Browse files
[NPUW] Change sorting order in online partitioning (#25447)
Change sorting order to prioritize fusing tail (instead of head) of the subgraph of the original model
1 parent a3a2b8b commit 7d33b17

File tree

1 file changed

+9
-1
lines changed
  • src/plugins/intel_npu/src/plugin/npuw/partitioning/online

1 file changed

+9
-1
lines changed

src/plugins/intel_npu/src/plugin/npuw/partitioning/online/snapshot.cpp

+9-1
Original file line numberDiff line numberDiff line change
@@ -445,8 +445,16 @@ std::shared_ptr<Repeated> Snapshot::tryGrowRepeatingGroups(const detail::GPtrSet
445445
if (a.empty()) {
446446
return false; // doesn't matter for stability - no groups are fused
447447
}
448-
return a.at(0).first->getId() < b.at(0).first->getId();
448+
// This std::sort allows to prioritize groups from the tail
449+
// of the original model. It's possible due to preservation of
450+
// group IDs in topological order throughout the whole partitioning process.
451+
// In the networks we're looking at, ensuring the merge order from the bottom
452+
// of the network gives a better structure of a repeated block which can be
453+
// later optimized by the plugin.
454+
return a.at(0).first->getId() > b.at(0).first->getId();
449455
}
456+
// Generally we prefer bigger blocks (in terms of number of layers)
457+
// to be merged first. For other cases check the comment above
450458
return a.size() > b.size();
451459
});
452460

0 commit comments

Comments
 (0)