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

Method PropagateUpdatedState

tensorflow/compiler/tf2xla/functionalize_cond.cc:965–996  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

963}
964
965Status FunctionalizeCond::PropagateUpdatedState(const Node* replacee) {
966 VLOG(2) << "Propagating update state for " << replacee->name() << " "
967 << state_map_.CondStateToString(replacee);
968 // Redo topological sort as the order could have changed.
969 // TODO(jpienaar): The original topological order could also be updated
970 // dynamically if needed.
971 std::vector<Node*> rev_topo_order;
972 GetPostOrder(*graph_, &rev_topo_order);
973
974 // All the outputs of the new node could potentially be updated.
975 std::unordered_set<Node*> changed;
976 for (auto n : replacee->out_nodes())
977 if (n->IsOp()) changed.insert(n);
978
979 // Iterate through the changed/possible changed nodes in topological order.
980 for (auto it = rev_topo_order.rbegin();
981 it != rev_topo_order.rend() && !changed.empty(); ++it) {
982 if (changed.find(*it) != changed.end()) {
983 // Update the node state.
984 Node* n = *it;
985 StateMap::CondId old_state = state_map_.LookupCondId(n);
986 state_map_.ResetCondId(n, nullptr);
987 TF_RETURN_IF_ERROR(DetermineCondState(n));
988 if (state_map_.LookupCondId(n) != old_state) {
989 for (auto out : n->out_nodes())
990 if (out->IsOp()) changed.insert(out);
991 }
992 changed.erase(n);
993 }
994 }
995 return Status::OK();
996}
997
998// Returns the most restrictive branch of two branches or neither. This is the
999// meet operator of the BranchType lattice.

Callers 1

BuildAndReplaceMethod · 0.80

Calls 14

GetPostOrderFunction · 0.85
CondStateToStringMethod · 0.80
IsOpMethod · 0.80
rbeginMethod · 0.80
rendMethod · 0.80
LookupCondIdMethod · 0.80
ResetCondIdMethod · 0.80
nameMethod · 0.65
out_nodesMethod · 0.45
insertMethod · 0.45
emptyMethod · 0.45
findMethod · 0.45

Tested by

no test coverage detected