Skip to content

Commit c4209bb

Browse files
ssjiachizkiyahu
authored andcommitted
[ET-VK][ez] Fix FuseClampPass incorrectly fusing conv+activation when conv has multiple users
Pull Request resolved: pytorch#17430 The FuseClampPass fuses patterns like conv -> relu into a single conv_with_clamp op. However, it did not check whether the convolution node's output has multiple consumers before fusing. When a conv output feeds both a relu and another op (e.g. a skip connection), fusing the relu into the conv incorrectly applies the activation to all consumers, corrupting the skip connection values. This was causing incorrect output in the MetaNet GreenScreen model, where decoder projection convolutions feed both into ResidualConvUnit (through relu) and into skip connections (without relu). The fix adds a check that the preceding conv has exactly one user before allowing fusion. ghstack-source-id: 340983071 @exported-using-ghexport Differential Revision: [D93145845](https://our.internmc.facebook.com/intern/diff/D93145845/)
1 parent 7f1eb4d commit c4209bb

1 file changed

Lines changed: 1 addition & 0 deletions

File tree

backends/transforms/fuse_conv_with_clamp.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ def call(self, graph_module: torch.fx.GraphModule):
4848
if (
4949
preceding_op.op == "call_function"
5050
and preceding_op.target in self.FUSEABLE_OPS
51+
and len(preceding_op.users) == 1
5152
):
5253
# Delete activation
5354
output_min_max = self.get_output_min_max_from_activation(

0 commit comments

Comments
 (0)