Skip to content

Commit 08bd601

Browse files
Fix dynamo kwarg (#85)
1 parent cc685ec commit 08bd601

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

optimum/exporters/onnx/convert.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@
5555
is_diffusers_available,
5656
is_onnxslim_available,
5757
is_torch_onnx_support_available,
58+
is_torch_version,
5859
is_transformers_version,
5960
logging,
6061
)
@@ -556,6 +557,12 @@ def remap(value):
556557
else:
557558
dynamix_axes = dict(chain(inputs.items(), config.outputs.items()))
558559

560+
if is_torch_version(">=", "2.9"):
561+
# Starting from 2.9 dynamo's default value is True
562+
dynamo_kwargs = {"dynamo": False}
563+
else:
564+
dynamo_kwargs = {}
565+
559566
# Export can work with named args but the dict containing named args has to be the last element of the args
560567
# tuple.
561568
onnx_export(
@@ -567,7 +574,7 @@ def remap(value):
567574
dynamic_axes=dynamix_axes,
568575
do_constant_folding=do_constant_folding,
569576
opset_version=opset,
570-
dynamo=False, # torch dynamo not yet supported
577+
**dynamo_kwargs,
571578
)
572579

573580
# check if external data was exported

0 commit comments

Comments
 (0)