Skip to content

Conversation

@vishwakftw
Copy link
Contributor

@vishwakftw vishwakftw commented Jul 31, 2018

  1. Tests added
  2. Doc string added

1. Tests added
2. Doc string added

TODO:
3. Derivative for n <= 0
}
return identities;
} else if (n < 0) {
AT_CHECK(a.dim() == 2, "Negative powers for batch matrices are currently not supported")

This comment was marked as off-topic.


Tensor matrix_power(const Tensor& a, int64_t n) {
AT_CHECK(a.dim() >= 2 && at::isFloatingType(a.type().scalarType()),
"pinverse(", a.type(), "{", a.sizes(), "}): expected a tensor "

This comment was marked as off-topic.

This comment was marked as off-topic.


Tensor result, z;
int64_t r;
while (n > 0) {

This comment was marked as off-topic.

This comment was marked as off-topic.

return identities;
} else if (n < 0) {
AT_CHECK(a.dim() == 2, "Negative powers for batch matrices are currently not supported")
Tensor a_ = at::native::inverse(a);

This comment was marked as off-topic.

This comment was marked as off-topic.

This comment was marked as off-topic.

AT_CHECK(a.dim() >= 2 && at::isFloatingType(a.type().scalarType()),
"matrix_power(", a.type(), "{", a.sizes(), "}): expected a tensor "
"of floating types with dim at least 2");
if (n == 0) {

This comment was marked as off-topic.

This comment was marked as off-topic.

This comment was marked as off-topic.

This comment was marked as off-topic.

@vishwakftw
Copy link
Contributor Author

This is ready for review.

@vishwakftw vishwakftw changed the title Add matrix_power [ready] Add matrix_power Aug 4, 2018
@vishwakftw
Copy link
Contributor Author

@fmassa Could you review this please?

@yf225
Copy link
Contributor

yf225 commented Aug 14, 2018

@fmassa Ping :)

"matrix_power(", a.type(), "{", a.sizes(), "}): expected a tensor "
"of floating types with dim at least 2");
if (n == 0) {
return a.clone().copy_(at::eye(a.size(-2), a.options()).expand_as(a));

This comment was marked as off-topic.

This comment was marked as off-topic.

This comment was marked as off-topic.

This comment was marked as off-topic.

Copy link
Member

@fmassa fmassa left a comment

Choose a reason for hiding this comment

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

Apart from the issue in the n==0 case, everything else looks good to me

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.

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

@yf225
Copy link
Contributor

yf225 commented Aug 21, 2018

@pytorchbot retest this please

@yf225
Copy link
Contributor

yf225 commented Aug 21, 2018

@vishwakftw I just retriggered the CI to see if the ASAN test failure is consistent, if so we probably should look at how to fix it or skip it.

@vishwakftw
Copy link
Contributor Author

Build failure seems to be unrelated to the PR.

@vishwakftw
Copy link
Contributor Author

@yf225 is this good to go? Sorry about the reminder.

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.

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


# Single matrix, but full rank
# This is for negative powers
from test_autograd import random_fullrank_matrix_distinct_singular_value

This comment was marked as off-topic.

This comment was marked as off-topic.

@vishwakftw
Copy link
Contributor Author

@yf225 could you try importing now? I am sorry if you are busy with other tasks - thought I should send a reminder just in case.

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.

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

@vishwakftw
Copy link
Contributor Author

@yf225 is this good to go?

@yf225
Copy link
Contributor

yf225 commented Sep 4, 2018

@vishwakftw Apologies for the delay - there are some internal dependency errors that I am still trying to figure out how to fix. I will have an update here as soon as possible.

@vishwakftw
Copy link
Contributor Author

No worries @yf225 . Thank you for helping out.

@yf225
Copy link
Contributor

yf225 commented Sep 5, 2018

@vishwakftw Sorry for the delay on this - I think your original idea of putting from test_autograd import random_fullrank_matrix_distinct_singular_value in _test_matrix_power is actually the correct one, as it prevents other tests that depend on test_torch.py to also depend on test_autograd.py. Do you mind reverting the commit for this (dcf13e5) and I can push it through internally? Thanks a lot and sorry for the confusion on this one.

@vishwakftw
Copy link
Contributor Author

No problem @yf225. I will revert the previous commit right away. Thank you again for helping out with this.

This reverts commit dcf13e5.
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.

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

@vishwakftw
Copy link
Contributor Author

@yf225 did the internal tests pass?

@ssnl ssnl mentioned this pull request Sep 8, 2018
@vishwakftw
Copy link
Contributor Author

Closing in favour of #11421

@vishwakftw vishwakftw closed this Sep 8, 2018
facebook-github-bot pushed a commit that referenced this pull request Sep 8, 2018
Summary:
vishwakftw Your patch needed some updates because the default native function dispatches changed from `[function, method]` to `[function]`. The CI was run before that change happened so it still shows green, but the internal test caught it.

I did some changes when rebasing and updating so I didn't just force push to your branch. Let's see if this passes CI and internal test. If it does, let me know if you want me to force push to your branch or use this PR instead.

Note to reviewers: patch was already approved at #10068 .

cc yf225
Pull Request resolved: #11421

Differential Revision: D9733407

Pulled By: SsnL

fbshipit-source-id: cf2ed293bb9942dcc5158934ff4def2f63252599
@vishwakftw vishwakftw deleted the matrix-power branch September 10, 2018 05:02
PenghuiCheng pushed a commit to PenghuiCheng/pytorch that referenced this pull request Sep 11, 2018
Summary:
vishwakftw Your patch needed some updates because the default native function dispatches changed from `[function, method]` to `[function]`. The CI was run before that change happened so it still shows green, but the internal test caught it.

I did some changes when rebasing and updating so I didn't just force push to your branch. Let's see if this passes CI and internal test. If it does, let me know if you want me to force push to your branch or use this PR instead.

Note to reviewers: patch was already approved at pytorch#10068 .

cc yf225
Pull Request resolved: pytorch#11421

Differential Revision: D9733407

Pulled By: SsnL

fbshipit-source-id: cf2ed293bb9942dcc5158934ff4def2f63252599
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants