OnlineCacheInput Class Reference

#include <online-feat-input.h>

Inheritance diagram for OnlineCacheInput:
Collaboration diagram for OnlineCacheInput:

Public Member Functions

 OnlineCacheInput (OnlineFeatInputItf *input)
 
virtual bool Compute (Matrix< BaseFloat > *output)
 
void GetCachedData (Matrix< BaseFloat > *output)
 
int32 Dim () const
 
void Deallocate ()
 
virtual ~OnlineCacheInput ()
 
- Public Member Functions inherited from OnlineFeatInputItf
virtual ~OnlineFeatInputItf ()
 

Private Attributes

OnlineFeatInputItfinput_
 
std::vector< Matrix< BaseFloat > *> data_
 

Detailed Description

Definition at line 130 of file online-feat-input.h.

Constructor & Destructor Documentation

◆ OnlineCacheInput()

OnlineCacheInput ( OnlineFeatInputItf input)
inline

Definition at line 132 of file online-feat-input.h.

References OnlineFeatInputItf::Compute().

132 : input_(input) { }
OnlineFeatInputItf * input_

◆ ~OnlineCacheInput()

virtual ~OnlineCacheInput ( )
inlinevirtual

Definition at line 145 of file online-feat-input.h.

Member Function Documentation

◆ Compute()

bool Compute ( Matrix< BaseFloat > *  output)
virtual

Implements OnlineFeatInputItf.

Definition at line 336 of file online-feat-input.cc.

References OnlineFeatInputItf::Compute(), data_, OnlineLdaInput::input_, and MatrixBase< Real >::NumRows().

Referenced by kaldi::GetOutput().

336  {
337  bool ans = input_->Compute(output);
338  if (output->NumRows() != 0)
339  data_.push_back(new Matrix<BaseFloat>(*output));
340  return ans;
341 }
std::vector< Matrix< BaseFloat > *> data_
OnlineFeatInputItf * input_
MatrixIndexT NumRows() const
Returns number of rows (or zero for empty matrix).
Definition: kaldi-matrix.h:64
virtual bool Compute(Matrix< BaseFloat > *output)=0

◆ Deallocate()

void Deallocate ( )

Definition at line 359 of file online-feat-input.cc.

References data_, and rnnlm::i.

359  {
360  for (size_t i = 0; i < data_.size(); i++) delete data_[i];
361  data_.clear();
362 }
std::vector< Matrix< BaseFloat > *> data_

◆ Dim()

int32 Dim ( ) const
inlinevirtual

Implements OnlineFeatInputItf.

Definition at line 141 of file online-feat-input.h.

141 { return input_->Dim(); }
virtual int32 Dim() const =0
OnlineFeatInputItf * input_

◆ GetCachedData()

void GetCachedData ( Matrix< BaseFloat > *  output)

Definition at line 343 of file online-feat-input.cc.

References data_, rnnlm::i, KALDI_ASSERT, MatrixBase< Real >::Range(), and Matrix< Real >::Resize().

Referenced by kaldi::GetOutput(), and kaldi::TestOnlineCmnInput().

343  {
344  int32 num_frames = 0, dim = 0;
345  for (size_t i = 0; i < data_.size(); i++) {
346  num_frames += data_[i]->NumRows();
347  dim = data_[i]->NumCols();
348  }
349  output->Resize(num_frames, dim);
350  int32 frame_offset = 0;
351  for (size_t i = 0; i < data_.size(); i++) {
352  int32 this_frames = data_[i]->NumRows();
353  output->Range(frame_offset, this_frames, 0, dim).CopyFromMat(*data_[i]);
354  frame_offset += this_frames;
355  }
356  KALDI_ASSERT(frame_offset == num_frames);
357 }
std::vector< Matrix< BaseFloat > *> data_
kaldi::int32 int32
#define KALDI_ASSERT(cond)
Definition: kaldi-error.h:185
SubMatrix< Real > Range(const MatrixIndexT row_offset, const MatrixIndexT num_rows, const MatrixIndexT col_offset, const MatrixIndexT num_cols) const
Return a sub-part of matrix.
Definition: kaldi-matrix.h:202
void Resize(const MatrixIndexT r, const MatrixIndexT c, MatrixResizeType resize_type=kSetZero, MatrixStrideType stride_type=kDefaultStride)
Sets matrix to a specified size (zero is OK as long as both r and c are zero).

Member Data Documentation

◆ data_

std::vector<Matrix<BaseFloat>* > data_
private

Definition at line 151 of file online-feat-input.h.

◆ input_

OnlineFeatInputItf* input_
private

Definition at line 148 of file online-feat-input.h.


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