-
Notifications
You must be signed in to change notification settings - Fork 5.3k
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
CUDA sparse-matrix class #298
Comments
@naxingyu, do you have time for this? I know you've done a lot lately.. |
I'll do this next week (this week on phone-topology). |
OK thanks-- check in with us when you've done the phone-topology thing On Wed, Oct 28, 2015 at 10:28 PM, Xingyu Na notifications@github.com
|
I'll create a interface for CuRowSparseMatrix similar to CuSparseMatrix.
Besides those, should I implement these?
And according to your design, I will add AddMatSmat as a member function Xingyu On 10/29/2015 10:31 AM, Daniel Povey wrote:
|
sure.
only if you have time-- they might be useful for some diagnostics. but we
yes.
|
It seems I should create a RowSparseMatrix class too? To handle the X. On 11/04/2015 11:59 AM, Daniel Povey wrote:
|
Actually no, because the regular SparseMatrix class already stores its data On Thu, Nov 5, 2015 at 4:09 AM, Xingyu Na notifications@github.com wrote:
|
Something needs to be coded for sparse-matrix support that's going to be quite important for the new 'chain' (post-CTC) stuff I am working on, and maybe some nearer-term things too (relating to multi-tree systems- we should be able to get a nice improvement).
We need to be able to efficiently do matrix multiplication by a sparse matrix. The current CuSparseMatrix class does not have a data format that is conducive to this.
in cu-sparse-matrix.h, I'd like a new class added, that stores its data per-row.
The class CuRowSparseMatrix will have members:
int32 num_rows_;
int32 elements_per_row_;
CuArray < std::pair<int32, Real> > data_; // pairs (column-index, value).
//dim = num_rows_ * elements_per_row_.
where elements_per_row_ will be like a stride; it will be the maximum number of nonzero elements per row; you'll pad with (-1, 0.0) in case some rows have fewer than the maximum number of elements.
You can pass the pointer to the data across the "C" interface as void*. It's messy but it avoids having to create a "C" equivalent to the C++ pair.
The key function that I want written (aside from the one to create the CuRowSparseMatrix from a SparseMatrix is the following function:
// Do *this = alpha * a * b + beta * *this.
// Only supports the case where trans_b = kTrans; will crash if trans_b = kNoTrans.
void CuMatrixBase::AddMatSmat(Real alpha, CuMatrixBase &a, MatrixTransposeType trans_a,
CuRowSparseMatrix &b, MatrixTransposeType trans_b, Real beta);
The kernel will do the summation over the elements_per_row_ elements using a simple for loop. You can assume that elements_per_row_ is fairly small, otherwise we wouldn't be using this.
Obviously there needs to be test code for this.
The text was updated successfully, but these errors were encountered: