Shape prop view/reshape/as_strided through prim::ListConstructs#11877
Closed
zou3519 wants to merge 3 commits intopytorch:masterfrom
Closed
Shape prop view/reshape/as_strided through prim::ListConstructs#11877zou3519 wants to merge 3 commits intopytorch:masterfrom
zou3519 wants to merge 3 commits intopytorch:masterfrom
Conversation
Previously, aten::view returned a Dynamic type when attr::size is a prim::ListConstruct. See [this for a repro](https://gist.github.com/zou3519/cbd610472ba3369f556fa612a7d93b28). This prevented a pre-multipled lstm input graph from being fusible (aten::view is necessary to do premultiplication). If aten::view is passed an output of a prim::ListConstruct node, then shape prop should be able to figure out its TensorType because we statically know the number of inputs to prim::ListConstruct. This PR implements that.
apaszke
reviewed
Sep 20, 2018
| auto input_node = node->namedInput(shape_input)->node(); | ||
| if (input_node->kind() == prim::ListConstruct) { | ||
| return tensor_types.at(0)->withDim(input_node->inputs().size()); | ||
| } |
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
test/test_jit.py
Outdated
| x = torch.randn(3, 1, 5, requires_grad=True) | ||
| graph = torch.jit.script(fn).graph | ||
| torch._C._jit_pass_complete_shape_analysis(graph, (x,), False) | ||
| self.assertExpectedGraph(graph) |
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
… test with better test
Contributor
facebook-github-bot
left a comment
There was a problem hiding this comment.
zou3519 has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.
apaszke
approved these changes
Sep 21, 2018
test/test_jit.py
Outdated
|
|
||
| x = torch.randn(3, 1, 5, requires_grad=True) | ||
| graph = torch.jit.script(fn).graph | ||
| torch._C._jit_pass_complete_shape_analysis(graph, (x,), False) |
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
Contributor
facebook-github-bot
left a comment
There was a problem hiding this comment.
zou3519 has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Previously, aten::view returned a Dynamic type when attr::size is a prim::ListConstruct.
See this for a repro.
This prevented a pre-multipled lstm input graph from being fusible (aten::view is necessary
to do premultiplication).
If aten::view is passed an output of a prim::ListConstruct node, then shape prop should
be able to figure out its TensorType because we statically know the number of inputs to
prim::ListConstruct. This PR implements that.