config QConfig in pytorch QAT

21 views Asked by At

I want to configure qconfig so that my weights are selected from the values (-2, -1, 0, 1, 2).

m.train()
m.qconfig = torch.quantization.QConfig(
    activation=MinMaxObserver.with_args(dtype=torch.qint8, quant_max=2, quant_min=-2), 
    weight=MinMaxObserver.with_args(dtype=torch.qint8, quant_max=2, quant_min=-2)
)
torch.quantization.prepare_qat(m, inplace=True)

m = train_model(m, train_loader, epochs=100)

m.eval()
torch.quantization.convert(m, inplace=True)

I tried to test everything, but unfortunately I did not succeed

0

There are 0 answers