24 #ifndef KALDI_CUDAMATRIX_CU_SPARSE_MATRIX_H_ 25 #define KALDI_CUDAMATRIX_CU_SPARSE_MATRIX_H_ 42 template <
typename Real>
44 const CuSparseMatrix<Real> &B,
48 class CuSparseMatrix {
67 template<
typename OtherReal>
83 template<
typename OtherReal>
100 template<
typename OtherReal>
118 void Write(std::ostream &os,
bool binary)
const;
120 void Read(std::istream &is,
bool binary);
252 #endif // KALDI_CUDAMATRIX_CU_SPARSE_MATRIX_H_ CuSparseMatrix(const SparseMatrix< Real > &smat)
Constructor from CPU-based sparse matrix.
This code computes Goodness of Pronunciation (GOP) and extracts phone-level pronunciation feature for...
MatrixIndexT NumRows() const
const Real * CsrVal() const
Returns pointer to the data array of length nnz_ that holds all nonzero values in zero-based CSR form...
void CopyToMat(CuMatrixBase< OtherReal > *dest, MatrixTransposeType trans=kNoTrans) const
void Resize(const MatrixIndexT num_rows, const MatrixIndexT num_cols, const MatrixIndexT nnz, MatrixResizeType resize_type=kSetZero)
Users of this class won't normally have to use Resize.
void Swap(SparseMatrix< Real > *smat)
Swap with CPU-based matrix.
void CopyFromSmat(const SparseMatrix< OtherReal > &smat)
Copy from CPU-based matrix.
Real FrobeniusNorm() const
void SelectRows(const CuArray< int32 > &row_indexes, const CuSparseMatrix< Real > &smat_other)
Select a subset of the rows of a CuSparseMatrix.
void Read(std::istream &is, bool binary)
std::vector< SparseVector< Real > > cpu_rows_
const int * CsrColIdx() const
Returns pointer to the integer array of length nnz_ that contains the column indices of the correspon...
const SparseMatrix< Real > & Smat() const
void CopyElementsToVec(CuVectorBase< Real > *vec) const
Copy elements to CuVector.
SparseMatrix< Real > & Smat()
MatrixIndexT NumElements() const
int * csr_row_ptr_col_idx_
CuSparseMatrix< Real > & operator=(const SparseMatrix< Real > &smat)
Copy from CPU-based matrix.
CuSparseMatrix(const CuSparseMatrix< Real > &smat, MatrixTransposeType trans=kNoTrans)
Constructor from GPU-based sparse matrix (supports transposition).
void CopyToSmat(SparseMatrix< OtherReal > *smat) const
Copy to CPU-based matrix.
CuSparseMatrix()
Default constructor.
const int * CsrRowPtr() const
Returns pointer to the integer array of length NumRows()+1 that holds indices of the first nonzero el...
Matrix for CUDA computing.
Real TraceMatSmat(const MatrixBase< Real > &A, const SparseMatrix< Real > &B, MatrixTransposeType trans)
void Write(std::ostream &os, bool binary) const
MatrixIndexT NumCols() const
Vector for CUDA computing.
void SetRandn(BaseFloat zero_prob)
Sets up to a pseudo-randomly initialized matrix, with each element zero with probability zero_prob an...