-
Notifications
You must be signed in to change notification settings - Fork 5.6k
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
[Dy2stat] Support Various-Length Return Grammar in Dy2stat #25249
[Dy2stat] Support Various-Length Return Grammar in Dy2stat #25249
Conversation
… grammar_return test=develop
… variable_return, test=develop
Thanks for your contribution! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM.
Is the rest corn case related with independent on tensor?
@@ -239,11 +241,44 @@ def _restore_out(self, out_vars): | |||
for i, idx in enumerate(self._outputs.var_ids): | |||
flatten_outputs[idx] = out_vars[i] | |||
outs = self._outputs.restore(flatten_outputs) | |||
if len(outs) == 1: | |||
if outs is not None and len(outs) == 1: | |||
outs = outs[0] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks to fix this.
No, the rest corner case is related to dynamic shape and compile time check |
PR types
New features
PR changes
Others
Describe
Support Various-Length Return Grammar in Dy2stat. This PR is a follow-up of #25176 .
The basic idea is putting no-value placeholder variables at
return
statement to make allreturn
statement have same length, after that the static graph can have fixed fetch output (code at return_transformer.py). Then remove those no-value placeholder when we finally return dygraph result (code at partial_program.py).However, various length return in Bert model is still not supported. The dy2stat can change the code as I wish but some ops which check shape at compile time (e.g. Reshape, MatMul) will throw error because of the no-value-placeholder may not have the required shape. Is this a matter? To me, those no-value placeholder will be replaced as really values meeting shape requirements at run time, so I think the solution should be some way to do the compile-time checking. By the way, every time when we have dynamic shape, it often causes problem in dy2stat. We should find a way to handle it in the future.
Fixing various return in Bert is my TODO thing and I will also find some other existing models for verification.