diff --git a/src/Native/LdaNative/lda_engine.cpp b/src/Native/LdaNative/lda_engine.cpp index e6e9838f86..005fe9f778 100644 --- a/src/Native/LdaNative/lda_engine.cpp +++ b/src/Native/LdaNative/lda_engine.cpp @@ -167,7 +167,7 @@ namespace lda { CTimer tmDebug(true); CheckFunction(0, tmDebug, "enter initializeBeforeTrain", false); //allocate model memory from the data preloaded - AllocateModelMemory(data_block_); + AllocateModelMemory(*data_block_); CheckFunction(0, tmDebug, "allocate model memory", false); double alloc_start = lda::get_time(); @@ -676,7 +676,7 @@ namespace lda { data_block_->Allocate(num_document, corpus_size); } - void LdaEngine::AllocateModelMemory(const LDADataBlock* data_block) + void LdaEngine::AllocateModelMemory(const LDADataBlock& data_block) { model_block_->InitFromDataBlock(data_block, V_, K_); diff --git a/src/Native/LdaNative/lda_engine.hpp b/src/Native/LdaNative/lda_engine.hpp index a87bcbed73..acda354941 100644 --- a/src/Native/LdaNative/lda_engine.hpp +++ b/src/Native/LdaNative/lda_engine.hpp @@ -52,7 +52,7 @@ namespace lda { void InitializeBeforeTest(); bool InitializeBeforeTrain(); void AllocateDataMemory(int num_document, int64_t corpus_size); - void AllocateModelMemory(const LDADataBlock* data_block); //in this case, model memory is allocated according to the datablock; + void AllocateModelMemory(const LDADataBlock& data_block); //in this case, model memory is allocated according to the datablock; void AllocateModelMemory(int num_vocabs, int num_topics, int64_t nonzero_num); void AllocateModelMemory(int num_vocabs, int num_topics, int64_t mem_block_size, int64_t alias_mem_block_size); void SetAlphaSum(float avgDocLength); //alphasum parameter is set by avgdoclength * alpha diff --git a/src/Native/LdaNative/model_block.cpp b/src/Native/LdaNative/model_block.cpp index 9a65317893..ce498a3860 100644 --- a/src/Native/LdaNative/model_block.cpp +++ b/src/Native/LdaNative/model_block.cpp @@ -353,12 +353,12 @@ namespace lda cout << "alias_mem_block_size = " << sizeof(alias_mem_block_size_) << endl; } - void LDAModelBlock::InitFromDataBlock(const LDADataBlock *data_block, int32_t num_vocabs, int32_t num_topics) + void LDAModelBlock::InitFromDataBlock(const LDADataBlock &data_block, int32_t num_vocabs, int32_t num_topics) { num_vocabs_ = num_vocabs; num_topics_ = num_topics; - int32_t doc_num = data_block->num_documents(); + int32_t doc_num = data_block.num_documents(); dict_ = new WordEntry[num_vocabs_]; for (int i = 0; i < num_vocabs_; ++i) { @@ -367,7 +367,7 @@ namespace lda for (int i = 0; i < doc_num; ++i) { - shared_ptr doc = data_block->GetOneDoc(i); + shared_ptr doc = data_block.GetOneDoc(i); int32_t doc_size = doc->size(); for (int j = 0; j < doc_size; ++j) { diff --git a/src/Native/LdaNative/model_block.h b/src/Native/LdaNative/model_block.h index 850c32e70f..a555a42199 100644 --- a/src/Native/LdaNative/model_block.h +++ b/src/Native/LdaNative/model_block.h @@ -45,7 +45,7 @@ namespace lda void Init(int32_t num_vocabs, int32_t num_topics, int64_t nonzero_num); void Init(int32_t num_vocabs, int32_t num_topics, int64_t mem_block_size, int64_t alias_mem_block_size); - void InitFromDataBlock(const LDADataBlock *data_block, int32_t num_vocabs, int32_t num_topics); + void InitFromDataBlock(const LDADataBlock &data_block, int32_t num_vocabs, int32_t num_topics); void GetModelStat(int64_t &mem_block_size, int64_t &alias_mem_block_size);