Skip to content

Commit

Permalink
inductor: only do the conv+bn folding for the freezing path (#109270)
Browse files Browse the repository at this point in the history
Pull Request resolved: #109270
Approved by: https://github.com/eellison
  • Loading branch information
XiaobingSuper authored and pytorchmergebot committed Sep 17, 2023
1 parent 51d2d82 commit c7017ff
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions torch/_inductor/fx_passes/pre_grad.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,12 +89,11 @@ def fuse_fx(gm: torch.fx.GraphModule, example_inputs):
gm = permute_matmul_fusion(gm)

# make sure the autograd is disabled.
if torch.is_grad_enabled():
if torch.is_grad_enabled() or not is_cpu:
return gm
if not is_cpu:
return gm
gm = remove_identity(gm)
gm = fuse_conv_bn(gm)
if config.freezing:
gm = remove_identity(gm)
gm = fuse_conv_bn(gm)
return gm


Expand Down

1 comment on commit c7017ff

@pytorchmergebot
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.