Summary:
This is a followup to https://github.com/pytorch/pytorch/pull/88354/files#diff-622913fdb49db90d6f3a8ab225b4badb7996023e6498e9f7c6d03fe9f32d0986R836
Reference to self.export got added to InstructionTranslatorBase (i.e. STORE_ATTR) but self.export is populated only for InstructionTranslators.
Here's an example failure
```
File "/scratch/williamwen/work/pytorch/torch/_dynamo/symbolic_convert.py", line 322, in step
getattr(self, inst.opname)(inst)
File "/scratch/williamwen/work/pytorch/torch/_dynamo/symbolic_convert.py", line 844, in STORE_ATTR
not self.export
AttributeError: 'InliningInstructionTranslator' object has no attribute 'export'
```
Let's populate with the base class with export flag.
Test Plan:
python test/dynamo/test_export_mutations.py
python test/dynamo/test_export.py
Pull Request resolved: https://github.com/pytorch/pytorch/pull/88508
Approved by: https://github.com/tugsbayasgalan
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