Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

jamesr66a
Copy link
Collaborator

@jamesr66a jamesr66a commented Jan 12, 2021

Stack from ghstack:

  1. Codify the interpreter pattern that was used, for ex, in shape prop. This is a pattern users will likely find repeatedly useful so it's good to have it first-class in the API. As seen in the test cases, this makes it incredibly easy to do simple analysis and transforms like swapping out individual nodes

  2. Add a small Transformer class that is an Interpreter but provides a transform method that yields a GraphModule from interpreting the code

image
image

TODO:

  • Write docstrings
  • Write docs
  • Look for more places this can be used

Differential Revision: D25880330

@facebook-github-bot
Copy link
Contributor

facebook-github-bot commented Jan 12, 2021

💊 CI failures summary and remediations

As of commit 64d7a19 (more details on the Dr. CI page):


  • 1/1 failures possibly* introduced in this PR
    • 1/1 non-CircleCI failure(s)

This comment was automatically generated by Dr. CI (expand for details).Follow this link to opt-out of these comments for your Pull Requests.

Please report bugs/suggestions to the (internal) Dr. CI Users group.

jamesr66a pushed a commit that referenced this pull request Jan 12, 2021
ghstack-source-id: 9a68a47
Pull Request resolved: #50420
@Chillee
Copy link
Collaborator

Chillee commented Jan 14, 2021

I think it might be easier to implement vmap with this.

1. Codify the interpreter pattern that was used, for ex, in [shape prop](https://github.com/pytorch/pytorch/blob/c3b4b2062748ed70e689f9f9ffe670e6fa20a071/torch/fx/experimental/shape_prop.py#L7). This is a pattern users will likely find repeatedly useful so it's good to have it first-class in the API. As seen in the test cases, this makes it incredibly easy to do simple analysis and transforms like swapping out individual nodes

2. Add a small `Transformer` class that is an `Interpreter` but provides a `transform` method that yields a GraphModule from interpreting the code

TODO:

- [ ] Write docstrings
- [ ] Write docs
- [ ] Look for more places this can be used

Differential Revision: [D25880330](https://our.internmc.facebook.com/intern/diff/D25880330)

[ghstack-poisoned]
jamesr66a pushed a commit that referenced this pull request Jan 26, 2021
ghstack-source-id: 04dc1ab
Pull Request resolved: #50420
1. Codify the interpreter pattern that was used, for ex, in [shape prop](https://github.com/pytorch/pytorch/blob/c3b4b2062748ed70e689f9f9ffe670e6fa20a071/torch/fx/experimental/shape_prop.py#L7). This is a pattern users will likely find repeatedly useful so it's good to have it first-class in the API. As seen in the test cases, this makes it incredibly easy to do simple analysis and transforms like swapping out individual nodes

2. Add a small `Transformer` class that is an `Interpreter` but provides a `transform` method that yields a GraphModule from interpreting the code

TODO:

- [ ] Write docstrings
- [ ] Write docs
- [ ] Look for more places this can be used

Differential Revision: [D25880330](https://our.internmc.facebook.com/intern/diff/D25880330)

[ghstack-poisoned]
1. Codify the interpreter pattern that was used, for ex, in [shape prop](https://github.com/pytorch/pytorch/blob/c3b4b2062748ed70e689f9f9ffe670e6fa20a071/torch/fx/experimental/shape_prop.py#L7). This is a pattern users will likely find repeatedly useful so it's good to have it first-class in the API. As seen in the test cases, this makes it incredibly easy to do simple analysis and transforms like swapping out individual nodes

2. Add a small `Transformer` class that is an `Interpreter` but provides a `transform` method that yields a GraphModule from interpreting the code

TODO:

- [ ] Write docstrings
- [ ] Write docs
- [ ] Look for more places this can be used

Differential Revision: [D25880330](https://our.internmc.facebook.com/intern/diff/D25880330)

[ghstack-poisoned]
@jamesr66a jamesr66a changed the title [WIP][FX] Add Interpreter and Transformer [FX] Add Interpreter and Transformer Jan 26, 2021
1. Codify the interpreter pattern that was used, for ex, in [shape prop](https://github.com/pytorch/pytorch/blob/c3b4b2062748ed70e689f9f9ffe670e6fa20a071/torch/fx/experimental/shape_prop.py#L7). This is a pattern users will likely find repeatedly useful so it's good to have it first-class in the API. As seen in the test cases, this makes it incredibly easy to do simple analysis and transforms like swapping out individual nodes

2. Add a small `Transformer` class that is an `Interpreter` but provides a `transform` method that yields a GraphModule from interpreting the code

TODO:

- [x] Write docstrings
- [ ] Write docs
- [ ] Look for more places this can be used

Differential Revision: [D25880330](https://our.internmc.facebook.com/intern/diff/D25880330)

[ghstack-poisoned]
1. Codify the interpreter pattern that was used, for ex, in [shape prop](https://github.com/pytorch/pytorch/blob/c3b4b2062748ed70e689f9f9ffe670e6fa20a071/torch/fx/experimental/shape_prop.py#L7). This is a pattern users will likely find repeatedly useful so it's good to have it first-class in the API. As seen in the test cases, this makes it incredibly easy to do simple analysis and transforms like swapping out individual nodes

2. Add a small `Transformer` class that is an `Interpreter` but provides a `transform` method that yields a GraphModule from interpreting the code

![image](https://user-images.githubusercontent.com/4685384/105924691-a7b0b700-5ff3-11eb-8de8-7967d6b8ac69.png)
![image](https://user-images.githubusercontent.com/4685384/105924696-abdcd480-5ff3-11eb-8454-a2bc36c3248e.png)


TODO:

- [x] Write docstrings
- [ ] Write docs
- [ ] Look for more places this can be used

Differential Revision: [D25880330](https://our.internmc.facebook.com/intern/diff/D25880330)

[ghstack-poisoned]
1. Codify the interpreter pattern that was used, for ex, in [shape prop](https://github.com/pytorch/pytorch/blob/c3b4b2062748ed70e689f9f9ffe670e6fa20a071/torch/fx/experimental/shape_prop.py#L7). This is a pattern users will likely find repeatedly useful so it's good to have it first-class in the API. As seen in the test cases, this makes it incredibly easy to do simple analysis and transforms like swapping out individual nodes

2. Add a small `Transformer` class that is an `Interpreter` but provides a `transform` method that yields a GraphModule from interpreting the code

![image](https://user-images.githubusercontent.com/4685384/105924691-a7b0b700-5ff3-11eb-8de8-7967d6b8ac69.png)
![image](https://user-images.githubusercontent.com/4685384/105924696-abdcd480-5ff3-11eb-8454-a2bc36c3248e.png)


TODO:

- [x] Write docstrings
- [ ] Write docs
- [ ] Look for more places this can be used

Differential Revision: [D25880330](https://our.internmc.facebook.com/intern/diff/D25880330)

[ghstack-poisoned]
jamesr66a pushed a commit that referenced this pull request Jan 27, 2021
ghstack-source-id: 9c449a5
Pull Request resolved: #50420
Copy link
Contributor

@zdevito zdevito left a comment

Choose a reason for hiding this comment

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

Looks pretty reasonable. I have a few suggestions to better decompose the components into reusable parts.

.. autoclass:: torch.fx.Interpreter
:members:

.. autoclass:: torch.fx.Transformer
Copy link
Contributor

Choose a reason for hiding this comment

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

still need a different name for this

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I haven't heard any good suggestions for this. Is the concern that this is the same name as the Transformer architecture? In that case, I would argue that "Transformer" is a terrible name for that architecture and I don't think we should let them squat on an English language common noun

1. Codify the interpreter pattern that was used, for ex, in [shape prop](https://github.com/pytorch/pytorch/blob/c3b4b2062748ed70e689f9f9ffe670e6fa20a071/torch/fx/experimental/shape_prop.py#L7). This is a pattern users will likely find repeatedly useful so it's good to have it first-class in the API. As seen in the test cases, this makes it incredibly easy to do simple analysis and transforms like swapping out individual nodes

2. Add a small `Transformer` class that is an `Interpreter` but provides a `transform` method that yields a GraphModule from interpreting the code

![image](https://user-images.githubusercontent.com/4685384/105924691-a7b0b700-5ff3-11eb-8de8-7967d6b8ac69.png)
![image](https://user-images.githubusercontent.com/4685384/105924696-abdcd480-5ff3-11eb-8454-a2bc36c3248e.png)


TODO:

- [x] Write docstrings
- [x] Write docs
- [ ] Look for more places this can be used

Differential Revision: [D25880330](https://our.internmc.facebook.com/intern/diff/D25880330)

[ghstack-poisoned]
@jamesr66a jamesr66a requested a review from zdevito January 29, 2021 22:22
1. Codify the interpreter pattern that was used, for ex, in [shape prop](https://github.com/pytorch/pytorch/blob/c3b4b2062748ed70e689f9f9ffe670e6fa20a071/torch/fx/experimental/shape_prop.py#L7). This is a pattern users will likely find repeatedly useful so it's good to have it first-class in the API. As seen in the test cases, this makes it incredibly easy to do simple analysis and transforms like swapping out individual nodes

2. Add a small `Transformer` class that is an `Interpreter` but provides a `transform` method that yields a GraphModule from interpreting the code

![image](https://user-images.githubusercontent.com/4685384/105924691-a7b0b700-5ff3-11eb-8de8-7967d6b8ac69.png)
![image](https://user-images.githubusercontent.com/4685384/105924696-abdcd480-5ff3-11eb-8454-a2bc36c3248e.png)


TODO:

- [x] Write docstrings
- [x] Write docs
- [ ] Look for more places this can be used

Differential Revision: [D25880330](https://our.internmc.facebook.com/intern/diff/D25880330)

[ghstack-poisoned]
jamesr66a pushed a commit that referenced this pull request Jan 29, 2021
ghstack-source-id: 9d200c9
Pull Request resolved: #50420
1. Codify the interpreter pattern that was used, for ex, in [shape prop](https://github.com/pytorch/pytorch/blob/c3b4b2062748ed70e689f9f9ffe670e6fa20a071/torch/fx/experimental/shape_prop.py#L7). This is a pattern users will likely find repeatedly useful so it's good to have it first-class in the API. As seen in the test cases, this makes it incredibly easy to do simple analysis and transforms like swapping out individual nodes

2. Add a small `Transformer` class that is an `Interpreter` but provides a `transform` method that yields a GraphModule from interpreting the code

![image](https://user-images.githubusercontent.com/4685384/105924691-a7b0b700-5ff3-11eb-8de8-7967d6b8ac69.png)
![image](https://user-images.githubusercontent.com/4685384/105924696-abdcd480-5ff3-11eb-8454-a2bc36c3248e.png)


TODO:

- [x] Write docstrings
- [x] Write docs
- [ ] Look for more places this can be used

Differential Revision: [D25880330](https://our.internmc.facebook.com/intern/diff/D25880330)

[ghstack-poisoned]
jamesr66a pushed a commit that referenced this pull request Jan 30, 2021
ghstack-source-id: 67c6b31
Pull Request resolved: #50420
1. Codify the interpreter pattern that was used, for ex, in [shape prop](https://github.com/pytorch/pytorch/blob/c3b4b2062748ed70e689f9f9ffe670e6fa20a071/torch/fx/experimental/shape_prop.py#L7). This is a pattern users will likely find repeatedly useful so it's good to have it first-class in the API. As seen in the test cases, this makes it incredibly easy to do simple analysis and transforms like swapping out individual nodes

2. Add a small `Transformer` class that is an `Interpreter` but provides a `transform` method that yields a GraphModule from interpreting the code

![image](https://user-images.githubusercontent.com/4685384/105924691-a7b0b700-5ff3-11eb-8de8-7967d6b8ac69.png)
![image](https://user-images.githubusercontent.com/4685384/105924696-abdcd480-5ff3-11eb-8454-a2bc36c3248e.png)


TODO:

- [x] Write docstrings
- [x] Write docs
- [ ] Look for more places this can be used

Differential Revision: [D25880330](https://our.internmc.facebook.com/intern/diff/D25880330)

[ghstack-poisoned]
jamesr66a pushed a commit that referenced this pull request Jan 30, 2021
ghstack-source-id: 5f2bd6f
Pull Request resolved: #50420
@facebook-github-bot
Copy link
Contributor

@jamesr66a merged this pull request in 609f76f.

@facebook-github-bot facebook-github-bot deleted the gh/jamesr66a/350/head branch February 5, 2021 15:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants