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;
}
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;
}
}
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;
}
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);
}
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);
}
Aggregations