use of org.apache.sysml.hops.codegen.cplan.CNode in project systemml by apache.
the class CPlanComparisonTest method testNotEqualUnaryBinaryNodes.
@Test
public void testNotEqualUnaryBinaryNodes() {
CNode c1 = createCNodeData(DataType.MATRIX);
CNode c2 = createCNodeData(DataType.SCALAR);
CNode un1 = new CNodeUnary(c1, UnaryType.ABS);
CNode bin2 = new CNodeBinary(c1, c2, BinType.DIV);
Assert.assertNotEquals(un1, bin2);
}
use of org.apache.sysml.hops.codegen.cplan.CNode in project systemml by apache.
the class CPlanComparisonTest method testNotEqualBinaryDAG2.
@Test
public void testNotEqualBinaryDAG2() {
CNode c1 = createCNodeData(DataType.MATRIX);
CNode c2 = createCNodeData(DataType.MATRIX);
CNode c3 = createCNodeData(DataType.MATRIX);
// DAG 2a: (c1*c2)*c3
CNode b1a = new CNodeBinary(c1, c2, BinType.MULT);
CNode b2a = new CNodeBinary(b1a, c3, BinType.MULT);
// DAG 2b: (c1*c2)*c1
CNode b1b = new CNodeBinary(c1, c2, BinType.MULT);
CNode b2b = new CNodeBinary(b1b, c1, BinType.MULT);
Assert.assertNotEquals(b2a, b2b);
}
use of org.apache.sysml.hops.codegen.cplan.CNode in project systemml by apache.
the class CPlanComparisonTest method testEqualUnaryNodes.
@Test
public void testEqualUnaryNodes() {
CNode c0 = createCNodeData(DataType.MATRIX);
CNode c1 = new CNodeUnary(c0, UnaryType.EXP);
CNode c2 = new CNodeUnary(c0, UnaryType.EXP);
Assert.assertEquals(c1.hashCode(), c2.hashCode());
Assert.assertEquals(c1, c2);
}
use of org.apache.sysml.hops.codegen.cplan.CNode in project incubator-systemml by apache.
the class CPlanCSERewriter method eliminateCommonSubexpressions.
public CNodeTpl eliminateCommonSubexpressions(CNodeTpl tpl) {
// Note: Compared to our traditional common subexpression elimination, on cplans,
// we don't have any parent references, and hence cannot use a collect-merge approach.
// In contrast, we exploit the hash signatures of cnodes as used in the plan cache.
// However, note that these signatures ignore input hops by default (for better plan
// cache hit rates), but are temporarily set to strict evaluation for this rewrite.
List<CNode> outputs = (tpl instanceof CNodeMultiAgg) ? ((CNodeMultiAgg) tpl).getOutputs() : Collections.singletonList(tpl.getOutput());
// step 1: set data nodes to strict comparison
tpl.resetVisitStatusOutputs();
for (CNode out : outputs) rSetStrictDataNodeComparision(out, true);
// step 2: perform common subexpression elimination
HashMap<CNode, CNode> cseSet = new HashMap<>();
tpl.resetVisitStatusOutputs();
for (CNode out : outputs) rEliminateCommonSubexpression(out, cseSet);
// step 3: reset data nodes to imprecise comparison
tpl.resetVisitStatusOutputs();
for (CNode out : outputs) rSetStrictDataNodeComparision(out, false);
tpl.resetVisitStatusOutputs();
return tpl;
}
use of org.apache.sysml.hops.codegen.cplan.CNode in project incubator-systemml by apache.
the class CPlanOpRewriter method rFindAndRemoveBinaryMS.
private static void rFindAndRemoveBinaryMS(CNode node, CNodeData mainInput, BinType type, String lit, String replace) {
for (int i = 0; i < node.getInput().size(); i++) {
CNode tmp = node.getInput().get(i);
if (TemplateUtils.isBinary(tmp, type) && tmp.getInput().get(1).isLiteral() && tmp.getInput().get(1).getVarname().equals(lit) && tmp.getInput().get(0) instanceof CNodeData && ((CNodeData) tmp.getInput().get(0)).getHopID() == mainInput.getHopID()) {
CNodeData cnode = new CNodeData(new LiteralOp(replace));
cnode.setLiteral(true);
node.getInput().set(i, cnode);
} else
rFindAndRemoveBinaryMS(tmp, mainInput, type, lit, replace);
}
}
Aggregations