summaryrefslogtreecommitdiff
path: root/kaldi_seq
diff options
context:
space:
mode:
Diffstat (limited to 'kaldi_seq')
-rw-r--r--kaldi_seq/Makefile11
-rw-r--r--kaldi_seq/src/kaldi_mmi.cpp3
-rw-r--r--kaldi_seq/src/kaldi_mpe.cpp13
3 files changed, 15 insertions, 12 deletions
diff --git a/kaldi_seq/Makefile b/kaldi_seq/Makefile
index 7e2dd2e..1232c5a 100644
--- a/kaldi_seq/Makefile
+++ b/kaldi_seq/Makefile
@@ -23,18 +23,21 @@ build: $(OBJ_DIR) $(OBJ_SUBDIR) $(OBJS)
install: $(LUA_DIR) $(LUA_SUBDIR) $(LIBS)
include $(KDIR)/src/kaldi.mk
-KL := -L/home/slhome/ymz09/mylibs/ -L$(KDIR)/tools/openfst-1.3.4/lib/ $(KDIR)/src/feat/kaldi-feat.a $(KDIR)/src/matrix/kaldi-matrix.a $(KDIR)/src/base/kaldi-base.a $(KDIR)/src/util/kaldi-util.a $(KDIR)/src/hmm/kaldi-hmm.a $(KDIR)/src/tree/kaldi-tree.a $(KDIR)/src/nnet/kaldi-nnet.a $(KDIR)/src/cudamatrix/kaldi-cudamatrix.a $(KDIR)/src/lat/kaldi-lat.a $(KDIR)/src/hmm/kaldi-hmm.a $(KDIR)/src/tree/kaldi-tree.a $(KDIR)/src/matrix/kaldi-matrix.a $(KDIR)/src/util/kaldi-util.a $(KDIR)/src/base/kaldi-base.a -lcblas -llapack_atlas -lfst -lcudart -lcublas -DHAVE_CUDA
+
+KL1 := -rdynamic -Wl,-rpath=$(KDIR)/tools/openfst/lib -L/usr/local/cuda/lib64 -Wl,-rpath,/usr/local/cuda/lib64 -Wl,-rpath=$(KDIR)/src/lib -L. -L$(KDIR)/src/nnet/ -L$(KDIR)/src/cudamatrix/ -L$(KDIR)/src/lat/ -L$(KDIR)/src/hmm/ -L$(KDIR)/src/tree/ -L$(KDIR)/src/matrix/ -L$(KDIR)/src/util/ -L$(KDIR)/src/base/ $(KDIR)/src/nnet//libkaldi-nnet.so $(KDIR)/src/cudamatrix//libkaldi-cudamatrix.so $(KDIR)/src/lat//libkaldi-lat.so $(KDIR)/src/hmm//libkaldi-hmm.so $(KDIR)/src/tree//libkaldi-tree.so $(KDIR)/src/matrix//libkaldi-matrix.so $(KDIR)/src/util//libkaldi-util.so $(KDIR)/src/base//libkaldi-base.so -L$(KDIR)/tools/openfst/lib -lfst /usr/lib/liblapack.so /usr/lib/libcblas.so /usr/lib/libatlas.so /usr/lib/libf77blas.so -lm -lpthread -ldl -lcublas -lcudart -lkaldi-nnet -lkaldi-cudamatrix -lkaldi-lat -lkaldi-hmm -lkaldi-tree -lkaldi-matrix -lkaldi-util -lkaldi-base
+
+KL2 := -msse -msse2 -Wall -pthread -DKALDI_DOUBLEPRECISION=0 -DHAVE_POSIX_MEMALIGN -Wno-sign-compare -Wno-unused-local-typedefs -Winit-self -DHAVE_EXECINFO_H=1 -rdynamic -DHAVE_CXXABI_H -DHAVE_ATLAS -I$(KDIR)/tools/ATLAS/include -I$(KDIR)/tools/openfst/include -Wno-sign-compare -g -fPIC -I/usr/local/cuda/include -L/usr/local/cuda/lib64 -DKALDI_NO_EXPF
$(OBJ_DIR) $(LUA_DIR) $(OBJ_SUBDIR) $(LUA_SUBDIR):
-mkdir -p $@
$(LUA_DIR)/%.lua: %.lua
cp $< $@
$(LIBS): $(OBJ_DIR)/src/kaldi_mpe.o $(OBJ_DIR)/src/kaldi_mmi.o $(OBJ_DIR)/init.o $(OBJ_DIR)/src/init.o
- gcc -shared -fPIC -o $@ $(OBJ_DIR)/src/kaldi_mpe.o $(OBJ_DIR)/src/kaldi_mmi.o $(OBJ_DIR)/init.o $(OBJ_DIR)/src/init.o -lstdc++ -Wl,-rpath=$(LIB_PATH) -L$(LIB_PATH) -lnervcore -lluaT $(KL)
+ gcc -shared -fPIC -o $@ $(OBJ_DIR)/src/kaldi_mpe.o $(OBJ_DIR)/src/kaldi_mmi.o $(OBJ_DIR)/init.o $(OBJ_DIR)/src/init.o -lstdc++ -Wl,-rpath=$(LIB_PATH) -L$(LIB_PATH) -lnervcore -lluaT $(KL1)
$(OBJ_DIR)/src/kaldi_mpe.o: src/kaldi_mpe.cpp
- g++ -o $@ -c $< -DHAVE_ATLAS $(KALDIINCLUDE) -g -fPIC $(INCLUDE) -DKALDI_DOUBLEPRECISION=0 -msse2 -DHAVE_POSIX_MEMALIGN
+ g++ -o $@ -c $< $(KALDIINCLUDE) -g -fPIC $(INCLUDE) $(KL2)
$(OBJ_DIR)/src/kaldi_mmi.o: src/kaldi_mmi.cpp
- g++ -o $@ -c $< -DHAVE_ATLAS $(KALDIINCLUDE) -g -fPIC $(INCLUDE) -DKALDI_DOUBLEPRECISION=0 -msse2 -DHAVE_POSIX_MEMALIGN
+ g++ -o $@ -c $< $(KALDIINCLUDE) -g -fPIC $(INCLUDE) $(KL2)
$(OBJ_DIR)/%.o: %.c
gcc -o $@ -c $< -g $(INCLUDE) -fPIC
clean:
diff --git a/kaldi_seq/src/kaldi_mmi.cpp b/kaldi_seq/src/kaldi_mmi.cpp
index a64abd0..ea9b4f1 100644
--- a/kaldi_seq/src/kaldi_mmi.cpp
+++ b/kaldi_seq/src/kaldi_mmi.cpp
@@ -164,12 +164,11 @@ extern "C" {
// Select the GPU
#if HAVE_CUDA == 1
- CuDevice::Instantiate().SelectGpuId(use_gpu);
+ CuDevice::Instantiate().SelectGpuId(mmi->use_gpu);
#endif
// Read the class-frame-counts, compute priors
mmi->log_prior = new PdfPrior(prior_opts);
- PdfPrior &log_prior = *(mmi->log_prior);
// Read transition model
mmi->trans_model = new TransitionModel;
diff --git a/kaldi_seq/src/kaldi_mpe.cpp b/kaldi_seq/src/kaldi_mpe.cpp
index 8cdf010..60384e2 100644
--- a/kaldi_seq/src/kaldi_mpe.cpp
+++ b/kaldi_seq/src/kaldi_mpe.cpp
@@ -205,12 +205,11 @@ extern "C" {
// Select the GPU
#if HAVE_CUDA == 1
- CuDevice::Instantiate().SelectGpuId(use_gpu);
+ CuDevice::Instantiate().SelectGpuId(mpe->use_gpu);
#endif
// Read the class-frame-counts, compute priors
mpe->log_prior = new PdfPrior(prior_opts);
- PdfPrior &log_prior = *(mpe->log_prior);
// Read transition model
mpe->trans_model = new TransitionModel;
@@ -256,7 +255,7 @@ extern "C" {
return 0;
}
- assert(sizeof(BaseFloat) == sizeof(float));
+ //assert(sizeof(BaseFloat) == sizeof(float));
// 1) get the features, numerator alignment
mpe->ref_ali = mpe->ref_ali_reader->Value(utt);
long mat_nrow = mat->nrow, mat_ncol = mat->ncol;
@@ -309,8 +308,9 @@ extern "C" {
NervMatrix * calc_diff_mpe(KaldiMPE * mpe, NervMatrix * mat, const char * key)
{
std::string utt(key);
- assert(sizeof(BaseFloat) == sizeof(float));
+ //assert(sizeof(BaseFloat) == sizeof(float));
+ CuMatrix<BaseFloat> nnet_diff;
kaldi::Matrix<BaseFloat> nnet_out_h;
nnet_out_h.Resize(mat->nrow, mat->ncol, kUndefined);
@@ -327,9 +327,10 @@ extern "C" {
PdfPriorOptions &prior_opts = *(mpe->prior_opts);
if (prior_opts.class_frame_counts != "") {
CuMatrix<BaseFloat> nnet_out;
- nnet_out.Resize(mat->nrow, mat->ncol, kUndefined);
+ nnet_out.Resize(nnet_out_h.NumRows(), nnet_out_h.NumCols(), kUndefined);
nnet_out.CopyFromMat(nnet_out_h);
mpe->log_prior->SubtractOnLogpost(&nnet_out);
+ nnet_out_h.Resize(nnet_out.NumRows(), nnet_out.NumCols(), kUndefined);
nnet_out.CopyToMat(&nnet_out_h);
nnet_out.Resize(0,0);
}
@@ -353,7 +354,6 @@ extern "C" {
}
// 6) convert the Posterior to a matrix,
- CuMatrix<BaseFloat> nnet_diff;
PosteriorToMatrixMapped(post, *(mpe->trans_model), &nnet_diff);
nnet_diff.Scale(-1.0); // need to flip the sign of derivative,
@@ -366,6 +366,7 @@ extern "C" {
<< " frames,"
<< " diff-range(" << nnet_diff.Min() << "," << nnet_diff.Max() << ")";
+ nnet_out_h.Resize(nnet_diff.NumRows(), nnet_diff.NumCols(), kUndefined);
nnet_diff.CopyToMat(&nnet_out_h);
nnet_diff.Resize(0,0); // release GPU memory,