34 using namespace kaldi;
45 template<
typename Real>
53 < tol * std::max(1.0, (
double) (std::abs(A(
i,
j)) + std::abs(B(
i,
j)))));
56 template<
typename Real>
64 < tol * std::max(1.0, (
double) (std::abs(A(
i,
j)) + std::abs(B(
i,
j)))));
67 template<
typename Real>
74 < tol * std::max(1.0, (
double) (std::abs(A(
i,
i)) + std::abs(B(
i,
i) + value))));
77 template<
typename Real>
84 < tol * std::max(1.0, (
double) (std::abs(A(
i,
i)) + std::abs(B(
i,
i) + value))));
88 template<
typename Real>
96 < tol * std::max(1.0, (
double) (std::abs(A(
i,
j)) + std::abs(B(
i,
j)))));
99 template<
typename Real>
104 diff.AddPacked(1.0, B);
105 Real a = std::max(A.
Max(), -A.
Min()), b = std::max(B.
Max(), -B.
Min()),
106 d = std::max(diff.Max(), -diff.Min());
107 return (
d <= tol * std::max(a, b));
113 template<
typename Real>
126 template<
typename Real>
147 template<
typename Real>
160 template<
typename Real>
169 Real scale_factor = 23.5896223;
170 A.
Scale(scale_factor);
171 B.
Scale(scale_factor);
176 template<
typename Real>
185 Real scale_factor = 23.5896223;
194 template<
typename Real>
203 Real value =
Rand() % 50;
210 template<
typename Real>
232 UnitTestCuPackedMatrixConstructor<Real>();
234 UnitTestCuPackedMatrixTrace<Real>();
235 UnitTestCuPackedMatrixScale<Real>();
236 UnitTestCuPackedMatrixAddToDiag<Real>();
237 UnitTestCuPackedMatrixSetUnit<Real>();
244 using namespace kaldi;
246 CuDevice::Instantiate().SetDebugStrideMode(
true);
248 CuDevice::Instantiate().SelectGpuId(
"yes");
250 kaldi::CudaPackedMatrixUnitTest<float>();
252 if (CuDevice::Instantiate().DoublePrecisionSupported()) {
253 kaldi::CudaPackedMatrixUnitTest<double>();
255 KALDI_WARN <<
"Double precision not supported";
258 kaldi::CudaPackedMatrixUnitTest<double>();
263 CuDevice::Instantiate().PrintProfile();
This code computes Goodness of Pronunciation (GOP) and extracts phone-level pronunciation feature for...
static void UnitTestCuPackedMatrixScale()
static void UnitTestCuPackedMatrixConstructor()
Real Trace() const
< Set to random values of a normal distribution
static void UnitTestCuPackedMatrixTrace()
MatrixIndexT NumRows() const
void CopyToPacked(PackedMatrix< Real > *dst) const
void AddToDiag(Real r)
< Set the diagonal value to alpha
void ScaleDiag(const Real alpha)
MatrixIndexT NumRows() const
static void AssertDiagEqual(const PackedMatrix< Real > &A, const CuPackedMatrix< Real > &B, float value, float tol=0.001)
void SetRandn()
< Set to unit matrix.
static void UnitTestCuPackedMatrixAddToDiag()
Packed matrix: base class for triangular and symmetric matrices.
void SetUnit()
< Set to zero
static void UnitTestCuPackedMatrixCopy()
int Rand(struct RandomState *state)
void ScaleDiag(Real alpha)
void CudaPackedMatrixUnitTest()
static void UnitTestCuPackedMatrixSetUnit()
#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))
static void UnitTestCuPackedMatrixScaleDiag()
static bool ApproxEqual(float a, float b, float relative_tolerance=0.001)
return abs(a - b) <= relative_tolerance * (abs(a)+abs(b)).
void CopyFromPacked(const CuPackedMatrix< Real > &src)