Skip to content

Commit 9420154

Browse files
authored
Fix onnx export for transformers>=4.45 (#2054)
* fix onnx export for transformers>=4.45 * fix tets * style
1 parent b42db7e commit 9420154

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

optimum/exporters/onnx/convert.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1128,7 +1128,11 @@ def onnx_export_from_model(
11281128

11291129
if check_if_transformers_greater("4.44.99"):
11301130
misplaced_generation_parameters = model.config._get_non_default_generation_parameters()
1131-
if isinstance(model, GenerationMixin) and len(misplaced_generation_parameters) > 0:
1131+
if (
1132+
isinstance(model, GenerationMixin)
1133+
and model.can_generate()
1134+
and len(misplaced_generation_parameters) > 0
1135+
):
11321136
logger.warning(
11331137
"Moving the following attributes in the config to the generation config: "
11341138
f"{misplaced_generation_parameters}. You are seeing this warning because you've set "

tests/exporters/onnx/test_exporters_onnx_cli.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -602,6 +602,7 @@ def test_diffusion(self):
602602
check=True,
603603
)
604604

605+
@require_sentence_transformers
605606
def test_sentence_transformers(self):
606607
with TemporaryDirectory() as tmpdirname:
607608
subprocess.run(

0 commit comments

Comments
 (0)