Skip to content

Commit 8092a89

Browse files
Changed command line argpasrse to process '--symmetric [True|False]'. (#19577)
### Description <!-- Describe your changes. --> Accept the command line option --symmetric and its optional value correctly. If the optional value matches uncased to 'True' then set symmetric to True else set symmetric to False. Asymmetric quantization will generate zero_point input. ``` usage: matmul_4bits_quantizer.py [-h] --input_model INPUT_MODEL --output_model OUTPUT_MODEL [--block_size BLOCK_SIZE] [--symmetric [{True,False}]] [--accuracy_level ACCURACY_LEVEL] [-v] [--nodes_to_exclude NODES_TO_EXCLUDE [NODES_TO_EXCLUDE ...]] ``` ### Motivation and Context <!-- - Why is this change required? What problem does it solve? - If it fixes an open issue, please link to the issue here. -->
1 parent 124bde9 commit 8092a89

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

onnxruntime/python/tools/quantization/matmul_4bits_quantizer.py

+8-1
Original file line numberDiff line numberDiff line change
@@ -349,6 +349,10 @@ def process(self):
349349
self.int4_quant_algo()
350350

351351

352+
def ort_convert_str_to_bool(value):
353+
return value.lower() in ("true", "1")
354+
355+
352356
def parse_args():
353357
parser = argparse.ArgumentParser(
354358
description="""Blockwise int4 quantization for MatMul 2D weight matrices.
@@ -366,7 +370,10 @@ def parse_args():
366370
"--symmetric",
367371
required=False,
368372
default=True,
369-
type=bool,
373+
const=True,
374+
nargs="?",
375+
type=ort_convert_str_to_bool,
376+
choices=[True, False],
370377
help="Indicate whether to quantize the model symmetrically",
371378
)
372379
parser.add_argument(

0 commit comments

Comments
 (0)