Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TorchDynamo: Add convolution unary fusion for cpu in inference mode #87063

Closed

Conversation

@XiaobingSuper XiaobingSuper requested a review from jansel as a code owner October 17, 2022 06:54
@pytorch-bot
Copy link

pytorch-bot bot commented Oct 17, 2022

🔗 Helpful Links

🧪 See artifacts and rendered test results at hud.pytorch.org/pr/87063

Note: Links to docs will display an error until the docs builds have been completed.

✅ No Failures

As of commit a8853c0:
💚 Looks good so far! There are no failures yet. 💚

This comment was automatically generated by Dr. CI and updates every 15 minutes.

torch/_inductor/ir.py Outdated Show resolved Hide resolved
torch/_inductor/ir.py Outdated Show resolved Hide resolved
Comment on lines 128 to 129
def fuse_conv_unary_eval(conv: nn.Module, unary: nn.Module):
assert not (conv.training), "Fusion only for eval!"
Copy link
Collaborator

Choose a reason for hiding this comment

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

why marking it as "eval" and requiring it not for "training"? The fusion can apply to forward graph and backward graph generated by AOTAutograd as long as the pattern matches per fuse_fx, right?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

For the current path, we do the fusion path before AOTAutograd, which doesn't have forward graph and backward graph. But if we do the fusion after AOTAutograd(at fw_compiler), the AOTAutograd will decompose some ops to many smaller ops, such as Gelu, it will be hard to do the fusion.

Comment on lines 159 to 161
eval_mode = all(not n.training for n in [conv, unary])
if not eval_mode:
continue
Copy link
Collaborator

Choose a reason for hiding this comment

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

ditto, why eval only?

Comment on lines 894 to 897
else:
log.warning(
"Register OneDNN fusion ops is failed which OneDNN is not enabled at build step"
)
Copy link
Collaborator

Choose a reason for hiding this comment

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

I don't think we have to warn here since the fx graph won't contain the corresponding aten ops and users don't have to care about the absence of the registration.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes, changed.

…ence mode"

cc jansel lezcano fdrocha mlazos soumith voznesenskym yanboliang

[ghstack-poisoned]
@pytorch-bot pytorch-bot bot added the ciflow/trunk Trigger trunk jobs on your pull request label Oct 24, 2022
@pytorchmergebot
Copy link
Collaborator

Merge started

Your change will be merged once all checks pass (ETA 0-4 Hours).

Learn more about merging in the wiki.

Questions? Feedback? Please reach out to the PyTorch DevX Team

Advanced Debugging
Check the merge workflow status
here

@github-actions
Copy link
Contributor

Hey @XiaobingSuper.
You've committed this PR, but it does not have both a 'release notes: ...' and 'topics: ...' label. Please add one of each to the PR. The 'release notes: ...' label should represent the part of PyTorch that this PR changes (fx, autograd, distributed, etc) and the 'topics: ...' label should represent the kind of PR it is (not user facing, new feature, bug fix, perf improvement, etc). The list of valid labels can be found here for the 'release notes: ...' and here for the 'topics: ...'.
For changes that are 'topic: not user facing' there is no need for a release notes label.

chunyuan-w added a commit that referenced this pull request Dec 9, 2022
…on for cpu in inference mode"



An FX transformation is added to fuse ConvTranspose2d with eltwise OPs in torchinductor for CPU in inference mode, following the implementation in #87063.

The fusion OP is implemented in #90264 and will be treated as an extern kernel call in torchinductor.

The fusion of ConvTranspose2d with the below OPs is supported:

- relu
- sigmoid
- tanh
- hardswish
- leaky_relu
- hardtanh
- gelu


cc mlazos soumith voznesenskym yanboliang penguinwu anijain2305 EikanWang jgong5 Guobing-Chen XiaobingSuper zhuhaozhe blzheng Xia-Weiwen wenzhe-nrv jiayisunx peterbell10 desertfire

[ghstack-poisoned]
chunyuan-w added a commit that referenced this pull request Dec 9, 2022
…ference mode"



An FX transformation is added to fuse ConvTranspose2d with eltwise OPs in torchinductor for CPU in inference mode, following the implementation in #87063.

The fusion OP is implemented in #90264 and will be treated as an extern kernel call in torchinductor.

The fusion of ConvTranspose2d with the below OPs is supported:

- relu
- sigmoid
- tanh
- hardswish
- leaky_relu
- hardtanh
- gelu


cc mlazos soumith voznesenskym yanboliang penguinwu anijain2305 EikanWang jgong5 Guobing-Chen XiaobingSuper zhuhaozhe blzheng Xia-Weiwen wenzhe-nrv jiayisunx peterbell10 desertfire

[ghstack-poisoned]
chunyuan-w added a commit that referenced this pull request Dec 13, 2022
…on for cpu in inference mode"



An FX transformation is added to fuse ConvTranspose2d with eltwise OPs in torchinductor for CPU in inference mode, following the implementation in #87063.

The fusion OP is implemented in #90264 and will be treated as an extern kernel call in torchinductor.

The fusion of ConvTranspose2d with the below OPs is supported:

- relu
- sigmoid
- tanh
- hardswish
- leaky_relu
- hardtanh
- gelu


cc mlazos soumith voznesenskym yanboliang penguinwu anijain2305 EikanWang jgong5 Guobing-Chen XiaobingSuper zhuhaozhe blzheng Xia-Weiwen wenzhe-nrv jiayisunx peterbell10 desertfire

[ghstack-poisoned]
chunyuan-w added a commit that referenced this pull request Dec 13, 2022
…ference mode"



An FX transformation is added to fuse ConvTranspose2d with eltwise OPs in torchinductor for CPU in inference mode, following the implementation in #87063.

The fusion OP is implemented in #90264 and will be treated as an extern kernel call in torchinductor.

The fusion of ConvTranspose2d with the below OPs is supported:

- relu
- sigmoid
- tanh
- hardswish
- leaky_relu
- hardtanh
- gelu


cc mlazos soumith voznesenskym yanboliang penguinwu anijain2305 EikanWang jgong5 Guobing-Chen XiaobingSuper zhuhaozhe blzheng Xia-Weiwen wenzhe-nrv jiayisunx peterbell10 desertfire

[ghstack-poisoned]
chunyuan-w added a commit that referenced this pull request Dec 15, 2022
…on for cpu in inference mode"



An FX transformation is added to fuse ConvTranspose2d with eltwise OPs in torchinductor for CPU in inference mode, following the implementation in #87063.

The fusion OP is implemented in #90264 and will be treated as an extern kernel call in torchinductor.

The fusion of ConvTranspose2d with the below OPs is supported:

- relu
- sigmoid
- tanh
- hardswish
- leaky_relu
- hardtanh
- gelu


cc mlazos soumith voznesenskym yanboliang penguinwu anijain2305 EikanWang jgong5 Guobing-Chen XiaobingSuper zhuhaozhe blzheng Xia-Weiwen wenzhe-nrv jiayisunx peterbell10 desertfire

[ghstack-poisoned]
chunyuan-w added a commit that referenced this pull request Dec 15, 2022
…ference mode"



An FX transformation is added to fuse ConvTranspose2d with eltwise OPs in torchinductor for CPU in inference mode, following the implementation in #87063.

The fusion OP is implemented in #90264 and will be treated as an extern kernel call in torchinductor.

The fusion of ConvTranspose2d with the below OPs is supported:

- relu
- sigmoid
- tanh
- hardswish
- leaky_relu
- hardtanh
- gelu


cc mlazos soumith voznesenskym yanboliang penguinwu anijain2305 EikanWang jgong5 Guobing-Chen XiaobingSuper zhuhaozhe blzheng Xia-Weiwen wenzhe-nrv jiayisunx peterbell10 desertfire

[ghstack-poisoned]
chunyuan-w added a commit that referenced this pull request Dec 15, 2022
…on for cpu in inference mode"



An FX transformation is added to fuse ConvTranspose2d with eltwise OPs in torchinductor for CPU in inference mode, following the implementation in #87063.

The fusion OP is implemented in #90264 and will be treated as an extern kernel call in torchinductor.

The fusion of ConvTranspose2d with the below OPs is supported:

- relu
- sigmoid
- tanh
- hardswish
- leaky_relu
- hardtanh
- gelu


cc mlazos soumith voznesenskym yanboliang penguinwu anijain2305 EikanWang jgong5 Guobing-Chen XiaobingSuper zhuhaozhe blzheng Xia-Weiwen wenzhe-nrv jiayisunx peterbell10 desertfire

[ghstack-poisoned]
chunyuan-w added a commit that referenced this pull request Dec 15, 2022
…ference mode"



An FX transformation is added to fuse ConvTranspose2d with eltwise OPs in torchinductor for CPU in inference mode, following the implementation in #87063.

The fusion OP is implemented in #90264 and will be treated as an extern kernel call in torchinductor.

The fusion of ConvTranspose2d with the below OPs is supported:

- relu
- sigmoid
- tanh
- hardswish
- leaky_relu
- hardtanh
- gelu


cc mlazos soumith voznesenskym yanboliang penguinwu anijain2305 EikanWang jgong5 Guobing-Chen XiaobingSuper zhuhaozhe blzheng Xia-Weiwen wenzhe-nrv jiayisunx peterbell10 desertfire

[ghstack-poisoned]
chunyuan-w added a commit that referenced this pull request Dec 15, 2022
…on for cpu in inference mode"



An FX transformation is added to fuse ConvTranspose2d with eltwise OPs in torchinductor for CPU in inference mode, following the implementation in #87063.

The fusion OP is implemented in #90264 and will be treated as an extern kernel call in torchinductor.

The fusion of ConvTranspose2d with the below OPs is supported:

- relu
- sigmoid
- tanh
- hardswish
- leaky_relu
- hardtanh
- gelu


cc mlazos soumith voznesenskym yanboliang penguinwu anijain2305 EikanWang jgong5 Guobing-Chen XiaobingSuper zhuhaozhe blzheng Xia-Weiwen wenzhe-nrv jiayisunx peterbell10 desertfire

[ghstack-poisoned]
chunyuan-w added a commit that referenced this pull request Dec 15, 2022
…ference mode"



An FX transformation is added to fuse ConvTranspose2d with eltwise OPs in torchinductor for CPU in inference mode, following the implementation in #87063.

The fusion OP is implemented in #90264 and will be treated as an extern kernel call in torchinductor.

The fusion of ConvTranspose2d with the below OPs is supported:

- relu
- sigmoid
- tanh
- hardswish
- leaky_relu
- hardtanh
- gelu


cc mlazos soumith voznesenskym yanboliang penguinwu anijain2305 EikanWang jgong5 Guobing-Chen XiaobingSuper zhuhaozhe blzheng Xia-Weiwen wenzhe-nrv jiayisunx peterbell10 desertfire

[ghstack-poisoned]
chunyuan-w added a commit that referenced this pull request Dec 15, 2022
…on for cpu in inference mode"



An FX transformation is added to fuse ConvTranspose2d with eltwise OPs in torchinductor for CPU in inference mode, following the implementation in #87063.

The fusion OP is implemented in #90264 and will be treated as an extern kernel call in torchinductor.

The fusion of ConvTranspose2d with the below OPs is supported:

- relu
- sigmoid
- tanh
- hardswish
- leaky_relu
- hardtanh
- gelu


cc mlazos soumith voznesenskym yanboliang penguinwu anijain2305 EikanWang jgong5 Guobing-Chen XiaobingSuper zhuhaozhe blzheng Xia-Weiwen wenzhe-nrv jiayisunx peterbell10 desertfire

[ghstack-poisoned]
chunyuan-w added a commit that referenced this pull request Dec 15, 2022
…ference mode"



An FX transformation is added to fuse ConvTranspose2d with eltwise OPs in torchinductor for CPU in inference mode, following the implementation in #87063.

The fusion OP is implemented in #90264 and will be treated as an extern kernel call in torchinductor.

The fusion of ConvTranspose2d with the below OPs is supported:

- relu
- sigmoid
- tanh
- hardswish
- leaky_relu
- hardtanh
- gelu


cc mlazos soumith voznesenskym yanboliang penguinwu anijain2305 EikanWang jgong5 Guobing-Chen XiaobingSuper zhuhaozhe blzheng Xia-Weiwen wenzhe-nrv jiayisunx peterbell10 desertfire

[ghstack-poisoned]
chunyuan-w added a commit that referenced this pull request Dec 15, 2022
…on for cpu in inference mode"



An FX transformation is added to fuse ConvTranspose2d with eltwise OPs in torchinductor for CPU in inference mode, following the implementation in #87063.

The fusion OP is implemented in #90264 and will be treated as an extern kernel call in torchinductor.

The fusion of ConvTranspose2d with the below OPs is supported:

- relu
- sigmoid
- tanh
- hardswish
- leaky_relu
- hardtanh
- gelu


cc mlazos soumith voznesenskym yanboliang penguinwu anijain2305 EikanWang jgong5 Guobing-Chen XiaobingSuper zhuhaozhe blzheng Xia-Weiwen wenzhe-nrv jiayisunx peterbell10 desertfire

[ghstack-poisoned]
chunyuan-w added a commit that referenced this pull request Dec 15, 2022
…ference mode"



An FX transformation is added to fuse ConvTranspose2d with eltwise OPs in torchinductor for CPU in inference mode, following the implementation in #87063.

The fusion OP is implemented in #90264 and will be treated as an extern kernel call in torchinductor.

The fusion of ConvTranspose2d with the below OPs is supported:

- relu
- sigmoid
- tanh
- hardswish
- leaky_relu
- hardtanh
- gelu


cc mlazos soumith voznesenskym yanboliang penguinwu anijain2305 EikanWang jgong5 Guobing-Chen XiaobingSuper zhuhaozhe blzheng Xia-Weiwen wenzhe-nrv jiayisunx peterbell10 desertfire

[ghstack-poisoned]
pytorchmergebot pushed a commit that referenced this pull request Dec 15, 2022
#90265)

An FX transformation is added to fuse ConvTranspose2d with eltwise OPs in torchinductor for CPU in inference mode, following the implementation in #87063.

The fusion OP is implemented in #90264 and will be treated as an extern kernel call in torchinductor.

The fusion of ConvTranspose2d with the below OPs is supported:

- relu
- sigmoid
- tanh
- hardswish
- leaky_relu
- hardtanh
- gelu

Pull Request resolved: #90265
Approved by: https://github.com/jgong5, https://github.com/jansel
chunyuan-w added a commit that referenced this pull request Dec 19, 2022
…on for cpu in inference mode"



An FX transformation is added to fuse ConvTranspose2d with eltwise OPs in torchinductor for CPU in inference mode, following the implementation in #87063.

The fusion OP is implemented in #90264 and will be treated as an extern kernel call in torchinductor.

The fusion of ConvTranspose2d with the below OPs is supported:

- relu
- sigmoid
- tanh
- hardswish
- leaky_relu
- hardtanh
- gelu


cc mlazos soumith voznesenskym yanboliang penguinwu anijain2305 EikanWang jgong5 Guobing-Chen XiaobingSuper zhuhaozhe blzheng Xia-Weiwen wenzhe-nrv jiayisunx peterbell10 desertfire

[ghstack-poisoned]
chunyuan-w added a commit that referenced this pull request Dec 19, 2022
…ference mode"



An FX transformation is added to fuse ConvTranspose2d with eltwise OPs in torchinductor for CPU in inference mode, following the implementation in #87063.

The fusion OP is implemented in #90264 and will be treated as an extern kernel call in torchinductor.

The fusion of ConvTranspose2d with the below OPs is supported:

- relu
- sigmoid
- tanh
- hardswish
- leaky_relu
- hardtanh
- gelu


cc mlazos soumith voznesenskym yanboliang penguinwu anijain2305 EikanWang jgong5 Guobing-Chen XiaobingSuper zhuhaozhe blzheng Xia-Weiwen wenzhe-nrv jiayisunx peterbell10 desertfire

[ghstack-poisoned]
chunyuan-w added a commit that referenced this pull request Dec 19, 2022
…on for cpu in inference mode"



An FX transformation is added to fuse ConvTranspose2d with eltwise OPs in torchinductor for CPU in inference mode, following the implementation in #87063.

The fusion OP is implemented in #90264 and will be treated as an extern kernel call in torchinductor.

The fusion of ConvTranspose2d with the below OPs is supported:

- relu
- sigmoid
- tanh
- hardswish
- leaky_relu
- hardtanh
- gelu


cc mlazos soumith voznesenskym yanboliang penguinwu anijain2305 EikanWang jgong5 Guobing-Chen XiaobingSuper zhuhaozhe blzheng Xia-Weiwen wenzhe-nrv jiayisunx peterbell10 desertfire

[ghstack-poisoned]
chunyuan-w added a commit that referenced this pull request Dec 19, 2022
…ference mode"



An FX transformation is added to fuse ConvTranspose2d with eltwise OPs in torchinductor for CPU in inference mode, following the implementation in #87063.

The fusion OP is implemented in #90264 and will be treated as an extern kernel call in torchinductor.

The fusion of ConvTranspose2d with the below OPs is supported:

- relu
- sigmoid
- tanh
- hardswish
- leaky_relu
- hardtanh
- gelu


cc mlazos soumith voznesenskym yanboliang penguinwu anijain2305 EikanWang jgong5 Guobing-Chen XiaobingSuper zhuhaozhe blzheng Xia-Weiwen wenzhe-nrv jiayisunx peterbell10 desertfire

[ghstack-poisoned]
@facebook-github-bot facebook-github-bot deleted the gh/XiaobingSuper/19/head branch June 8, 2023 15:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

5 participants