Spaces:
Sleeping
Sleeping
Create utils/quantize.py
Browse files- utils/quantize.py +8 -0
utils/quantize.py
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import torch.quantization as tq
|
| 2 |
+
|
| 3 |
+
def apply_int8(model):
|
| 4 |
+
model.qconfig = tq.get_default_qconfig("fbgemm")
|
| 5 |
+
tq.prepare(model, inplace=True)
|
| 6 |
+
# calibration pass must already be done
|
| 7 |
+
tq.convert(model, inplace=True)
|
| 8 |
+
return model
|