onnxruntime/orttraining/orttraining/python/training/torchdynamo
ashari4 18c97381cd
Detect fake tensor mode if it has already been created. (#16220)
### Description
<!-- Describe your changes. -->

Detect fake tensor mode if it has already been created. Follows this
example in pytorch:
86c7652503/torch/_inductor/compile_fx.py (L280)


### Motivation and Context
As of torch nightly 6/2/23, when trying to run a torch dynamo graph on
the ORT backend, we observe

```
E           torch._dynamo.exc.BackendCompilerFailed: backend='compiler_fn' raised:
E           AssertionError: Mixing fake modes NYI
E           
E           
E           You can suppress this exception and fall back to eager by setting:
E               import torch._dynamo
E               torch._dynamo.config.suppress_errors = True
```
The issue is that `ort_backend.py` creates a new fake tensor mode even
though one has already been created by torch.
2023-06-02 23:17:49 -07:00
..
__init__.py Enable ORT in TorchDynamo (#13259) 2022-11-01 11:19:29 -07:00
ort_backend.py Detect fake tensor mode if it has already been created. (#16220) 2023-06-02 23:17:49 -07:00
register_backend.py Adopt linrtunner as the linting tool - take 2 (#15085) 2023-03-24 15:29:03 -07:00