29 : nnet_(nnet), pad_input_(pad_input),
30 is_first_chunk_(true), finished_(false) {
55 KALDI_ERR <<
"Feature dimension is " << dim <<
", but network expects " 63 int32 num_effective_input_rows = 0;
75 dim).CopyRowsFromVec(input.
Row(0));
77 0, dim).CopyFromMat(input);
82 num_effective_input_rows = input_data.
NumRows();
84 int32 extra_input_rows = 0;
101 0, dim).CopyFromMat(input);
103 num_effective_input_rows = input_data.
NumRows() + extra_input_rows;
105 if (num_effective_input_rows >=
110 *output =
data_.back();
124 int32 num_effective_input_rows = num_stored_frames + num_frames_padding;
135 input_data.
Resize(num_frames_padding, dim);
144 *output =
data_.back();
161 if (component.
Context().size() > 1) {
171 input_data.
NumRows(), 0, dim).CopyFromMat(
173 input_data = input_data_temp;
177 component.
Context().front(), dim);
194 int32 first_offset = last_offset - input_data.
NumRows() + 1;
200 chunk_size_assumed =
chunk_info_[c + 1].ChunkSize();
201 last_offset =
chunk_info_[c + 1].GetOffset(chunk_size_assumed - 1);
202 first_offset = last_offset - (input_data.
NumRows() -
204 component.
Context().front())) + 1;
209 component.
Propagate(input_chunk_info, output_chunk_info,
210 input_data, &output_data);
void CopyFromMat(const MatrixBase< OtherReal > &src, MatrixTransposeType trans=kNoTrans)
This code computes Goodness of Pronunciation (GOP) and extracts phone-level pronunciation feature for...
const Component & GetComponent(int32 c) const
int32 LeftContext() const
Returns the left-context summed over all the Components...
virtual int32 InputDim() const =0
Get size of input vectors.
std::vector< CuMatrix< BaseFloat > > data_
std::vector< CuMatrix< BaseFloat > > reusable_component_inputs_
const CuSubVector< Real > Row(MatrixIndexT i) const
std::vector< ChunkInfo > chunk_info_
Abstract class, basic element of the network, it is a box with defined inputs, outputs, and tranformation functions interface.
NnetOnlineComputer(const Nnet &nnet, bool pad_input)
CuSubMatrix< Real > Range(const MatrixIndexT row_offset, const MatrixIndexT num_rows, const MatrixIndexT col_offset, const MatrixIndexT num_cols) const
This class represents a matrix that's stored on the GPU if we have one, and in memory if not...
void CopyRowsFromVec(const CuVectorBase< Real > &v)
This function has two modes of operation.
void Flush(CuMatrix< BaseFloat > *output)
virtual std::vector< int32 > Context() const
Return a vector describing the temporal context this component requires for each frame of output...
CuVector< BaseFloat > last_seen_input_frame_
int32 NumComponents() const
Returns number of components– think of this as similar to # of layers, but e.g.
int32 RightContext() const
Returns the right-context summed over all the Components...
ChunkInfo is a class whose purpose is to describe the structure of matrices holding features...
CuMatrix< BaseFloat > unprocessed_buffer_
CuSubMatrix< Real > RowRange(const MatrixIndexT row_offset, const MatrixIndexT num_rows) const
Matrix for CUDA computing.
MatrixIndexT NumCols() const
virtual void Propagate(const ChunkInfo &in_info, const ChunkInfo &out_info, const CuMatrixBase< BaseFloat > &in, CuMatrixBase< BaseFloat > *out) const =0
Perform forward pass propagation Input->Output.
#define KALDI_ASSERT(cond)
void Compute(const CuMatrixBase< BaseFloat > &input, CuMatrix< BaseFloat > *output)
MatrixIndexT NumRows() const
Dimensions.
void ComputeChunkInfo(int32 input_chunk_size, int32 num_chunks, std::vector< ChunkInfo > *chunk_info_out) const
Uses the output of the Context() functions of the network, to compute a vector of size NumComponents(...
void Resize(MatrixIndexT rows, MatrixIndexT cols, MatrixResizeType resize_type=kSetZero, MatrixStrideType stride_type=kDefaultStride)
Allocate the memory.
int32 InputDim() const
Dimension of the input features, e.g.