Commits


ashari4 authored and GitHub committed 18c97381cd6
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: https://github.com/pytorch/pytorch/blob/86c76525033418f6e9fed6134a6af66eff79d1d5/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.