"docs/en/git@developer.sourcefind.cn:OpenDAS/mmcv.git" did not exist on "d493a5d523f4731457435548b255781367c1c92f"
Unverified Commit f1a2e56e authored by Casper's avatar Casper Committed by GitHub
Browse files

Pseudo dequantize function (#127)

parent b9ed6641
......@@ -54,6 +54,19 @@ class AwqQuantizer:
else:
return w
def pseudo_dequantize_tensor(self, w: nn.Linear, scales: torch.Tensor, zeros: torch.Tensor):
# get repeated count
repeat_count = w.weight.data.shape[-1] // zeros.shape[-1]
# get zeros and scales in correct shape
zeros = zeros.repeat(1, repeat_count).reshape(w.weight.data.shape)
scales = scales.repeat(1, repeat_count).reshape(w.weight.data.shape)
# dequantize
w = (w.weight.data - zeros) * scales
return w
def quantize(self):
for i in tqdm(range(len(self.modules)), desc="AWQ"):
# [STEP 1]: Get layer, extract linear modules, extract input features
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment