1, I fuse conv2d and batchnorm2d
2,Specify the configuration of the quantization methods
3, Use the [ torch.quantization.prepare() ]
4,Calibrate the model by running inference against a calibration dataset
but it comes to setp 4, i got this

111.png917×199 31.6 KB

I don’t know why the code runs with torch.nn.modules.conv instead of torch.quantized
That`s the code:

model.to(‘cpu’)
model.eval()
model.qconfig = torch.quantization.get_default_qconfig(‘fbgemm’)
torch.quantization.prepare(model, inplace=True)
evaluate(model, data_loader_test, 10)
torch.quantization.convert(model, inplace=True)
top1, top5, loss = evaluate(model, data_loader_test)   —> WRONG