Convenience entry point invoked by Engine::backward() before traversal.
Builds a topological ordering of the backward graph rooted at
root_node using an iterative post-order DFS over raw Node*
(mirroring Engine::topo_order but avoiding shared_ptr reference-
counting overhead during the scan), then constructs a FusionPass
and invokes FusionPass::run on the result.
See Also
FusionPass — the underlying pattern-matching pass.
Parameters
root_nodeNode*Root of the backward graph (usually the
grad_fn of the loss tensor). nullptr is tolerated and short-circuits to 0.Returns
intTotal number of fusions applied, or 0 when root_node is null or the resulting graph has fewer than two nodes.