cu-matrix-test.cc File Reference
#include <iostream>
#include <vector>
#include <cstdlib>
#include "base/kaldi-common.h"
#include "util/common-utils.h"
#include "cudamatrix/cu-matrix-lib.h"
Include dependency graph for cu-matrix-test.cc:

Go to the source code of this file.

Namespaces

 kaldi
 This code computes Goodness of Pronunciation (GOP) and extracts phone-level pronunciation feature for mispronunciations detection tasks, the reference:
 

Functions

template<typename Real >
static void InitRand (VectorBase< Real > *v)
 
template<typename Real >
static void InitRand (MatrixBase< Real > *M)
 
template<typename Real >
static void RandZeroToOneMatrix (MatrixBase< Real > *mat)
 
template<typename Real >
static void UnitTestCuMatrixTraceMatMat ()
 
template<typename Real >
static void UnitTestCuCholesky ()
 
template<typename Real >
static void UnitTestCuMatrixApplyLog ()
 
template<typename Real >
static void UnitTestCuMatrixApplyExpSpecial ()
 
template<typename Real >
static void UnitTestCuMatrixApplyExp ()
 
template<typename Real >
static void UnitTestCuMatrixApplyExpLimited ()
 
template<typename Real >
static void UnitTestCuMatrixSigmoid ()
 
template<typename Real >
static void UnitTestCuMatrixScale ()
 
template<typename Real >
static void UnitTestCuMatrixAdd ()
 
template<typename Real >
static void UnitTestCuMatrixSoftHinge ()
 
template<typename Real >
static void UnitTestCuMatrixGroupPnorm ()
 
template<typename Real >
static void UnitTestCuMatrixGroupMax ()
 
template<typename Real >
static void UnitTestCuMatrixSet ()
 
template<typename Real >
static void UnitTestCuMatrixApplyPow ()
 
template<typename Real >
static void UnitTestCuMatrixApplyPowAbs ()
 
template<typename Real >
static void UnitTestCuMatrixCopyRowsFromVec ()
 
template<typename Real >
static void UnitTestCuMatrixCopyColsFromVec ()
 
template<typename Real >
static void UnitTestCuMatrixCopyRows ()
 
template<typename Real >
static void UnitTestCuMatrixCopyToRows ()
 
template<typename Real >
static void UnitTestCuMatrixAddRows ()
 
template<typename Real >
static void UnitTestCuMatrixMulRows ()
 
template<typename Real >
static void UnitTestCuMatrixAddToRows ()
 
template<typename Real >
void UnitTestCuMatrixCopyCross ()
 
template<typename Real >
void UnitTestCuMatrixCopyCross2 ()
 
template<typename Real >
static void UnitTestCuMatrixSumColumnRanges ()
 
template<typename Real >
static void UnitTestCuMatrixAddRowRanges ()
 
template<typename Real >
static void UnitTestCuMatrixCopyCols ()
 
template<typename Real >
static void UnitTextCuMatrixAddSmat ()
 
template<typename Real >
static void UnitTextCuMatrixAddMatSmat ()
 
template<typename Real >
static void UnitTextCuMatrixAddSmatMat ()
 
template<typename Real >
static void UnitTestCuMatrixAddCols ()
 
template<typename Real >
static void UnitTestCuMatrixApplyFloor ()
 
template<typename Real >
static void UnitTestCuMatrixApplyCeiling ()
 
template<typename Real >
static void UnitTestCuMatrixApplyHeaviside ()
 
template<typename Real >
static void UnitTestCuMatrixHeaviside ()
 
template<typename Real >
static void UnitTestCuMatrixMulElements ()
 
template<typename Real >
static void UnitTestCuMatrixDivElements ()
 
template<typename Real >
static void UnitTestCuMatrixMax ()
 
template<typename Real >
static void UnitTestCuMatrixMin ()
 
template<typename Real >
static void UnitTestCuMatrixMulColsVec ()
 
template<typename Real >
static void UnitTestCuMatrixMulRowsVec ()
 
template<typename Real >
static void UnitTestCuMatrixMulRowsGroupMat ()
 
template<typename Real >
static void UnitTestCuMatrixDiffGroupPnorm ()
 
template<typename Real >
static void UnitTestCuMatrixGroupMaxDeriv ()
 
template<typename Real >
static void UnitTestCuMatrixAddDiagVecMat ()
 
template<typename Real >
static void UnitTestCuMatrixAddMatDiagVec ()
 
template<typename Real >
static void UnitTestCuMatrixAddMatMatElements ()
 
template<typename Real >
static void UnitTestCuMatrixSetMatMatDivMat ()
 
template<typename Real >
static void UnitTestCuMatrixDivRowsVec ()
 
template<typename Real >
static void UnitTestCuMatrixAddMat ()
 
template<typename Real >
static void UnitTestCuMatrixAddMatBlocks1 ()
 
template<typename Real >
static void UnitTestCuMatrixAddMatBlocks1Trans ()
 
template<typename Real >
static void UnitTestCuMatrixAddMatBlocks2 ()
 
template<typename Real >
static void UnitTestCuMatrixReduceSum ()
 
template<typename Real >
static void UnitTestCuMatrixReduceMax ()
 
template<typename Real >
static void UnitTestCuMatrixReduceMin ()
 
template<typename Real >
static void UnitTestCuMatrixAddVecToCols ()
 
template<typename Real >
static void UnitTestCuMatrixAddVecToRows ()
 
template<typename Real >
static void UnitTestCuMatrixSymAddMat2 ()
 
template<typename Real >
static void UnitTestCuMatrixSymInvertPosDef ()
 
template<typename Real >
static void UnitTestCuMatrixAddMatMat ()
 
template<typename Real >
static void UnitTestCuMatrixAddVecVec ()
 
template<typename Real >
static void UnitTestCuMatrixAddMatMatBatched ()
 
template<typename Real >
static void UnitTestCuMatrixAddToDiag ()
 
template<typename Real >
static void UnitTestCuMatrixAdd2 ()
 
template<typename Real >
static void UnitTestCuMatrixCopyFromMat ()
 
template<typename Real >
static void UnitTestCuMatrixCopyFromTp ()
 
template<typename Real >
static void UnitTestCuMatrixAddMatTp ()
 
template<typename Real >
static void UnitTestCuMatrixTranspose ()
 
template<typename Real >
static void UnitTestCuMatrixAddTpMat ()
 
template<typename Real >
static void UnitTestCuVectorAddVec ()
 
template<typename Real >
static void UnitTestCuVectorAddRowSumMat ()
 
template<typename Real >
static void UnitTestCuVectorAddRowSumMatLarge ()
 
template<typename Real >
static void UnitTestCuVectorAddColSumMat ()
 
template<typename Real >
static void UnitTestCuSubMatrix ()
 
template<typename Real >
static void UnitTestCuVectorAddColSumMatLarge ()
 
template<typename Real >
static void UnitTestCuVectorInvertElements ()
 
template<typename Real >
static void UnitTestCuMatrixInvertElements ()
 
template<class Real >
static void UnitTestCuMatrixIO ()
 
template<typename Real >
static void UnitTestCuVectorAddTpVec ()
 
template<typename Real >
static void UnitTestCuApproxEqual ()
 
template<typename Real >
static void UnitTestCuVectorMulTp ()
 
template<typename Real , typename OtherReal >
static void UnitTestCuCopy ()
 
template<typename Real >
static void UnitTestCuSigmoid ()
 
template<typename Real >
static void UnitTestCuDiffSigmoid ()
 
template<typename Real >
static void UnitTestCuDiffSoftmax ()
 
template<typename Real >
static void UnitTestCuDiffLogSoftmax ()
 
template<typename Real >
static void UnitTestCuSoftmax ()
 
template<typename Real >
static void UnitTestCuLogSoftmax ()
 
template<typename Real >
static void UnitTestCuFindRowMaxId ()
 
template<typename Real >
static void UnitTestCuDiffXent ()
 
template<typename Real >
void UnitTestCheck ()
 
template<typename Real >
void UnitTestSwapCu2Cu ()
 
template<typename Real >
void UnitTestSwapCu2M ()
 
template<typename Real >
void UnitTestCuTanh ()
 
template<typename Real >
static void UnitTestCuDiffTanh ()
 
static int32 DoubleFactorial (int32 i)
 
template<typename Real >
static void UnitTestCuMatrixSetRandn ()
 
template<typename Real >
static void UnitTestCuMatrixSetRandUniform ()
 
template<typename Real >
static void UnitTestCuMatrixCopyLowerToUpper ()
 
template<typename Real >
static void UnitTestCuMatrixSetZeroAboveDiag ()
 
template<typename Real >
static void UnitTestCuMatrixCopyUpperToLower ()
 
template<typename Real >
static void UnitTestCuMatrixObjfDeriv ()
 
template<typename Real >
static void UnitTestCuMatrixAddElements ()
 
template<typename Real >
static void UnitTestCuMatrixAddToElements ()
 
template<typename Real >
static void UnitTestCuMatrixLookup ()
 
template<typename Real >
static void UnitTestCuMatrixEqualElementMask ()
 
template<typename Real >
void CudaMatrixUnitTest ()
 
int main ()
 

Function Documentation

◆ main()

int main ( )

Definition at line 3061 of file cu-matrix-test.cc.

References rnnlm::i, KALDI_LOG, KALDI_WARN, and kaldi::SetVerboseLevel().

3061  {
3062  SetVerboseLevel(1);
3063  int32 loop = 0;
3064  bool test_threads = true;
3065  // num_threads only matters if test_threads == true. Don't make it
3066  // to large, because it will affect CPU usage if you are using CPU.
3067  int32 num_threads = 4;
3068 
3069 
3070 #if HAVE_CUDA == 1
3071  for (loop = 0; loop < 2; loop++) {
3072  CuDevice::Instantiate().SetDebugStrideMode(true);
3073  if (test_threads)
3074  CuDevice::Instantiate().AllowMultithreading();
3075  if (loop == 0)
3076  CuDevice::Instantiate().SelectGpuId("no");
3077  else
3078  CuDevice::Instantiate().SelectGpuId("yes");
3079 #endif
3080 
3081  if (test_threads) {
3082  KALDI_LOG << "Doing matrix unit test with "
3083  << num_threads << " threads.";
3084  std::vector<std::thread*> threads;
3085  for (int32 i = 0; i < num_threads - 1; i++)
3086  threads.push_back(new std::thread(kaldi::CudaMatrixUnitTest<float>));
3087  // the last thread running is the main thread.
3088  kaldi::CudaMatrixUnitTest<float>();
3089  for (size_t i = 0; i < threads.size(); i++) {
3090  threads[i]->join();
3091  delete threads[i];
3092  }
3093  } else {
3094  kaldi::CudaMatrixUnitTest<float>();
3095  }
3096 
3097 #if HAVE_CUDA == 1
3098  if (CuDevice::Instantiate().DoublePrecisionSupported()) {
3099  kaldi::CudaMatrixUnitTest<double>();
3100  } else {
3101  KALDI_WARN << "Double precision not supported";
3102  }
3103 #else
3104  kaldi::CudaMatrixUnitTest<double>();
3105 #endif
3106 
3107  if (loop == 0)
3108  KALDI_LOG << "Tests without GPU use succeeded.";
3109  else
3110  KALDI_LOG << "Tests with GPU use (if available) succeeded.";
3111 #if HAVE_CUDA == 1
3112  } // No for loop if 'HAVE_CUDA != 1',
3113  CuDevice::Instantiate().PrintProfile();
3114 #endif
3115  return 0;
3116 }
kaldi::int32 int32
void SetVerboseLevel(int32 i)
This should be rarely used, except by programs using Kaldi as library; command-line programs set the ...
Definition: kaldi-error.h:64
#define KALDI_WARN
Definition: kaldi-error.h:150
#define KALDI_LOG
Definition: kaldi-error.h:153