Fix torch listconstruct errors when dependent on inputs flexible shapes #2050
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Recommodation for merge:
No.
There're some unit tests still needs to be added.
What it fixes
This PR is trying to fix #1921, along with other bugs that suffers the same reason.
The root cause is discussed in #1926, that when converting a
torch.listconstruct
, if any value in it depends on a dynamic shape which roots in the net input, the converted result is a bare python list and failed to parse in the subsequent op.Design of this fix
This fix happends inside
listconstruct
parsing, runs a DFS from the current node to each parent layer all the way to the net root. And works on this asssumption:What it does and does not
gather
, and what it gathers from is not a name incontext.torch_graph.nodes
, i.e. the net inputs.