[Fix] Check tensor dtype before using torch.allclose in _trace log (#128438)
#### Issue
`torch.allclose` errors out during logging due to different dtypes.
#### Test
* `pytest test/test_jit.py`
Pull Request resolved: https://github.com/pytorch/pytorch/pull/128438
Approved by: https://github.com/angelayi
diff --git a/torch/jit/_trace.py b/torch/jit/_trace.py
index 5bdd71f..7db8560 100644
--- a/torch/jit/_trace.py
+++ b/torch/jit/_trace.py
@@ -656,6 +656,8 @@
return False
if isinstance(orig, torch.Tensor):
+ if orig.dtype != loaded.dtype:
+ return False
if not torch.allclose(orig, loaded):
return False
else: