MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / PruneForTargets

Function PruneForTargets

tensorflow/core/graph/subgraph.cc:191–216  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

189}
190
191Status PruneForTargets(Graph* g, const NameIndex& name_index,
192 const std::vector<Node*>& fetch_nodes,
193 const gtl::ArraySlice<string>& target_nodes) {
194 string not_found;
195 std::unordered_set<const Node*> targets;
196 for (Node* n : fetch_nodes) {
197 if (!AddNodeToTargets(n->name(), name_index, &targets)) {
198 strings::StrAppend(&not_found, n->name(), " ");
199 }
200 }
201 for (const string& s : target_nodes) {
202 if (!AddNodeToTargets(s, name_index, &targets)) {
203 strings::StrAppend(&not_found, s, " ");
204 }
205 }
206 if (!not_found.empty()) {
207 return errors::NotFound("PruneForTargets: Some target nodes not found: ",
208 not_found);
209 }
210 PruneForReverseReachability(g, std::move(targets));
211
212 // Reconnect nodes with no outgoing edges to the sink node
213 FixupSourceAndSinkEdges(g);
214
215 return Status::OK();
216}
217
218} // namespace
219

Callers 1

RewriteGraphForExecutionFunction · 0.85

Calls 7

AddNodeToTargetsFunction · 0.85
NotFoundFunction · 0.85
FixupSourceAndSinkEdgesFunction · 0.85
nameMethod · 0.65
StrAppendFunction · 0.50
emptyMethod · 0.45

Tested by

no test coverage detected