[fx] fix qualified name for methods of torch.Tensor (#162407)

This fixes an error in the previous PR.

Pull Request resolved: https://github.com/pytorch/pytorch/pull/162407
Approved by: https://github.com/ezyang, https://github.com/XuehaiPan
This commit is contained in:
Isuru Fernando
2025-09-08 19:14:38 +00:00
committed by PyTorch MergeBot
parent 8494afb837
commit 4590438329
2 changed files with 2 additions and 2 deletions

View File

@ -2998,7 +2998,7 @@ class CommonTemplate:
x = torch.rand(10)
with x.device:
out = torch.compile(fn)(x)
out = torch.compile(fn, backend=lambda gm, _: gm)(x)
ref = fn(x)
for a, b in zip(out, ref):
self.assertTrue(torch.allclose(a, b))

View File

@ -155,7 +155,7 @@ def _get_qualified_name(func: Callable[..., Any]) -> str:
isinstance(func, (types.MethodDescriptorType, types.WrapperDescriptorType))
and func is getattr(torch.Tensor, func.__name__, None)
) or (
func.__module__ == torch._tensor
func.__module__ == torch._tensor.__name__
and func.__qualname__ == f"Tensor.{func.__name__}"
):
return f"torch.Tensor.{func.__name__}"