FasterDecoder::Token Class Reference

#include <faster-decoder.h>

Collaboration diagram for FasterDecoder::Token:

Public Member Functions

 Token (const Arc &arc, BaseFloat ac_cost, Token *prev)
 
 Token (const Arc &arc, Token *prev)
 
bool operator< (const Token &other)
 

Static Public Member Functions

static void TokenDelete (Token *tok)
 

Public Attributes

Arc arc_
 
Tokenprev_
 
int32 ref_count_
 
double cost_
 

Detailed Description

Definition at line 106 of file faster-decoder.h.

Constructor & Destructor Documentation

◆ Token() [1/2]

Token ( const Arc arc,
BaseFloat  ac_cost,
Token prev 
)
inline

Definition at line 116 of file faster-decoder.h.

References FasterDecoder::Token::cost_, and FasterDecoder::Token::ref_count_.

116  :
117  arc_(arc), prev_(prev), ref_count_(1) {
118  if (prev) {
119  prev->ref_count_++;
120  cost_ = prev->cost_ + arc.weight.Value() + ac_cost;
121  } else {
122  cost_ = arc.weight.Value() + ac_cost;
123  }
124  }

◆ Token() [2/2]

Token ( const Arc arc,
Token prev 
)
inline

Definition at line 125 of file faster-decoder.h.

References FasterDecoder::Token::cost_, and FasterDecoder::Token::ref_count_.

125  :
126  arc_(arc), prev_(prev), ref_count_(1) {
127  if (prev) {
128  prev->ref_count_++;
129  cost_ = prev->cost_ + arc.weight.Value();
130  } else {
131  cost_ = arc.weight.Value();
132  }
133  }

Member Function Documentation

◆ operator<()

bool operator< ( const Token other)
inline

Definition at line 134 of file faster-decoder.h.

References FasterDecoder::Token::cost_.

134  {
135  return cost_ > other.cost_;
136  }

◆ TokenDelete()

static void TokenDelete ( Token tok)
inlinestatic

Definition at line 138 of file faster-decoder.h.

References KALDI_ASSERT, FasterDecoder::Token::prev_, and FasterDecoder::Token::ref_count_.

Referenced by FasterDecoder::ClearToks(), FasterDecoder::ProcessEmitting(), and FasterDecoder::ProcessNonemitting().

138  {
139  while (--tok->ref_count_ == 0) {
140  Token *prev = tok->prev_;
141  delete tok;
142  if (prev == NULL) return;
143  else tok = prev;
144  }
145 #ifdef KALDI_PARANOID
146  KALDI_ASSERT(tok->ref_count_ > 0);
147 #endif
148  }
Token(const Arc &arc, BaseFloat ac_cost, Token *prev)
#define KALDI_ASSERT(cond)
Definition: kaldi-error.h:185

Member Data Documentation

◆ arc_

◆ cost_

◆ prev_

◆ ref_count_

int32 ref_count_

The documentation for this class was generated from the following file: