First draft at adding support for conjugate.#63
Conversation
|
This PR is ready to merge. Currently the conjugate tests are only run on the reference backend and oneMKL. Once we add conjugate support to the other backends, we can enable the tests for them. Some tests are failing on cuSPARSE and rocSPARSE, but this PR doesn't touch any related code, so I think that is unrelated. It might be an issue with the machines the self-hosted runners are on. |
| if (__detail::is_conjugated(a) || __detail::is_conjugated(b) || | ||
| __detail::is_conjugated(c)) { | ||
| throw std::runtime_error( | ||
| "aoclsparse backend does not support conjugated views."); | ||
| } |
There was a problem hiding this comment.
ok, so here is a design question it seems like we should have the following checks:
not transposed + not conjugate == is_nontransposed
not transposed + conjugate == is_conjugated
transposed + not conjugate == is_transposed
transposed + conjugate == is_conjugate_transposed
MKL and AOCL and other libraries support nontranspose/transpose/conjugatetranspose but not conjugate. in the is_conjugated() function do we need to rule out is_transposed() so we can correctly capture conjugate_transpose ?
There was a problem hiding this comment.
nevermind, it just hasn't been implemented yet here. see mkl backend for actual implementation.
There was a problem hiding this comment.
User Data: input is CSR
csr_view<I,O,T>csrV(/* user data in csr */);
matrix_handle csrA(csrV);
sparse::spmv(transposed(csrA), x,y) // y = A^T * x
sparse::spmv(conjugated(transposed(csrA)), x,y) // y = A^H * x
sparse::spmm(csrA,W,Z) // Z = A*W
converts to in MKL backend
mkl::sparse::matrix_handle_t csrA;
mkl::sparse::set_csr_data(csrA, /* user data */)
mkl::sparse::gemv(csrA, transpose::trans, x,y)
mkl::sparse::gemv(csrA, transpose::conjtrans, x,y)
mkl::sparse::gemm(csrA, transpose::nontrans, W, Z)
There was a problem hiding this comment.
this is orthogonal to PR, but as this is a common use case, we will want to add a transposed_view object to the mix eventually.
spencerpatty
left a comment
There was a problem hiding this comment.
These changes look good to me.
Summary: MKL and reference impls now have full support for handling conjugate_views -- on the sparse matrix objects but not on vectors or dense matrices. Most libraries don't handle conjugate only, but the reference implementation does.
• Implemented conjugated support alongside scaled with a new conjugated_view and inspector logic to detect
conjugated inputs. Reference backend now conjugates values via std::conj, while vendor backends either
apply conjugate-transpose where supported (oneMKL CSC) or throw when conjugated views are passed. Added
complex-number SpMV tests for conjugated A and B.
Testing: