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

Method CheckFetch

tensorflow/core/common_runtime/direct_session.cc:1825–1884  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1823}
1824
1825Status DirectSession::CheckFetch(const NamedTensorList& feeds,
1826 const std::vector<string>& fetches,
1827 const ExecutorsAndKeys* executors_and_keys,
1828 const RunState* run_state) {
1829 const Graph* graph = executors_and_keys->graph.get();
1830 const NameNodeMap* name_to_node = &executors_and_keys->name_to_node;
1831
1832 // Build the set of pending feeds that we haven't seen.
1833 std::unordered_set<TensorId, TensorId::Hasher> pending_feeds;
1834 {
1835 mutex_lock l(executor_lock_);
1836 for (const auto& input : run_state->pending_inputs) {
1837 // Skip if the feed has already been fed.
1838 if (input.second) continue;
1839 TensorId id(ParseTensorName(input.first));
1840 auto it = name_to_node->find(id.first);
1841 if (it == name_to_node->end()) {
1842 return errors::NotFound("Feed ", input.first, ": not found");
1843 }
1844 pending_feeds.insert(id);
1845 }
1846 }
1847 for (const auto& it : feeds) {
1848 TensorId id(ParseTensorName(it.first));
1849 pending_feeds.erase(id);
1850 }
1851
1852 // Initialize the stack with the fetch nodes.
1853 std::vector<const Node*> stack;
1854 for (const string& fetch : fetches) {
1855 TensorId id(ParseTensorName(fetch));
1856 auto it = name_to_node->find(id.first);
1857 if (it == name_to_node->end()) {
1858 return errors::NotFound("Fetch ", fetch, ": not found");
1859 }
1860 stack.push_back(it->second);
1861 }
1862
1863 // Any tensor needed for fetches can't be in pending_feeds.
1864 std::vector<bool> visited(graph->num_node_ids(), false);
1865 while (!stack.empty()) {
1866 const Node* n = stack.back();
1867 stack.pop_back();
1868
1869 for (const Edge* in_edge : n->in_edges()) {
1870 const Node* in_node = in_edge->src();
1871 if (pending_feeds.count({in_node->name(), in_edge->src_output()}) > 0) {
1872 return errors::InvalidArgument("Fetch ", in_node->name(), ":",
1873 in_edge->src_output(),
1874 " can't be computed from the feeds"
1875 " that have been fed so far.");
1876 }
1877 if (!visited[in_node->id()]) {
1878 visited[in_node->id()] = true;
1879 stack.push_back(in_node);
1880 }
1881 }
1882 }

Callers

nothing calls this directly

Calls 15

ParseTensorNameFunction · 0.85
NotFoundFunction · 0.85
InvalidArgumentFunction · 0.85
pop_backMethod · 0.80
nameMethod · 0.65
getMethod · 0.45
findMethod · 0.45
endMethod · 0.45
insertMethod · 0.45
eraseMethod · 0.45
push_backMethod · 0.45
num_node_idsMethod · 0.45

Tested by

no test coverage detected