Move & rename onnx_export#1685
Conversation
| return export_output | ||
|
|
||
|
|
||
| def onnx_export_from_model( |
There was a problem hiding this comment.
The function is also renamed to onnx_export_from_model to explicit its role, and documented.
| if ( | ||
| not custom_architecture | ||
| and library_name != "diffusers" | ||
| and task + "-with-past" | ||
| in TasksManager.get_supported_tasks_for_model_type(model_type, "onnx", library_name=library_name) | ||
| and not monolith | ||
| ): | ||
| # -with-past is the default. | ||
| task = task + "-with-past" |
There was a problem hiding this comment.
This is added compared to main - the default should be the export with KV cache.
| """ | ||
| library_name = TasksManager._infer_library_from_model(model) | ||
|
|
||
| # TODO: call standardize_model_attributes here once its model_name_or_path argument is optional. |
There was a problem hiding this comment.
As standardize_model_attributes is not called here but only in main_export, calling this function with a timm/diffusers/sentence-transformers model will fail. Only Transformers is working, I believe.
| library_name (`Optional[str]`, *optional*):: | ||
| The library name of the model. Can be any of "transformers", "timm", "diffusers", "sentence_transformers". | ||
| """ | ||
| # TODO: make model_name_or_path an optional argument here. |
There was a problem hiding this comment.
@mht-sharma Is this argument needed? For timm, the config indeed seem not to be attached to the timm.models.xxx.Xxx (e.g. timm.models.resnet.ResNet) instance, but is this an issue for the export? Do we need any info from the config.json?
For diffusers, sentence-transformers, we are fine.
There was a problem hiding this comment.
Thank you @mht-sharma, can you in #1686 make it so that standardize_model_attributes is called here:
optimum/optimum/exporters/onnx/convert.py
Line 991 in 32a51af
Co-authored-by: Ella Charlaix <80481427+echarlaix@users.noreply.github.com>
* move & rename onnx_export * fix test * Update optimum/exporters/onnx/convert.py Co-authored-by: Ella Charlaix <80481427+echarlaix@users.noreply.github.com> --------- Co-authored-by: Ella Charlaix <80481427+echarlaix@users.noreply.github.com>
As per title. It should ideally not be in
__main__.py, as this file is kept simply for backward compatibility ofpythonm -m optimum.exporters.onnx.Motivation: not seeing
from optimum.exporters.onnx.__main__ import onnx_exportin code snippets.