#include <nnet-optimize-utils.h>
Classes | |
struct | MatrixPruneInfo |
Public Member Functions | |
DerivativeTimeLimiter (const Nnet &nnet, int32 min_deriv_time, int32 max_deriv_time, NnetComputation *computation) | |
void | LimitDerivTimes () |
Private Member Functions | |
void | ComputeMatrixPruneInfo () |
void | ComputeSubmatrixMaps () |
void | ModifyCommands () |
void | PruneMatrices () |
void | RemoveUnusedMemos () |
bool | CanLimitMatrix (const Analyzer &analyzer, int32 matrix_index) const |
void | LimitMatrices (const std::vector< bool > &will_limit) |
void | MapSimpleMatrixCommand (NnetComputation::Command *c) |
void | MapIndexesCommand (NnetComputation::Command *c) |
void | MapIndexesMultiCommand (NnetComputation::Command *c) |
void | MapAddRowRangesCommand (NnetComputation::Command *c) |
void | ModifyCommand (NnetComputation::Command *command) |
void | ResizeMatrices () |
void | GetPruneValues (int32 initial_submatrix, int32 new_submatrix, int32 *left_prune, int32 *right_prune) const |
bool | RowIsKept (int32 submatrix, int32 row_index) const |
Private Attributes | |
const Nnet & | nnet_ |
int32 | min_deriv_time_ |
int32 | max_deriv_time_ |
NnetComputation * | computation_ |
std::vector< int32 > | whole_submatrices_ |
std::vector< MatrixPruneInfo > | matrix_prune_info_ |
std::vector< int32 > | submatrix_map_ |
std::vector< int32 > | submatrix_map_if_deriv_ |
std::vector< MatrixPruneInfo > | prune_info_ |
std::unordered_set< int32 > | memos_to_delete_ |
Definition at line 226 of file nnet-optimize-utils.h.
DerivativeTimeLimiter | ( | const Nnet & | nnet, |
int32 | min_deriv_time, | ||
int32 | max_deriv_time, | ||
NnetComputation * | computation | ||
) |
Definition at line 1930 of file nnet-optimize-utils.cc.
Definition at line 2070 of file nnet-optimize-utils.cc.
References ComputationVariables::AppendVariablesForSubmatrix(), NnetComputation::Command::command_type, NnetComputation::commands, DerivativeTimeLimiter::computation_, KALDI_ASSERT, KALDI_VLOG, kaldi::nnet3::kSetConst, DerivativeTimeLimiter::submatrix_map_, Analyzer::variable_accesses, Analyzer::variables, and DerivativeTimeLimiter::whole_submatrices_.
Referenced by DerivativeTimeLimiter::PruneMatrices().
|
private |
Definition at line 1972 of file nnet-optimize-utils.cc.
References NnetComputation::MatrixDebugInfo::cindexes, DerivativeTimeLimiter::computation_, DerivativeTimeLimiter::MatrixPruneInfo::fully_inside_range, rnnlm::i, KALDI_ASSERT, NnetComputation::matrices, NnetComputation::matrix_debug_info, DerivativeTimeLimiter::matrix_prune_info_, DerivativeTimeLimiter::max_deriv_time_, DerivativeTimeLimiter::min_deriv_time_, DerivativeTimeLimiter::MatrixPruneInfo::partly_inside_range, DerivativeTimeLimiter::MatrixPruneInfo::row_begin, and DerivativeTimeLimiter::MatrixPruneInfo::row_end.
Referenced by DerivativeTimeLimiter::LimitDerivTimes().
|
private |
Definition at line 2013 of file nnet-optimize-utils.cc.
References DerivativeTimeLimiter::computation_, DerivativeTimeLimiter::MatrixPruneInfo::fully_inside_range, NnetComputation::matrix_debug_info, NnetComputation::SubMatrixInfo::matrix_index, DerivativeTimeLimiter::matrix_prune_info_, NnetComputation::NewSubMatrix(), NnetComputation::SubMatrixInfo::num_rows, DerivativeTimeLimiter::MatrixPruneInfo::partly_inside_range, DerivativeTimeLimiter::MatrixPruneInfo::row_begin, DerivativeTimeLimiter::MatrixPruneInfo::row_end, NnetComputation::SubMatrixInfo::row_offset, NnetComputation::submatrices, DerivativeTimeLimiter::submatrix_map_, and DerivativeTimeLimiter::submatrix_map_if_deriv_.
Referenced by DerivativeTimeLimiter::LimitDerivTimes().
|
inlineprivate |
Definition at line 1564 of file nnet-optimize-utils.cc.
References ModelUpdateConsolidator::computation_, KALDI_ASSERT, NnetComputation::SubMatrixInfo::matrix_index, NnetComputation::SubMatrixInfo::num_rows, NnetComputation::SubMatrixInfo::row_offset, and NnetComputation::submatrices.
void LimitDerivTimes | ( | ) |
Definition at line 1939 of file nnet-optimize-utils.cc.
References DerivativeTimeLimiter::computation_, DerivativeTimeLimiter::ComputeMatrixPruneInfo(), DerivativeTimeLimiter::ComputeSubmatrixMaps(), NnetComputation::GetWholeSubmatrices(), KALDI_ASSERT, DerivativeTimeLimiter::max_deriv_time_, DerivativeTimeLimiter::min_deriv_time_, DerivativeTimeLimiter::ModifyCommands(), DerivativeTimeLimiter::PruneMatrices(), kaldi::nnet3::RemoveNoOps(), DerivativeTimeLimiter::RemoveUnusedMemos(), kaldi::nnet3::RenumberComputation(), and DerivativeTimeLimiter::whole_submatrices_.
Referenced by kaldi::nnet3::LimitDerivativeTimes().
|
inlineprivate |
Definition at line 2116 of file nnet-optimize-utils.cc.
References NnetComputation::MatrixDebugInfo::cindexes, NnetComputation::SubMatrixInfo::col_offset, DerivativeTimeLimiter::computation_, NnetComputation::IsWholeMatrix(), KALDI_ASSERT, NnetComputation::matrices, NnetComputation::matrix_debug_info, NnetComputation::SubMatrixInfo::matrix_index, DerivativeTimeLimiter::matrix_prune_info_, NnetComputation::SubMatrixInfo::num_cols, NnetComputation::MatrixInfo::num_rows, NnetComputation::SubMatrixInfo::num_rows, DerivativeTimeLimiter::MatrixPruneInfo::partly_inside_range, DerivativeTimeLimiter::MatrixPruneInfo::row_begin, DerivativeTimeLimiter::MatrixPruneInfo::row_end, NnetComputation::SubMatrixInfo::row_offset, and NnetComputation::submatrices.
Referenced by DerivativeTimeLimiter::PruneMatrices().
|
private |
Definition at line 1860 of file nnet-optimize-utils.cc.
References NnetComputation::Command::arg1, NnetComputation::Command::arg2, NnetComputation::Command::arg3, NnetComputation::Command::command_type, ModelUpdateConsolidator::computation_, rnnlm::i, NnetComputation::indexes_ranges, KALDI_ASSERT, kaldi::nnet3::kNoOperation, and NnetComputation::submatrices.
|
private |
Definition at line 1735 of file nnet-optimize-utils.cc.
References NnetComputation::Command::arg1, NnetComputation::Command::arg2, NnetComputation::Command::arg3, NnetComputation::Command::command_type, ModelUpdateConsolidator::computation_, rnnlm::i, NnetComputation::indexes, KALDI_ASSERT, kaldi::nnet3::kNoOperation, and NnetComputation::submatrices.
|
private |
Definition at line 1798 of file nnet-optimize-utils.cc.
References NnetComputation::Command::arg1, NnetComputation::Command::arg2, NnetComputation::Command::command_type, ModelUpdateConsolidator::computation_, rnnlm::i, NnetComputation::indexes_multi, KALDI_ASSERT, kaldi::nnet3::kNoOperation, and NnetComputation::submatrices.
|
private |
Definition at line 1686 of file nnet-optimize-utils.cc.
References NnetComputation::Command::arg1, NnetComputation::Command::arg2, NnetComputation::Command::command_type, ModelUpdateConsolidator::computation_, kaldi::nnet3::kNoOperation, NnetComputation::NewSubMatrix(), and NnetComputation::submatrices.
|
private |
Definition at line 1604 of file nnet-optimize-utils.cc.
References NnetComputation::Command::arg1, NnetComputation::Command::arg3, NnetComputation::Command::arg4, NnetComputation::Command::arg5, NnetComputation::Command::arg6, NnetComputation::Command::arg7, NnetComputation::Command::command_type, Nnet::GetComponent(), kaldi::nnet3::kAcceptInput, kaldi::nnet3::kAddRowRanges, kaldi::nnet3::kAddRows, kaldi::nnet3::kAddRowsMulti, kaldi::nnet3::kAddToRowsMulti, KALDI_ASSERT, KALDI_ERR, kaldi::nnet3::kAllocMatrix, kaldi::nnet3::kBackprop, kaldi::nnet3::kBackpropNoModelUpdate, kaldi::nnet3::kCopyRows, kaldi::nnet3::kCopyRowsMulti, kaldi::nnet3::kCopyToRowsMulti, kaldi::nnet3::kDeallocMatrix, kaldi::nnet3::kMatrixAdd, kaldi::nnet3::kMatrixCopy, kaldi::nnet3::kNoOperation, kaldi::nnet3::kNoOperationMarker, kaldi::nnet3::kNoOperationPermanent, kaldi::nnet3::kPropagate, kaldi::nnet3::kProvideOutput, kaldi::nnet3::kSetConst, kaldi::nnet3::kSimpleComponent, kaldi::nnet3::kSwapMatrix, kaldi::nnet3::kUsesMemo, ModelUpdateConsolidator::nnet_, and Component::Properties().
Referenced by DerivativeTimeLimiter::ModifyCommands().
|
private |
Definition at line 2057 of file nnet-optimize-utils.cc.
References NnetComputation::commands, DerivativeTimeLimiter::computation_, and DerivativeTimeLimiter::ModifyCommand().
Referenced by DerivativeTimeLimiter::LimitDerivTimes().
|
private |
Definition at line 2179 of file nnet-optimize-utils.cc.
References DerivativeTimeLimiter::CanLimitMatrix(), DerivativeTimeLimiter::computation_, DerivativeTimeLimiter::MatrixPruneInfo::fully_inside_range, Analyzer::Init(), MatrixAccesses::is_input, MatrixAccesses::is_output, KALDI_ASSERT, DerivativeTimeLimiter::LimitMatrices(), NnetComputation::matrices, Analyzer::matrix_accesses, NnetComputation::matrix_debug_info, DerivativeTimeLimiter::matrix_prune_info_, kaldi::nnet3::MatrixIsUnused(), DerivativeTimeLimiter::nnet_, DerivativeTimeLimiter::MatrixPruneInfo::partly_inside_range, kaldi::nnet3::RemoveCommandsForUnusedMatrix(), and DerivativeTimeLimiter::whole_submatrices_.
Referenced by DerivativeTimeLimiter::LimitDerivTimes().
|
private |
Definition at line 1955 of file nnet-optimize-utils.cc.
References NnetComputation::Command::arg5, NnetComputation::Command::command_type, NnetComputation::commands, DerivativeTimeLimiter::computation_, KALDI_ASSERT, kaldi::nnet3::kPropagate, and DerivativeTimeLimiter::memos_to_delete_.
Referenced by DerivativeTimeLimiter::LimitDerivTimes().
|
private |
Definition at line 1580 of file nnet-optimize-utils.cc.
References NnetComputation::MatrixDebugInfo::cindexes, ModelUpdateConsolidator::computation_, NnetComputation::MatrixDebugInfo::is_deriv, KALDI_ASSERT, NnetComputation::matrix_debug_info, and NnetComputation::submatrices.
|
private |
Definition at line 342 of file nnet-optimize-utils.h.
Referenced by DerivativeTimeLimiter::CanLimitMatrix(), ComputationExpander::ComputeCommands(), ComputationExpander::ComputeDebugInfo(), ComputationExpander::ComputeMatrixInfo(), DerivativeTimeLimiter::ComputeMatrixPruneInfo(), ComputationExpander::ComputePrecomputedIndexes(), ComputationExpander::ComputeSubmatrixInfo(), DerivativeTimeLimiter::ComputeSubmatrixMaps(), ComputationExpander::Expand(), ComputationExpander::ExpandRowRangesCommand(), ComputationExpander::ExpandRowsCommand(), ComputationExpander::ExpandRowsMultiCommand(), ComputationExpander::GetNewMatrixLocationInfo(), ComputationExpander::GetNewSubmatLocationInfo(), ComputationExpander::InitStrideInfo(), DerivativeTimeLimiter::LimitDerivTimes(), DerivativeTimeLimiter::LimitMatrices(), DerivativeTimeLimiter::ModifyCommands(), MemoryCompressionOptimizer::ModifyComputation(), ComputationLoopedOptimizer::Optimize(), MemoryCompressionOptimizer::Optimize(), MemoryCompressionOptimizer::ProcessMatrix(), DerivativeTimeLimiter::PruneMatrices(), DerivativeTimeLimiter::RemoveUnusedMemos(), RowOpsSplitter::SplitCommand(), RowOpsSplitter::SplitCommands(), and RowOpsSplitter::SplitIndexes().
|
private |
Definition at line 348 of file nnet-optimize-utils.h.
Referenced by DerivativeTimeLimiter::ComputeMatrixPruneInfo(), DerivativeTimeLimiter::ComputeSubmatrixMaps(), DerivativeTimeLimiter::LimitMatrices(), and DerivativeTimeLimiter::PruneMatrices().
|
private |
Definition at line 338 of file nnet-optimize-utils.h.
Referenced by DerivativeTimeLimiter::ComputeMatrixPruneInfo(), and DerivativeTimeLimiter::LimitDerivTimes().
|
private |
Definition at line 367 of file nnet-optimize-utils.h.
Referenced by DerivativeTimeLimiter::RemoveUnusedMemos().
|
private |
Definition at line 337 of file nnet-optimize-utils.h.
Referenced by DerivativeTimeLimiter::ComputeMatrixPruneInfo(), and DerivativeTimeLimiter::LimitDerivTimes().
|
private |
Definition at line 335 of file nnet-optimize-utils.h.
Referenced by ComputationExpander::ComputePrecomputedIndexes(), ComputationExpander::ComputeSubmatrixInfo(), ComputationLoopedOptimizer::Optimize(), MemoryCompressionOptimizer::Optimize(), MemoryCompressionOptimizer::ProcessMatrix(), and DerivativeTimeLimiter::PruneMatrices().
|
private |
Definition at line 363 of file nnet-optimize-utils.h.
|
private |
Definition at line 354 of file nnet-optimize-utils.h.
Referenced by DerivativeTimeLimiter::CanLimitMatrix(), and DerivativeTimeLimiter::ComputeSubmatrixMaps().
|
private |
Definition at line 361 of file nnet-optimize-utils.h.
Referenced by DerivativeTimeLimiter::ComputeSubmatrixMaps().
|
private |
Definition at line 346 of file nnet-optimize-utils.h.
Referenced by DerivativeTimeLimiter::CanLimitMatrix(), DerivativeTimeLimiter::LimitDerivTimes(), and DerivativeTimeLimiter::PruneMatrices().