use of org.apache.sysml.hops.codegen.opt.InterestingPoint in project incubator-systemml by apache.
the class CPlanMemoTable method pruneRedundant.
public void pruneRedundant(long hopID, boolean pruneDominated, InterestingPoint[] matPoints) {
if (!contains(hopID))
return;
// prune redundant plans (i.e., equivalent)
setDistinct(hopID, _plans.get(hopID));
// prune closed templates without group references
_plans.get(hopID).removeIf(p -> p.isClosed() && !p.hasPlanRef());
// heuristic that only consider materialization points)
if (pruneDominated) {
HashSet<MemoTableEntry> rmList = new HashSet<>();
List<MemoTableEntry> list = _plans.get(hopID);
Hop hop = _hopRefs.get(hopID);
for (MemoTableEntry e1 : list) for (MemoTableEntry e2 : list) if (e1 != e2 && e1.subsumes(e2)) {
// check that childs don't have multiple consumers
boolean rmSafe = true;
for (int i = 0; i <= 2; i++) {
rmSafe &= (e1.isPlanRef(i) && !e2.isPlanRef(i)) ? (matPoints != null && !InterestingPoint.isMatPoint(matPoints, hopID, e1.input(i))) || hop.getInput().get(i).getParent().size() == 1 : true;
}
if (rmSafe)
rmList.add(e2);
}
// update current entry list, by removing rmList
remove(hop, rmList);
}
}
use of org.apache.sysml.hops.codegen.opt.InterestingPoint in project systemml by apache.
the class CPlanMemoTable method pruneRedundant.
public void pruneRedundant(long hopID, boolean pruneDominated, InterestingPoint[] matPoints) {
if (!contains(hopID))
return;
// prune redundant plans (i.e., equivalent)
setDistinct(hopID, _plans.get(hopID));
// prune closed templates without group references
_plans.get(hopID).removeIf(p -> p.isClosed() && !p.hasPlanRef());
// heuristic that only consider materialization points)
if (pruneDominated) {
HashSet<MemoTableEntry> rmList = new HashSet<>();
List<MemoTableEntry> list = _plans.get(hopID);
Hop hop = _hopRefs.get(hopID);
for (MemoTableEntry e1 : list) for (MemoTableEntry e2 : list) if (e1 != e2 && e1.subsumes(e2)) {
// check that childs don't have multiple consumers
boolean rmSafe = true;
for (int i = 0; i <= 2; i++) {
rmSafe &= (e1.isPlanRef(i) && !e2.isPlanRef(i)) ? (matPoints != null && !InterestingPoint.isMatPoint(matPoints, hopID, e1.input(i))) || hop.getInput().get(i).getParent().size() == 1 : true;
}
if (rmSafe)
rmList.add(e2);
}
// update current entry list, by removing rmList
remove(hop, rmList);
}
}
Aggregations