fix compile merging (#2150)

This commit is contained in:
Awni Hannun
2025-05-02 15:08:50 -07:00
committed by GitHub
parent 481349495b
commit 9c5e7da507
2 changed files with 18 additions and 0 deletions

View File

@@ -168,6 +168,15 @@ void merge_one(array& dst, array& src, ParentsMap& parents_map) {
parent.first.inputs()[parent.second] = dst;
pairs.push_back(parent);
}
// If src is a parent of dst, remove it from dst's parents
for (auto it = pairs.begin(); it != pairs.end();) {
if (it->first.id() == src.id()) {
it = pairs.erase(it);
} else {
it++;
}
}
// Remove the source from the map to avoid fusing with it again
parents_map.erase(src_parents);
}