Skip to content

Commit

Permalink
Fix ORT test for unknown architecture for task (#1212)
Browse files Browse the repository at this point in the history
* fix

* fix style

* git old test
  • Loading branch information
fxmarty authored Jul 19, 2023
1 parent 77c690b commit 21943aa
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion optimum/exporters/onnx/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,7 @@ def main_export(
# TODO: support onnx_config.py in the model repo
if custom_architecture and custom_onnx_configs is None:
raise ValueError(
"Trying to export a model with a custom architecture, but no custom onnx configuration was passed as `custom_onnx_configs`. Please refer to https://huggingface.co/docs/optimum/main/en/exporters/onnx/usage_guides/export_a_model#custom-export-of-transformers-models for an example on how to export custom models."
f"Trying to export a {model.config.model_type.replace('-', '_')} model, that is a custom or unsupported architecture for the task {task}, but no custom onnx configuration was passed as `custom_onnx_configs`. Please refer to https://huggingface.co/docs/optimum/main/en/exporters/onnx/usage_guides/export_a_model#custom-export-of-transformers-models for an example on how to export custom models. For the task {task}, the Optimum ONNX exporter supports natively the architectures: {TasksManager.get_supported_model_type_for_task(task, exporter='onnx')}."
)

if custom_architecture and original_task == "auto":
Expand Down
2 changes: 1 addition & 1 deletion tests/exporters/onnx/test_onnx_export.py
Original file line number Diff line number Diff line change
Expand Up @@ -587,4 +587,4 @@ def test_custom_export_trust_remote_error(self):
no_post_process=True,
)

self.assertIn("export a model with a custom architecture, but no custom onnx", str(context.exception))
self.assertIn("custom or unsupported architecture", str(context.exception))
2 changes: 1 addition & 1 deletion tests/onnxruntime/test_modeling.py
Original file line number Diff line number Diff line change
Expand Up @@ -1089,7 +1089,7 @@ def test_load_vanilla_transformers_which_is_not_supported(self):
with self.assertRaises(Exception) as context:
_ = ORTModelForQuestionAnswering.from_pretrained(MODEL_NAMES["t5"], export=True)

self.assertIn("Unrecognized configuration class", str(context.exception))
self.assertIn("custom or unsupported architecture", str(context.exception))

@parameterized.expand(SUPPORTED_ARCHITECTURES)
def test_compare_to_transformers(self, model_arch):
Expand Down

0 comments on commit 21943aa

Please sign in to comment.