32 using namespace kaldi;
37 template<
typename Real>
39 return (
sizeof(Real) == 8 ?
"<double>" :
"<float>");
42 template<
typename Real>
49 for (;tim.
Elapsed() < time_in_secs; iter++) {
77 KALDI_LOG <<
"For CuSpMatrix::Invert" << NameOf<Real>() <<
", for dim = " 78 << dim <<
", speed was " << gflops <<
" gigaflops.";
83 template<
typename Real>
91 for (;tim.
Elapsed() < time_in_secs; iter++) {
96 KALDI_LOG <<
"For CuSpMatrix::CopyFromMat" << NameOf<Real>()
97 <<
", with copy-type " 100 "kTakeMeanAndCheck")) <<
" and dim = " 101 << dim <<
", speed was " << gflops <<
" gigaflops.";
108 std::vector<int32> sizes;
112 sizes.push_back(128);
113 sizes.push_back(256);
114 sizes.push_back(512);
115 sizes.push_back(1024);
116 int32 ns = sizes.size();
118 for (
int32 s = 0; s < ns; s++) {
119 UnitTestCuSpMatrixInvert<Real>(sizes[s]);
120 UnitTestCuSpMatrixCopyFromMat<Real>(sizes[s],
kTakeLower);
121 UnitTestCuSpMatrixCopyFromMat<Real>(sizes[s],
kTakeUpper);
122 UnitTestCuSpMatrixCopyFromMat<Real>(sizes[s],
kTakeMean);
134 CuDevice::Instantiate().SelectGpuId(
"yes");
137 kaldi::CuSpMatrixSpeedTest<float>();
139 if (CuDevice::Instantiate().DoublePrecisionSupported()) {
140 kaldi::CuSpMatrixSpeedTest<double>();
142 KALDI_WARN <<
"Double precision not supported";
145 kaldi::CuSpMatrixSpeedTest<double>();
148 CuDevice::Instantiate().PrintProfile();
This code computes Goodness of Pronunciation (GOP) and extracts phone-level pronunciation feature for...
Packed symetric matrix class.
void AddToDiag(Real r)
< Set the diagonal value to alpha
This class represents a matrix that's stored on the GPU if we have one, and in memory if not...
void Invert()
Note: the CuMatrix version of the Invert() function will only work for positive definite matrices; it...
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 CopyFromMat(const CuMatrixBase< Real > &orig, SpCopyType copy_type=kTakeLower)
void CopyToSp(SpMatrix< Real > *dst) const
#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))
static void UnitTestCuSpMatrixInvert(int32 dim)
static void UnitTestCuSpMatrixCopyFromMat(int32 dim, SpCopyType copy_type)
void CuSpMatrixSpeedTest()
double Elapsed() const
Returns time in seconds.
void AddMat2(const Real alpha, const CuMatrixBase< Real > &M, MatrixTransposeType transM, const Real beta)