Search in sources :

Example 41 with CNode

use of org.apache.sysml.hops.codegen.cplan.CNode in project incubator-systemml by apache.

the class TemplateUtils method getMaxVectorIntermediates.

public static int getMaxVectorIntermediates(CNode node) {
    if (node.isVisited())
        return 0;
    int max = 0;
    for (CNode input : node.getInput()) max = Math.max(max, getMaxVectorIntermediates(input));
    max = Math.max(max, (node instanceof CNodeTernary && ((CNodeTernary) node).getType().isVectorPrimitive()) ? 1 : 0);
    max = Math.max(max, (node instanceof CNodeBinary) ? (((CNodeBinary) node).getType().isVectorVectorPrimitive() ? 3 : ((CNodeBinary) node).getType().isVectorScalarPrimitive() ? 2 : ((CNodeBinary) node).getType().isVectorMatrixPrimitive() ? 1 : 0) : 0);
    max = Math.max(max, (node instanceof CNodeUnary && ((CNodeUnary) node).getType().isVectorScalarPrimitive()) ? 2 : 0);
    node.setVisited();
    return max;
}
Also used : CNode(org.apache.sysml.hops.codegen.cplan.CNode) CNodeTernary(org.apache.sysml.hops.codegen.cplan.CNodeTernary) CNodeUnary(org.apache.sysml.hops.codegen.cplan.CNodeUnary) CNodeBinary(org.apache.sysml.hops.codegen.cplan.CNodeBinary)

Example 42 with CNode

use of org.apache.sysml.hops.codegen.cplan.CNode in project incubator-systemml by apache.

the class TemplateUtils method skipTranspose.

public static CNode skipTranspose(CNode cdataOrig, Hop hop, HashMap<Long, CNode> tmp, boolean compileLiterals) {
    if (HopRewriteUtils.isTransposeOperation(hop)) {
        CNode cdata = tmp.get(hop.getInput().get(0).getHopID());
        if (cdata == null) {
            // never accessed
            cdata = TemplateUtils.createCNodeData(hop.getInput().get(0), compileLiterals);
            tmp.put(hop.getInput().get(0).getHopID(), cdata);
        }
        tmp.put(hop.getHopID(), cdata);
        return cdata;
    } else {
        return cdataOrig;
    }
}
Also used : CNode(org.apache.sysml.hops.codegen.cplan.CNode)

Example 43 with CNode

use of org.apache.sysml.hops.codegen.cplan.CNode in project incubator-systemml by apache.

the class TemplateUtils method countVectorIntermediates.

public static int countVectorIntermediates(CNode node) {
    if (node.isVisited())
        return 0;
    node.setVisited();
    // compute vector requirements over all inputs
    int ret = 0;
    for (CNode c : node.getInput()) ret += countVectorIntermediates(c);
    // compute vector requirements of current node
    int cntBin = (node instanceof CNodeBinary && ((CNodeBinary) node).getType().isVectorPrimitive() && !((CNodeBinary) node).getType().name().endsWith("_ADD")) ? 1 : 0;
    int cntUn = (node instanceof CNodeUnary && ((CNodeUnary) node).getType().isVectorScalarPrimitive()) ? 1 : 0;
    int cntTn = (node instanceof CNodeTernary && ((CNodeTernary) node).getType().isVectorPrimitive()) ? 1 : 0;
    return ret + cntBin + cntUn + cntTn;
}
Also used : CNode(org.apache.sysml.hops.codegen.cplan.CNode) CNodeTernary(org.apache.sysml.hops.codegen.cplan.CNodeTernary) CNodeUnary(org.apache.sysml.hops.codegen.cplan.CNodeUnary) CNodeBinary(org.apache.sysml.hops.codegen.cplan.CNodeBinary)

Example 44 with CNode

use of org.apache.sysml.hops.codegen.cplan.CNode in project incubator-systemml by apache.

the class CPlanComparisonTest method testNotEqualUnaryTernaryNodes.

@Test
public void testNotEqualUnaryTernaryNodes() {
    CNode c1 = createCNodeData(DataType.MATRIX);
    CNode c2 = createCNodeData(DataType.SCALAR);
    CNode c3 = createCNodeData(DataType.MATRIX);
    CNode un1 = new CNodeUnary(c1, UnaryType.ABS);
    CNode ter2 = new CNodeTernary(c1, c2, c3, TernaryType.PLUS_MULT);
    Assert.assertNotEquals(un1, ter2);
}
Also used : CNode(org.apache.sysml.hops.codegen.cplan.CNode) CNodeTernary(org.apache.sysml.hops.codegen.cplan.CNodeTernary) CNodeUnary(org.apache.sysml.hops.codegen.cplan.CNodeUnary) Test(org.junit.Test)

Example 45 with CNode

use of org.apache.sysml.hops.codegen.cplan.CNode in project incubator-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);
}
Also used : CNode(org.apache.sysml.hops.codegen.cplan.CNode) CNodeUnary(org.apache.sysml.hops.codegen.cplan.CNodeUnary) Test(org.junit.Test)

Aggregations

CNode (org.apache.sysml.hops.codegen.cplan.CNode)64 CNodeBinary (org.apache.sysml.hops.codegen.cplan.CNodeBinary)27 Test (org.junit.Test)26 CNodeUnary (org.apache.sysml.hops.codegen.cplan.CNodeUnary)21 Hop (org.apache.sysml.hops.Hop)19 CNodeData (org.apache.sysml.hops.codegen.cplan.CNodeData)17 CNodeTernary (org.apache.sysml.hops.codegen.cplan.CNodeTernary)16 HashMap (java.util.HashMap)13 Pair (org.apache.sysml.runtime.matrix.data.Pair)11 ArrayList (java.util.ArrayList)9 HashSet (java.util.HashSet)9 AggBinaryOp (org.apache.sysml.hops.AggBinaryOp)8 MemoTableEntry (org.apache.sysml.hops.codegen.template.CPlanMemoTable.MemoTableEntry)8 CNodeMultiAgg (org.apache.sysml.hops.codegen.cplan.CNodeMultiAgg)7 AggUnaryOp (org.apache.sysml.hops.AggUnaryOp)6 BinaryOp (org.apache.sysml.hops.BinaryOp)6 LiteralOp (org.apache.sysml.hops.LiteralOp)6 UnaryOp (org.apache.sysml.hops.UnaryOp)6 CNodeCell (org.apache.sysml.hops.codegen.cplan.CNodeCell)5 CNodeRow (org.apache.sysml.hops.codegen.cplan.CNodeRow)5