Fix for GPU Diag issue #1679#1684
Closed
kmp5VT wants to merge 0 commit into
Closed
Conversation
Contributor
|
Your PR requires formatting changes to meet the project's style guidelines. Click here to view the suggested changes.diff --git a/NDTensors/test/test_diag.jl b/NDTensors/test/test_diag.jl
index ac54e023f..86640c254 100644
--- a/NDTensors/test/test_diag.jl
+++ b/NDTensors/test/test_diag.jl
@@ -123,10 +123,10 @@ end
## Test dot on GPU
@test dot(t, A) ≈ dot(dev(array(t)), array(A)) rtol = sqrt(eps(elt))
-
- NDTensors.outer!(A, t,t);
+
+ NDTensors.outer!(A, t, t)
for i in NDTensors.cpu(A)
- @test i == one(elt)
+ @test i == one(elt)
end
end
nothing |
mtfishman
reviewed
Nov 15, 2025
| end | ||
| t1 = T1.storage.data | ||
| t2 = T2.storage.data | ||
| array(R) .= t1 .* t2' |
Member
There was a problem hiding this comment.
It looks like there are a few issues with this proposal:
t2'will complex conjugate the elements, whileouter[!]isn't supposed to conjugate the elements. Maybetransposecould be used as an alternative.t1 * transpose(t2)whent1andt2are vectors will output a matrix whose length this the product of the lengths of the diagonals ofT1andT2, I don't understand how the shapes of this operation work out sinceRin general is a tensor whose length is the product of the total lengths ofT1andT2(not just the lengths of their diagonals). I think maybe you want to do something liket1 * transpose(t2)and reshape it into a vector (or relatedly, something likekron(t1, t2), which has an in-place counterpartkron!) and use that to write into the diagonal values ofR.
It looks like you'll need to investigate this more to make sure it really does the correct operation.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
This is a generic Fix for the outer product of two diag tensors (i.e. outer product of two vectors blas ger function.) This uses Julia a .* b' feature from julia and seems to work on CPU and GPU with no indexing problem.
I added a unit tests to check in the NDTensors/diag test