This class creates an initial version of the NnetComputation, without any optimization or sharing of matrices. More...
#include <nnet-compile.h>
Classes | |
struct | StepInfo |
Public Member Functions | |
Compiler (const ComputationRequest &request, const Nnet &nnet) | |
Compiler (const std::vector< const ComputationRequest *> &request, const Nnet &nnet) | |
void | CreateComputation (const CompilerOptions &opts, NnetComputation *computation) |
Private Member Functions | |
void | ComputeStepDependencies (const std::vector< int32 > &this_step, int32 step_index, unordered_set< int32 > *dep_steps) |
void | ComputeDerivNeeded (const std::vector< std::vector< int32 > > &steps, const std::vector< int32 > &step_to_segment, std::vector< bool > *deriv_needed) |
void | CreateStepInfo (const std::vector< bool > &deriv_needed, const std::vector< int32 > &step_to_segment, std::vector< std::vector< int32 > > *by_step, NnetComputation *computation) |
MatrixStrideType | GetStrideType (int32 node_index) const |
void | DefineMatrices (NnetComputation *computation) const |
void | DefineSubmatrices (NnetComputation *computation) |
void | AllocateMatrices (const std::vector< int32 > &whole_submatrices, NnetComputation *computation) const |
void | SetUpPrecomputedIndexes (const std::vector< int32 > &step_to_segment, NnetComputation *computation) |
void | CompileForward (int32 step, NnetComputation *computation) const |
void | AddForwardStepComponent (int32 step, NnetComputation *computation) const |
void | AddForwardStepInput (int32 step, NnetComputation *computation) const |
bool | IsInputStep (int32 step) const |
void | CompileForwardDescriptor (int32 step, NnetComputation *computation) const |
void | CompileForwardSumDescriptor (int32 step, int32 part_index, NnetComputation *computation) const |
void | ComputeInputLocationsList (int32 step, int32 part_index, std::vector< std::vector< std::pair< int32, int32 > > > *input_locations) const |
BaseFloat | SplitByScale (const SumDescriptor &descriptor, const std::vector< std::vector< std::pair< int32, int32 > > > &input_locations_list, std::vector< std::pair< BaseFloat, std::vector< std::vector< std::pair< int32, int32 > > > > > *split_locations_lists) const |
This function helps to handle scalar factors in Descriptors (expressions like `Scale(-1.0, <descriptor)`). More... | |
void | ComputeValueSubmatLocationsList (const std::vector< std::vector< std::pair< int32, int32 > > > &input_locations_list, std::vector< std::vector< std::pair< int32, int32 > > > *submat_locations_list) const |
void | ComputeDerivSubmatLocationsList (const std::vector< std::vector< std::pair< int32, int32 > > > &input_locations_list, std::vector< std::vector< std::pair< int32, int32 > > > *submat_locations_list) const |
void | CompileForwardFromSubmatLocationsList (int32 value_submatrix_index, BaseFloat alpha, const std::vector< std::vector< std::pair< int32, int32 > > > &submat_locations, NnetComputation *computation) const |
Adds to 'computation' commands for part of the forward computation corresponding to a Descriptor. More... | |
void | CompileForwardFromSubmatLocations (int32 value_submatrix_index, BaseFloat alpha, const std::vector< std::pair< int32, int32 > > &submat_locations, NnetComputation *computation) const |
Adds to 'computation' commands for part of the forward computation corresponding to a Descriptor. More... | |
void | CompileForwardFromIndexes (int32 value_submatrix_index, int32 input_submatrix_index, BaseFloat alpha, const std::vector< int32 > &indexes, NnetComputation *computation) const |
Adds to `computation` a command that adds to the submatrix in `value_submatrix_index` a quantity consisting of alpha times the submatrix in `input_submatrix_index`, with a row mapping given by `indexes`. More... | |
void | CompileBackward (int32 step, NnetComputation *computation) |
void | AddBackwardStepComponent (int32 step, NnetComputation *computation) const |
void | AddBackwardStepInput (int32 step, NnetComputation *computation) const |
void | CompileBackwardDescriptor (int32 step, NnetComputation *computation) |
void | CompileBackwardSumDescriptor (int32 step, int32 part_index, NnetComputation *computation) const |
void | CompileBackwardFromSubmatLocationsList (int32 deriv_submatrix_index, BaseFloat alpha, const std::vector< std::vector< std::pair< int32, int32 > > > &submat_locations, NnetComputation *computation) const |
void | CompileBackwardFromSubmatLocations (int32 deriv_submatrix_index, BaseFloat alpha, const std::vector< std::pair< int32, int32 > > &submat_locations, NnetComputation *computation) const |
void | CompileBackwardFromIndexes (int32 deriv_submatrix_index, int32 input_deriv_submatrix_index, BaseFloat alpha, const std::vector< int32 > &indexes, NnetComputation *computation) const |
void | DeallocateMatrices (const std::vector< int32 > &whole_submatrices, const std::vector< int32 > &step_to_segment, NnetComputation *computation) |
void | OutputDebugInfo (NnetComputation *computation) const |
void | AddCommands (const std::vector< bool > &deriv_needed, const std::vector< int32 > &step_to_segment, NnetComputation *computation) |
Private Attributes | |
std::vector< const ComputationRequest * > | requests_ |
const Nnet & | nnet_ |
ComputationGraph | graph_ |
std::vector< StepInfo > | steps_ |
std::vector< std::pair< int32, int32 > > | cindex_id_to_location_ |
This maps each cindex_id to its location. More... | |
This class creates an initial version of the NnetComputation, without any optimization or sharing of matrices.
Note: for a user-level interface that includes optimization, see class CachingOptimizingCompiler in nnet-optimize.h.
Definition at line 44 of file nnet-compile.h.
Compiler | ( | const ComputationRequest & | request, |
const Nnet & | nnet | ||
) |
Definition at line 29 of file nnet-compile.cc.
References Compiler::requests_.
Compiler | ( | const std::vector< const ComputationRequest *> & | request, |
const Nnet & | nnet | ||
) |
Definition at line 35 of file nnet-compile.cc.
References rnnlm::i, KALDI_ASSERT, and Compiler::requests_.
|
private |
Definition at line 1149 of file nnet-compile.cc.
References NnetComputation::commands, NetworkNode::component_index, Compiler::StepInfo::deriv, Nnet::GetComponent(), Nnet::GetNode(), KALDI_ASSERT, kaldi::nnet3::kBackprop, kaldi::nnet3::kBackpropNeedsInput, kaldi::nnet3::kBackpropNeedsOutput, kaldi::nnet3::kComponent, kaldi::nnet3::kUpdatableComponent, kaldi::nnet3::kUsesMemo, Compiler::nnet_, NetworkNode::node_type, Component::Properties(), Compiler::steps_, NetworkNode::u, and Compiler::StepInfo::value.
Referenced by Compiler::CompileBackward().
|
private |
Definition at line 1131 of file nnet-compile.cc.
References NnetComputation::commands, Nnet::GetNode(), NnetComputation::IsWholeMatrix(), KALDI_ASSERT, kaldi::nnet3::kComponent, kaldi::nnet3::kInput, kaldi::nnet3::kProvideOutput, Compiler::nnet_, and Compiler::steps_.
Referenced by Compiler::CompileBackward().
|
private |
Definition at line 107 of file nnet-compile.cc.
References Compiler::AllocateMatrices(), NnetComputation::commands, Compiler::CompileBackward(), Compiler::CompileForward(), Compiler::DeallocateMatrices(), NnetComputation::GetWholeSubmatrices(), kaldi::nnet3::kNoOperationMarker, NnetComputation::matrices, NnetComputation::need_model_derivative, Compiler::requests_, Compiler::SetUpPrecomputedIndexes(), and Compiler::steps_.
Referenced by Compiler::CreateComputation().
|
private |
Definition at line 1097 of file nnet-compile.cc.
References NnetComputation::commands, NetworkNode::component_index, Nnet::GetComponent(), Nnet::GetNode(), KALDI_ASSERT, kaldi::nnet3::kComponent, kaldi::nnet3::kPropagate, kaldi::nnet3::kStoresStats, kaldi::nnet3::kUsesMemo, Compiler::nnet_, NetworkNode::node_type, Component::Properties(), Compiler::requests_, Compiler::steps_, NetworkNode::u, and Compiler::StepInfo::value.
Referenced by Compiler::CompileForward().
|
private |
Definition at line 1080 of file nnet-compile.cc.
References NnetComputation::commands, Nnet::GetNode(), NnetComputation::IsWholeMatrix(), kaldi::nnet3::kAcceptInput, KALDI_ASSERT, kaldi::nnet3::kComponent, kaldi::nnet3::kInput, Compiler::nnet_, and Compiler::steps_.
Referenced by Compiler::CompileForward().
|
private |
Definition at line 1189 of file nnet-compile.cc.
References NnetComputation::commands, Compiler::StepInfo::deriv, Compiler::graph_, ComputationGraph::is_input, Nnet::IsOutputNode(), KALDI_ASSERT, kaldi::nnet3::kAllocMatrix, kaldi::nnet3::kSetConst, NnetComputation::matrices, Compiler::nnet_, Compiler::StepInfo::node_index, Compiler::StepInfo::output_cindex_ids, Compiler::steps_, NnetComputation::submatrices, and Compiler::StepInfo::value.
Referenced by Compiler::AddCommands().
|
private |
Definition at line 1050 of file nnet-compile.cc.
References Compiler::AddBackwardStepComponent(), Compiler::AddBackwardStepInput(), NnetComputation::commands, Compiler::CompileBackwardDescriptor(), Nnet::GetNode(), Compiler::IsInputStep(), KALDI_ASSERT, KALDI_ERR, kaldi::nnet3::kComponent, kaldi::nnet3::kDescriptor, kaldi::nnet3::kDimRange, kaldi::nnet3::kInput, kaldi::nnet3::kNoOperationPermanent, Compiler::nnet_, Compiler::StepInfo::node_index, NetworkNode::node_type, and Compiler::steps_.
Referenced by Compiler::AddCommands().
|
private |
Definition at line 1029 of file nnet-compile.cc.
References NnetComputation::commands, Compiler::CompileBackwardSumDescriptor(), Compiler::StepInfo::deriv, Nnet::IsOutputNode(), NnetComputation::IsWholeMatrix(), kaldi::nnet3::kAcceptInput, KALDI_ASSERT, Compiler::nnet_, Compiler::StepInfo::node_index, Compiler::steps_, and Compiler::StepInfo::value_parts.
Referenced by Compiler::CompileBackward().
|
private |
Definition at line 939 of file nnet-compile.cc.
References NnetComputation::commands, kaldi::nnet3::HasContiguousProperty(), rnnlm::i, NnetComputation::indexes, NnetComputation::indexes_ranges, kaldi::nnet3::kAddRowRanges, kaldi::nnet3::kAddRows, KALDI_ASSERT, KALDI_ERR, kaldi::nnet3::kMatrixAdd, and NnetComputation::submatrices.
Referenced by Compiler::CompileBackwardFromSubmatLocations().
|
private |
Definition at line 887 of file nnet-compile.cc.
References NnetComputation::commands, Compiler::CompileBackwardFromIndexes(), kaldi::nnet3::ConvertToIndexes(), NnetComputation::indexes_multi, kaldi::IsSortedAndUniq(), kaldi::nnet3::kAddToRowsMulti, and KALDI_ERR.
Referenced by Compiler::CompileBackwardFromSubmatLocationsList().
|
private |
Definition at line 818 of file nnet-compile.cc.
References Compiler::CompileBackwardFromSubmatLocations(), rnnlm::i, and kaldi::nnet3::SplitLocationsBackward().
Referenced by Compiler::CompileBackwardSumDescriptor().
|
private |
Definition at line 835 of file nnet-compile.cc.
References Compiler::CompileBackwardFromSubmatLocationsList(), Compiler::ComputeDerivSubmatLocationsList(), Compiler::StepInfo::deriv_parts, NetworkNode::descriptor, Nnet::GetNode(), rnnlm::i, Compiler::StepInfo::input_locations_list, KALDI_ASSERT, Compiler::nnet_, Compiler::StepInfo::node_index, Descriptor::Part(), Compiler::SplitByScale(), and Compiler::steps_.
Referenced by Compiler::CompileBackwardDescriptor().
|
private |
Definition at line 406 of file nnet-compile.cc.
References Compiler::AddForwardStepComponent(), Compiler::AddForwardStepInput(), NnetComputation::commands, Compiler::CompileForwardDescriptor(), Nnet::GetNode(), Compiler::IsInputStep(), KALDI_ASSERT, KALDI_ERR, kaldi::nnet3::kComponent, kaldi::nnet3::kDescriptor, kaldi::nnet3::kDimRange, kaldi::nnet3::kInput, kaldi::nnet3::kNoOperationPermanent, Compiler::nnet_, Compiler::StepInfo::node_index, NetworkNode::node_type, and Compiler::steps_.
Referenced by Compiler::AddCommands().
|
private |
Definition at line 432 of file nnet-compile.cc.
References NnetComputation::commands, Compiler::CompileForwardSumDescriptor(), Nnet::IsOutputNode(), NnetComputation::IsWholeMatrix(), KALDI_ASSERT, kaldi::nnet3::kProvideOutput, Compiler::nnet_, Compiler::StepInfo::node_index, Compiler::steps_, and Compiler::StepInfo::value.
Referenced by Compiler::CompileForward().
|
private |
Adds to `computation` a command that adds to the submatrix in `value_submatrix_index` a quantity consisting of alpha times the submatrix in `input_submatrix_index`, with a row mapping given by `indexes`.
Definition at line 738 of file nnet-compile.cc.
References NnetComputation::commands, rnnlm::i, NnetComputation::indexes, kaldi::nnet3::kAddRows, kaldi::nnet3::kMatrixAdd, and NnetComputation::submatrices.
Referenced by Compiler::CompileForwardFromSubmatLocations().
|
private |
Adds to 'computation' commands for part of the forward computation corresponding to a Descriptor.
This is called from CompileForwardFromSubmatLocationsList.
[in] | value_submatrix_index | The submatrix index of the quanitity we are computing (part of a Descriptor; it's something like Sum(tdnn1, tdnn2) in general). |
[in] | alpha | The scale (1.0 unless Scale(...) expressions are involved in descriptors) with which these terms are present in the summation. |
[in] | submat_locations | Indexed by the row index corresponding to the rows of the submatrix referred to by 'value_submatrix_index', this reprenents the source vector which we are adding to this row, in the format (submatrix-index, row-index), or (-1, -1) if in this case there is nothing to add. |
[in,out] | computation | The computation which we are adding commands to. |
Definition at line 772 of file nnet-compile.cc.
References NnetComputation::commands, Compiler::CompileForwardFromIndexes(), kaldi::nnet3::ConvertToIndexes(), NnetComputation::indexes_multi, and kaldi::nnet3::kAddRowsMulti.
Referenced by Compiler::CompileForwardFromSubmatLocationsList().
|
private |
Adds to 'computation' commands for part of the forward computation corresponding to a Descriptor.
This is called from CompileForwardSumDescriptor.
[in] | value_submatrix_index | The submatrix index of the quanitity we are computing (part of a Descriptor; it's something like Sum(tdnn1, tdnn2) in general). |
[in] | alpha | The scale (1.0 unless Scale(...) expressions are involved in descriptors) with which these terms are present in the summation. |
[in] | submat_locations | Indexed by the row index of the submatrix referred to by 'value_submatrix_index', each element is a list of sources over which we must sum to obtain that row. Each source is a pair (submatrix-index, row-index). |
Definition at line 799 of file nnet-compile.cc.
References Compiler::CompileForwardFromSubmatLocations(), rnnlm::i, and kaldi::nnet3::SplitLocations().
Referenced by Compiler::CompileForwardSumDescriptor().
|
private |
Definition at line 676 of file nnet-compile.cc.
References NnetComputation::commands, Compiler::CompileForwardFromSubmatLocationsList(), Compiler::ComputeValueSubmatLocationsList(), NetworkNode::descriptor, Nnet::GetNode(), SumDescriptor::GetScaleForNode(), rnnlm::i, Compiler::StepInfo::input_locations_list, KALDI_ASSERT, kaldi::nnet3::kSetConst, Compiler::nnet_, Compiler::StepInfo::node_index, Descriptor::Part(), Compiler::SplitByScale(), Compiler::steps_, and Compiler::StepInfo::value_parts.
Referenced by Compiler::CompileForwardDescriptor().
|
private |
Definition at line 176 of file nnet-compile.cc.
References ComputationGraph::cindexes, NetworkNode::component_index, Compiler::ComputeStepDependencies(), Nnet::GetComponent(), Nnet::GetNode(), Nnet::GetNodeNames(), kaldi::GetVerboseLevel(), Compiler::graph_, rnnlm::i, ComputationRequest::IndexForInput(), ComputationRequest::IndexForOutput(), ComputationRequest::inputs, ComputationGraph::is_input, Nnet::IsComponentNode(), Nnet::IsOutputNode(), KALDI_ASSERT, KALDI_VLOG, kaldi::nnet3::kUpdatableComponent, UpdatableComponent::LearningRate(), ComputationRequest::need_model_derivative, Compiler::nnet_, ComputationRequest::outputs, Component::Properties(), Compiler::requests_, and NetworkNode::u.
Referenced by Compiler::CreateComputation().
|
private |
Definition at line 531 of file nnet-compile.cc.
References rnnlm::i, and Compiler::steps_.
Referenced by Compiler::CompileBackwardSumDescriptor().
|
private |
Definition at line 457 of file nnet-compile.cc.
References Compiler::cindex_id_to_location_, NetworkNode::descriptor, ComputationGraph::GetCindexId(), Nnet::GetNode(), Compiler::graph_, rnnlm::i, SumDescriptor::IsComputable(), rnnlm::j, KALDI_ASSERT, kaldi::nnet3::kNoTime, Compiler::nnet_, Descriptor::Part(), Compiler::steps_, and Index::t.
Referenced by Compiler::CreateStepInfo().
|
private |
Definition at line 142 of file nnet-compile.cc.
References Compiler::cindex_id_to_location_, ComputationGraph::cindexes, ComputationGraph::dependencies, Compiler::graph_, Nnet::IsComponentNode(), KALDI_ASSERT, and Compiler::nnet_.
Referenced by Compiler::ComputeDerivNeeded().
|
private |
Definition at line 503 of file nnet-compile.cc.
References rnnlm::i, and Compiler::steps_.
Referenced by Compiler::CompileForwardSumDescriptor().
void CreateComputation | ( | const CompilerOptions & | opts, |
NnetComputation * | computation | ||
) |
Definition at line 50 of file nnet-compile.cc.
References Compiler::AddCommands(), ComputationGraphBuilder::AllOutputsAreComputable(), ComputationStepsComputer::Check(), Compiler::cindex_id_to_location_, NnetComputation::Clear(), ComputationGraphBuilder::Compute(), kaldi::nnet3::ComputeComputationPhases(), Compiler::ComputeDerivNeeded(), ComputationStepsComputer::ComputeForSegment(), kaldi::nnet3::ConsolidateIoOperations(), Compiler::CreateStepInfo(), ComputationGraphBuilder::ExplainWhyAllOutputsNotComputable(), Compiler::graph_, KALDI_ERR, Compiler::nnet_, CompilerOptions::output_debug_info, Compiler::OutputDebugInfo(), ComputationGraphBuilder::Prune(), and Compiler::requests_.
Referenced by kaldi::nnet3::CompileLoopedInternal(), CachingOptimizingCompiler::CompileNoShortcut(), kaldi::nnet3::UnitTestNnetAnalyze(), kaldi::nnet3::UnitTestNnetCompile(), kaldi::nnet3::UnitTestNnetCompute(), and kaldi::nnet3::UnitTestNnetOptimizeWithOptions().
|
private |
Definition at line 279 of file nnet-compile.cc.
References Compiler::cindex_id_to_location_, ComputationGraph::cindexes, Compiler::ComputeInputLocationsList(), ComputationGraph::dependencies, Compiler::StepInfo::deriv, Compiler::StepInfo::deriv_parts, NetworkNode::descriptor, NetworkNode::dim, NetworkNode::Dim(), SumDescriptor::Dim(), Descriptor::Dim(), NetworkNode::dim_offset, Nnet::GetNode(), Compiler::GetStrideType(), Compiler::graph_, Compiler::StepInfo::input_locations_list, KALDI_ASSERT, KALDI_PARANOID_ASSERT, kaldi::nnet3::kDescriptor, kaldi::nnet3::kDimRange, NnetComputation::NewMatrix(), NnetComputation::NewSubMatrix(), Compiler::nnet_, Compiler::StepInfo::node_index, NetworkNode::node_type, Descriptor::NumParts(), Compiler::StepInfo::output_cindex_ids, Compiler::StepInfo::output_indexes, Descriptor::Part(), Compiler::StepInfo::segment, Compiler::steps_, NnetComputation::submatrices, Compiler::StepInfo::value, and Compiler::StepInfo::value_parts.
Referenced by Compiler::CreateComputation().
|
private |
Definition at line 1293 of file nnet-compile.cc.
References NnetComputation::commands, Compiler::StepInfo::deriv, Nnet::GetNodeNames(), rnnlm::i, ComputationRequest::inputs, Nnet::IsInputNode(), Nnet::IsOutputNode(), KALDI_ASSERT, kaldi::nnet3::kDeallocMatrix, NnetComputation::matrices, Compiler::nnet_, Compiler::StepInfo::node_index, Compiler::requests_, Compiler::steps_, NnetComputation::submatrices, and Compiler::StepInfo::value.
Referenced by Compiler::AddCommands().
|
private |
|
private |
|
private |
Definition at line 252 of file nnet-compile.cc.
References NetworkNode::component_index, Nnet::GetComponent(), Nnet::GetNode(), Nnet::IsComponentInputNode(), Nnet::IsComponentNode(), kaldi::kDefaultStride, kaldi::nnet3::kInputContiguous, kaldi::nnet3::kOutputContiguous, kaldi::kStrideEqualNumCols, Compiler::nnet_, Component::Properties(), and NetworkNode::u.
Referenced by Compiler::CreateStepInfo().
Definition at line 397 of file nnet-compile.cc.
References Nnet::GetNode(), KALDI_ASSERT, kaldi::nnet3::kInput, Compiler::nnet_, Compiler::StepInfo::node_index, NetworkNode::node_type, and Compiler::steps_.
Referenced by Compiler::CompileBackward(), and Compiler::CompileForward().
|
private |
Definition at line 1346 of file nnet-compile.cc.
References kaldi::nnet3::AppendCindexes(), NnetComputation::MatrixDebugInfo::cindexes, Compiler::StepInfo::deriv, NnetComputation::MatrixDebugInfo::is_deriv, NnetComputation::IsWholeMatrix(), NnetComputation::matrices, NnetComputation::matrix_debug_info, Compiler::StepInfo::node_index, Compiler::StepInfo::output_indexes, Compiler::steps_, NnetComputation::submatrices, and Compiler::StepInfo::value.
Referenced by Compiler::CreateComputation().
|
private |
Definition at line 1239 of file nnet-compile.cc.
References NetworkNode::component_index, NnetComputation::component_precomputed_indexes, NnetComputation::PrecomputedIndexesInfo::data, Nnet::GetComponent(), Nnet::GetNode(), NnetComputation::PrecomputedIndexesInfo::input_indexes, KALDI_ASSERT, kaldi::nnet3::kComponent, ComputationRequest::misc_info, ComputationRequest::NeedDerivatives(), Compiler::nnet_, Compiler::StepInfo::node_index, NetworkNode::node_type, Compiler::StepInfo::output_indexes, NnetComputation::PrecomputedIndexesInfo::output_indexes, Compiler::StepInfo::precomputed_indexes_index, Component::PrecomputeIndexes(), Compiler::requests_, Compiler::steps_, and NetworkNode::u.
Referenced by Compiler::AddCommands().
|
private |
This function helps to handle scalar factors in Descriptors (expressions like `Scale(-1.0, <descriptor)`).
It splits an input_locations_list for one SumDescriptor (consisting of one of the appended-together parts of a Descriptor) by scale, such that each split-up locations_list corresponds to a single scaling factor. The scaling factors are all 1.0 by default, but may be different from 1.0 if the user uses `Scale(...)` expressions in descriptors, e.g. `Scale(-1.0, lstm1.z)`. To help efficiency, this function treats the case where all the scales in the expression are the same (usually 1.0), as a special case. In this case, 'split_locations_lists' will be empty and the shared scale (e.g. 1.0) is returned.
[in] | descriptor | The SumDescriptor for which we're getting scalar factors. |
[in] | input_locations_list | This is one element of the input_locations_list from the StepInfo of the step we are computing, corresponding to this SumDescriptor (i.e. one part of the Descriptor). It is indexed by row-index, then it is a list of pairs (step, row-index), representing source Cindexes of a summation. This function will work out what scaling factors the pairs in these lists have. |
[out] | split_locations_lists | We write to this location. If all the scaling factors are the same this will be set to the empty list and the common scaling factor returned. Otherwise +infinity will be returned and the split-up list will be written to the location. Each element (*split_locations_lists)[i] will be set to a pair (alpha, partial_input_locations_list) where alpha is the scaling factor associated with this split-up piece (e.g. -1.0 if it was part of an expression like `Scale(-1.0, lstm1.z)`), and 'partial_input_locations_list' is a vector with the same dimension as 'input_locations_list' (indexed by row-index), where partial_input_locations_list[r] will contain a subset of the pairs present in input_locations_list[r], and if we were to append together all the (*split_locations_lists)[*].second.partial_input_locations_list[r], we'd get a list with the same members as input_locations_list[r], although not necessarily in the same order. |
Definition at line 557 of file nnet-compile.cc.
References SumDescriptor::GetNodeDependencies(), SumDescriptor::GetScaleForNode(), rnnlm::i, rnnlm::j, KALDI_ASSERT, kaldi::SortAndUniq(), and Compiler::steps_.
Referenced by Compiler::CompileBackwardSumDescriptor(), and Compiler::CompileForwardSumDescriptor().
This maps each cindex_id to its location.
However, you should not rely on its accuracy for cindex_ids that correspond to the Descriptors at Component inputs, since it's possible in principle for such cindex_ids to exist at >1 location. (This is not a problem in practice, because we only need this for the outputs of component-nodes, and for computation inputs). A location is a pair (step-index, matrix-row-index).
Definition at line 161 of file nnet-compile.h.
Referenced by Compiler::ComputeInputLocationsList(), Compiler::ComputeStepDependencies(), Compiler::CreateComputation(), and Compiler::CreateStepInfo().
|
private |
Definition at line 64 of file nnet-compile.h.
Referenced by Compiler::AllocateMatrices(), Compiler::ComputeDerivNeeded(), Compiler::ComputeInputLocationsList(), Compiler::ComputeStepDependencies(), Compiler::CreateComputation(), and Compiler::CreateStepInfo().
|
private |
Definition at line 63 of file nnet-compile.h.
Referenced by Compiler::AddBackwardStepComponent(), Compiler::AddBackwardStepInput(), Compiler::AddForwardStepComponent(), Compiler::AddForwardStepInput(), Compiler::AllocateMatrices(), Compiler::CompileBackward(), Compiler::CompileBackwardDescriptor(), Compiler::CompileBackwardSumDescriptor(), Compiler::CompileForward(), Compiler::CompileForwardDescriptor(), Compiler::CompileForwardSumDescriptor(), Compiler::ComputeDerivNeeded(), Compiler::ComputeInputLocationsList(), Compiler::ComputeStepDependencies(), Compiler::CreateComputation(), Compiler::CreateStepInfo(), Compiler::DeallocateMatrices(), Compiler::GetStrideType(), Compiler::IsInputStep(), and Compiler::SetUpPrecomputedIndexes().
|
private |
Definition at line 62 of file nnet-compile.h.
Referenced by Compiler::AddCommands(), Compiler::AddForwardStepComponent(), Compiler::Compiler(), Compiler::ComputeDerivNeeded(), Compiler::CreateComputation(), Compiler::DeallocateMatrices(), and Compiler::SetUpPrecomputedIndexes().
|
private |
Definition at line 153 of file nnet-compile.h.
Referenced by Compiler::AddBackwardStepComponent(), Compiler::AddBackwardStepInput(), Compiler::AddCommands(), Compiler::AddForwardStepComponent(), Compiler::AddForwardStepInput(), Compiler::AllocateMatrices(), Compiler::CompileBackward(), Compiler::CompileBackwardDescriptor(), Compiler::CompileBackwardSumDescriptor(), Compiler::CompileForward(), Compiler::CompileForwardDescriptor(), Compiler::CompileForwardSumDescriptor(), Compiler::ComputeDerivSubmatLocationsList(), Compiler::ComputeInputLocationsList(), Compiler::ComputeValueSubmatLocationsList(), Compiler::CreateStepInfo(), Compiler::DeallocateMatrices(), Compiler::IsInputStep(), Compiler::OutputDebugInfo(), Compiler::SetUpPrecomputedIndexes(), and Compiler::SplitByScale().