22 #include <cuda_runtime_api.h> 23 #include <cublas_v2.h> 39 data_(NULL), scale_(range / std::numeric_limits<I>::max()),
40 truncate_(truncate), num_rows_(0), num_cols_(0), stride_(0) {
44 KALDI_ERR <<
"You instantiated CuCompressedMatrix while GPU use " 45 "was not compiled in.";
55 CuDevice::Instantiate().Free(
data_);
75 data_ =
static_cast<I*
>(
82 dim3 dimGrid, dimBlock;
87 cuda_mat_compress_sign(dimGrid, dimBlock, mat.
Data(), mat.
Dim(),
90 cuda_mat_compress(dimGrid, dimBlock, mat.
Data(), mat.
Dim(),
94 CU_SAFE_CALL(cudaGetLastError());
96 CuDevice::Instantiate().AccuProfile(__func__, tim);
101 template <
typename I>
108 dim3 dimGrid, dimBlock;
110 &dimGrid, &dimBlock);
112 cuda_mat_uncompress(dimGrid, dimBlock, mat->
Data(), mat->
Dim(),
135 KALDI_ERR <<
"Unknown compressed-matrix type";
This code computes Goodness of Pronunciation (GOP) and extracts phone-level pronunciation feature for...
virtual void CopyToMat(CuMatrixBase< BaseFloat > *mat) const
Copies the contents of *this to 'mat', which should be correctly sized beforehand.
virtual MatrixIndexT NumRows() const
CuCompressedMatrix(BaseFloat range, bool truncate=true)
Constructor which sets 'scale_' according to scale_ = range / std::numeric_limits<I>::max().
virtual void CopyFromMat(const CuMatrixBase< BaseFloat > &mat)
Sets *this to an appropriately compressed copy of 'mat', which includes resizing *this.
Class CuCompressedMatrix, templated on an integer type (expected to be one of: int8, uint8, int16, uint16), this provides a way to approximate a CuMatrix in a more memory-efficient format.
virtual MatrixIndexT NumCols() const
const Real * Data() const
Return data pointer (const).
Matrix for CUDA computing.
MatrixIndexT NumCols() const
#define KALDI_ASSERT(cond)
MatrixIndexT NumRows() const
Dimensions.
Class CuCompressedMatrixBase is an abstract base class that allows you to compress a matrix of type C...
CuCompressedMatrixBase * NewCuCompressedMatrix(CuCompressedMatrixType t, BaseFloat range, bool truncat)
This function allocates a new CuCompressedMatrix with type determined by t, and with the 'range' and ...