29 using namespace kaldi;
    34 template<
typename Real>
    39   return Acopy.ApproxEqual(Bcopy, tol);
    49     std::vector<CuMatrix<Real> > data(num_blocks);
    50     for (
int32 b = 0; b < num_blocks; b++) {
    53       data[b].Resize(dimM, dimN);
    58     std::ostringstream os;
    59     bool binary = (
i % 4 < 2);
    63     std::istringstream is(os.str());
    79     std::vector<CuMatrix<Real> > data(num_blocks);
    80     for (
int32 b = 0; b < num_blocks; b++) {
    84       data[b].Resize(dimM, dimN);
    95     int32 X_num_rows = 100 + 
Rand() % 255, X_num_cols = B_num_cols,
    96         A_num_rows = X_num_rows, A_num_cols = B_num_rows;
    97     if (data.size() == 0) { X_num_rows = 0; A_num_rows = 0; }
   100     Real alpha = 2.0, beta = -1.0;
   107     Xcopy.AddMatMat(alpha, A, transA, Bcopy, transB, beta);
   119     std::vector<CuMatrix<Real> > data(num_blocks);
   120     for (
int32 b = 0; b < num_blocks; b++) {
   122       if (
i == 0) { dimM = 1; dimN = 1; }
   125       data[b].Resize(dimM, dimN);
   126       KALDI_LOG << 
"dimM " << dimM << 
", dimN " << dimN << 
", stride " << data[b].Stride();
   134     int32 C_num_rows = B_num_rows, C_num_cols = 100 + 
Rand() % 255;
   135     if (C_num_rows == 0) C_num_cols = 0;
   136     int32 D_num_rows = C_num_cols, D_num_cols = B_num_cols;
   143     CuMatrix<Real> C(C_num_rows, C_num_cols), D(D_num_rows, D_num_cols);
   149     Real alpha = 2.0, beta = -1.0;
   153     B.
AddMatMat(alpha, C, transC, D, transD, beta);
   155     Bmat.
AddMatMat(alpha, C, transC, D, transD, beta);
   162       KALDI_WARN << 
"CuBlockMatrixTest failure, please report to maintainers: Bcopy = "   163                  << Bcopy << 
", B = " << B << 
", C = " << C << 
", D = " << D
   164                  << 
", Bmat = " << B << 
" transD = " << transD << 
", transC = "   166       KALDI_ERR << 
"Please give this log to the maintainers.";
   174   UnitTestCuBlockMatrixIO<Real>();
   175   UnitTestCuBlockMatrixAddMatBlock<Real>();
   176   UnitTestCuBlockMatrixAddMatMat<Real>();
   187   for (; loop < 2; loop++) {
   188     CuDevice::Instantiate().SetDebugStrideMode(
true);
   190       CuDevice::Instantiate().SelectGpuId(
"no"); 
   192       CuDevice::Instantiate().SelectGpuId(
"yes"); 
   195     kaldi::CuBlockMatrixUnitTest<float>();
   197     if (CuDevice::Instantiate().DoublePrecisionSupported()) {
   198       kaldi::CuBlockMatrixUnitTest<double>();
   200       KALDI_WARN << 
"Double precision not supported";
   203     kaldi::CuBlockMatrixUnitTest<double>();
   207       KALDI_LOG << 
"Tests without GPU use succeeded.";
   209       KALDI_LOG << 
"Tests with GPU use (if available) succeeded.";
   212   CuDevice::Instantiate().PrintProfile();
 This code computes Goodness of Pronunciation (GOP) and extracts phone-level pronunciation feature for...
 
static void UnitTestCuBlockMatrixAddMatBlock()
 
void CuBlockMatrixUnitTest()
 
void CopyFromMat(const CuMatrix< Real > &M)
Copies elements within the block structure from matrix M, discarding others. 
 
void AddMatBlock(Real alpha, const CuMatrixBase< Real > &A, MatrixTransposeType transA, const CuBlockMatrix< Real > &B, MatrixTransposeType transB, Real beta)
This function is like AddMatMat but for where the second argument is of type CuBlockMatrix (a block-d...
 
void swap(basic_filebuf< CharT, Traits > &x, basic_filebuf< CharT, Traits > &y)
 
The class CuBlockMatrix holds a vector of objects of type CuMatrix, say, M_1, M_2, . 
 
This class represents a matrix that's stored on the GPU if we have one, and in memory if not...
 
MatrixIndexT NumRows() const
 
void SetVerboseLevel(int32 i)
This should be rarely used, except by programs using Kaldi as library; command-line programs set the ...
 
void AddMatMat(BaseFloat alpha, const CuMatrix< Real > &A, MatrixTransposeType transA, const CuMatrix< Real > &B, MatrixTransposeType transB, BaseFloat beta)
Does *this = alpha A B + beta * *this, discarding elements of the product outside the block structure...
 
void AddMatMat(Real alpha, const CuMatrixBase< Real > &A, MatrixTransposeType transA, const CuMatrixBase< Real > &B, MatrixTransposeType transB, Real beta)
C = alpha * A(^T)*B(^T) + beta * C. 
 
static void UnitTestCuBlockMatrixAddMatMat()
 
int Rand(struct RandomState *state)
 
static void UnitTestCuBlockMatrixIO()
 
#define KALDI_ASSERT(cond)
 
static void AssertEqual(float a, float b, float relative_tolerance=0.001)
assert abs(a - b) <= relative_tolerance * (abs(a)+abs(b)) 
 
void Read(std::istream &is, bool binary)
 
MatrixIndexT NumCols() const
 
static bool ApproxEqual(float a, float b, float relative_tolerance=0.001)
return abs(a - b) <= relative_tolerance * (abs(a)+abs(b)). 
 
void Write(std::ostream &os, bool binary) const