[inductor][easy] add a missing parenthesis (#107001)
If I understand the code correctly, we want to add a fusion choice if
- node2 is template or foreach
and
- can_fuse return true for (node2, node1)
But the code misses a pair of parenthesis since in python 'and' has higher precedence than 'or'. This does not cause much damage since even if we add a pair of nodes that can not be fused, we will skip them later when we call can_fuse again (in fuse_nodes_once). Fixing this mainly to avoid confusion.
Pull Request resolved: https://github.com/pytorch/pytorch/pull/107001
Approved by: https://github.com/jansel, https://github.com/mlazos
diff --git a/torch/_inductor/scheduler.py b/torch/_inductor/scheduler.py
index bcab98b..0bf65b3 100644
--- a/torch/_inductor/scheduler.py
+++ b/torch/_inductor/scheduler.py
@@ -1159,10 +1159,8 @@
if self.can_fuse(node1, node2):
possible_fusions.append(key)
- elif (
- node2.is_template()
- or node2.is_foreach()
- and self.can_fuse(node2, node1)
+ elif (node2.is_template() or node2.is_foreach()) and self.can_fuse(
+ node2, node1
):
# foreach fusions and epilogue fusions are order dependent
possible_fusions.append((node2, node1))