summaryrefslogtreecommitdiff
path: root/kaldi_io/src/cwrapper_kaldi.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'kaldi_io/src/cwrapper_kaldi.cpp')
-rw-r--r--kaldi_io/src/cwrapper_kaldi.cpp29
1 files changed, 17 insertions, 12 deletions
diff --git a/kaldi_io/src/cwrapper_kaldi.cpp b/kaldi_io/src/cwrapper_kaldi.cpp
index d16f316..83331ce 100644
--- a/kaldi_io/src/cwrapper_kaldi.cpp
+++ b/kaldi_io/src/cwrapper_kaldi.cpp
@@ -10,10 +10,11 @@ extern "C" {
#include "cwrapper_kaldi.h"
#include "string.h"
#include "assert.h"
-#include "nerv/common.h"
+#include "nerv/lib/common.h"
+#include "nerv/lib/matrix/mmatrix.h"
- extern Matrix *nerv_matrix_host_float_create(long nrow, long ncol, Status *status);
- extern Matrix *nerv_matrix_host_double_create(long nrow, long ncol, Status *status);
+ extern Matrix *nerv_matrix_host_float_create(long nrow, long ncol, MContext *context, Status *status);
+ extern Matrix *nerv_matrix_host_double_create(long nrow, long ncol, MContext *context, Status *status);
struct KaldiFeatureRepo {
kaldi::SequentialBaseFloatMatrixReader* feature_reader;
@@ -26,7 +27,8 @@ extern "C" {
return repo;
}
- Matrix *kaldi_feature_repo_read_utterance(KaldiFeatureRepo *repo, lua_State *L, int debug) {
+ Matrix *kaldi_feature_repo_read_utterance(KaldiFeatureRepo *repo, lua_State *L,
+ int debug, MContext *context) {
Matrix *mat; /* nerv implementation */
repo->utt = repo->feature_reader->Key();
@@ -37,9 +39,9 @@ extern "C" {
Status status;
assert(sizeof(BaseFloat) == sizeof(float));
if(sizeof(BaseFloat) == sizeof(float))
- mat = nerv_matrix_host_float_create(n, m, &status);
+ mat = nerv_matrix_host_float_create(n, m, context, &status);
else if(sizeof(BaseFloat) == sizeof(double))
- mat = nerv_matrix_host_double_create(n, m, &status);
+ mat = nerv_matrix_host_double_create(n, m, context, &status);
NERV_LUA_CHECK_STATUS(L, status);
size_t stride = mat->stride;
if (debug)
@@ -99,7 +101,10 @@ extern "C" {
return repo;
}
- Matrix *kaldi_lookup_feature_repo_read_utterance(KaldiLookupFeatureRepo *repo, KaldiFeatureRepo *frepo, int nframes, lua_State *L, int debug) {
+ Matrix *kaldi_lookup_feature_repo_read_utterance(KaldiLookupFeatureRepo *repo,
+ KaldiFeatureRepo *frepo,
+ int nframes, lua_State *L,
+ int debug, MContext *context) {
Matrix *mat; /* nerv implementation */
StringToString_t::iterator mit = repo->map.find(frepo->utt);
if (mit == repo->map.end())
@@ -115,9 +120,9 @@ extern "C" {
Status status;
assert(sizeof(BaseFloat) == sizeof(float));
if(sizeof(BaseFloat) == sizeof(float))
- mat = nerv_matrix_host_float_create(n, m, &status);
+ mat = nerv_matrix_host_float_create(n, m, context, &status);
else if(sizeof(BaseFloat) == sizeof(double))
- mat = nerv_matrix_host_double_create(n, m, &status);
+ mat = nerv_matrix_host_double_create(n, m, context, &status);
NERV_LUA_CHECK_STATUS(L, status);
size_t stride = mat->stride;
if (debug)
@@ -149,7 +154,7 @@ extern "C" {
Matrix *kaldi_label_repo_read_utterance(KaldiLabelRepo *repo, KaldiFeatureRepo *frepo, int nframes,
lua_State *L,
- int debug) {
+ int debug, MContext *context) {
Matrix *mat;
kaldi::Posterior targets = repo->targets_reader->Value(frepo->utt);
@@ -159,9 +164,9 @@ extern "C" {
Status status;
assert(sizeof(BaseFloat) == sizeof(float));
if(sizeof(BaseFloat) == sizeof(float))
- mat = nerv_matrix_host_float_create(n, m, &status);
+ mat = nerv_matrix_host_float_create(n, m, context, &status);
else if(sizeof(BaseFloat) == sizeof(double))
- mat = nerv_matrix_host_double_create(n, m, &status);
+ mat = nerv_matrix_host_double_create(n, m, context, &status);
NERV_LUA_CHECK_STATUS(L, status);
size_t stride = mat->stride;
if (debug)