AssertionError: torch.nn.quantized.ReLU does not support inplace

I tries to set relu in qconfig in prepare method of quantisation and came across this errors during .convert

args=args=[criterion,evaluation_loader, converter, opt, True]
            self.validation(fuse_m,args)
            
            # Convert to Quantize Model
            quantise_model=torch.quantization.convert(fuse_m, inplace=True)
Traceback (most recent call last):
  File "test_5step_quant.py", line 474, in <module>
    m.model("//media/ai/OCR_DATA/IIIT5k",15)
  File "test_5step_quant.py", line 448, in model
    self.test(opt)
  File "test_5step_quant.py", line 315, in test
    quantise_model=torch.quantization.convert(fuse_m, inplace=False)
  File "/home/remote/.local/lib/python3.6/site-packages/torch/quantization/quantize.py", line 293, in convert
    convert(mod, mapping, inplace=True)
  File "/home/remote/.local/lib/python3.6/site-packages/torch/quantization/quantize.py", line 293, in convert
    convert(mod, mapping, inplace=True)
  File "/home/remote/.local/lib/python3.6/site-packages/torch/quantization/quantize.py", line 294, in convert
    reassign[name] = swap_module(mod, mapping)
  File "/home/remote/.local/lib/python3.6/site-packages/torch/quantization/quantize.py", line 316, in swap_module
    new_mod = mapping[type(mod)].from_float(mod)
  File "/home/remote/.local/lib/python3.6/site-packages/torch/nn/quantized/modules/activation.py", line 44, in from_float
    return ReLU(mod.inplace)
  File "/home/remote/.local/lib/python3.6/site-packages/torch/nn/quantized/modules/activation.py", line 34, in __init__
    assert not inplace, 'torch.nn.quantized.ReLU does not support inplace'
AssertionError: torch.nn.quantized.ReLU does not support inplace

should be fixed in https://github.com/pytorch/pytorch/pull/33105, cc @raghuramank100

1 Like