Skip to content

Commit b2a2bbb

Browse files
committed
Change the meaning of inputs2, add_second_input
1 parent 3ff259e commit b2a2bbb

17 files changed

+69
-43
lines changed

onnx_diagnostic/_command_lines_parser.py

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -349,6 +349,15 @@ def get_parser_validate() -> ArgumentParser:
349349
python -m onnx_diagnostic validate -m microsoft/Phi-4-mini-reasoning \\
350350
--run -v 1 -o dump_test --no-quiet --repeat 2 --warmup 2 \\
351351
--dtype float16 --device cuda --export modelbuilder
352+
353+
position_ids is usually not needed, they can be removed by adding:
354+
355+
--drop position_ids
356+
357+
The behaviour may be modified compare the original configuration,
358+
the following argument can be rope_scaling to dynamic:
359+
360+
--mop \"rope_scaling={'rope_type': 'dynamic', 'factor': 10.0}\""
352361
"""
353362
),
354363
formatter_class=RawTextHelpFormatter,
@@ -403,10 +412,12 @@ def get_parser_validate() -> ArgumentParser:
403412
)
404413
parser.add_argument(
405414
"--inputs2",
406-
default=True,
407-
action=BooleanOptionalAction,
415+
default=1,
416+
type=int,
408417
help="Validates the model on a second set of inputs\n"
409-
"to check the exported model supports dynamism.",
418+
"to check the exported model supports dynamism. The values is used "
419+
"as an increment to the first set of inputs. A high value may trick "
420+
"a different behavior in the model and missed by the exporter.",
410421
)
411422
parser.add_argument(
412423
"--runtime",
@@ -422,7 +433,8 @@ def get_parser_validate() -> ArgumentParser:
422433
parser.add_argument(
423434
"--drop",
424435
help="Drops the following inputs names, it should be a list\n"
425-
"with comma separated values.",
436+
"with comma separated values, example:\n"
437+
"--drop position_ids",
426438
)
427439
parser.add_argument(
428440
"--opset",

onnx_diagnostic/tasks/automatic_speech_recognition.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ def get_inputs(
3333
head_dim: int,
3434
batch_size: int = 2,
3535
sequence_length: int = 30,
36-
add_second_input: bool = False,
36+
add_second_input: int = 1,
3737
**kwargs, # unused
3838
):
3939
"""
@@ -144,7 +144,7 @@ def get_inputs(
144144
decoder_layers=decoder_layers,
145145
head_dim=head_dim,
146146
batch_size=batch_size + 1,
147-
sequence_length=sequence_length + 1,
147+
sequence_length=sequence_length + add_second_input,
148148
**kwargs,
149149
)["inputs"]
150150
return res

onnx_diagnostic/tasks/feature_extraction.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ def get_inputs(
2222
batch_size: int,
2323
sequence_length: int,
2424
dummy_max_token_id: int,
25-
add_second_input: bool = False,
25+
add_second_input: int = 1,
2626
**kwargs, # unused
2727
):
2828
"""
@@ -56,7 +56,7 @@ def get_inputs(
5656
model=model,
5757
config=config,
5858
batch_size=batch_size + 1,
59-
sequence_length=sequence_length + 1,
59+
sequence_length=sequence_length + add_second_input,
6060
dummy_max_token_id=dummy_max_token_id,
6161
**kwargs,
6262
)["inputs"]

onnx_diagnostic/tasks/fill_mask.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ def get_inputs(
2222
batch_size: int,
2323
sequence_length: int,
2424
dummy_max_token_id: int,
25-
add_second_input: bool = False,
25+
add_second_input: int = 1,
2626
**kwargs, # unused
2727
):
2828
"""
@@ -58,7 +58,7 @@ def get_inputs(
5858
model=model,
5959
config=config,
6060
batch_size=batch_size + 1,
61-
sequence_length=sequence_length + 1,
61+
sequence_length=sequence_length + add_second_input,
6262
dummy_max_token_id=dummy_max_token_id,
6363
**kwargs,
6464
)["inputs"]

onnx_diagnostic/tasks/image_classification.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ def get_inputs(
3434
input_channels: int,
3535
batch_size: int = 2,
3636
dynamic_rope: bool = False,
37-
add_second_input: bool = False,
37+
add_second_input: int = 1,
3838
**kwargs, # unused
3939
):
4040
"""
@@ -78,8 +78,8 @@ def get_inputs(
7878
res["inputs2"] = get_inputs(
7979
model=model,
8080
config=config,
81-
input_width=input_width + 1,
82-
input_height=input_height + 1,
81+
input_width=input_width + add_second_input,
82+
input_height=input_height + add_second_input,
8383
input_channels=input_channels,
8484
batch_size=batch_size + 1,
8585
dynamic_rope=dynamic_rope,

onnx_diagnostic/tasks/image_text_to_text.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ def get_inputs(
3232
sequence_length2: int = 3,
3333
n_images: int = 2,
3434
dynamic_rope: bool = False,
35-
add_second_input: bool = False,
35+
add_second_input: int = 1,
3636
**kwargs, # unused
3737
):
3838
"""
@@ -116,8 +116,8 @@ def get_inputs(
116116
height=height,
117117
num_channels=num_channels,
118118
batch_size=batch_size + 1,
119-
sequence_length=sequence_length + 1,
120-
sequence_length2=sequence_length2 + 1,
119+
sequence_length=sequence_length + add_second_input,
120+
sequence_length2=sequence_length2 + add_second_input,
121121
n_images=n_images + 1,
122122
dynamic_rope=dynamic_rope,
123123
**kwargs,

onnx_diagnostic/tasks/mixture_of_expert.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ def get_inputs(
4141
sequence_length2: int = 3,
4242
n_images: int = 2,
4343
dynamic_rope: bool = False,
44-
add_second_input: bool = False,
44+
add_second_input: int = 1,
4545
**kwargs, # unused
4646
):
4747
"""

onnx_diagnostic/tasks/object_detection.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ def get_inputs(
2727
input_channels: int,
2828
batch_size: int = 2,
2929
dynamic_rope: bool = False,
30-
add_second_input: bool = False,
30+
add_second_input: int = 1,
3131
**kwargs, # unused
3232
):
3333
"""
@@ -68,8 +68,8 @@ def get_inputs(
6868
res["inputs2"] = get_inputs(
6969
model=model,
7070
config=config,
71-
input_width=input_width + 1,
72-
input_height=input_height + 1,
71+
input_width=input_width + add_second_input,
72+
input_height=input_height + add_second_input,
7373
input_channels=input_channels,
7474
batch_size=batch_size + 1,
7575
dynamic_rope=dynamic_rope,

onnx_diagnostic/tasks/sentence_similarity.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ def get_inputs(
2222
batch_size: int,
2323
sequence_length: int,
2424
dummy_max_token_id: int,
25-
add_second_input: bool = False,
25+
add_second_input: int = 1,
2626
**kwargs, # unused
2727
):
2828
"""
@@ -58,7 +58,7 @@ def get_inputs(
5858
model=model,
5959
config=config,
6060
batch_size=batch_size + 1,
61-
sequence_length=sequence_length + 1,
61+
sequence_length=sequence_length + add_second_input,
6262
dummy_max_token_id=dummy_max_token_id,
6363
**kwargs,
6464
)["inputs"]

onnx_diagnostic/tasks/summarization.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ def get_inputs(
2929
batch_size: int = 2,
3030
sequence_length: int = 30,
3131
sequence_length2: int = 3,
32-
add_second_input: bool = False,
32+
add_second_input: int = 1,
3333
**kwargs, # unused
3434
):
3535
"""
@@ -154,8 +154,8 @@ def get_inputs(
154154
head_dim_encoder=head_dim_encoder,
155155
head_dim_decoder=head_dim_decoder,
156156
batch_size=batch_size + 1,
157-
sequence_length=sequence_length + 1,
158-
sequence_length2=sequence_length2 + 1,
157+
sequence_length=sequence_length + add_second_input,
158+
sequence_length2=sequence_length2 + add_second_input,
159159
**kwargs,
160160
)["inputs"]
161161
return res

0 commit comments

Comments
 (0)