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
FEAT: Add CSR <--> COO Conversion in all backends #1642
Conversation
build arrayfire windows ci |
@@ -307,7 +307,7 @@ af_err af_sparse_convert_to(af_array *out, const af_array in, | |||
|
|||
// Right now dest_storage can only be AF_STORAGE_DENSE |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This comment seems out of date. Please update
|
||
ovPtr[0] = 0; | ||
for(int x = 0; x < (int)ovalues.elements(); x++) { | ||
int row = std::get<0>(pairKeyVal[x]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a cleaner way to do the same thing:
tie(row, ovPtr[x], ocPtr[x]) = pairKeyVal[x];
@@ -339,18 +339,52 @@ Array<T> sparseConvertStorageToDense(const SparseArray<T> &in_) | |||
//////////////////////////////////////////////////////////////////////////////// | |||
// Common to MKL and Not MKL |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What does this comment mean?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are 2 code paths: One that uses MKL and one that is used when compiled without MKL support. This section is common to both as it does not depend on MKL.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess non-MKL would be more meaningful. I understand now.
Array<int> irowIdx = in_.getRowIdx(); | ||
Array<int> icolIdx = in_.getColIdx(); | ||
|
||
kernel::csr_coo<T>()(ovalues, orowIdx, ocolIdx, ivalues, irowIdx, icolIdx); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are making a copy in the function and then you are making a copy during the construction of csr_coo. This seems unnecessary.
@@ -145,6 +145,21 @@ struct nnz_func_def_t | |||
int *, int *); | |||
}; | |||
|
|||
//cusparseStatus_t cusparseZgthr(cusparseHandle_t handle, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
commented code.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is in line with other libraries/code we are using where we keep a commented version of the function declaration around as reference.
int *P = memAlloc<int>(nNZ); | ||
CUSPARSE_CHECK(cusparseCreateIdentityPermutation(getHandle(), nNZ, P)); | ||
|
||
CUSPARSE_CHECK(cusparseXcoosortByColumn( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Memory leak on error
converted.getRowIdx().get(), converted.getColIdx().get(), | ||
P, (void*)pBuffer)); | ||
|
||
CUSPARSE_CHECK(gthr_func<T>()( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
memory leak on error
char *pBuffer = memAlloc<char>(pBufferSizeInBytes); | ||
|
||
int *P = memAlloc<int>(nNZ); | ||
CUSPARSE_CHECK(cusparseCreateIdentityPermutation(getHandle(), nNZ, P)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Memory leak on error.
int *P = memAlloc<int>(nNZ); | ||
CUSPARSE_CHECK(cusparseCreateIdentityPermutation(getHandle(), nNZ, P)); | ||
|
||
CUSPARSE_CHECK(cusparseXcoosortByRow( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
memory leak on error
cooT.getRowIdx().get(), cooT.getColIdx().get(), | ||
P, (void*)pBuffer)); | ||
|
||
CUSPARSE_CHECK(gthr_func<T>()( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Memory leak on error
build arrayfire windows ci |
AF_STORAGE_COO
<-->AF_STORAGE_CSR
using thesparseConvertTo
function.COO
row/col indices from denseFixes CSR <-> COO in #821
[skip arrayfire ci]