Disallow module attribute mutation (#88354)
Summary:
See https://github.com/pytorch/torchdynamo/issues/1475
Not allowing any new mutations happen inside forward() function during
export.
Test Plan:
Run `python test/dynamo/test_export.py` and make sure it passes
Added new unit tests (3 positive tests and 4 negative tests)
Here's what the actual error looks like
```
File "/home/mnachin/local/miniconda3/envs/pytorch/lib/python3.9/site-packages/torch/_dynamo/symbolic_convert.py", line 322, in step
getattr(self, inst.opname)(inst)
File "/home/mnachin/local/miniconda3/envs/pytorch/lib/python3.9/site-packages/torch/_dynamo/symbolic_convert.py", line 835, in STORE_ATTR
assert not self.export, f"Mutating module attribute {inst.argval} during export."
AssertionError: Mutating module attribute a during export.
from user code:
File "/data/users/mnachin/pytorch/test/dynamo/test_export_mutations.py", line 25, in forward
self.a = self.a.to(torch.float64)
Set torch._dynamo.config.verbose=True for more information
```
Pull Request resolved: https://github.com/pytorch/pytorch/pull/88354
Approved by: https://github.com/tugsbayasgalan, https://github.com/jansel