use chomsky_cost::{CostModel, CpuCostModel, GpuCostModel};
use chomsky_extract::IKunExtractor;
use chomsky_uir::egraph::{EGraph, Language};
use chomsky_uir::intent::IKun;
#[test]
fn test_heterogeneous_extraction() {
let egraph = EGraph::<IKun, ()>::new();
let f = egraph.add(IKun::Symbol("double".to_string()));
let x = egraph.add(IKun::Symbol("data".to_string()));
let generic_map = egraph.add(IKun::Map(f, x));
let cpu_map = egraph.add(IKun::CpuMap(f, x));
let gpu_map = egraph.add(IKun::GpuMap(f, x));
egraph.union(generic_map, cpu_map);
egraph.union(generic_map, gpu_map);
egraph.rebuild();
let root = egraph.union_find.find(generic_map);
{
let extractor = IKunExtractor::new(&egraph, CpuCostModel);
let tree = extractor.extract(root);
match tree {
chomsky_uir::IKunTree::Extension(name, _) if name == "CpuMap" => {}
_ => {
}
}
println!("CPU Tree: {:?}", tree);
}
{
let extractor = IKunExtractor::new(&egraph, GpuCostModel);
let tree = extractor.extract(root);
println!("GPU Tree: {:?}", tree);
}
}