Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix onnx export #2053

Merged
merged 2 commits into from
Oct 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion optimum/exporters/onnx/convert.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@

import numpy as np
import onnx
from transformers.generation import GenerationMixin
from transformers.modeling_utils import get_parameter_dtype
from transformers.utils import is_tf_available, is_torch_available

Expand Down Expand Up @@ -1127,7 +1128,7 @@ def onnx_export_from_model(

if check_if_transformers_greater("4.44.99"):
misplaced_generation_parameters = model.config._get_non_default_generation_parameters()
if model.can_generate() and len(misplaced_generation_parameters) > 0:
if isinstance(model, GenerationMixin) and len(misplaced_generation_parameters) > 0:
logger.warning(
"Moving the following attributes in the config to the generation config: "
f"{misplaced_generation_parameters}. You are seeing this warning because you've set "
Expand Down
8 changes: 8 additions & 0 deletions tests/exporters/onnx/test_exporters_onnx_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -602,6 +602,14 @@ def test_diffusion(self):
check=True,
)

def test_sentence_transformers(self):
with TemporaryDirectory() as tmpdirname:
subprocess.run(
f"python3 -m optimum.exporters.onnx --model sentence-transformers-testing/stsb-bert-tiny-onnx --task feature-extraction {tmpdirname}",
shell=True,
check=True,
)

def test_legacy(self):
with TemporaryDirectory() as tmpdirname:
subprocess.run(
Expand Down
Loading