Skip to content

Commit

Permalink
Remove ignored from reachable
Browse files Browse the repository at this point in the history
  • Loading branch information
Alex-Fischman committed Apr 14, 2024
1 parent 76b138f commit 47d237c
Showing 1 changed file with 8 additions and 13 deletions.
21 changes: 8 additions & 13 deletions dag_in_context/src/greedy_dag_extractor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -212,19 +212,10 @@ pub fn extract(
continue;
}
// Add the children to the frontier
let node = egraph.nodes.get(&nid).unwrap();
let ignored_children = cm.ignored_children(&node.op);
for (i, child) in node.children.iter().enumerate() {
if !ignored_children.contains(&i) {
frontier.push_back(child.clone());
}
for child in &egraph.nodes.get(&nid).unwrap().children {
frontier.push_back(child.clone());
}
}
// Get unreachable nodes with set complement
let mut unreachable: HashSet<_> = egraph.nodes.keys().cloned().collect();
for nid in reachable {
unreachable.remove(&nid);
}

let n2c = |nid: &NodeId| egraph.nid_to_cid(nid);
let parents = build_parent_index(egraph);
Expand All @@ -238,7 +229,7 @@ pub fn extract(
let class_id = n2c(&node_id);
let node = &egraph[&node_id];

if unextractables.contains(&node.op) || unreachable.contains(&node_id) {
if unextractables.contains(&node.op) && !reachable.contains(&node_id) {
continue;
}

Expand Down Expand Up @@ -301,7 +292,11 @@ impl CostModel for DefaultCostModel {
// TODO: the cost of Call is more complicated than this
"Call" => 1000.,
// Other
_ => panic!("no cost for {op}"),
// _ => panic!("no cost for {op}"),
_ => {
eprintln!("no cost for {op}");
0.
}
};

NotNan::new(cost).unwrap()
Expand Down

0 comments on commit 47d237c

Please sign in to comment.