[BE]: Remove unnecessary copy of gradients in util (#144329)

No need to copy gradients to CPU too

Pull Request resolved: https://github.com/pytorch/pytorch/pull/144329
Approved by: https://github.com/awgu, https://github.com/cyyever
This commit is contained in:
Aaron Gokaslan
2025-01-08 16:52:12 +00:00
committed by PyTorch MergeBot
parent e14c36d3f4
commit 373541fbf4

View File

@ -2492,7 +2492,7 @@ def same(
return True
score = torch.nn.functional.cosine_similarity(ref, res, dim=0, eps=1e-6)
if score < 0.99:
log.warning("Similarity score=%s", score.cpu().detach().item())
log.warning("Similarity score=%s", score.detach().cpu().item())
return score >= 0.99
else:
if not exact_dtype: