30 num_chunks_computed_(0),
31 current_log_post_subsampled_offset_(-1),
34 input_features_(input_features),
35 ivector_features_(ivector_features),
36 computer_(info_.opts.compute_config, info_.computation,
45 if (nnet_input_dim != feat_input_dim) {
46 KALDI_ERR <<
"Input feature dimension mismatch: got " << feat_input_dim
47 <<
" but network expects " << nnet_input_dim;
49 if (nnet_ivector_dim != feat_ivector_dim) {
50 KALDI_ERR <<
"Ivector feature dimension mismatch: got " << feat_ivector_dim
51 <<
" but network expects " << nnet_ivector_dim;
61 if (features_ready == 0)
74 int32 non_subsampled_output_frames_ready =
76 int32 num_chunks_ready = non_subsampled_output_frames_ready /
90 int32 subsampled_frame)
const {
94 if (features_ready == 0) {
108 num_subsampled_frames_ready = (features_ready + sf - 1) / sf;
109 return (subsampled_frame +
frame_offset_ == num_subsampled_frames_ready - 1);
121 int32 begin_input_frame, end_input_frame;
138 if (end_input_frame > num_feature_frames_ready && !is_finished) {
149 KALDI_ERR <<
"Attempt to access frame past the end of the available input";
157 for (
int32 i = begin_input_frame;
i < end_input_frame;
i++) {
160 if (input_frame < 0) input_frame = 0;
161 if (input_frame >= num_feature_frames_ready)
162 input_frame = num_feature_frames_ready - 1;
165 feats_chunk.
Swap(&this_feats);
186 int32 most_recent_input_frame = num_feature_frames_ready - 1,
189 if (num_ivector_frames_ready > 0) {
190 int32 ivector_frame_to_use = std::min<int32>(
191 most_recent_input_frame, num_ivector_frames_ready - 1);
204 cu_ivectors.
Swap(&ivectors);
234 (num_chunks_computed_ - 1) *
255 trans_model_.TransitionIdToPdfFast(index));
This code computes Goodness of Pronunciation (GOP) and extracts phone-level pronunciation feature for...
int32 InputDim(const std::string &input_name) const
ComputationRequest request1
int32 frame_subsampling_factor
MatrixIndexT NumCols() const
Returns number of columns (or zero for empty matrix).
virtual int32 NumFramesReady() const
The call NumFramesReady() will return the number of frames currently available for this decodable obj...
ComputationRequest request2
virtual void GetFrame(int32 frame, VectorBase< BaseFloat > *feat)=0
Gets the feature vector for this frame.
int32 frames_right_context
virtual BaseFloat LogLikelihood(int32 subsampled_frame, int32 index)
Returns the log likelihood, which will be negated in the decoder.
std::vector< IoSpecification > inputs
This class represents a matrix that's stored on the GPU if we have one, and in memory if not...
void EnsureFrameIsComputed(int32 subsampled_frame)
If the neural-network outputs for this frame are not cached, this function computes them (and possibl...
void Swap(Matrix< Real > *other)
Swaps the contents of *this and *other. Shallow swap.
virtual bool IsLastFrame(int32 subsampled_frame) const
Returns true if this is the last frame.
OnlineFeatureInterface * ivector_features_
This file contains some miscellaneous functions dealing with class Nnet.
const NnetSimpleLoopedComputationOptions & opts
void AcceptInput(const std::string &node_name, CuMatrix< BaseFloat > *input)
e.g.
Matrix< BaseFloat > current_log_post_
virtual BaseFloat LogLikelihood(int32 subsampled_frame, int32 transition_id)
Returns the log likelihood, which will be negated in the decoder.
DecodableNnetLoopedOnlineBase(const DecodableNnetSimpleLoopedInfo &info, OnlineFeatureInterface *input_features, OnlineFeatureInterface *ivector_features)
void AddVecToRows(Real alpha, const CuVectorBase< Real > &row, Real beta=1.0)
(for each row r of *this), r = alpha * row + beta * r
int32 frames_left_context
void Swap(Matrix< Real > *mat)
const DecodableNnetSimpleLoopedInfo & info_
virtual bool IsLastFrame(int32 frame) const =0
Returns true if this is the last frame.
int32 current_log_post_subsampled_offset_
A class representing a vector.
#define KALDI_ASSERT(cond)
MatrixIndexT NumRows() const
Returns number of rows (or zero for empty matrix).
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).
OnlineFeatureInterface is an interface for online feature processing (it is also usable in the offlin...
void GetOutputDestructive(const std::string &output_name, CuMatrix< BaseFloat > *output)
void CopyRowsFromVec(const VectorBase< Real > &v)
This function has two modes of operation.
int32 num_chunks_computed_
When you instantiate class DecodableNnetSimpleLooped, you should give it a const reference to this cl...
CuVector< BaseFloat > log_priors
virtual int32 NumFramesReady() const =0
returns the feature dimension.
Represents a non-allocating general vector which can be defined as a sub-vector of higher-level vecto...
OnlineFeatureInterface * input_features_
virtual int32 Dim() const =0
void SetFrameOffset(int32 frame_offset)
Sets the frame offset value.
void Run()
This does either the forward or backward computation, depending when it is called (in a typical compu...