aboutsummaryrefslogtreecommitdiffhomepage
path: root/tensorflow/core/graph
diff options
context:
space:
mode:
authorGravatar A. Unique TensorFlower <gardener@tensorflow.org>2018-06-15 19:05:30 -0700
committerGravatar TensorFlower Gardener <gardener@tensorflow.org>2018-06-15 19:07:56 -0700
commite2755e00fc3c68251d6a591b7ea76d6714976720 (patch)
treeb7473c51dcd8c0c250bf9ac2b388ccab2a95525b /tensorflow/core/graph
parent68af4047fdfa89fa7b7d222a50a38eb0a469d946 (diff)
Don't check for duplicates in FetchOutputs and FeedInputs when creating a ControlEdge. There cannot be a duplicate, since fetch_node and feed_node are newly created. This change reduces the complexity of FetchOutputs from quadratic to linear.
PiperOrigin-RevId: 200807286
Diffstat (limited to 'tensorflow/core/graph')
-rw-r--r--tensorflow/core/graph/subgraph.cc12
1 files changed, 9 insertions, 3 deletions
diff --git a/tensorflow/core/graph/subgraph.cc b/tensorflow/core/graph/subgraph.cc
index 193cf88aed..60337e30aa 100644
--- a/tensorflow/core/graph/subgraph.cc
+++ b/tensorflow/core/graph/subgraph.cc
@@ -81,7 +81,9 @@ Status FeedInputs(
// Update name_index
(*name_index)[feed_node->name()] = feed_node;
- g->AddControlEdge(g->source_node(), feed_node);
+ // Duplicate control edges aren't allowed, but feed_node was *just* created
+ // so there's no need to check for a duplicate.
+ g->AddControlEdge(g->source_node(), feed_node, true);
// Look through edges coming out of "n" for edges whose src_output() index
// matches "output_index". If found, replace the edges with a connection
@@ -107,7 +109,9 @@ Status FeedInputs(
g->AddEdge(feed_node, 0, e->dst(), e->dst_input());
} else {
CHECK_EQ(Graph::kControlSlot, e->src_output());
- g->AddControlEdge(feed_node, e->dst());
+ // Duplicate control edges aren't allowed, but feed_node was *just*
+ // created so there's no need to check for a duplicate.
+ g->AddControlEdge(feed_node, e->dst(), true);
}
g->RemoveEdge(e);
}
@@ -160,7 +164,9 @@ Status FetchOutputs(
// Update the index.
(*name_index)[fetch_node->name()] = fetch_node;
- g->AddControlEdge(fetch_node, g->sink_node());
+ // Duplicate control edges aren't allowed, but fetch_node was *just* created
+ // so there's no need to check for a duplicate.
+ g->AddControlEdge(fetch_node, g->sink_node(), true);
out_fetch_nodes->push_back(fetch_node);
out_fetch_types->push_back(BaseType(n->output_type(id.second)));
}