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

fuse ConvTranspose2d+BatchNorm2d+ReLU #1462

Open
yokosyun opened this issue Dec 28, 2024 · 1 comment
Open

fuse ConvTranspose2d+BatchNorm2d+ReLU #1462

yokosyun opened this issue Dec 28, 2024 · 1 comment
Labels
enhancement New feature or request

Comments

@yokosyun
Copy link

Feature Support Request

I would like to fuse ConvTranspose2d+BatchNorm2d+ReLU

AssertionError: did not find fuser method for: (<class 'torch.nn.modules.conv.ConvTranspose2d'>, <class 'torch.nn.modules.batchnorm.BatchNorm2d'>, <class 'torch.nn.modules.activation.ReLU'>)

Reproduce

pip3 install torch --index-url https://download.pytorch.org/whl/cu121
python3 fuse.py

fuse.py

import torch
import torch.nn as nn

class DummyModel(nn.Module):
    def __init__(self):
        super(DummyModel, self).__init__()
        self.conv = nn.ConvTranspose2d(3, 32, 3, 1)
        self.bn = nn.BatchNorm2d(32)
        self.relu = nn.ReLU()

    def forward(self, x):
        x = self.conv(x)
        x = self.bn(x)
        x = self.relu(x)
        return x


modules_to_fuse = ["conv", "bn", "relu"]
model = DummyModel()
model.eval()
model = torch.ao.quantization.fuse_modules(model, modules_to_fuse)
@jerryzh168
Copy link
Contributor

jerryzh168 commented Dec 28, 2024

yes conv_transpose2d + bn + relu is indeed not supported right now: https://github.com/pytorch/pytorch/blob/c3c27aef3429e4d4cdff9c3d036c569da5df7276/torch/ao/quantization/fuser_method_mappings.py#L209, this is our older tool that we plan to deprecate, what do you want to achieve in the end? if it's just the fusion, there are multiple ways to do it.

@supriyar supriyar added the enhancement New feature or request label Jan 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants