Skip to content
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

Added linalg.eigh, linalg.eigvalsh #45526

Closed
wants to merge 53 commits into from

Conversation

IvanYashchuk
Copy link
Collaborator

@IvanYashchuk IvanYashchuk commented Sep 29, 2020

This PR adds torch.linalg.eigh, and torch.linalg.eigvalsh for NumPy compatibility.
The current torch.symeig uses (on CPU) a different LAPACK routine than NumPy (syev vs syevd). Even though it shouldn't matter in practice, torch.linalg.eigh uses syevd (as NumPy does).

Ref #42666

@IvanYashchuk IvanYashchuk added module: numpy Related to numpy support, and also numpy compatibility of our operators module: linear algebra Issues related to specialized linear algebra operations in PyTorch; includes matrix multiply matmul labels Sep 29, 2020
@dr-ci
Copy link

dr-ci bot commented Sep 29, 2020

💊 CI failures summary and remediations

As of commit bd41343 (more details on the Dr. CI page):


💚 💚 Looks good so far! There are no failures yet. 💚 💚


This comment was automatically generated by Dr. CI (expand for details).Follow this link to opt-out of these comments for your Pull Requests.

Please report bugs/suggestions on the GitHub issue tracker or post in the (internal) Dr. CI Users group.

See how this bot performed.

This comment has been revised 110 times.

@IvanYashchuk IvanYashchuk marked this pull request as ready for review October 5, 2020 08:55
torch/linalg/__init__.py Outdated Show resolved Hide resolved
torch/linalg/__init__.py Outdated Show resolved Hide resolved
@VitalyFedyunin VitalyFedyunin added the triaged This issue has been looked at a team member, and triaged and prioritized into an appropriate module label Oct 5, 2020
Copy link
Collaborator

@nikitaved nikitaved left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me. My issues were addressed.

@mruberry
Copy link
Collaborator

@IvanYashchuk Is this ready for review?

torch/linalg/__init__.py Outdated Show resolved Hide resolved
torch/linalg/__init__.py Outdated Show resolved Hide resolved
torch/linalg/__init__.py Outdated Show resolved Hide resolved
torch/linalg/__init__.py Outdated Show resolved Hide resolved
Copy link
Collaborator

@mruberry mruberry left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @IvanYashchuk!

This looks really good. I made a lot of document suggestions but they should be easy to fix so we can merge this soon.

@IvanYashchuk
Copy link
Collaborator Author

@mruberry, thank you for the feedback! I've fixed documentation issues.

I've added a small change to the source code #45526 (comment)

Copy link
Collaborator

@mruberry mruberry left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool, looks great, @IvanYashchuk!

Copy link
Contributor

@facebook-github-bot facebook-github-bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mruberry has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

@mruberry
Copy link
Collaborator

Internal build errors are due to the user of toupper:

error: no member named 'toupper' in namespace 'std'; did you mean simply 'toupper'?
  char uplo_uppercase = std::toupper(uplo[0]);

I'm not entirely sure why this happens on some builds. Would you try importing its header and verifying we're calling it with unsigned chars following https://en.cppreference.com/w/cpp/string/byte/toupper?

the argument should first be converted to unsigned char
@IvanYashchuk
Copy link
Collaborator Author

Hey @mruberry, let's see if tests pass now.
I've modified the code to use static casts, now it should be safe as suggested. Also added missing #include <cctype>.

Copy link
Contributor

@facebook-github-bot facebook-github-bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mruberry has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

@IvanYashchuk
Copy link
Collaborator Author

Resolved the accumulated merge conflicts.
@mruberry, can we try importing this again?

Copy link
Contributor

@facebook-github-bot facebook-github-bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mruberry has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

@IvanYashchuk
Copy link
Collaborator Author

Autograd tests got broken with the last branch update. I'll fix that.

Copy link
Contributor

@facebook-github-bot facebook-github-bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mruberry has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

@facebook-github-bot
Copy link
Contributor

@mruberry merged this pull request in 4ed7f36.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla signed Merged module: linear algebra Issues related to specialized linear algebra operations in PyTorch; includes matrix multiply matmul module: numpy Related to numpy support, and also numpy compatibility of our operators open source triaged This issue has been looked at a team member, and triaged and prioritized into an appropriate module
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants