convolution.cc File Reference
#include <iterator>
#include <sstream>
#include <iomanip>
#include "nnet3/convolution.h"
#include "nnet3/nnet-parse.h"
#include "nnet3/nnet-compile-utils.h"
Include dependency graph for convolution.cc:

Go to the source code of this file.

Namespaces

 kaldi
 This code computes Goodness of Pronunciation (GOP) and extracts phone-level pronunciation feature for mispronunciations detection tasks, the reference:
 
 kaldi::nnet3
 
 kaldi::nnet3::time_height_convolution
 

Functions

static void ReverseColumnMapping (const std::vector< int32 > &columns, int32 input_dim, std::vector< std::vector< int32 > > *backward_columns)
 This function, used in ConvolutionComputation::ComputeDerived(), reverses a mapping that may not be unique. More...
 
static bool VectorIsContiguous (const std::vector< int32 > &vec)
 
static void ConvolveForwardInternal (const ConvolutionComputation &cc, const CuMatrixBase< BaseFloat > &input, const CuMatrixBase< BaseFloat > &params, CuMatrixBase< BaseFloat > *temp_mat, CuMatrixBase< BaseFloat > *output)
 
void ConvolveForward (const ConvolutionComputation &conv_comp, const CuMatrixBase< BaseFloat > &input, const CuMatrixBase< BaseFloat > &params, CuMatrixBase< BaseFloat > *output)
 This does the forward computation of convolution. More...
 
static void ConvolveBackwardDataInternal (const ConvolutionComputation &cc, const CuMatrixBase< BaseFloat > &params, const CuMatrixBase< BaseFloat > &output_deriv, CuMatrixBase< BaseFloat > *temp_mat, CuMatrixBase< BaseFloat > *input_deriv)
 
void ConvolveBackwardData (const ConvolutionComputation &conv_comp, const CuMatrixBase< BaseFloat > &params, const CuMatrixBase< BaseFloat > &output_deriv, CuMatrixBase< BaseFloat > *input_deriv)
 This does the part of the backward derivative computation of convolution, that propagates derivatives back to the input data. More...
 
static void ConvolveBackwardParamsInternal (const ConvolutionComputation &cc, const CuMatrixBase< BaseFloat > &input, const CuMatrixBase< BaseFloat > &output_deriv, BaseFloat alpha, CuMatrixBase< BaseFloat > *temp_mat, CuMatrixBase< BaseFloat > *params_deriv)
 
void ConvolveBackwardParams (const ConvolutionComputation &conv_comp, const CuMatrixBase< BaseFloat > &input, const CuMatrixBase< BaseFloat > &output_deriv, BaseFloat alpha, CuMatrixBase< BaseFloat > *params_deriv)
 This does the part of the backward derivative computation of convolution, that computes derivatives w.r.t. More...
 
void PadModelHeight (const ConvolutionModel &model, ConvolutionModel *model_padded)
 This function takes a model that might require zero padding in the height dimension and outputs a model accepting a possibly-larger input dimension which does not require zero padding. More...
 
static void ComputeTempMatrixSize (const ConvolutionComputationOptions &opts, ConvolutionComputation *computation)
 This function sets 'temp_rows' and 'temp_cols' in 'computation'. More...
 
void UnPadModelHeight (const ConvolutionComputationOptions &opts, const ConvolutionModel &model, const ConvolutionModel &model_padded, ConvolutionComputation *computation)
 This function modifies, if necessary, a computation that has been built for the model 'model_padded', so that it can work for the original model 'model'. More...
 
void PadComputationInputTime (const ConvolutionModel &model, ConvolutionComputationIo *io)
 This function extends the set of input indexes that the computation has, to account for any required zero-padding in the time dimension. More...
 
static int32 RoundDownToMultipleOf (int32 i, int32 n)
 
static void ShiftAllTimeOffsets (int32 shift, ConvolutionModel *model)
 
static int32 PrepareIoForAppending (ConvolutionComputationIo *io, ConvolutionComputationIo *io_appended)
 
void AppendInputFrames (const ConvolutionModel &model, ConvolutionComputationIo *io, ConvolutionModel *model_appended, ConvolutionComputationIo *io_appended)
 This function takes an input model and I/O specification, and it modifies both of them if necessary to ensure that the output 'io_appended' object has the same input and output time strides (i.e. More...
 
static bool TimeValueInInput (const ConvolutionComputationIo &io, int32 t)
 
void CheckModelAndIo (const ConvolutionModel &model, const ConvolutionComputationIo &io, bool allow_extra_input=false)
 Check that this model and this I/O request are compatible in terms of required context, etc, and crash if not. More...
 
void CompileConvolutionComputation (const ConvolutionModel &model, const std::vector< Index > &input_indexes, const std::vector< Index > &output_indexes, const ConvolutionComputationOptions &opts, ConvolutionComputation *computation, std::vector< Index > *input_indexes_modified, std::vector< Index > *output_indexes_modified)
 This function does the compilation for a convolution computation; it's a wrapper for the functions below, which should not have to be called by the end user. More...
 
static int32 FindGcdOfDifferences (std::vector< int32 > &vec)
 
static void RegularizeTList (std::vector< int32 > &t_values, int32 *start, int32 *step, int32 *num_values)
 
static void CreateIndexes (const std::vector< std::pair< int32, int32 > > &n_x_pairs, int32 t_start, int32 t_step, int32 num_t_values, int32 reorder_t, std::vector< Index > *indexes)
 Creates a vector of indexes with a regular structure, according to these specifications. More...
 
static void SetSomeIndexesBlank (const std::vector< Index > &ref_indexes, std::vector< Index > *indexes)
 This function modifies 'indexes' by, for any Indexes which was not present in 'ref_indexes', setting the 't' value to kNoTime. More...
 
void GetComputationIo (const std::vector< Index > &input_indexes, const std::vector< Index > &output_indexes, ConvolutionComputationIo *io)
 This function takes lists of input and output indexes to a computation (e.g. More...
 
void GetIndexesForComputation (const ConvolutionComputationIo &io, const std::vector< Index > &orig_input_indexes, const std::vector< Index > &orig_output_indexes, std::vector< Index > *input_indexes, std::vector< Index > *output_indexes)
 This function computes the reordered and possibly padded indexes corresponding to the computation in 'io'. More...
 
void MakeComputation (const ConvolutionModel &model, ConvolutionComputationIo &io, const ConvolutionComputationOptions &opts, ConvolutionComputation *computation)