-
Notifications
You must be signed in to change notification settings - Fork 217
Replace deprecated libtorch APIs with torch::linalg equivalents #1528
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -49,7 +49,7 @@ public void TestLUSolve() | |
| Assert.Equal(new long[] { 2, 3, 3 }, A_LU.shape); | ||
| Assert.Equal(new long[] { 2, 3 }, pivots.shape); | ||
|
|
||
| var x = lu_solve(b, A_LU, pivots); | ||
| var x = linalg.lu_solve(A_LU, pivots, b); | ||
| Assert.Equal(new long[] { 2, 3, 1 }, x.shape); | ||
|
|
||
| var y = norm(bmm(A, x) - b); | ||
|
|
@@ -67,7 +67,7 @@ public void TestLUSolve() | |
| Assert.Equal(new long[] { 2, 3 }, pivots.shape); | ||
| Assert.Equal(new long[] { 2 }, infos.shape); | ||
|
|
||
| var x = lu_solve(b, A_LU, pivots); | ||
| var x = linalg.lu_solve(A_LU, pivots, b); | ||
| Assert.Equal(new long[] { 2, 3, 1 }, x.shape); | ||
|
|
||
| var y = norm(bmm(A, x) - b); | ||
|
|
@@ -305,6 +305,20 @@ public void CholeskyTest() | |
| Assert.True(a.allclose(l.matmul(l.swapaxes(-2, -1)))); // Worked this in to get it tested. Alias for 'transpose' | ||
| } | ||
|
|
||
| [Fact] | ||
| [TestOf(nameof(Tensor.cholesky))] | ||
| public void CholeskyUpperTest() | ||
| { | ||
| var a = randn(new long[] { 3, 2, 2 }, float64); | ||
| a = a.matmul(a.swapdims(-2, -1)); | ||
| #pragma warning disable CS0618 // Obsolete | ||
| var u = a.cholesky(upper: true); | ||
| #pragma warning restore CS0618 | ||
|
|
||
| // U should be upper-triangular: for real inputs U^T * U == A (more generally, U^H * U == A) | ||
| Assert.True(a.allclose(u.swapaxes(-2, -1).matmul(u))); | ||
| } | ||
|
Comment on lines
+318
to
+320
|
||
|
|
||
| [Fact] | ||
| [TestOf(nameof(linalg.cholesky_ex))] | ||
| public void CholeskyExTest() | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.