Public Member Functions | |
ComputationLoopedOptimizer (const Nnet &nnet, NnetComputation *computation) | |
bool | Optimize () |
Static Private Member Functions | |
static int32 | FindTimeShift (const NnetComputation &computation) |
static void | CreateMatrixPairs (const NnetComputation &computation, std::vector< std::pair< int32, int32 > > *matrix_to_pair) |
static int32 | NormalizeCindexes (std::vector< Cindex > *cindexes) |
static void | GetPairToMatrixMap (std::vector< std::pair< int32, int32 > > &matrix_to_pair, unordered_map< std::pair< int32, int32 >, int32, PairHasher< int32 > > *pair_to_matrix) |
static void | ConvertListsToPairLists (const std::vector< std::vector< int32 > > &active_matrices, const std::vector< std::pair< int32, int32 > > &matrix_to_pair, std::vector< std::vector< std::pair< int32, int32 > > > *active_pairs) |
static bool | ListsAreEqualExceptForPossibleShift (const std::vector< std::pair< int32, int32 > > &a, const std::vector< std::pair< int32, int32 > > &b, int32 shift) |
static bool | FindFirstRepeat (const std::vector< std::vector< std::pair< int32, int32 > > > &active_pairs, int32 time_shift_per_segment, int32 *seg1, int32 *seg2) |
static void | GetIdentifiedMatrices (const std::vector< std::pair< int32, int32 > > &pair_list1, const std::vector< std::pair< int32, int32 > > &pair_list2, const unordered_map< std::pair< int32, int32 >, int32, PairHasher< int32 > > &pair_to_matrix, std::vector< int32 > *matrix_list1, std::vector< int32 > *matrix_list2) |
static void | CheckIdentifiedMatrices (const NnetComputation &computation, const std::vector< int32 > &list1, const std::vector< int32 > &list2, int32 time_difference) |
static void | FormInfiniteLoop (int32 command1, int32 command2, NnetComputation *computation) |
static void | AddMatrixSwapCommands (const std::vector< int32 > &matrices1, const std::vector< int32 > &matrices2, NnetComputation *computation) |
static void | GetMatrixSwapOrder (const std::vector< int32 > &matrices1, const std::vector< int32 > &matrices2, std::vector< std::pair< int32, int32 > > *swaps) |
static void | FindActiveMatrices (const NnetComputation &computation, const Analyzer &analyzer, const std::vector< int32 > &splice_point_commands, std::vector< std::vector< int32 > > *active_matrices) |
Given a list of command indexes ('splice_point_commands') which are expected to be command indexes of the kNoOperationMarker at segment boundaries, this function outputs for each of these command indexes a list of matrices which are 'active' at that point in time. More... | |
Private Attributes | |
const Nnet & | nnet_ |
NnetComputation * | computation_ |
Analyzer | analyzer_ |
std::vector< std::pair< int32, int32 > > | matrix_to_pair_ |
std::vector< int32 > | splice_point_commands_ |
Definition at line 3890 of file nnet-optimize-utils.cc.
|
inline |
Definition at line 3892 of file nnet-optimize-utils.cc.
References kaldi::nnet3::Optimize().
|
staticprivate |
Definition at line 4419 of file nnet-optimize-utils.cc.
References NnetComputation::Command::command_type, NnetComputation::commands, NnetComputation::GetWholeSubmatrices(), rnnlm::i, KALDI_ASSERT, kaldi::nnet3::kGotoLabel, and kaldi::nnet3::kSwapMatrix.
|
staticprivate |
Definition at line 4331 of file nnet-optimize-utils.cc.
References NnetComputation::MatrixDebugInfo::cindexes, rnnlm::i, NnetComputation::MatrixDebugInfo::is_deriv, KALDI_ASSERT, kaldi::nnet3::kNoTime, NnetComputation::matrices, NnetComputation::matrix_debug_info, NnetComputation::MatrixInfo::num_cols, NnetComputation::MatrixInfo::num_rows, and NnetComputation::MatrixInfo::stride_type.
|
staticprivate |
|
staticprivate |
Definition at line 4144 of file nnet-optimize-utils.cc.
References KALDI_ASSERT, NnetComputation::matrices, and NnetComputation::matrix_debug_info.
|
staticprivate |
Given a list of command indexes ('splice_point_commands') which are expected to be command indexes of the kNoOperationMarker at segment boundaries, this function outputs for each of these command indexes a list of matrices which are 'active' at that point in time.
By 'active' we mean that the matrix has been written to before that time (including zeroing), and will be read after that time. These is the list of matrices that 'need to be in scope' at those points in time. '*active_matrices' is indexed by the same index as 'splice_point_commands', and is then a list of active matrices, in numerical order of matrix index. Note: for each i, (*active_matrices)[i] will be sorted and unique.
Definition at line 4293 of file nnet-optimize-utils.cc.
References ComputationAnalysis::FirstNontrivialAccess(), NnetComputation::GetWholeSubmatrices(), rnnlm::i, kaldi::IsSortedAndUniq(), KALDI_ASSERT, ComputationAnalysis::LastAccess(), and NnetComputation::matrices.
|
staticprivate |
Definition at line 4232 of file nnet-optimize-utils.cc.
References KALDI_ASSERT.
|
staticprivate |
Definition at line 4070 of file nnet-optimize-utils.cc.
References NnetComputation::Command::arg1, NnetComputation::Command::arg2, NnetComputation::commands, kaldi::nnet3::GetCommandsOfType(), NnetComputation::IsWholeMatrix(), KALDI_ASSERT, KALDI_ERR, kaldi::nnet3::kNoOperationMarker, kaldi::nnet3::kProvideOutput, NnetComputation::matrices, NnetComputation::matrix_debug_info, and NnetComputation::submatrices.
|
staticprivate |
Definition at line 4453 of file nnet-optimize-utils.cc.
References NnetComputation::commands, KALDI_ASSERT, kaldi::nnet3::kGotoLabel, kaldi::nnet3::kNoOperationLabel, and kaldi::nnet3::kNoOperationPermanent.
|
staticprivate |
|
staticprivate |
|
staticprivate |
Definition at line 4177 of file nnet-optimize-utils.cc.
|
staticprivate |
Definition at line 4121 of file nnet-optimize-utils.cc.
References KALDI_ERR, and kaldi::nnet3::kNoTime.
bool Optimize | ( | ) |
Definition at line 4473 of file nnet-optimize-utils.cc.
References DerivativeTimeLimiter::computation_, kaldi::nnet3::FixGotoLabel(), kaldi::nnet3::GetCommandsOfType(), KALDI_ASSERT, KALDI_VLOG, kaldi::nnet3::kNoOperationPermanent, NnetComputation::matrix_debug_info, DerivativeTimeLimiter::nnet_, and kaldi::nnet3::RenumberComputation().
Referenced by kaldi::nnet3::OptimizeLoopedComputation().
|
private |
Definition at line 4063 of file nnet-optimize-utils.cc.
|
private |
Definition at line 4062 of file nnet-optimize-utils.cc.
Definition at line 4064 of file nnet-optimize-utils.cc.
|
private |
Definition at line 4061 of file nnet-optimize-utils.cc.
|
private |
Definition at line 4066 of file nnet-optimize-utils.cc.