#include <nnet-computation.h>
Classes | |
struct | Command |
struct | MatrixDebugInfo |
struct | MatrixInfo |
struct | PrecomputedIndexesInfo |
struct | SubMatrixInfo |
Public Member Functions | |
int32 | NewMatrix (int32 num_rows, int32 num_cols, MatrixStrideType stride_type) |
Convenience function used when adding new matrices. More... | |
int32 | NewSubMatrix (int32 base_submatrix, int32 row_offset, int32 num_rows, int32 col_offset, int32 num_cols) |
Convenience function used when adding new sub-matrices. More... | |
bool | IsWholeMatrix (int32 submatrix_index) const |
void | ComputeCudaIndexes () |
void | Print (std::ostream &os, const Nnet &nnet) const |
void | Read (std::istream &istream, bool binary) |
void | Write (std::ostream &ostream, bool binary) const |
void | GetSubmatrixStrings (const Nnet &nnet, std::vector< std::string > *submat_strings) const |
void | GetWholeSubmatrices (std::vector< int32 > *whole_submatrices) const |
void | GetCommandStrings (const Nnet &nnet, std::string *preamble, std::vector< std::string > *command_strings) const |
~NnetComputation () | |
void | Clear () |
NnetComputation (const NnetComputation &other) | |
NnetComputation & | operator= (const NnetComputation &other) |
NnetComputation () | |
Public Attributes | |
std::vector< MatrixInfo > | matrices |
std::vector< MatrixDebugInfo > | matrix_debug_info |
std::vector< SubMatrixInfo > | submatrices |
std::vector< PrecomputedIndexesInfo > | component_precomputed_indexes |
std::vector< std::vector< int32 > > | indexes |
std::vector< std::vector< std::pair< int32, int32 > > > | indexes_multi |
std::vector< std::vector< std::pair< int32, int32 > > > | indexes_ranges |
std::vector< Command > | commands |
bool | need_model_derivative |
std::vector< CuArray< int32 > > | indexes_cuda |
std::vector< CuArray< Int32Pair > > | indexes_ranges_cuda |
Definition at line 303 of file nnet-computation.h.
~NnetComputation | ( | ) |
Definition at line 78 of file nnet-computation.cc.
References rnnlm::i.
NnetComputation | ( | const NnetComputation & | other | ) |
Definition at line 1134 of file nnet-computation.cc.
References NnetComputation::component_precomputed_indexes, and rnnlm::i.
|
inline |
Definition at line 514 of file nnet-computation.h.
|
inline |
Definition at line 507 of file nnet-computation.h.
References kaldi::nnet2::NnetComputation().
Referenced by Compiler::CreateComputation().
void ComputeCudaIndexes | ( | ) |
Definition at line 84 of file nnet-computation.cc.
References rnnlm::i, and KALDI_ASSERT.
Referenced by CachingOptimizingCompiler::CompileNoShortcut(), CachingOptimizingCompiler::CompileViaShortcut(), DecodableNnetSimpleLoopedInfo::Init(), kaldi::nnet3::UnitTestNnetCompute(), and kaldi::nnet3::UnitTestNnetOptimizeWithOptions().
void GetCommandStrings | ( | const Nnet & | nnet, |
std::string * | preamble, | ||
std::vector< std::string > * | command_strings | ||
) | const |
Definition at line 944 of file nnet-computation.cc.
References kaldi::nnet3::GetIndexesMultiStrings(), kaldi::nnet3::GetIndexesStrings(), kaldi::nnet3::PrintCommand(), and kaldi::nnet3::PrintComputationPreamble().
Referenced by NnetComputer::ExecuteCommand(), and NnetComputer::Init().
void GetSubmatrixStrings | ( | const Nnet & | nnet, |
std::vector< std::string > * | submat_strings | ||
) | const |
Definition at line 424 of file nnet-computation.cc.
References NnetComputation::SubMatrixInfo::col_offset, rnnlm::i, KALDI_ASSERT, NnetComputation::SubMatrixInfo::matrix_index, NnetComputation::SubMatrixInfo::num_cols, NnetComputation::SubMatrixInfo::num_rows, and NnetComputation::SubMatrixInfo::row_offset.
Referenced by ComputationExpander::ComputeSubmatrixInfo(), NnetComputer::Init(), and kaldi::nnet3::UnitTestNnetAnalyze().
void GetWholeSubmatrices | ( | std::vector< int32 > * | whole_submatrices | ) | const |
Definition at line 1173 of file nnet-computation.cc.
References NnetComputation::IsWholeMatrix(), KALDI_ASSERT, NnetComputation::matrices, and NnetComputation::submatrices.
Referenced by Compiler::AddCommands(), ComputationLoopedOptimizer::AddMatrixSwapCommands(), ComputationLoopedOptimizer::FindActiveMatrices(), MatrixExtender::FixComputation(), DerivativeTimeLimiter::LimitDerivTimes(), and MemoryCompressionOptimizer::ModifyComputation().
Definition at line 975 of file nnet-computation.cc.
References KALDI_ASSERT, NnetComputation::MatrixInfo::num_cols, and NnetComputation::MatrixInfo::num_rows.
Referenced by Compiler::AddBackwardStepInput(), Compiler::AddForwardStepInput(), ComputationChecker::CheckComputationIndexes(), Compiler::CompileBackwardDescriptor(), Compiler::CompileForwardDescriptor(), kaldi::nnet3::ComputeMatrixAccesses(), ModelUpdateConsolidator::ConsolidateSubmatrices(), NnetComputer::DebugAfterExecute(), NnetComputer::DebugBeforeExecute(), ComputationLoopedOptimizer::FindTimeShift(), NnetComputer::GetIoMatrixIndex(), NnetComputation::GetWholeSubmatrices(), DerivativeTimeLimiter::LimitMatrices(), VariableMergingOptimizer::MayBeMerged(), and Compiler::OutputDebugInfo().
int32 NewMatrix | ( | int32 | num_rows, |
int32 | num_cols, | ||
MatrixStrideType | stride_type | ||
) |
Convenience function used when adding new matrices.
Writes to 'this->matrices' and 'this->submatrices'; and if 'this->matrix_debug_info' is nonempty, also increases its size by one. Returns the *sub-matrix* index corresponding to the newly added matrix.
Definition at line 128 of file nnet-computation.cc.
References KALDI_ASSERT, and kaldi::kDefaultStride.
Referenced by ModelUpdateConsolidator::ConsolidateSubmatrices(), and Compiler::CreateStepInfo().
int32 NewSubMatrix | ( | int32 | base_submatrix, |
int32 | row_offset, | ||
int32 | num_rows, | ||
int32 | col_offset, | ||
int32 | num_cols | ||
) |
Convenience function used when adding new sub-matrices.
base_submatrix is the submatrix of which we want a column and/or row range. As a convenience, -1 for the 'num_rows' or the 'num_cols' will be interpreted as 'as much as possible'. Returns the new sub-matrix index. Writes to 'this->submatrices'. There is no mechanism to stop duplicates from being created, but calling RenumberComputation() will remove such duplicates.
Definition at line 102 of file nnet-computation.cc.
References KALDI_ASSERT, and NnetComputation::SubMatrixInfo::matrix_index.
Referenced by DerivativeTimeLimiter::ComputeSubmatrixMaps(), ModelUpdateConsolidator::ConsolidateSubmatrices(), Compiler::CreateStepInfo(), DerivativeTimeLimiter::MapSimpleMatrixCommand(), kaldi::nnet3::ReplaceRowWithMatrixOps(), kaldi::nnet3::SnipMultiRowOp(), kaldi::nnet3::SnipRangesRowOp(), kaldi::nnet3::SnipSingleRowOp(), and RowOpsSplitter::SplitCommand().
NnetComputation & operator= | ( | const NnetComputation & | other | ) |
Definition at line 1151 of file nnet-computation.cc.
References NnetComputation::commands, NnetComputation::component_precomputed_indexes, rnnlm::i, NnetComputation::indexes, NnetComputation::indexes_cuda, NnetComputation::indexes_multi, NnetComputation::indexes_ranges, NnetComputation::indexes_ranges_cuda, NnetComputation::matrices, NnetComputation::matrix_debug_info, NnetComputation::need_model_derivative, and NnetComputation::submatrices.
void Print | ( | std::ostream & | os, |
const Nnet & | nnet | ||
) | const |
Definition at line 717 of file nnet-computation.cc.
References kaldi::nnet3::GetIndexesMultiStrings(), kaldi::nnet3::GetIndexesStrings(), kaldi::nnet3::PrintCommand(), and kaldi::nnet3::PrintComputationPreamble().
Referenced by kaldi::nnet3::CheckComputation(), CachingOptimizingCompiler::CompileNoShortcut(), ComputationExpander::ComputeSubmatrixInfo(), NnetComputationPrintInserter::Print(), NnetComputer::Run(), kaldi::nnet3::UnitTestNnetAnalyze(), kaldi::nnet3::UnitTestNnetCompile(), kaldi::nnet3::UnitTestNnetCompileLooped(), kaldi::nnet3::UnitTestNnetCompute(), kaldi::nnet3::UnitTestNnetModelDerivatives(), and kaldi::nnet3::UnitTestNnetOptimizeWithOptions().
void Read | ( | std::istream & | istream, |
bool | binary | ||
) |
Definition at line 732 of file nnet-computation.cc.
References NnetComputation::PrecomputedIndexesInfo::data, kaldi::nnet3::ExpectToken(), rnnlm::i, NnetComputation::PrecomputedIndexesInfo::input_indexes, KALDI_ASSERT, KALDI_ERR, ComputationRequest::need_model_derivative, NnetComputation::PrecomputedIndexesInfo::output_indexes, kaldi::ReadBasicType(), kaldi::nnet3::ReadIndexVector(), kaldi::ReadIntegerPairVector(), kaldi::ReadIntegerVector(), ComponentPrecomputedIndexes::ReadNew(), and kaldi::ReadToken().
Referenced by ComputationCache::Read(), and kaldi::nnet3::UnitTestNnetComputationIo().
void Write | ( | std::ostream & | ostream, |
bool | binary | ||
) | const |
Definition at line 866 of file nnet-computation.cc.
References NnetComputation::PrecomputedIndexesInfo::data, NnetComputation::PrecomputedIndexesInfo::input_indexes, ComputationRequest::need_model_derivative, NnetComputation::PrecomputedIndexesInfo::output_indexes, ComponentPrecomputedIndexes::Write(), kaldi::WriteBasicType(), kaldi::nnet3::WriteIndexVector(), kaldi::WriteIntegerPairVector(), kaldi::WriteIntegerVector(), and kaldi::WriteToken().
Referenced by kaldi::nnet3::UnitTestNnetComputationIo().
std::vector<Command> commands |
Definition at line 439 of file nnet-computation.h.
Referenced by Compiler::AddBackwardStepComponent(), Compiler::AddBackwardStepInput(), Compiler::AddCommands(), ModelUpdateConsolidator::AddCommandsToComputation(), Compiler::AddForwardStepComponent(), Compiler::AddForwardStepInput(), ComputationLoopedOptimizer::AddMatrixSwapCommands(), Compiler::AllocateMatrices(), DerivativeTimeLimiter::CanLimitMatrix(), kaldi::nnet3::CheckComputation(), ComputationChecker::CheckComputationCompression(), ComputationChecker::CheckComputationIndexes(), ComputationChecker::CheckComputationMatrixAccesses(), kaldi::nnet3::CheckComputationOnline(), ComputationChecker::CheckComputationUndefined(), NnetComputer::CheckNoPendingIo(), Compiler::CompileBackward(), Compiler::CompileBackwardDescriptor(), Compiler::CompileBackwardFromIndexes(), Compiler::CompileBackwardFromSubmatLocations(), Compiler::CompileForward(), Compiler::CompileForwardDescriptor(), Compiler::CompileForwardFromIndexes(), Compiler::CompileForwardFromSubmatLocations(), Compiler::CompileForwardSumDescriptor(), kaldi::nnet3::CompileLoopedInternal(), kaldi::nnet3::ComputeCommandAttributes(), ComputationExpander::ComputeCommands(), kaldi::nnet3::ComputeMatrixAccesses(), ComputationExpander::ComputePrecomputedIndexes(), kaldi::nnet3::ConsolidateIoOperations(), ModelUpdateConsolidator::ConsolidateModelUpdate(), ModelUpdateConsolidator::ConsolidateUpdateForComponent(), kaldi::nnet3::ConvertAdditionToAssignment(), ComputationAnalysis::DataInvalidatedCommand(), Compiler::DeallocateMatrices(), NnetComputer::DebugAfterExecute(), NnetComputer::DebugBeforeExecute(), VariableMergingOptimizer::DoMerge(), NnetComputer::ExecuteCommand(), MatrixExtender::ExtendMatrices(), ComputationLoopedOptimizer::FindTimeShift(), ComputationAnalysis::FirstAccess(), ComputationAnalysis::FirstNontrivialAccess(), ComputationAnalysis::FirstNontrivialMatrixAccess(), MatrixExtender::FixComputation(), kaldi::nnet3::FixGotoLabel(), ComputationLoopedOptimizer::FormInfiniteLoop(), kaldi::nnet3::GetCommandsOfType(), NnetComputer::GetIoMatrixIndex(), kaldi::nnet3::GetMaxMemoryUse(), kaldi::nnet3::IdentifySubmatrixArgsInComputation(), kaldi::nnet3::InsertCommands(), ComputationAnalysis::LastAccess(), ComputationAnalysis::LastWriteAccess(), MatrixExtender::MatrixExtender(), kaldi::nnet3::MatrixIsUnused(), VariableMergingOptimizer::MayBeMerged(), VariableMergingOptimizer::MergeVariables(), DerivativeTimeLimiter::ModifyCommands(), kaldi::nnet3::MoveSizingCommands(), NnetComputation::operator=(), kaldi::nnet3::OptimizeMemoryCompression(), kaldi::nnet3::PrintCommand(), MemoryCompressionOptimizer::ProcessMatrix(), kaldi::nnet3::RemoveCommandsForUnusedMatrix(), ComputationRenumberer::RemoveIndexesMultiDuplicates(), kaldi::nnet3::RemoveNoOps(), kaldi::nnet3::RemoveUnnecessaryAllocation(), kaldi::nnet3::RemoveUnnecessaryZeroing(), ComputationRenumberer::RemoveUnusedIndexesMulti(), DerivativeTimeLimiter::RemoveUnusedMemos(), ComputationRenumberer::RenumberIndexes(), ComputationRenumberer::RenumberIndexesRanges(), ComputationRenumberer::RenumberMemos(), kaldi::nnet3::ReplaceRowWithMatrixOps(), NnetComputer::Run(), kaldi::nnet3::SnipMultiRowOp(), kaldi::nnet3::SnipRangesRowOp(), kaldi::nnet3::SnipRowOps(), kaldi::nnet3::SnipSingleRowOp(), RowOpsSplitter::SplitCommand(), RowOpsSplitter::SplitCommands(), kaldi::nnet3::SplitComputationIntoSegments(), and kaldi::nnet3::UnitTestNnetAnalyze().
std::vector<PrecomputedIndexesInfo> component_precomputed_indexes |
Definition at line 412 of file nnet-computation.h.
Referenced by ComputationChecker::CheckComputationIndexes(), ComputationExpander::ComputePrecomputedIndexes(), NnetComputer::ExecuteCommand(), NnetComputation::NnetComputation(), NnetComputation::operator=(), and Compiler::SetUpPrecomputedIndexes().
std::vector<std::vector<int32> > indexes |
Definition at line 419 of file nnet-computation.h.
Referenced by ComputationChecker::CheckComputationIndexes(), Compiler::CompileBackwardFromIndexes(), Compiler::CompileForwardFromIndexes(), kaldi::nnet3::ComputeCommandAttributes(), ComputationExpander::ExpandRowsCommand(), kaldi::nnet3::GetIndexesStrings(), NnetComputer::Init(), DerivativeTimeLimiter::MapIndexesCommand(), NnetComputation::operator=(), ComputationRenumberer::RenumberIndexes(), kaldi::nnet3::ReplaceRowWithMatrixOps(), kaldi::nnet3::SnipSingleRowOp(), and RowOpsSplitter::SplitCommand().
Definition at line 445 of file nnet-computation.h.
Referenced by NnetComputer::ExecuteCommand(), NnetComputer::Init(), and NnetComputation::operator=().
Definition at line 425 of file nnet-computation.h.
Referenced by ComputationChecker::CheckComputationIndexes(), Compiler::CompileBackwardFromSubmatLocations(), Compiler::CompileForwardFromSubmatLocations(), kaldi::nnet3::ComputeCommandAttributes(), ComputationExpander::ExpandRowsMultiCommand(), kaldi::nnet3::GetIndexesMultiStrings(), NnetComputer::GetPointers(), kaldi::nnet3::IdentifySubmatrixArgsInComputation(), DerivativeTimeLimiter::MapIndexesMultiCommand(), NnetComputation::operator=(), ComputationRenumberer::RemoveIndexesMultiDuplicates(), ComputationRenumberer::RemoveUnusedIndexesMulti(), kaldi::nnet3::SnipMultiRowOp(), and RowOpsSplitter::SplitIndexes().
Definition at line 430 of file nnet-computation.h.
Referenced by ComputationChecker::CheckComputationIndexes(), Compiler::CompileBackwardFromIndexes(), ComputationExpander::ExpandRowRangesCommand(), NnetComputer::Init(), DerivativeTimeLimiter::MapAddRowRangesCommand(), NnetComputation::operator=(), kaldi::nnet3::PrintCommand(), ComputationRenumberer::RenumberIndexesRanges(), and kaldi::nnet3::SnipRangesRowOp().
Definition at line 448 of file nnet-computation.h.
Referenced by NnetComputer::ExecuteCommand(), NnetComputer::Init(), and NnetComputation::operator=().
std::vector<MatrixInfo> matrices |
Definition at line 390 of file nnet-computation.h.
Referenced by NnetComputer::AcceptInput(), Compiler::AddCommands(), Compiler::AllocateMatrices(), ModelUpdateConsolidator::AppendDebugInfoForSubmatrix(), MatrixExtender::CanBeExtended(), ComputationChecker::CheckComputationDebugInfo(), ComputationChecker::CheckComputationUndefined(), ComputationLoopedOptimizer::CheckIdentifiedMatrices(), ComputationExpander::ComputeDebugInfo(), kaldi::nnet3::ComputeMatrixAccesses(), ComputationExpander::ComputeMatrixInfo(), ComputationRenumberer::ComputeMatrixIsUsed(), DerivativeTimeLimiter::ComputeMatrixPruneInfo(), kaldi::nnet3::ComputeMatrixToSubmatrix(), ComputationVariables::ComputeSplitPoints(), ModelUpdateConsolidator::ConsolidateSubmatrices(), ComputationLoopedOptimizer::CreateMatrixPairs(), Compiler::DeallocateMatrices(), VariableMergingOptimizer::DoMerge(), NnetComputer::ExecuteCommand(), MatrixExtender::Extend(), ComputationLoopedOptimizer::FindActiveMatrices(), ComputationLoopedOptimizer::FindTimeShift(), ComputationAnalysis::FirstNontrivialMatrixAccess(), MatrixExtender::FixComputation(), MatrixExtender::FixDebugInfo(), kaldi::nnet3::GetIndexesMultiStrings(), kaldi::nnet3::GetSubMatrixOfSubMatrix(), NnetComputation::GetWholeSubmatrices(), NnetComputer::Init(), ComputationExpander::InitStrideInfo(), ComputationAnalysis::LastMatrixAccess(), DerivativeTimeLimiter::LimitMatrices(), MatrixExtender::MatrixExtender(), VariableMergingOptimizer::MayBeMerged(), NnetComputation::operator=(), MemoryCompressionOptimizer::Optimize(), Compiler::OutputDebugInfo(), kaldi::nnet3::PrintComputationPreamble(), DerivativeTimeLimiter::PruneMatrices(), kaldi::nnet3::RemoveUnnecessaryAllocation(), and ComputationRenumberer::RenumberMatrices().
std::vector<MatrixDebugInfo> matrix_debug_info |
Definition at line 394 of file nnet-computation.h.
Referenced by ModelUpdateConsolidator::AppendDebugInfoForSubmatrix(), ComputationChecker::CheckComputationDebugInfo(), ComputationLoopedOptimizer::CheckIdentifiedMatrices(), ComputationExpander::ComputeDebugInfo(), DerivativeTimeLimiter::ComputeMatrixPruneInfo(), ComputationExpander::ComputeSubmatrixInfo(), DerivativeTimeLimiter::ComputeSubmatrixMaps(), ModelUpdateConsolidator::ConsolidateSubmatrices(), ComputationLoopedOptimizer::CreateMatrixPairs(), ComputationLoopedOptimizer::FindTimeShift(), MatrixExtender::FixComputation(), MatrixExtender::FixDebugInfo(), ComputationExpander::GetNewMatrixLocationInfo(), ComputationExpander::GetNewSubmatLocationInfo(), ComputationExpander::InitStrideInfo(), DerivativeTimeLimiter::LimitMatrices(), NnetComputation::operator=(), ComputationLoopedOptimizer::Optimize(), Compiler::OutputDebugInfo(), kaldi::nnet3::PrintComputationPreamble(), DerivativeTimeLimiter::PruneMatrices(), ComputationRenumberer::RenumberMatrices(), and DerivativeTimeLimiter::RowIsKept().
bool need_model_derivative |
Definition at line 442 of file nnet-computation.h.
Referenced by Compiler::AddCommands(), kaldi::nnet3::ConsolidateModelUpdate(), NnetComputer::ExecuteCommand(), ComputationExpander::Expand(), NnetComputation::operator=(), and kaldi::nnet3::PrintCommand().
std::vector<SubMatrixInfo> submatrices |
Definition at line 404 of file nnet-computation.h.
Referenced by Compiler::AllocateMatrices(), ModelUpdateConsolidator::AppendDebugInfoForSubmatrix(), MatrixExtender::CanBeExtended(), ComputationChecker::CheckComputationIndexes(), Compiler::CompileBackwardFromIndexes(), Compiler::CompileForwardFromIndexes(), kaldi::nnet3::ComputeMatrixAccesses(), ComputationRenumberer::ComputeMatrixIsUsed(), kaldi::nnet3::ComputeMatrixToSubmatrix(), ComputationVariables::ComputeSplitPoints(), ComputationExpander::ComputeSubmatrixInfo(), ComputationRenumberer::ComputeSubmatrixIsUsed(), DerivativeTimeLimiter::ComputeSubmatrixMaps(), ComputationVariables::ComputeVariablesForSubmatrix(), ModelUpdateConsolidator::ConsolidateSubmatrices(), Compiler::CreateStepInfo(), ComputationAnalysis::DataInvalidatedCommand(), Compiler::DeallocateMatrices(), VariableMergingOptimizer::DoMerge(), NnetComputer::ExecuteCommand(), ComputationExpander::ExpandRowRangesCommand(), ComputationExpander::ExpandRowsCommand(), ComputationExpander::ExpandRowsMultiCommand(), MatrixExtender::Extend(), ComputationLoopedOptimizer::FindTimeShift(), ComputationAnalysis::FirstAccess(), ComputationAnalysis::FirstNontrivialAccess(), MatrixExtender::FixComputation(), kaldi::nnet3::GetIndexesMultiStrings(), NnetComputer::GetIoMatrixIndex(), kaldi::nnet3::GetMaxMemoryUse(), ComputationExpander::GetNewSubmatLocationInfo(), DerivativeTimeLimiter::GetPruneValues(), NnetComputer::GetSubMatrix(), kaldi::nnet3::GetSubMatrixOfSubMatrix(), NnetComputation::GetWholeSubmatrices(), kaldi::nnet3::IdentifyMatrixArgsInComputation(), ComputationAnalysis::LastAccess(), ComputationAnalysis::LastWriteAccess(), DerivativeTimeLimiter::LimitMatrices(), DerivativeTimeLimiter::MapAddRowRangesCommand(), DerivativeTimeLimiter::MapIndexesCommand(), DerivativeTimeLimiter::MapIndexesMultiCommand(), DerivativeTimeLimiter::MapSimpleMatrixCommand(), MatrixExtender::MatrixExtender(), VariableMergingOptimizer::MayBeMerged(), NnetComputation::operator=(), Compiler::OutputDebugInfo(), kaldi::nnet3::PrintCommand(), kaldi::nnet3::RemoveUnnecessaryAllocation(), ComputationRenumberer::RenumberMatrices(), ComputationRenumberer::RenumberSubmatrices(), DerivativeTimeLimiter::RowIsKept(), ComputationRenumberer::SetUpMappings(), and kaldi::nnet3::UnitTestNnetAnalyze().