MCPcopy Create free account
hub / github.com/OpenGVLab/EfficientQAT / forward

Method forward

quantize/int_linear_real.py:157–171  ·  view source on GitHub ↗
(self, x)

Source from the content-addressed store, hash-verified

155 self.qzeros = torch.from_numpy(qzeros)
156
157 def forward(self, x):
158 if self.use_fake:
159 weight = self.weight
160 if self.fake_transpose:
161 weight = weight.transpose(0,1)
162 else:
163 weight = dequant_dim0(self.qweight, self.bits, self.maxq, self.infeatures, self.outfeatures)
164 dim0, dim1 = weight.shape
165 # dim2 = (dim1*dim0)//self.group_size
166 zeros = dequant_dim1(self.qzeros, self.bits, self.maxq, self.zeros_dim0, self.zeros_dim1)
167 weight = ((weight.view(-1, self.group_size, dim1) - zeros.view(-1, 1, dim1)) * self.scales.view(-1, 1, dim1)).reshape(dim0, dim1)
168 # out = torch.matmul(x, weight)
169 out = torch.matmul(x, weight.to(x.dtype))
170 out = out + self.bias if self.bias is not None else out
171 return out
172
173
174def load_quantized_model(model_path, wbits, group_size):

Callers

nothing calls this directly

Calls 2

dequant_dim0Function · 0.90
dequant_dim1Function · 0.90

Tested by

no test coverage detected