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 encoder-decoder ONNX merge #924

Merged
merged 7 commits into from
Mar 27, 2023

Conversation

fxmarty
Copy link
Contributor

@fxmarty fxmarty commented Mar 27, 2023

Fixes #921

In next PRs:

  1. Add the support for merged decoder for seq2seq models in optimum-cli export onnx
  2. Add the support for merged decoder for seq2seq models in ORTModel

@HuggingFaceDocBuilderDev
Copy link

HuggingFaceDocBuilderDev commented Mar 27, 2023

The documentation is not available anymore as the PR was closed or merged.

outputs_only_in_1 = model1_outputs - model2_outputs
outputs_only_in_2 = model2_outputs - model1_outputs
if len(outputs_only_in_2) > 0:
raise ValueError("The ModelProto model2 should not have more outputs than model1.")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
raise ValueError("The ModelProto model2 should not have more outputs than model1.")
raise ValueError("The 2nd ModelProto should not have more outputs than 1st model.")

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And btw why can model 1 have more outputs than model2 but not inverse?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

merge_decoders is asymmetrical for now - it was before as well as we use the outputs of model1. It's indeed not good and can be changed in an other PR.

Copy link
Member

@michaelbenayoun michaelbenayoun left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

optimum/onnx/transformations_utils.py Show resolved Hide resolved
optimum/onnx/transformations_utils.py Outdated Show resolved Hide resolved
optimum/onnx/transformations_utils.py Outdated Show resolved Hide resolved

outputs_only_in_1 = model1_outputs - model2_outputs
outputs_only_in_2 = model2_outputs - model1_outputs
if len(outputs_only_in_2) > 0:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the raw number of element check enough?
Because we could check if one is a subset of the other as well if needed?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, fixed with set checks!

optimum/onnx/transformations_utils.py Outdated Show resolved Hide resolved
optimum/onnx/transformations_utils.py Show resolved Hide resolved
optimum/onnx/transformations_utils.py Outdated Show resolved Hide resolved
optimum/onnx/transformations_utils.py Show resolved Hide resolved
else:
model2.graph.output.remove(model_output_2)

# We use model1 (normally the decoder) for the output shape
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

<3

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

<3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Regression: merge_decoders fails in 1.7.3
4 participants