refuse to generate a symbolic variable if a float input is inf (#139846)

Fixes `PYTORCH_TEST_WITH_INDUCTOR=1 tlp python test/test_torch.py TestTorchDeviceTypeCPU.test_cauchy_cpu_float64` when `specialize_float=False`

Pull Request resolved: https://github.com/pytorch/pytorch/pull/139846
Approved by: https://github.com/ruidazeng, https://github.com/ezyang
ghstack dependencies: #139569, #139457, #139568, #139572
This commit is contained in:
Bob Ren 2024-11-06 21:52:33 -08:00 committed by PyTorch MergeBot
parent c4a323ed05
commit a4e7b8001c

View File

@ -435,7 +435,7 @@ class FakeTensorConverter:
with no_dispatch():
value = t.item()
if not math.isnan(value):
if not math.isnan(value) and not math.isinf(value):
# Peephole strip out unnecessary torch.as_tensor(x).item()
if isinstance(source, FloatTensorSource):
item_source = source.base