hustzxd / LSQuantization

The PyTorch implementation of Learned Step size Quantization (LSQ) in ICLR2020 (unofficial)
124 stars 21 forks source link

How to deploy the quantized model? #7

Open jiinhui opened 2 years ago

jiinhui commented 2 years ago

When we have trained the quantization model, how to deploy it?

Siamw commented 2 years ago

use original model with strict=False

jiinhui commented 2 years ago

use original model with strict=False

I mean it is different with the official interface about the Quantization Aware Training(https://pytorch.org/docs/stable/quantization.html),I don't know how to get the int8 model from the trained model.

Siamw commented 2 years ago

not sure what int8 model means.

anyway, i use this method. at model init part,

during training self.conv1 = lsqconv(~~)

during inferencing self.conv1 = nn.Conv2d(~~)

name "self.conv1" does not changed and weights/ bias shapes are same between them. so it works.

i wrote "using strict=false" because if not, it causes error when using upper codes.

jiinhui commented 2 years ago

not sure what int8 model means.

anyway, i use this method. at model init part,

during training self.conv1 = lsqconv(~~)

during inferencing self.conv1 = nn.Conv2d(~~)

name "self.conv1" does not changed and weights/ bias shapes are same between them. so it works.

i wrote "using strict=false" because if not, it causes error when using upper codes.

int8 means 8 bit , which is quantized from the float model (32 bit)

BYFgithub commented 1 year ago

Hello,请问你的这个问题后来弄清楚了吗,我刚接触,现在也想知道怎么得到int8模型