35 using namespace kaldi;
40 template<
typename Real>
48 < tol * std::max(1.0, (
double) (std::abs(A(
i,
j)) + std::abs(B(
i,
j)))));
51 template<
typename Real>
59 < tol * std::max(1.0, (
double) (std::abs(A(
i,
j)) + std::abs(B(
i,
j)))));
62 template<
typename Real>
70 < tol * std::max(1.0, (
double) (std::abs(A(
i,
j)) + std::abs(B(
i,
j)))));
78 template<
typename Real>
87 AssertEqual<Real>(A, B, 0.005);
90 AssertEqual<Real>(A, B, 0.005);
94 template<
typename Real>
106 AssertEqual<Real>(A, B);
107 AssertEqual<Real>(B, C);
111 template<
typename Real>
133 template<
typename Real>
138 dim += 32 * (
Rand() % 5);
154 AssertEqual<Real>(C, D);
162 if (
i % 5 == 0) { dimM = 0; }
165 std::ostringstream os;
166 bool binary = (
i % 4 < 2);
167 mat.
Write(os, binary);
170 std::istringstream is(os.str());
171 mat2.
Read(is, binary);
177 UnitTestCuTpMatrixIO<Real>();
178 UnitTestCuTpMatrixInvert<Real>();
179 UnitTestCuTpMatrixCopyFromTp<Real>();
180 UnitTestCuTpMatrixCholesky<Real>();
181 UnitTestCuTpMatrixCopyFromMat<Real>();
188 using namespace kaldi;
193 for (; loop < 2; loop++) {
194 CuDevice::Instantiate().SetDebugStrideMode(
true);
196 CuDevice::Instantiate().SelectGpuId(
"no");
198 CuDevice::Instantiate().SelectGpuId(
"yes");
200 kaldi::CudaTpMatrixUnitTest<float>();
202 if (CuDevice::Instantiate().DoublePrecisionSupported()) {
203 kaldi::CudaTpMatrixUnitTest<double>();
205 KALDI_WARN <<
"Double precision not supported";
208 kaldi::CudaTpMatrixUnitTest<double>();
212 KALDI_LOG <<
"Tests without GPU use succeeded.";
214 KALDI_LOG <<
"Tests with GPU use (if available) succeeded.";
217 CuDevice::Instantiate().PrintProfile();
void AddMat2(const Real alpha, const MatrixBase< Real > &M, MatrixTransposeType transM, const Real beta)
rank-N update: if (transM == kNoTrans) (*this) = beta*(*this) + alpha * M * M^T, or (if transM == kTr...
This code computes Goodness of Pronunciation (GOP) and extracts phone-level pronunciation feature for...
Packed symetric matrix class.
Real Trace() const
< Set to random values of a normal distribution
void CopyFromTp(const CuTpMatrix< Real > &other)
MatrixIndexT NumRows() const
void CudaTpMatrixUnitTest()
A class for storing matrices.
This class represents a matrix that's stored on the GPU if we have one, and in memory if not...
MatrixIndexT NumRows() const
void Cholesky(const CuSpMatrix< Real > &Orig)
void SetRandn()
< Set to unit matrix.
void SetRandn()
< Set to unit matrix.
void SetVerboseLevel(int32 i)
This should be rarely used, except by programs using Kaldi as library; command-line programs set the ...
void Cholesky(const SpMatrix< Real > &orig)
Packed matrix: base class for triangular and symmetric matrices.
void Read(std::istream &in, bool binary)
void SetRandn()
Sets to random values of a normal distribution.
static void UnitTestCuTpMatrixIO()
static void UnitTestCuTpMatrixCopyFromTp()
Packed symetric matrix class.
int Rand(struct RandomState *state)
static void UnitTestCuTpMatrixInvert()
static void UnitTestCuTpMatrixCopyFromMat()
#define KALDI_ASSERT(cond)
Matrix for CUDA computing.
static void AssertEqual(float a, float b, float relative_tolerance=0.001)
assert abs(a - b) <= relative_tolerance * (abs(a)+abs(b))
void CopyFromMat(const MatrixBase< Real > &M, MatrixTransposeType Trans=kNoTrans)
CopyFromMat copies the lower triangle of M into *this (or the upper triangle, if Trans == kTrans)...
void Write(std::ostream &out, bool binary) const
void CopyFromMat(const CuMatrixBase< Real > &M, MatrixTransposeType Trans=kNoTrans)
static void UnitTestCuTpMatrixCholesky()