Skip to content

Commit

Permalink
[src] Add some asserts in RNNLM code (#2314)
Browse files Browse the repository at this point in the history
  • Loading branch information
hainan-xv authored and danpovey committed Mar 27, 2018
1 parent d7e8890 commit 785198e
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/rnnlm/rnnlm-compute-state.cc
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,14 @@ RnnlmComputeStateInfo::RnnlmComputeStateInfo(
KALDI_ERR << "Embedding file and nnet have different embedding sizes. ";
}

if (opts.bos_index <= 0 || opts.bos_index >= word_embedding_mat.NumRows()) {
KALDI_ERR < "--bos-symbol option isn't set correctly.";
}

if (opts.eos_index <= 0 || opts.eos_index >= word_embedding_mat.NumRows()) {
KALDI_ERR < "--eos-symbol option isn't set correctly.";
}

nnet3::ComputationRequest request1, request2, request3;
CreateLoopedComputationRequestSimple(rnnlm,
1, // num_frames
Expand Down Expand Up @@ -85,6 +93,7 @@ RnnlmComputeState* RnnlmComputeState::GetSuccessorState(int32 next_word) const {
}

void RnnlmComputeState::AddWord(int32 word_index) {
KALDI_ASSERT(word_index > 0 && word_index < info_.word_embedding_mat.NumRows());
previous_word_ = word_index;
AdvanceChunk();

Expand Down

0 comments on commit 785198e

Please sign in to comment.