diff --git a/src/scheduler/Scheduler.cpp b/src/scheduler/Scheduler.cpp index 18210a1f8fb0e9f2474e90279ab413668a592e29..f65729d64b2b1e4e64ea34caff37abacfb7f5787 100644 --- a/src/scheduler/Scheduler.cpp +++ b/src/scheduler/Scheduler.cpp @@ -1165,8 +1165,14 @@ std::vector<std::shared_ptr<Aidge::Node>> Aidge::Scheduler::getStaticScheduling( [](const auto& lhs, const auto& rhs) { return ((lhs->early < rhs->early) || (lhs->early == rhs->early && lhs->late < rhs->late)); }); } else if (sorting == EarlyLateSort::AsLateAsPossible) { + // The last condition (lhs->early > rhs->early) ensures that when on a + // branch join, one does not switch branch just before the join if there + // is only a single node (scheduled as late as possible, since not in the + // critical path) in one of the branch. + // @raphaelmillet Required for PNeuro export. + // TODO: add branch-level sorting policies (shortest to longuest branch for example) std::stable_sort(staticSchedule.begin(), staticSchedule.end(), - [](const auto& lhs, const auto& rhs) { return ((lhs->late < rhs->late) || (lhs->late == rhs->late && lhs->early < rhs->early)); }); + [](const auto& lhs, const auto& rhs) { return ((lhs->late < rhs->late) || (lhs->late == rhs->late && lhs->early > rhs->early)); }); } std::vector<std::shared_ptr<Node>> schedule;