You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi.
I am having an issue to correctly executing the multiplication of two sparse matrices and storing the result in a sparse format. Here is a simple code that I have been using to multiply for that reason. I tried different sparse formats for the three matrices, the only case that produces the correct result is when both dimensions are dense or when both matrices are CSR. In the later case, the results is still stored in a dense format. For all other cases, the program produce wrong results for SpMM. Is multiplication of two sparse matrices and storing it in a sparse format is still not supported yet ? or I am missing doing something wrong ? Thank you.
int main(int argc, char* argv[]) {
/* Sparse Matrix Multiplication */
Format dense ({Dense,Dense});
Format csr({Dense,Sparse});
Format coo({Sparse,Singleton});
Format csc ({Dense,Sparse},{1,0});
Yeah, there is an issue with sparse outputs at the moment.
There is some ongoing work to support workspaces, which will improve the memory handling of sparse outputs. Until then, sparse outputs sometimes generate invalid output. See issues #184, #297.
For now, your program seems to work correctly in all cases, as long as A is dense.
Hi.
I am having an issue to correctly executing the multiplication of two sparse matrices and storing the result in a sparse format. Here is a simple code that I have been using to multiply for that reason. I tried different sparse formats for the three matrices, the only case that produces the correct result is when both dimensions are dense or when both matrices are CSR. In the later case, the results is still stored in a dense format. For all other cases, the program produce wrong results for SpMM. Is multiplication of two sparse matrices and storing it in a sparse format is still not supported yet ? or I am missing doing something wrong ? Thank you.
int main(int argc, char* argv[]) {
/* Sparse Matrix Multiplication */
Format dense ({Dense,Dense});
Format csr({Dense,Sparse});
Format coo({Sparse,Singleton});
Format csc ({Dense,Sparse},{1,0});
int row = 5 ;
//dense version
//Tensor A("A", {row,row}, dense);
//Tensor B("B", {row,row}, dense);
//Tensor C("c", {row,row}, dense);
//csr version
Tensor A("A", {row,row}, csr);
Tensor B("B", {row,row}, csr);
Tensor C("c", {row,row}, csr);
//coo version
//Tensor A("A", {row,row}, coo);
//Tensor B("B", {row,row}, coo);
//Tensor C("c", {row,row}, coo);
//csc version
//Tensor A("A", {row,row}, csc);
//Tensor B("B", {row,row}, csc);
//Tensor C("c", {row,row}, csc);
B(0,0) = 1.0 ;
B(1,0) = 2.0 ;
B(2,0) = 3.0 ; B(2,1) = 4.0 ;
B(3,2) = 5.0 ;
C(0,0) = 1.0 ;
C(1,0) = 2.0 ;
C(2,0) = 3.0 ; C(2,1) = 4.0 ;
C(3,2) = 5.0 ;
B.pack();
C.pack();
IndexVar i, j, k;
//A(i,j) = B(i,k) * C(k,j); //version_1
IndexExpr mul = B(i,k) * C(k,j); //version 2
IndexStmt matmul = (A(i,j) = sum(k,mul));
A.compile();
A.assemble();
A.compute();
write("out1.tns", A);
}
The text was updated successfully, but these errors were encountered: