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

Method DetermineAncestorState

tensorflow/compiler/tf2xla/functionalize_cond.cc:1305–1337  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1303}
1304
1305Status FunctionalizeCond::DetermineAncestorState(Node* dst) {
1306 StateMap::AncestorId id = nullptr;
1307 StateMap::AncestorState state;
1308
1309 auto insert = [&](StateMap::AncestorId id, Node* src) {
1310 auto other_id = state_map_.LookupAncestorId(src);
1311 if (other_id != id && other_id != nullptr) {
1312 state.insert(other_id->begin(), other_id->end());
1313 }
1314 if (IsMerge(src)) {
1315 state.insert({{src, 0}, AncestorNode::AncestorNodeType::kMerge});
1316 } else if (IsSwitch(src)) {
1317 OutputTensor pred;
1318 // For dead switch nodes, GetSwitchPredicate() will fail, and we use
1319 // the switch node directly as ancestor.
1320 if (GetSwitchPredicate(*src, &pred).ok()) {
1321 state.insert({pred, AncestorNode::AncestorNodeType::kPred});
1322 } else {
1323 state.insert({{src, 0}, AncestorNode::AncestorNodeType::kSwitch});
1324 }
1325 }
1326 return state_map_.GetAncestorId(state);
1327 };
1328
1329 // Compute the union of all the switch/merge nodes that affects the input of
1330 // dst.
1331 for (auto e : dst->in_edges()) {
1332 Node* src = e->src();
1333 id = insert(id, src);
1334 }
1335 state_map_.ResetAncestorId(dst, id);
1336 return Status::OK();
1337}
1338
1339void FunctionalizeCond::DeleteReachableAndDeadNodes(
1340 const std::vector<Node*>& merge_order) {

Callers

nothing calls this directly

Calls 11

GetSwitchPredicateFunction · 0.85
LookupAncestorIdMethod · 0.80
GetAncestorIdMethod · 0.80
ResetAncestorIdMethod · 0.80
IsMergeFunction · 0.50
IsSwitchFunction · 0.50
insertMethod · 0.45
beginMethod · 0.45
endMethod · 0.45
okMethod · 0.45
srcMethod · 0.45

Tested by

no test coverage detected