Skip to content

Commit

Permalink
Fix an apparent typo in nnet3::ComputeNnetComputationEpochs()
Browse files Browse the repository at this point in the history
  • Loading branch information
vdp committed Apr 30, 2016
1 parent 4488d3c commit 2310a19
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 17 deletions.
16 changes: 8 additions & 8 deletions src/nnet3/nnet-graph-test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -135,14 +135,14 @@ void BuildTestTopSortOrder(std::vector<int32> *node_to_order) {

// The topological sorting order of the above SCC graph is as follows (from
// our particular algorithm):
// 0 --> 3
// 1 --> 2
// 2 --> 1
// 3 --> 0
(*node_to_order)[0] = 3;
(*node_to_order)[1] = 2;
(*node_to_order)[2] = 1;
(*node_to_order)[3] = 0;
// 0 --> 0
// 1 --> 1
// 2 --> 2
// 3 --> 3
(*node_to_order)[0] = 0;
(*node_to_order)[1] = 1;
(*node_to_order)[2] = 2;
(*node_to_order)[3] = 3;
}

void UnitTestComputeGraphTranspose() {
Expand Down
14 changes: 7 additions & 7 deletions src/nnet3/nnet-graph.cc
Original file line number Diff line number Diff line change
Expand Up @@ -230,18 +230,18 @@ void ComputeTopSortOrder(const std::vector<std::vector<int32> > &graph,
std::vector<bool> cycle_detector(graph.size(), false);
std::vector<bool> is_visited(graph.size(), false);

std::vector<int32> reversed_orders;
std::vector<int32> orders;
for(int32 i = 0; i < graph.size(); ++i) {
if (!is_visited[i]) {
ComputeTopSortOrderRecursive(i, graph, &cycle_detector,
&is_visited, &reversed_orders);
&is_visited, &orders);
}
}

KALDI_ASSERT(node_to_order->size() == reversed_orders.size());
for (int32 i = 0; i < reversed_orders.size(); ++i) {
KALDI_ASSERT(reversed_orders[i] >= 0 && reversed_orders[i] < graph.size());
(*node_to_order)[reversed_orders[i]] = graph.size() - i - 1;
KALDI_ASSERT(node_to_order->size() == orders.size());
for (int32 i = 0; i < orders.size(); ++i) {
KALDI_ASSERT(orders[i] >= 0 && orders[i] < graph.size());
(*node_to_order)[orders[i]] = i;
}
}

Expand Down Expand Up @@ -283,7 +283,7 @@ void ComputeNnetComputationEpochs(const Nnet &nnet,
ComputeGraphTranspose(scc_graph, &scc_graph_transpose);

std::vector<int32> scc_node_to_epoch;
ComputeTopSortOrder(scc_graph, &scc_node_to_epoch);
ComputeTopSortOrder(scc_graph_transpose, &scc_node_to_epoch);
if (GetVerboseLevel() >= 6) {
std::ostringstream os;
for (int32 i = 0; i < scc_node_to_epoch.size(); i++)
Expand Down
4 changes: 2 additions & 2 deletions src/nnet3/nnet-graph.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ std::string PrintGraphToString(const std::vector<std::vector<int32> > &graph);
/// where graph->size() == nnet.NumNodes(). For each node-index
/// n, the vector in (*graph)[n] will contain a list of all the nodes
/// that have a direct dependency on node n (in order to compute them).
/// For instance, if n is an input node, (*graph)[n] will be the empty
/// list because it won't depend on anything.
/// For instance, if n is the output node, (*graph)[n] will be the empty
/// list because no other node will depend on it.
void NnetToDirectedGraph(const Nnet &nnet,
std::vector<std::vector<int32> > *graph);

Expand Down

0 comments on commit 2310a19

Please sign in to comment.