Hello,
I have a simple model, trained and quantized using prepare_fx and conver_fx with qconfig fbqemm.
Then I save it and reload it using load_state_dict and got an ordered dictionary.
The question is: there are some unclear fileds in the dictionary,
What are ‘a_input_scale_0’, ‘a_input_zero_point_0’, ‘a.scale’, 'a.zero_point '? Since we noticed that a._packed_params._packed_params already contains scale and zero_point itself.
And where is the bias ?
Any help is appreciated, thank you
######## The model
class myModel(nn.Module):
def init(self):
super().init()
self.a = nn.Linear(32, 35, bias=True)
self.b = nn.Linear(98, 1, bias=True)
def forward(self, x):
x = self.a(x)
x = self.b(x.transpose(1, 2))
x = x.view(x.size(0), -1)
return x
The ouput state_dict of quantized model
a_input_scale_0 tensor(0.0895)
a_input_zero_point_0 tensor(67)
a.scale tensor(0.0581)
a.zero_point tensor(61)
a._packed_params.dtype torch.qint8
a._packed_params._packed_params (tensor([[ 0.1049, -0.0834, 0.0367, …, 0.1226, 0.0114, -0.0518],
[-0.0455, -0.0371, -0.0236, …, -0.0337, 0.0017, -0.0303],
[ 0.0721, -0.0401, -0.1162, …, -0.1643, 0.0521, 0.1102],
…,
[-0.0614, -0.0341, 0.0034, …, -0.0461, 0.0938, -0.0461],
[ 0.0778, -0.0519, -0.2309, …, 0.2543, 0.3295, 0.1142],
[-0.0360, -0.0337, -0.0067, …, -0.1887, -0.0584, -0.0831]],
size=(35, 32), dtype=torch.qint8,
quantization_scheme=torch.per_channel_affine,
scale=tensor([0.0013, 0.0017, 0.0020, 0.0015, 0.0014, 0.0014, 0.0016, 0.0021, 0.0018,
0.0021, 0.0018, 0.0018, 0.0021, 0.0018, 0.0014, 0.0018, 0.0024, 0.0017,
0.0018, 0.0016, 0.0017, 0.0020, 0.0017, 0.0018, 0.0024, 0.0014, 0.0019,
0.0018, 0.0021, 0.0017, 0.0015, 0.0018, 0.0017, 0.0026, 0.0022],
dtype=torch.float64),
zero_point=tensor([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]),
axis=0), Parameter containing:
tensor([-0.0608, -0.0085, 0.0056, -0.0036, -0.0117, 0.1390, 0.1868, 0.2030,
-0.1790, -0.2360, 0.0027, 0.1740, -0.0881, -0.2767, -0.0704, 0.0934,
-0.0325, 0.2201, 0.2068, 0.0948, 0.1345, 0.1555, 0.0917, -0.0823,
-0.3508, 0.2088, -0.0425, 0.0863, -0.1298, 0.0901, 0.2117, -0.1644,
-0.0104, -0.0356, -0.0740], requires_grad=True))
b.scale tensor(0.1606)
b.zero_point tensor(64)
b._packed_params.dtype torch.qint8
b._packed_params._packed_params (tensor([[ 0.1418, 0.0219, 0.1013, -0.0760, -0.0068, -0.0270, -0.0523, 0.0219,
-0.1266, -0.0270, -0.0169, -0.1064, -0.1435, -0.0101, -0.0861, -0.1570,
-0.0810, -0.0709, -0.1182, -0.1401, -0.0051, -0.1587, -0.1536, -0.0557,
-0.0355, -0.1131, -0.1249, -0.0101, -0.0321, -0.1047, -0.0540, -0.0017,
-0.0760, -0.0338, -0.0777, 0.0101, 0.0101, -0.0338, 0.0675, 0.0000,
-0.0490, 0.0523, 0.0253, -0.0608, 0.0793, 0.0203, 0.0625, -0.0135,
0.0388, 0.0658, 0.0523, 0.0388, 0.0743, 0.0338, 0.0152, 0.1418,
0.0321, 0.1249, 0.0625, 0.0304, 0.1773, 0.0675, 0.0726, 0.0540,
0.1891, 0.0979, 0.1705, 0.0743, 0.1013, 0.1519, 0.0709, 0.1688,
0.1536, 0.0709, 0.1199, 0.1587, 0.1941, 0.1165, 0.1502, 0.1435,
0.2144, 0.0709, 0.0996, 0.1519, 0.1688, 0.1367, 0.1722, 0.1199,
0.1351, 0.1435, 0.1469, 0.0912, 0.1587, 0.0709, 0.1351, 0.0270,
0.0236, 0.0945]], size=(1, 98), dtype=torch.qint8,
quantization_scheme=torch.per_channel_affine,
scale=tensor([0.0017], dtype=torch.float64), zero_point=tensor([0]),
axis=0), Parameter containing:
tensor([0.1705], requires_grad=True))