Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
OpenDAS
AutoAWQ
Commits
f1a2e56e
Unverified
Commit
f1a2e56e
authored
Oct 29, 2023
by
Casper
Committed by
GitHub
Oct 29, 2023
Browse files
Pseudo dequantize function (#127)
parent
b9ed6641
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
0 deletions
+13
-0
awq/quantize/quantizer.py
awq/quantize/quantizer.py
+13
-0
No files found.
awq/quantize/quantizer.py
View file @
f1a2e56e
...
@@ -54,6 +54,19 @@ class AwqQuantizer:
...
@@ -54,6 +54,19 @@ class AwqQuantizer:
else
:
else
:
return
w
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
):
def
quantize
(
self
):
for
i
in
tqdm
(
range
(
len
(
self
.
modules
)),
desc
=
"AWQ"
):
for
i
in
tqdm
(
range
(
len
(
self
.
modules
)),
desc
=
"AWQ"
):
# [STEP 1]: Get layer, extract linear modules, extract input features
# [STEP 1]: Get layer, extract linear modules, extract input features
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment