- Als neu kennzeichnen
- Lesezeichen
- Abonnieren
- Stummschalten
- RSS-Feed abonnieren
- Kennzeichnen
- Anstößigen Inhalt melden
Hello, I am using mkl_sparse_convert_csr to perform transpose function by calling with SPARSE_OPERATION_TRANSPOSE option.
However, the values of the result matrix is transposed correctly with the row & col left unchanged.
Here is the code.
#include <bits/stdc++.h>
#include <mkl.h>
#include <omp.h>
using namespace std;
namespace {
// Output MKL sparse matrix in CSR format.
void Print(const sparse_matrix_t &mat) {
sparse_index_base_t index_base;
MKL_INT rows, cols;
MKL_INT *rows_start, *rows_end, *col_idx;
float *values;
assert(mkl_sparse_s_export_csr(mat, &index_base, &rows, &cols, &rows_start,
&rows_end, &col_idx,
&values) == SPARSE_STATUS_SUCCESS);
cout << "IndexBase=" << (index_base == SPARSE_INDEX_BASE_ZERO ? 0 : 1)
<< endl;
cout << "Rows=" << rows << " Cols=" << cols << endl;
for (int i = 0; i < rows; ++i) {
cout << "RowsKey=" << i << ":";
for (int j = rows_start; j < rows_end; ++j) {
cout << "(" << col_idx
}
cout << endl;
}
}
} // namespace
int main() {
// Auto log flush.
cout.setf(std::ios::unitbuf);
mkl_set_num_threads(1);
const MKL_INT n = 4, m = 5;
// Create matrix a.
vector<float> values = {1, 2, 2, 1};
vector<MKL_INT> rows_start = {0, 0, 2, 3};
vector<MKL_INT> rows_end = {0, 2, 3, 4};
vector<MKL_INT> col_idx = {0, 2, 2, 3};
sparse_matrix_t mat_a;
assert(mkl_sparse_s_create_csr(&mat_a, SPARSE_INDEX_BASE_ZERO, n, m,
rows_start.data(), rows_end.data(),
col_idx.data(),
values.data()) == SPARSE_STATUS_SUCCESS);
cout << "Matrix A:" << endl;
Print(mat_a);
sparse_matrix_t mat_b;
assert(mkl_sparse_convert_csr(mat_a, SPARSE_OPERATION_TRANSPOSE, &mat_b) ==
SPARSE_STATUS_SUCCESS);
cout << "Matrix B:" << endl;
Print(mat_b);
mkl_sparse_destroy(mat_b);
mkl_sparse_destroy(mat_a);
return 0;
}
The result is here:
Matrix A:
IndexBase=0
Rows=4 Cols=5
RowsKey=0:
RowsKey=1:(0,1)(2,2)
RowsKey=2:(2,2)
RowsKey=3:(3,1)
Matrix B:
IndexBase=0
Rows=4 Cols=5
RowsKey=0:(1,1)
RowsKey=1:
RowsKey=2:(1,2)(2,2)
RowsKey=3:(3,1)
As you can see, the rows=4 & cols=5 in the matrix B.
Any idea what the problem is? Is there any useful information?
Thank you very much in advance.
Zixi
Link kopiert
- Als neu kennzeichnen
- Lesezeichen
- Abonnieren
- Stummschalten
- RSS-Feed abonnieren
- Kennzeichnen
- Anstößigen Inhalt melden
I wonder the behaviour of mkl_sparse_convert_csr.
Is the result meet expectation?
I don't see anything about it in the document.
- Als neu kennzeichnen
- Lesezeichen
- Abonnieren
- Stummschalten
- RSS-Feed abonnieren
- Kennzeichnen
- Anstößigen Inhalt melden
Is it a bug in mkl_sparse_convert_csr? Any progress?
- Als neu kennzeichnen
- Lesezeichen
- Abonnieren
- Stummschalten
- RSS-Feed abonnieren
- Kennzeichnen
- Anstößigen Inhalt melden
Yes, this is the bug with converter in the case of transpose and conjugate cases. The issue is escalated. We will update the status of this issue asap.
- Als neu kennzeichnen
- Lesezeichen
- Abonnieren
- Stummschalten
- RSS-Feed abonnieren
- Kennzeichnen
- Anstößigen Inhalt melden
Hello,
Thanks for your confirmation.
Now I use mkl_sparse_add to perform the transpose.
Thanks,
Zixi
- Als neu kennzeichnen
- Lesezeichen
- Abonnieren
- Stummschalten
- RSS-Feed abonnieren
- Kennzeichnen
- Anstößigen Inhalt melden
The fix of the issue available in MKL 2019 u5 which we released the last week. You may check this update and let us know how this update will work on your side.

- RSS-Feed abonnieren
- Thema als neu kennzeichnen
- Thema als gelesen kennzeichnen
- Diesen Thema für aktuellen Benutzer floaten
- Lesezeichen
- Abonnieren
- Drucker-Anzeigeseite