Skip to content

Commit 301c0ad

Browse files
committed
Add --skip-quant option
1 parent 9afe3ac commit 301c0ad

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

extract.py

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ def extract_wiki_content(lang_code, page="Python_(programming_language)"):
2626
parser.add_argument('--lang-code', default='en', help='Language code (default: en)')
2727
parser.add_argument('--output', default='onnx/', help='Output folder (default: onnx/)')
2828
parser.add_argument('--text', default='', help="Text to feed the stanza model for extraction")
29+
parser.add_argument('--skip-quant', type=bool, action="store_true", help="Don't quantize model")
30+
2931
args = parser.parse_args()
3032

3133
if not args.stanza_dir:
@@ -105,13 +107,14 @@ def extract_onnx(self, inputs):
105107
model_simp, check = simplify(m)
106108
onnx.save(m, outfile)
107109

108-
quant_pre_process(outfile, outfile_optim, skip_symbolic_shape=True)
109-
quantized_model = quantize_dynamic(outfile_optim, outfile_quant, weight_type=QuantType.QUInt8)
110-
if os.path.isfile(outfile_quant):
111-
os.unlink(outfile)
112-
os.rename(outfile_quant, outfile)
113-
if os.path.isfile(outfile_optim):
114-
os.unlink(outfile_optim)
110+
if not args.skip_quant:
111+
quant_pre_process(outfile, outfile_optim, skip_symbolic_shape=True)
112+
quantized_model = quantize_dynamic(outfile_optim, outfile_quant, weight_type=QuantType.QUInt8)
113+
if os.path.isfile(outfile_quant):
114+
os.unlink(outfile)
115+
os.rename(outfile_quant, outfile)
116+
if os.path.isfile(outfile_optim):
117+
os.unlink(outfile_optim)
115118
else:
116119
print("Something went wrong")
117120
exit(1)

0 commit comments

Comments
 (0)