Skip to content

Commit ee21142

Browse files
bwastifacebook-github-bot
authored andcommitted
Move custom passes to last optimization step (#29256)
Summary: Pull Request resolved: #29256 .. Test Plan: .. Reviewed By: ZolotukhinM Differential Revision: D18340212 fbshipit-source-id: 30f4850c8a21bdab42c7cf04b4b92b1787449ee2
1 parent 6ea4219 commit ee21142

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

torch/csrc/jit/graph_executor.cpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -713,10 +713,6 @@ bool needsGradient(const std::shared_ptr<const Graph>& graph) {
713713
}
714714

715715
void runNondiffOptimization(std::shared_ptr<Graph>& graph) {
716-
// run custom passes that different backends can register
717-
for (const auto& pass : getCustomPasses()) {
718-
pass(graph);
719-
}
720716
// decomposition pass, decompose certain ops that will be used in the
721717
// following passes (like batchmm and jit fusion)
722718
DecomposeOps(graph);
@@ -732,6 +728,12 @@ void runNondiffOptimization(std::shared_ptr<Graph>& graph) {
732728
QuantFusion(graph);
733729

734730
FuseGraph(graph);
731+
732+
// Run custom passes that different backends can register.
733+
// This is done last to give internal optimization passes priority.
734+
for (const auto& pass : getCustomPasses()) {
735+
pass(graph);
736+
}
735737
}
736738

737739
void runOptimization(std::shared_ptr<Graph>& graph) {

0 commit comments

Comments
 (0)