AccumulateMultiThreadedClass Class Reference
Inheritance diagram for AccumulateMultiThreadedClass:
Collaboration diagram for AccumulateMultiThreadedClass:

Public Member Functions

 AccumulateMultiThreadedClass (const DiagGmm &diag_gmm, const MatrixBase< BaseFloat > &data, const VectorBase< BaseFloat > &frame_weights, AccumDiagGmm *accum, double *tot_like)
 
 AccumulateMultiThreadedClass (const AccumulateMultiThreadedClass &other)
 
void operator() ()
 
 ~AccumulateMultiThreadedClass ()
 
- Public Member Functions inherited from MultiThreadable
virtual ~MultiThreadable ()
 

Private Attributes

const DiagGmmdiag_gmm_
 
const MatrixBase< BaseFloat > & data_
 
const VectorBase< BaseFloat > & frame_weights_
 
AccumDiagGmmdest_accum_
 
AccumDiagGmm accum_
 
double * tot_like_ptr_
 
double tot_like_
 

Additional Inherited Members

- Public Attributes inherited from MultiThreadable
int32 thread_id_
 
int32 num_threads_
 

Detailed Description

Definition at line 486 of file mle-diag-gmm.cc.

Constructor & Destructor Documentation

◆ AccumulateMultiThreadedClass() [1/2]

AccumulateMultiThreadedClass ( const DiagGmm diag_gmm,
const MatrixBase< BaseFloat > &  data,
const VectorBase< BaseFloat > &  frame_weights,
AccumDiagGmm accum,
double *  tot_like 
)
inline

Definition at line 488 of file mle-diag-gmm.cc.

492  :
493  diag_gmm_(diag_gmm), data_(data),
494  frame_weights_(frame_weights), dest_accum_(accum),
495  tot_like_ptr_(tot_like), tot_like_(0.0) { }
const MatrixBase< BaseFloat > & data_
const VectorBase< BaseFloat > & frame_weights_

◆ AccumulateMultiThreadedClass() [2/2]

Definition at line 496 of file mle-diag-gmm.cc.

References data_, and KALDI_ASSERT.

496  :
497  MultiThreadable(other),
498  diag_gmm_(other.diag_gmm_), data_(other.data_),
499  frame_weights_(other.frame_weights_), dest_accum_(other.dest_accum_),
500  accum_(diag_gmm_, dest_accum_->Flags()), tot_like_ptr_(other.tot_like_ptr_),
501  tot_like_(0.0) {
502  KALDI_ASSERT(data_.NumRows() == frame_weights_.Dim());
503  }
const MatrixBase< BaseFloat > & data_
GmmFlagsType Flags() const
Definition: mle-diag-gmm.h:182
#define KALDI_ASSERT(cond)
Definition: kaldi-error.h:185
const VectorBase< BaseFloat > & frame_weights_

◆ ~AccumulateMultiThreadedClass()

Definition at line 520 of file mle-diag-gmm.cc.

520  {
521  if (accum_.Dim() != 0) { // if our accumulator is set up (this is not true
522  // for the single object we use to initialize the others)
523  dest_accum_->Add(1.0, accum_);
525  }
526  }
void Add(double scale, const AccumDiagGmm &acc)
Increment with stats from this other accumulator (times scale)
int32 Dim() const
Returns the dimensionality of the feature vectors.
Definition: mle-diag-gmm.h:126

Member Function Documentation

◆ operator()()

void operator() ( )
inlinevirtual

Implements MultiThreadable.

Definition at line 504 of file mle-diag-gmm.cc.

References data_, and KALDI_VLOG.

504  {
505  int32 num_frames = data_.NumRows(), num_threads = num_threads_,
506  block_size = (num_frames + num_threads - 1) / num_threads,
507  block_start = block_size * thread_id_,
508  block_end = std::min(num_frames, block_start + block_size);
509  tot_like_ = 0.0;
510  double tot_weight = 0.0;
511  for (int32 t = block_start; t < block_end; t++) {
512  tot_like_ += frame_weights_(t) *
514  tot_weight += frame_weights_(t);
515  }
516  KALDI_VLOG(3) << "Thread " << thread_id_ << " saw average likeliood/frame "
517  << (tot_like_ / tot_weight) << " over " << tot_weight
518  << " (weighted) frames.";
519  }
kaldi::int32 int32
const MatrixBase< BaseFloat > & data_
BaseFloat AccumulateFromDiag(const DiagGmm &gmm, const VectorBase< BaseFloat > &data, BaseFloat frame_posterior)
Accumulate for all components given a diagonal-covariance GMM.
#define KALDI_VLOG(v)
Definition: kaldi-error.h:156
const VectorBase< BaseFloat > & frame_weights_

Member Data Documentation

◆ accum_

AccumDiagGmm accum_
private

Definition at line 532 of file mle-diag-gmm.cc.

◆ data_

const MatrixBase<BaseFloat>& data_
private

Definition at line 529 of file mle-diag-gmm.cc.

◆ dest_accum_

AccumDiagGmm* dest_accum_
private

Definition at line 531 of file mle-diag-gmm.cc.

◆ diag_gmm_

const DiagGmm& diag_gmm_
private

Definition at line 528 of file mle-diag-gmm.cc.

◆ frame_weights_

const VectorBase<BaseFloat>& frame_weights_
private

Definition at line 530 of file mle-diag-gmm.cc.

◆ tot_like_

double tot_like_
private

Definition at line 534 of file mle-diag-gmm.cc.

◆ tot_like_ptr_

double* tot_like_ptr_
private

Definition at line 533 of file mle-diag-gmm.cc.


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