-
Notifications
You must be signed in to change notification settings - Fork 26.3k
[dynamo] Add is_mutable() and is_immutable() methods to VariableTracker
#139341
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
Conversation
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/139341
Note: Links to docs will display an error until the docs builds have been completed. ✅ You can merge normally! (1 Unrelated Failure)As of commit 4ccd9c8 with merge base b82a51b ( FLAKY - The following job failed but was likely due to flakiness present on trunk:
This comment was automatically generated by Dr. CI and updates every 15 minutes. |
…Tracker`
This patch adds 2 simple methods `VariableTracker.is_mutable()` and
`VariableTracker.is_immutable()`, which helps clarify intention. For
instance, rather than writing
```python
if var.mutation_type:
...
```
After this patch one can write
```python
if var.is_mutable():
...
```
This patch also simplifies `mutation_type` propagation in some
`ListVariable` methods.
ghstack-source-id: d8954a3
Pull Request resolved: #139341
…Tracker`
This patch adds 2 simple methods `VariableTracker.is_mutable()` and
`VariableTracker.is_immutable()`, which helps clarify intention. For
instance, rather than writing
```python
if var.mutation_type:
...
```
After this patch one can write
```python
if var.is_mutable():
...
```
This patch also simplifies `mutation_type` propagation in some
`ListVariable` methods.
ghstack-source-id: 289e2a9
Pull Request resolved: #139341
torch/_dynamo/variables/base.py
Outdated
|
|
||
| def is_mutable(self): | ||
| """Whether Dynamo allows mutation on this variable.""" | ||
| return self.mutation_type |
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.
Nit - return self.mutation_type is not None?
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.
Good call, updating.
…Tracker`
This patch adds 2 simple methods `VariableTracker.is_mutable()` and
`VariableTracker.is_immutable()`, which helps clarify intention. For
instance, rather than writing
```python
if var.mutation_type:
...
```
After this patch one can write
```python
if var.is_mutable():
...
```
This patch also simplifies `mutation_type` propagation in some
`ListVariable` methods.
ghstack-source-id: d252122
Pull Request resolved: #139341
|
@pytorchbot merge |
Merge startedYour change will be merged once all checks pass (ETA 0-4 Hours). Learn more about merging in the wiki. Questions? Feedback? Please reach out to the PyTorch DevX Team |
…Tracker` (pytorch#139341) This patch adds 2 simple methods `VariableTracker.is_mutable()` and `VariableTracker.is_immutable()`, which helps clarify intention. For instance, rather than writing ```python if var.mutation_type: ... ``` After this patch one can write ```python if var.is_mutable(): ... ``` This patch also simplifies `mutation_type` propagation in some `ListVariable` methods. Pull Request resolved: pytorch#139341 Approved by: https://github.com/mlazos, https://github.com/anijain2305 ghstack dependencies: pytorch#139339, pytorch#139340
Stack from ghstack (oldest at bottom):
is_mutable()andis_immutable()methods toVariableTracker#139341MutationTypeclasses intovariables/base.py#139340mutable_localand add documentation #139339This patch adds 2 simple methods
VariableTracker.is_mutable()andVariableTracker.is_immutable(), which helps clarify intention. Forinstance, rather than writing
After this patch one can write
This patch also simplifies
mutation_typepropagation in someListVariablemethods.cc @voznesenskym @penguinwu @EikanWang @jgong5 @Guobing-Chen @XiaobingSuper @zhuhaozhe @blzheng @wenzhe-nrv @jiayisunx @chenyang78 @kadeng @chauhang @amjames