An abstract representation of a set of Cindexes. More...
#include <nnet-computation-graph.h>
Classes | |
struct | CindexInfo |
Public Types | |
enum | ComputableInfo { kUnknown = 0, kComputable = 1, kNotComputable = 2, kWillNotCompute = 3 } |
Public Member Functions | |
ComputationGraphBuilder (const Nnet &nnet, ComputationGraph *graph) | |
void | Compute (const ComputationRequest &request) |
bool | AllOutputsAreComputable () const |
void | ExplainWhyAllOutputsNotComputable () const |
void | GetComputableInfo (std::vector< std::vector< bool > > *computable) const |
void | Prune () |
Private Member Functions | |
void | PrintCindexId (std::ostream &os, int32 cindex_id) const |
void | ExplainWhyNotComputable (int32 cindex_id) const |
void | AddInputs () |
void | AddOutputs () |
void | BuildGraphOneIter () |
void | UpdateComputableInfo (int32 cindex_id) |
void | SetAsWillNotCompute (int32 cindex_id) |
ComputableInfo | ComputeComputableInfo (int32 cindex_id) const |
void | AddCindexId (int32 cindex_id) |
void | AddDependencies (int32 cindex_id) |
void | IncrementUsableCount (int32 cindex_id) |
void | DecrementUsableCount (int32 cindex_id) |
void | PruneDependencies (int32 cindex_id) |
void | ComputeRequiredArray (int32 start_cindex_id, std::vector< bool > *required) const |
void | Check (int32 start_cindex_id) const |
Private Attributes | |
const Nnet & | nnet_ |
const ComputationRequest * | request_ |
ComputationGraph * | graph_ |
std::vector< std::vector< int32 > > | depend_on_this_ |
std::vector< CindexInfo > | cindex_info_ |
int32 | current_distance_ |
std::vector< int32 > | current_queue_ |
std::vector< int32 > | next_queue_ |
An abstract representation of a set of Cindexes.
See Building the ComputationGraph.
Definition at line 117 of file nnet-computation-graph.h.
enum ComputableInfo |
Enumerator | |
---|---|
kUnknown | |
kComputable | |
kNotComputable | |
kWillNotCompute |
Definition at line 162 of file nnet-computation-graph.h.
ComputationGraphBuilder | ( | const Nnet & | nnet, |
ComputationGraph * | graph | ||
) |
Definition at line 456 of file nnet-computation-graph.cc.
References ComputationGraph::cindexes, ComputationGraphBuilder::graph_, and KALDI_ASSERT.
|
inlineprivate |
Definition at line 227 of file nnet-computation-graph.cc.
References KALDI_PARANOID_ASSERT.
Referenced by ComputationGraphBuilder::AddDependencies().
|
private |
Definition at line 626 of file nnet-computation-graph.cc.
References ComputationGraphBuilder::AddCindexId(), ComputationGraphBuilder::cindex_info_, ComputationGraph::cindexes, NetworkNode::component_index, ComputationGraphBuilder::depend_on_this_, ComputationGraph::dependencies, NetworkNode::descriptor, ComputationGraph::GetCindexId(), Nnet::GetComponent(), Descriptor::GetDependencies(), Component::GetInputIndexes(), Nnet::GetNode(), ComputationGraphBuilder::graph_, rnnlm::i, ComputationGraphBuilder::IncrementUsableCount(), KALDI_ERR, kaldi::nnet3::kComponent, kaldi::nnet3::kDescriptor, kaldi::nnet3::kDimRange, kaldi::nnet3::kInput, ComputationRequest::misc_info, ComputationGraphBuilder::next_queue_, ComputationGraphBuilder::nnet_, NetworkNode::node_index, NetworkNode::node_type, ComputationGraphBuilder::request_, kaldi::RoundUpToNearestPowerOfTwo(), kaldi::SortAndUniq(), and NetworkNode::u.
Referenced by ComputationGraphBuilder::BuildGraphOneIter().
|
private |
Definition at line 254 of file nnet-computation-graph.cc.
References rnnlm::i, ComputationGraph::is_input, rnnlm::j, KALDI_ASSERT, KALDI_ERR, kaldi::nnet3::kComponent, kaldi::nnet3::kInput, and rnnlm::n.
Referenced by ComputationGraphBuilder::Compute().
|
private |
Definition at line 278 of file nnet-computation-graph.cc.
References rnnlm::i, ComputationGraph::is_input, rnnlm::j, KALDI_ASSERT, KALDI_ERR, and rnnlm::n.
Referenced by ComputationGraphBuilder::Compute().
bool AllOutputsAreComputable | ( | ) | const |
Definition at line 305 of file nnet-computation-graph.cc.
Referenced by Compiler::CreateComputation().
|
private |
Definition at line 896 of file nnet-computation-graph.cc.
References ComputationGraphBuilder::AddDependencies(), ComputationGraphBuilder::cindex_info_, ComputationGraphBuilder::current_distance_, ComputationGraphBuilder::current_queue_, ComputationGraphBuilder::kUnknown, ComputationGraphBuilder::next_queue_, and ComputationGraphBuilder::UpdateComputableInfo().
Referenced by ComputationGraphBuilder::Compute().
|
private |
Definition at line 496 of file nnet-computation-graph.cc.
References ComputationGraphBuilder::cindex_info_, ComputationGraph::cindexes, ComputationGraphBuilder::ComputeComputableInfo(), count, ComputationGraphBuilder::current_queue_, ComputationGraphBuilder::depend_on_this_, ComputationGraph::dependencies, ComputationGraphBuilder::graph_, Nnet::IsOutputNode(), kaldi::IsSortedAndUniq(), rnnlm::j, KALDI_ASSERT, KALDI_ERR, ComputationGraphBuilder::kNotComputable, ComputationGraphBuilder::kUnknown, ComputationGraphBuilder::nnet_, and kaldi::RandInt().
Referenced by ComputationGraphBuilder::Compute().
void Compute | ( | const ComputationRequest & | request | ) |
Definition at line 466 of file nnet-computation-graph.cc.
References ComputationGraphBuilder::AddInputs(), ComputationGraphBuilder::AddOutputs(), ComputationGraphBuilder::BuildGraphOneIter(), ComputationGraphBuilder::Check(), ComputationGraph::cindexes, ComputationGraphBuilder::current_distance_, ComputationGraphBuilder::current_queue_, kaldi::GetVerboseLevel(), ComputationGraphBuilder::graph_, KALDI_ERR, KALDI_VLOG, kaldi::RandInt(), ComputationGraphBuilder::request_, and ComputationGraph::segment_ends.
Referenced by Compiler::CreateComputation(), and kaldi::nnet3::EvaluateComputationRequest().
|
private |
Definition at line 720 of file nnet-computation-graph.cc.
References ComputationGraphBuilder::cindex_info_, ComputationGraph::cindexes, NetworkNode::component_index, NetworkNode::descriptor, ComputationGraph::GetCindexId(), Nnet::GetComponent(), Nnet::GetNode(), ComputationGraphBuilder::graph_, ComputationGraph::is_input, Component::IsComputable(), Descriptor::IsComputable(), KALDI_ERR, kaldi::nnet3::kComponent, ComputationGraphBuilder::kComputable, kaldi::nnet3::kDescriptor, kaldi::nnet3::kDimRange, kaldi::nnet3::kInput, ComputationGraphBuilder::kNotComputable, ComputationGraphBuilder::kUnknown, ComputationRequest::misc_info, ComputationGraphBuilder::nnet_, NetworkNode::node_index, NetworkNode::node_type, ComputationGraphBuilder::request_, and NetworkNode::u.
Referenced by ComputationGraphBuilder::Check(), and ComputationGraphBuilder::UpdateComputableInfo().
Definition at line 918 of file nnet-computation-graph.cc.
References ComputationGraphBuilder::cindex_info_, ComputationGraph::cindexes, rnnlm::d, ComputationGraph::dependencies, ComputationGraphBuilder::graph_, Nnet::IsOutputNode(), KALDI_ASSERT, rnnlm::n, ComputationGraphBuilder::nnet_, and Nnet::NumNodes().
Referenced by ComputationGraphBuilder::Prune().
|
private |
Definition at line 881 of file nnet-computation-graph.cc.
References ComputationGraphBuilder::cindex_info_, ComputationGraph::dependencies, ComputationGraphBuilder::graph_, KALDI_PARANOID_ASSERT, and ComputationGraphBuilder::kNotComputable.
Referenced by ComputationGraphBuilder::UpdateComputableInfo().
void ExplainWhyAllOutputsNotComputable | ( | ) | const |
Definition at line 334 of file nnet-computation-graph.cc.
References rnnlm::i, KALDI_ASSERT, and KALDI_LOG.
Referenced by Compiler::CreateComputation().
|
private |
Definition at line 134 of file nnet-computation-graph.cc.
References ComputationGraphBuilder::CindexInfo::computable, ComputationGraph::dependencies, KALDI_ASSERT, and KALDI_LOG.
void GetComputableInfo | ( | std::vector< std::vector< bool > > * | computable | ) | const |
Definition at line 787 of file nnet-computation-graph.cc.
References ComputationGraphBuilder::cindex_info_, ComputationGraph::cindexes, ComputationGraph::GetCindexId(), Nnet::GetNodeIndex(), ComputationGraphBuilder::graph_, rnnlm::i, IoSpecification::indexes, rnnlm::j, KALDI_ASSERT, ComputationGraphBuilder::kComputable, rnnlm::n, IoSpecification::name, ComputationGraphBuilder::nnet_, ComputationRequest::outputs, and ComputationGraphBuilder::request_.
Referenced by kaldi::nnet3::EvaluateComputationRequest().
|
private |
Definition at line 859 of file nnet-computation-graph.cc.
References ComputationGraphBuilder::cindex_info_, ComputationGraphBuilder::CindexInfo::computable, ComputationGraph::dependencies, ComputationGraphBuilder::graph_, ComputationGraphBuilder::kNotComputable, ComputationGraphBuilder::kUnknown, ComputationGraphBuilder::next_queue_, ComputationGraphBuilder::CindexInfo::queued, and ComputationGraphBuilder::CindexInfo::usable_count.
Referenced by ComputationGraphBuilder::AddDependencies().
|
private |
Definition at line 125 of file nnet-computation-graph.cc.
References KALDI_ASSERT.
void Prune | ( | ) |
Definition at line 569 of file nnet-computation-graph.cc.
References ComputationGraphBuilder::cindex_info_, ComputationGraph::cindexes, ComputationGraphBuilder::ComputeRequiredArray(), ComputationGraphBuilder::depend_on_this_, ComputationGraphBuilder::graph_, rnnlm::i, ComputationGraph::is_input, KALDI_ASSERT, ComputationGraphBuilder::kComputable, ComputationGraphBuilder::PruneDependencies(), ComputationGraph::Renumber(), and ComputationGraph::segment_ends.
Referenced by Compiler::CreateComputation().
|
private |
Definition at line 367 of file nnet-computation-graph.cc.
References NetworkNode::component_index, ComputationGraphBuilder::CindexInfo::computable, ComputationGraph::dependencies, NetworkNode::descriptor, rnnlm::i, Component::IsComputable(), Descriptor::IsComputable(), KALDI_ASSERT, KALDI_ERR, kaldi::nnet3::kComponent, kaldi::nnet3::kDescriptor, kaldi::nnet3::kDimRange, kaldi::nnet3::kInput, NetworkNode::node_type, kaldi::SortAndUniq(), NetworkNode::u, and ComputationGraphBuilder::CindexInfo::usable_count.
Referenced by ComputationGraphBuilder::Prune().
|
private |
|
private |
Definition at line 812 of file nnet-computation-graph.cc.
References ComputationGraphBuilder::cindex_info_, ComputationGraphBuilder::ComputeComputableInfo(), ComputationGraphBuilder::DecrementUsableCount(), ComputationGraphBuilder::depend_on_this_, ComputationGraph::dependencies, ComputationGraphBuilder::graph_, KALDI_ASSERT, ComputationGraphBuilder::kNotComputable, ComputationGraphBuilder::kUnknown, and ComputationGraphBuilder::next_queue_.
Referenced by ComputationGraphBuilder::BuildGraphOneIter().
|
private |
Definition at line 279 of file nnet-computation-graph.h.
Referenced by ComputationGraphBuilder::AddDependencies(), ComputationGraphBuilder::BuildGraphOneIter(), ComputationGraphBuilder::Check(), ComputationGraphBuilder::ComputeComputableInfo(), ComputationGraphBuilder::ComputeRequiredArray(), ComputationGraphBuilder::DecrementUsableCount(), ComputationGraphBuilder::GetComputableInfo(), ComputationGraphBuilder::IncrementUsableCount(), ComputationGraphBuilder::Prune(), and ComputationGraphBuilder::UpdateComputableInfo().
|
private |
Definition at line 283 of file nnet-computation-graph.h.
Referenced by ComputationGraphBuilder::BuildGraphOneIter(), and ComputationGraphBuilder::Compute().
|
private |
Definition at line 286 of file nnet-computation-graph.h.
Referenced by ComputationGraphBuilder::BuildGraphOneIter(), ComputationGraphBuilder::Check(), and ComputationGraphBuilder::Compute().
|
private |
Definition at line 275 of file nnet-computation-graph.h.
Referenced by ComputationGraphBuilder::AddDependencies(), ComputationGraphBuilder::Check(), ComputationGraphBuilder::Prune(), and ComputationGraphBuilder::UpdateComputableInfo().
|
private |
Definition at line 271 of file nnet-computation-graph.h.
Referenced by ComputationGraphBuilder::AddDependencies(), ComputationGraphBuilder::Check(), ComputationGraphBuilder::ComputationGraphBuilder(), ComputationGraphBuilder::Compute(), ComputationGraphBuilder::ComputeComputableInfo(), ComputationGraphBuilder::ComputeRequiredArray(), ComputationGraphBuilder::DecrementUsableCount(), ComputationGraphBuilder::GetComputableInfo(), ComputationGraphBuilder::IncrementUsableCount(), ComputationGraphBuilder::Prune(), and ComputationGraphBuilder::UpdateComputableInfo().
|
private |
Definition at line 289 of file nnet-computation-graph.h.
Referenced by ComputationGraphBuilder::AddDependencies(), ComputationGraphBuilder::BuildGraphOneIter(), ComputationGraphBuilder::IncrementUsableCount(), and ComputationGraphBuilder::UpdateComputableInfo().
|
private |
|
private |
Definition at line 270 of file nnet-computation-graph.h.
Referenced by ComputationGraphBuilder::AddDependencies(), ComputationGraphBuilder::Compute(), ComputationGraphBuilder::ComputeComputableInfo(), and ComputationGraphBuilder::GetComputableInfo().