Hello, I want to know how does PyTorch implement quantization without rewrite the layer definition.
Actually, because of certain reasons, I have to write a quantization framework with PyTorch for my project. Here is an simple example of my implementaion:
def quantization_decorator(func):
    @wraps(func)
    def wrapper(_, x):
        do_quantization(x)
        x = func(x)
        do_quantization(x)
        return x
    return wrapper

class Conv2d(nn.Conv2d):
    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
    
    @quantization_decorator
    def forward(self, x):
        super().forward(x)

Since my quantization method is defined as a decorator,
ADWANTAGE: I can add it to forward to choose whether to quantize this module.
DISAWANTAGE: I have to rewrite each layer, e.g. class Conv2d in my example.
I want to know how does PyTorch implement quantization, so that I can optimize my framework (simpler, faster and more customizable).
Thank you.