Skip to content

Replace torch.norm with torch.linalg.vector_norm for PyTorch future update #2660

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

namgyu-youn
Copy link
Contributor

Based on https://docs.pytorch.org/docs/stable/generated/torch.norm.html, torch.norm will be deprecated. Therefore, this update replaces torch.norm() with torch.linalg.vector_norm() for the foreseeable future.

Copy link

pytorch-bot bot commented Aug 1, 2025

🔗 Helpful Links

🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/ao/2660

Note: Links to docs will display an error until the docs builds have been completed.

This comment was automatically generated by Dr. CI and updates every 15 minutes.

@meta-cla meta-cla bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Aug 1, 2025
@jerryzh168
Copy link
Contributor

thanks, according to the linked doc, it looks like there is three functions:

Use torch.linalg.vector_norm() when computing vector norms and torch.linalg.matrix_norm() when computing matrix norms. For a function with a similar behavior as this one see torch.linalg.norm().

and the closest one is torch.linalg.norm() that probably works for both vector and matrix?

@namgyu-youn
Copy link
Contributor Author

thanks, according to the linked doc, it looks like there is three functions:

Use torch.linalg.vector_norm() when computing vector norms and torch.linalg.matrix_norm() when computing matrix norms. For a function with a similar behavior as this one see torch.linalg.norm().

and the closest one is torch.linalg.norm() that probably works for both vector and matrix?

@jerryzh168 In my last experience, torch.linalg.vector_norm() has better visibility because developers can directly check that it is a vector norm. How about using torch.linalg.vector_norm()?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants